[PATCH] D120639: [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

2022-03-17 Thread luxufan via Phabricator via cfe-commits
StephenFan added a comment.
Herald added subscribers: s, arichardson.

Ping :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120639/new/

https://reviews.llvm.org/D120639

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121345: [RISCV] Add +experimental-zvfh extension to cover half types in vectors.

2022-03-17 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.
Herald added subscribers: s, arichardson.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121345/new/

https://reviews.llvm.org/D121345

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121749: [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

2022-03-17 Thread Krystian Kuzniarek via Phabricator via cfe-commits
kuzkry added a subscriber: MyDeveloperDay.
kuzkry added a comment.

I removed @MyDeveloperDay, as this is a trivial PR and already got 3 approvals.

Anyway, could someone please deliver this one for me? My name and email in git 
format is "Krystian Kuzniarek "


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121749/new/

https://reviews.llvm.org/D121749

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119479: [clang][extract-api] Add global record support

2022-03-17 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hello,

Did you see this sanitizer error when running global_record.c?

https://lab.llvm.org/buildbot/#/builders/5/builds/20765/steps/13/logs/stdio


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119479/new/

https://reviews.llvm.org/D119479

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 34ce42f - [clang-format] Reformat. NFC.

2022-03-17 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-03-17T09:27:31+01:00
New Revision: 34ce42fe4de5318176e13e4cb758dfa7a0d8176b

URL: 
https://github.com/llvm/llvm-project/commit/34ce42fe4de5318176e13e4cb758dfa7a0d8176b
DIFF: 
https://github.com/llvm/llvm-project/commit/34ce42fe4de5318176e13e4cb758dfa7a0d8176b.diff

LOG: [clang-format] Reformat. NFC.

Added: 


Modified: 
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestJson.cpp
clang/unittests/Format/MacroExpanderTest.cpp
clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
clang/unittests/Format/TestLexer.h

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index de6cdf4afd729..2dcc4fd62c5e8 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -1163,9 +1163,8 @@ void 
WhitespaceManager::alignArrayInitializersLeftJustified(
 auto Offset = std::distance(Cells.begin(), CellIter);
 for (const auto *Next = CellIter->NextColumnElement; Next != nullptr;
  Next = Next->NextColumnElement) {
-  if (RowCount > CellDescs.CellCounts.size()) {
+  if (RowCount > CellDescs.CellCounts.size())
 break;
-  }
   auto *Start = (Cells.begin() + RowCount * CellDescs.CellCounts[0]);
   auto *End = Start + Offset;
   auto ThisNetWidth = getNetWidth(Start, End, CellDescs.InitialSpaces);

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 8ee6040cd0f69..469252a252887 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7217,9 +7217,8 @@ TEST_F(FormatTest, MemoizationTests) {
   OnePerLine.BinPackParameters = false;
   std::string input = "Constructor()\n"
   ": (a,\n";
-  for (unsigned i = 0, e = 80; i != e; ++i) {
+  for (unsigned i = 0, e = 80; i != e; ++i)
 input += "   a,\n";
-  }
   input += "   a) {}";
   verifyFormat(input, OnePerLine);
 }

diff  --git a/clang/unittests/Format/FormatTestJson.cpp 
b/clang/unittests/Format/FormatTestJson.cpp
index 14a48182f9dfe..e213f6bcbe712 100644
--- a/clang/unittests/Format/FormatTestJson.cpp
+++ b/clang/unittests/Format/FormatTestJson.cpp
@@ -30,14 +30,12 @@ class FormatTestJson : public ::testing::Test {
 if (Style.isJson() && !Style.DisableFormat) {
   auto Err = Replaces.add(
   tooling::Replacement(tooling::Replacement("", 0, 0, "x = ")));
-  if (Err) {
+  if (Err)
 llvm::errs() << "Bad Json variable insertion\n";
-  }
 }
 auto ChangedCode = applyAllReplacements(Code, Replaces);
-if (!ChangedCode) {
+if (!ChangedCode)
   llvm::errs() << "Bad Json varibale replacement\n";
-}
 StringRef NewCode = *ChangedCode;
 
 std::vector Ranges(1, tooling::Range(0, NewCode.size()));

diff  --git a/clang/unittests/Format/MacroExpanderTest.cpp 
b/clang/unittests/Format/MacroExpanderTest.cpp
index 7ec98a5e82b7b..37fa8d1cfc179 100644
--- a/clang/unittests/Format/MacroExpanderTest.cpp
+++ b/clang/unittests/Format/MacroExpanderTest.cpp
@@ -28,9 +28,8 @@ class MacroExpanderTest : public ::testing::Test {
   llvm::SmallVector
   lexArgs(const std::vector &Args) {
 llvm::SmallVector Result;
-for (const auto &Arg : Args) {
+for (const auto &Arg : Args)
   Result.push_back(uneof(Lex.lex(Arg)));
-}
 return Result;
   }
 
@@ -78,9 +77,8 @@ class MacroExpanderTest : public ::testing::Test {
 TEST_F(MacroExpanderTest, SkipsDefinitionOnError) {
   auto Macros =
   create({"A(", "B(,", "C(a,", "D(a a", "E(a, a", "F(,)", "G(a;"});
-  for (const auto *Name : {"A", "B", "C", "D", "E", "F", "G"}) {
+  for (const auto *Name : {"A", "B", "C", "D", "E", "F", "G"})
 EXPECT_FALSE(Macros->defined(Name)) << "for Name " << Name;
-  }
 }
 
 TEST_F(MacroExpanderTest, ExpandsWithoutArguments) {

diff  --git a/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp 
b/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
index 50b861fea1daf..342fdd3418098 100644
--- a/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ b/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -469,7 +469,8 @@ TEST_F(NamespaceEndCommentsFixerTest, WorksForObjCpp) {
 fixNamespaceEndComments("namespace {\n"
 "int i;\n"
 "int j;\n"
-"}", ObjCppStyle));
+"}",
+ObjCppStyle));
 }
 
 TEST_F(NamespaceEndCommentsFixerTest, AddsMacroEndComment) {

diff  --git a/clang/unittests/Format/TestLexer.h 
b/clang/unittests/Format/TestLexer.h
index ae9818d7561b8..a1585fc5cac6d 100644
--- a/clang/unittests/Format/TestLexer.h
+++ b/clang/unittests/Format/TestLexer.h
@@ -37

[clang] e2a1f8e - Reland "[clang][driver] Emit a warning if -xc/-xc++ is after the last input file"

2022-03-17 Thread Yi Kong via cfe-commits

Author: Yi Kong
Date: 2022-03-17T16:31:01+08:00
New Revision: e2a1f8ec27b88be670cd867c43588f24516d2bbf

URL: 
https://github.com/llvm/llvm-project/commit/e2a1f8ec27b88be670cd867c43588f24516d2bbf
DIFF: 
https://github.com/llvm/llvm-project/commit/e2a1f8ec27b88be670cd867c43588f24516d2bbf.diff

LOG: Reland "[clang][driver] Emit a warning if -xc/-xc++ is after the last 
input file"

This reverts commit ba59476515cf4598dd25bcfacfbca11b4f4da3d4.

Added: 
clang/test/Driver/x-args.c

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index afedb37797e32..0a62d4b85c9d1 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -365,6 +365,9 @@ def warn_drv_preprocessed_input_file_unused : Warning<
 def warn_drv_unused_argument : Warning<
   "argument unused during compilation: '%0'">,
   InGroup;
+def warn_drv_unused_x : Warning<
+  "'-x %0' after last input file has no effect">,
+  InGroup;
 def warn_drv_empty_joined_argument : Warning<
   "joined argument expects additional value: '%0'">,
   InGroup;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 70822490e63b8..8099c1d71f0e7 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2308,6 +2308,14 @@ void Driver::BuildInputs(const ToolChain &TC, 
DerivedArgList &Args,
 assert(!Args.hasArg(options::OPT_x) && "-x and /TC or /TP is not allowed");
   }
 
+  // Warn -x after last input file has no effect
+  {
+Arg *LastXArg = Args.getLastArgNoClaim(options::OPT_x);
+Arg *LastInputArg = Args.getLastArgNoClaim(options::OPT_INPUT);
+if (LastXArg && LastInputArg && LastInputArg->getIndex() < 
LastXArg->getIndex())
+  Diag(clang::diag::warn_drv_unused_x) << LastXArg->getValue();
+  }
+
   for (Arg *A : Args) {
 if (A->getOption().getKind() == Option::InputClass) {
   const char *Value = A->getValue();

diff  --git a/clang/test/Driver/x-args.c b/clang/test/Driver/x-args.c
new file mode 100644
index 0..b49f474babf0f
--- /dev/null
+++ b/clang/test/Driver/x-args.c
@@ -0,0 +1,7 @@
+// RUN: %clang -fsyntax-only -Werror -xc %s
+// RUN: %clang -fsyntax-only -Werror %s -xc %s
+
+// RUN: %clang -fsyntax-only %s -xc++ -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -fsyntax-only -xc %s -xc++ -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -fsyntax-only %s -xc %s -xc++ -fsyntax-only 2>&1 | FileCheck %s
+// CHECK: '-x c++' after last input file has no effect



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] dc142ea - [clang-format] Correctly recognize binary operators in template arguments with parenthesized literals.

2022-03-17 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-03-17T09:36:25+01:00
New Revision: dc142ea184a526fb2879f84c4c82fff195d36b9d

URL: 
https://github.com/llvm/llvm-project/commit/dc142ea184a526fb2879f84c4c82fff195d36b9d
DIFF: 
https://github.com/llvm/llvm-project/commit/dc142ea184a526fb2879f84c4c82fff195d36b9d.diff

LOG: [clang-format] Correctly recognize binary operators in template arguments 
with parenthesized literals.

Fixes https://github.com/llvm/llvm-project/issues/24602.

Before, code like `foo` was formatted correctly but `foo` 
wasn't.
This patch fixes this inconsistency.

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D121846

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index f1ff1995c806d..9c94590dc0b9a 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2177,14 +2177,21 @@ class AnnotatingParser {
 
 if (PrevToken->Tok.isLiteral() ||
 PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
-   tok::kw_false, tok::r_brace) ||
-NextToken->Tok.isLiteral() ||
-NextToken->isOneOf(tok::kw_true, tok::kw_false) ||
-NextToken->isUnaryOperator() ||
-// If we know we're in a template argument, there are no named
-// declarations. Thus, having an identifier on the right-hand side
-// indicates a binary operator.
-(InTemplateArgument && NextToken->Tok.isAnyIdentifier()))
+   tok::kw_false, tok::r_brace))
+  return TT_BinaryOperator;
+
+const FormatToken *NextNonParen = NextToken;
+while (NextNonParen && NextNonParen->is(tok::l_paren))
+  NextNonParen = NextNonParen->getNextNonComment();
+if (NextNonParen && (NextNonParen->Tok.isLiteral() ||
+ NextNonParen->isOneOf(tok::kw_true, tok::kw_false) ||
+ NextNonParen->isUnaryOperator()))
+  return TT_BinaryOperator;
+
+// If we know we're in a template argument, there are no named 
declarations.
+// Thus, having an identifier on the right-hand side indicates a binary
+// operator.
+if (InTemplateArgument && NextToken->Tok.isAnyIdentifier())
   return TT_BinaryOperator;
 
 // "&&(" is quite unlikely to be two successive unary "&".
@@ -4508,12 +4515,11 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine 
&Line,
 
   // We only break before r_paren if we're in a block indented context.
   if (Right.is(tok::r_paren)) {
-if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
+if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent)
   return Right.MatchingParen &&
  !(Right.MatchingParen->Previous &&
(Right.MatchingParen->Previous->is(tok::kw_for) ||
 Right.MatchingParen->Previous->isIf()));
-}
 
 return false;
   }

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 469252a252887..4ef4c9a8612a7 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -10333,6 +10333,11 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
   verifyFormat("vector v;");
   verifyFormat("foo();");
   verifyFormat("foo();");
+  verifyFormat("foo();");
+  verifyFormat("foo();");
+  verifyFormat("foo();");
+  verifyFormat("foo();");
+  verifyFormat("foo();");
   verifyFormat("decltype(*::std::declval()) void F();");
   verifyFormat("typeof(*::std::declval()) void F();");
   verifyFormat("_Atomic(*::std::declval()) void F();");



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121846: [clang-format] Correctly recognize binary operators in template arguments with parenthesized literals.

2022-03-17 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
curdeius marked an inline comment as done.
Closed by commit rGdc142ea184a5: [clang-format] Correctly recognize binary 
operators in template arguments with… (authored by curdeius).

Changed prior to commit:
  https://reviews.llvm.org/D121846?vs=415962&id=416092#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121846/new/

https://reviews.llvm.org/D121846

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10333,6 +10333,11 @@
   verifyFormat("vector v;");
   verifyFormat("foo();");
   verifyFormat("foo();");
+  verifyFormat("foo();");
+  verifyFormat("foo();");
+  verifyFormat("foo();");
+  verifyFormat("foo();");
+  verifyFormat("foo();");
   verifyFormat("decltype(*::std::declval()) void F();");
   verifyFormat("typeof(*::std::declval()) void F();");
   verifyFormat("_Atomic(*::std::declval()) void F();");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2177,14 +2177,21 @@
 
 if (PrevToken->Tok.isLiteral() ||
 PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
-   tok::kw_false, tok::r_brace) ||
-NextToken->Tok.isLiteral() ||
-NextToken->isOneOf(tok::kw_true, tok::kw_false) ||
-NextToken->isUnaryOperator() ||
-// If we know we're in a template argument, there are no named
-// declarations. Thus, having an identifier on the right-hand side
-// indicates a binary operator.
-(InTemplateArgument && NextToken->Tok.isAnyIdentifier()))
+   tok::kw_false, tok::r_brace))
+  return TT_BinaryOperator;
+
+const FormatToken *NextNonParen = NextToken;
+while (NextNonParen && NextNonParen->is(tok::l_paren))
+  NextNonParen = NextNonParen->getNextNonComment();
+if (NextNonParen && (NextNonParen->Tok.isLiteral() ||
+ NextNonParen->isOneOf(tok::kw_true, tok::kw_false) ||
+ NextNonParen->isUnaryOperator()))
+  return TT_BinaryOperator;
+
+// If we know we're in a template argument, there are no named 
declarations.
+// Thus, having an identifier on the right-hand side indicates a binary
+// operator.
+if (InTemplateArgument && NextToken->Tok.isAnyIdentifier())
   return TT_BinaryOperator;
 
 // "&&(" is quite unlikely to be two successive unary "&".
@@ -4508,12 +4515,11 @@
 
   // We only break before r_paren if we're in a block indented context.
   if (Right.is(tok::r_paren)) {
-if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
+if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent)
   return Right.MatchingParen &&
  !(Right.MatchingParen->Previous &&
(Right.MatchingParen->Previous->is(tok::kw_for) ||
 Right.MatchingParen->Previous->isIf()));
-}
 
 return false;
   }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10333,6 +10333,11 @@
   verifyFormat("vector v;");
   verifyFormat("foo();");
   verifyFormat("foo();");
+  verifyFormat("foo();");
+  verifyFormat("foo();");
+  verifyFormat("foo();");
+  verifyFormat("foo();");
+  verifyFormat("foo();");
   verifyFormat("decltype(*::std::declval()) void F();");
   verifyFormat("typeof(*::std::declval()) void F();");
   verifyFormat("_Atomic(*::std::declval()) void F();");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2177,14 +2177,21 @@
 
 if (PrevToken->Tok.isLiteral() ||
 PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
-   tok::kw_false, tok::r_brace) ||
-NextToken->Tok.isLiteral() ||
-NextToken->isOneOf(tok::kw_true, tok::kw_false) ||
-NextToken->isUnaryOperator() ||
-// If we know we're in a template argument, there are no named
-// declarations. Thus, having an identifier on the right-hand side
-// indicates a binary operator.
-(InTemplateArgument && NextToken->Tok.isAnyIdentifier()))
+   tok::kw_false, tok::r_brace))
+  return TT_BinaryOperator;
+
+const FormatToken *NextNonParen = NextToken;
+while (NextNonParen && NextNonParen->is(tok::l_paren))
+  NextNonParen = Next

[clang] 45cb2df - [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

2022-03-17 Thread Marek Kurdej via cfe-commits

Author: Krystian Kuzniarek
Date: 2022-03-17T09:45:43+01:00
New Revision: 45cb2df6788ca96a2ed6e9638b803563f51466f2

URL: 
https://github.com/llvm/llvm-project/commit/45cb2df6788ca96a2ed6e9638b803563f51466f2
DIFF: 
https://github.com/llvm/llvm-project/commit/45cb2df6788ca96a2ed6e9638b803563f51466f2.diff

LOG: [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

Misalignment of clang/docs/ClangFormatStyleOptions.rst and
clang/include/clang/Format/Format.h was introduced in c24b3db45.

Regenerated with:
python clang/docs/tools/dump_format_style.py

Reviewed By: sstwcw, curdeius, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D121749

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index a9e35fdceb810..543e7bbf410a3 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -358,8 +358,8 @@ the configuration (without a prefix: ``Auto``).
   /* A comment. */
   double e = 4;
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound assignments
+like ``+=`` are aligned along with ``=``.
 
 .. code-block:: c++
 
@@ -371,10 +371,9 @@ the configuration (without a prefix: ``Auto``).
   a &= 2;
   bbb = 2;
 
-  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether 
short
-assignment operators are left-padded to the same length as long
-ones in order to put all assignment operators to the right of
-the left hand side.
+  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether 
short assignment
+operators are left-padded to the same length as long ones in order to
+put all assignment operators to the right of the left hand side.
 
 .. code-block:: c++
 
@@ -482,8 +481,8 @@ the configuration (without a prefix: ``Auto``).
   /* A comment. */
   double e = 4;
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound assignments
+like ``+=`` are aligned along with ``=``.
 
 .. code-block:: c++
 
@@ -495,10 +494,9 @@ the configuration (without a prefix: ``Auto``).
   a &= 2;
   bbb = 2;
 
-  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether 
short
-assignment operators are left-padded to the same length as long
-ones in order to put all assignment operators to the right of
-the left hand side.
+  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether 
short assignment
+operators are left-padded to the same length as long ones in order to
+put all assignment operators to the right of the left hand side.
 
 .. code-block:: c++
 
@@ -606,8 +604,8 @@ the configuration (without a prefix: ``Auto``).
   /* A comment. */
   double e = 4;
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound assignments
+like ``+=`` are aligned along with ``=``.
 
 .. code-block:: c++
 
@@ -619,10 +617,9 @@ the configuration (without a prefix: ``Auto``).
   a &= 2;
   bbb = 2;
 
-  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether 
short
-assignment operators are left-padded to the same length as long
-ones in order to put all assignment operators to the right of
-the left hand side.
+  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether 
short assignment
+operators are left-padded to the same length as long ones in order to
+put all assignment operators to the right of the left hand side.
 
 .. code-block:: c++
 
@@ -731,8 +728,8 @@ the configuration (without a prefix: ``Auto``).
   /* A comment. */
   double e = 4;
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound assignments
+like ``+=`` are aligned along with ``=``.
 
 .. code-block:: c++
 
@@ -744,10 +741,9 @@ the configuration (without a prefix: ``Auto``).
   a &= 2;
   bbb = 2;
 
-  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether 
short
-assignment operators are left-padded to the same length as long
-ones in order to put all assignment operators to the right of

[PATCH] D121749: [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

2022-03-17 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45cb2df6788c: [clang-format][docs] Regenerate 
ClangFormatStyleOptions.rst (authored by kuzkry, committed by curdeius).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121749/new/

https://reviews.llvm.org/D121749

Files:
  clang/docs/ClangFormatStyleOptions.rst

Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -358,8 +358,8 @@
   /* A comment. */
   double e = 4;
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
+like ``+=`` are aligned along with ``=``.
 
 .. code-block:: c++
 
@@ -371,10 +371,9 @@
   a &= 2;
   bbb = 2;
 
-  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short
-assignment operators are left-padded to the same length as long
-ones in order to put all assignment operators to the right of
-the left hand side.
+  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short assignment
+operators are left-padded to the same length as long ones in order to
+put all assignment operators to the right of the left hand side.
 
 .. code-block:: c++
 
@@ -482,8 +481,8 @@
   /* A comment. */
   double e = 4;
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
+like ``+=`` are aligned along with ``=``.
 
 .. code-block:: c++
 
@@ -495,10 +494,9 @@
   a &= 2;
   bbb = 2;
 
-  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short
-assignment operators are left-padded to the same length as long
-ones in order to put all assignment operators to the right of
-the left hand side.
+  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short assignment
+operators are left-padded to the same length as long ones in order to
+put all assignment operators to the right of the left hand side.
 
 .. code-block:: c++
 
@@ -606,8 +604,8 @@
   /* A comment. */
   double e = 4;
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
+like ``+=`` are aligned along with ``=``.
 
 .. code-block:: c++
 
@@ -619,10 +617,9 @@
   a &= 2;
   bbb = 2;
 
-  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short
-assignment operators are left-padded to the same length as long
-ones in order to put all assignment operators to the right of
-the left hand side.
+  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short assignment
+operators are left-padded to the same length as long ones in order to
+put all assignment operators to the right of the left hand side.
 
 .. code-block:: c++
 
@@ -731,8 +728,8 @@
   /* A comment. */
   double e = 4;
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
+like ``+=`` are aligned along with ``=``.
 
 .. code-block:: c++
 
@@ -744,10 +741,9 @@
   a &= 2;
   bbb = 2;
 
-  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short
-assignment operators are left-padded to the same length as long
-ones in order to put all assignment operators to the right of
-the left hand side.
+  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short assignment
+operators are left-padded to the same length as long ones in order to
+put all assignment operators to the right of the left hand side.
 
 .. code-block:: c++
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 5a62495 - [pseudo] Fix some naming-style violations.

2022-03-17 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-03-17T09:47:24+01:00
New Revision: 5a624956ced826745447dd95381624fb4bb10a7f

URL: 
https://github.com/llvm/llvm-project/commit/5a624956ced826745447dd95381624fb4bb10a7f
DIFF: 
https://github.com/llvm/llvm-project/commit/5a624956ced826745447dd95381624fb4bb10a7f.diff

LOG: [pseudo] Fix some naming-style violations.

Added: 


Modified: 
clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
clang-tools-extra/pseudo/lib/Grammar.cpp
clang-tools-extra/pseudo/lib/GrammarBNF.cpp
clang-tools-extra/pseudo/lib/LRGraph.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
index ab71b6a56af1e..7e94c4b89d854 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
@@ -157,11 +157,11 @@ struct GrammarTable {
 
   struct Nonterminal {
 std::string Name;
-// Corresponding rules that construct the non-terminal, it is a [start, 
end)
+// Corresponding rules that construct the non-terminal, it is a [Start, 
End)
 // index range of the Rules table.
 struct {
-  RuleID start;
-  RuleID end;
+  RuleID Start;
+  RuleID End;
 } RuleRange;
   };
 

diff  --git a/clang-tools-extra/pseudo/lib/Grammar.cpp 
b/clang-tools-extra/pseudo/lib/Grammar.cpp
index 542d30c7c5051..c362a14a51e13 100644
--- a/clang-tools-extra/pseudo/lib/Grammar.cpp
+++ b/clang-tools-extra/pseudo/lib/Grammar.cpp
@@ -36,8 +36,8 @@ Grammar::Grammar(std::unique_ptr Table) : 
T(std::move(Table)) {
 llvm::ArrayRef Grammar::rulesFor(SymbolID SID) const {
   assert(isNonterminal(SID));
   const auto &R = T->Nonterminals[SID].RuleRange;
-  assert(R.end <= T->Rules.size());
-  return llvm::makeArrayRef(&T->Rules[R.start], R.end - R.start);
+  assert(R.End <= T->Rules.size());
+  return llvm::makeArrayRef(&T->Rules[R.Start], R.End - R.Start);
 }
 
 const Rule &Grammar::lookupRule(RuleID RID) const {
@@ -65,7 +65,7 @@ std::string Grammar::dumpRules(SymbolID SID) const {
   assert(isNonterminal(SID));
   std::string Result;
   const auto &Range = T->Nonterminals[SID].RuleRange;
-  for (RuleID RID = Range.start; RID < Range.end; ++RID)
+  for (RuleID RID = Range.Start; RID < Range.End; ++RID)
 Result.append(dumpRule(RID)).push_back('\n');
   return Result;
 }
@@ -140,17 +140,17 @@ std::vector> followSets(const 
Grammar &G) {
 for (const auto &R : G.table().Rules) {
   // Rule 2: for a rule X := ... Y Z, we add all symbols from FIRST(Z) to
   // FOLLOW(Y).
-  for (size_t i = 0; i + 1 < R.seq().size(); ++i) {
-if (isToken(R.seq()[i]))
+  for (size_t I = 0; I + 1 < R.seq().size(); ++I) {
+if (isToken(R.seq()[I]))
   continue;
 // We only need to consider the next symbol because symbols are
 // non-nullable.
-SymbolID Next = R.seq()[i + 1];
+SymbolID Next = R.seq()[I + 1];
 if (isToken(Next))
   // First set for a terminal is itself.
-  Changed |= ExpandFollowSet(R.seq()[i], {Next});
+  Changed |= ExpandFollowSet(R.seq()[I], {Next});
 else
-  Changed |= ExpandFollowSet(R.seq()[i], FirstSets[Next]);
+  Changed |= ExpandFollowSet(R.seq()[I], FirstSets[Next]);
   }
   // Rule 3: for a rule X := ... Z, we add all symbols from FOLLOW(X) to
   // FOLLOW(Z).

diff  --git a/clang-tools-extra/pseudo/lib/GrammarBNF.cpp 
b/clang-tools-extra/pseudo/lib/GrammarBNF.cpp
index 5e4739719eacd..57ed2ca7c8f0b 100644
--- a/clang-tools-extra/pseudo/lib/GrammarBNF.cpp
+++ b/clang-tools-extra/pseudo/lib/GrammarBNF.cpp
@@ -203,7 +203,7 @@ class GrammarBuilder {
 const auto &T = G.table();
 for (SymbolID SID = 0; SID < T.Nonterminals.size(); ++SID) {
   auto Range = T.Nonterminals[SID].RuleRange;
-  if (Range.start == Range.end)
+  if (Range.Start == Range.End)
 Diagnostics.push_back(
 llvm::formatv("No rules for nonterminal: {0}", G.symbolName(SID)));
   llvm::StringRef NameRef = T.Nonterminals[SID].Name;
@@ -216,7 +216,7 @@ class GrammarBuilder {
   if (T.Rules[RID] == T.Rules[RID + 1])
 Diagnostics.push_back(
 llvm::formatv("Duplicate rule: `{0}`", G.dumpRule(RID)));
-  // Warning for nullable non-terminals
+  // Warning for nullable nonterminals
   if (T.Rules[RID].Size == 0)
 Diagnostics.push_back(
 llvm::formatv("Rule `{0}` has a nullable RHS", G.dumpRule(RID)));

diff  --git a/clang-tools-extra/pseudo/lib/LRGraph.cpp 
b/clang-tools-extra/pseudo/lib/LRGraph.cpp
index edb544fef4940..9dc0cdbbdab81 100644
--- a/clang-tools-extra/pseudo/lib/LRGraph.cpp
+++ b/clang-tools-extra/pseudo/lib/LRGraph.cpp
@@ -75,7 +75,7 @@ State closure(ItemSet Queue, const Grammar &G) {
 if (pseudo::isToken(NextSym))
   continue;
 auto

[PATCH] D121890: [clang-format] Copy help options to the doc directory.

2022-03-17 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
sstwcw added a reviewer: clang-format.
sstwcw added a project: clang-format.
Herald added a project: All.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The options listed in ClangFormat.rst lag behind those output by the
-help command line option.  Specifically, these are missing.

--files
--qualifier-alignment


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121890

Files:
  clang/docs/ClangFormat.rst

Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -28,74 +28,71 @@
 
   OPTIONS:
 
-  Clang-format options:
-
---Werror   - If set, changes formatting warnings to errors
---Wno-error=- If set don't error out on the specified warning type.
-  =unknown -   If set, unknown format options are only warned about.
-   This can be used to enable formatting, even if the
-   configuration contains unknown (newer) options.
-   Use with caution, as this might lead to dramatically
-   differing format depending on an option being
-   supported or not.
---assume-filename= - Override filename used to determine the language.
- When reading from stdin, clang-format assumes this
- filename to determine the language.
---cursor=- The position of the cursor when invoking
- clang-format from an editor integration
---dry-run  - If set, do not actually make the formatting changes
---dump-config  - Dump configuration options to stdout and exit.
- Can be used with -style option.
---fallback-style=  - The name of the predefined style used as a
- fallback in case clang-format is invoked with
- -style=file, but can not find the .clang-format
- file to use.
- Use -fallback-style=none to skip formatting.
---ferror-limit=  - Set the maximum number of clang-format errors to
- emit before stopping (0 = no limit). Used only
- with --dry-run or -n
--i - Inplace edit s, if specified.
---length=- Format a range of this length (in bytes).
- Multiple ranges can be formatted by specifying
- several -offset and -length pairs.
- When only a single -offset is specified without
- -length, clang-format will format up to the end
- of the file.
- Can only be used with one input file.
---lines=   - : - format a range of
- lines (both 1-based).
- Multiple ranges can be formatted by specifying
- several -lines arguments.
- Can't be used with -offset and -length.
- Can only be used with one input file.
--n - Alias for --dry-run
---offset=- Format a range starting at this byte offset.
- Multiple ranges can be formatted by specifying
- several -offset and -length pairs.
- Can only be used with one input file.
---output-replacements-xml  - Output replacements as XML.
---sort-includes- If set, overrides the include sorting behavior
- determined by the SortIncludes style flag
---style=   - Coding style, currently supports:
-   LLVM, Google, Chromium, Mozilla, WebKit.
- Use -style=file to load style configuration from
- .clang-format file located in one of the parent
- directories of the source file (or current
- directory for stdin).
- Use -style=file: to load style
- configuration from a format file located at
- . This path can be absolute or
- relative to the working directory.
- Use -style="{key: value, ...}" to set specific
- parameters, e.g.:
-   -style="{BasedOnSt

[PATCH] D121890: [clang-format] Copy help options to the doc directory.

2022-03-17 Thread sstwcw via Phabricator via cfe-commits
sstwcw updated this revision to Diff 416097.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121890/new/

https://reviews.llvm.org/D121890

Files:
  clang/docs/ClangFormat.rst

Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -30,72 +30,69 @@
 
   Clang-format options:
 
---Werror   - If set, changes formatting warnings to errors
---Wno-error=- If set don't error out on the specified warning type.
-  =unknown -   If set, unknown format options are only warned about.
-   This can be used to enable formatting, even if the
-   configuration contains unknown (newer) options.
-   Use with caution, as this might lead to dramatically
-   differing format depending on an option being
-   supported or not.
---assume-filename= - Override filename used to determine the language.
- When reading from stdin, clang-format assumes this
- filename to determine the language.
---cursor=- The position of the cursor when invoking
- clang-format from an editor integration
---dry-run  - If set, do not actually make the formatting changes
---dump-config  - Dump configuration options to stdout and exit.
- Can be used with -style option.
---fallback-style=  - The name of the predefined style used as a
- fallback in case clang-format is invoked with
- -style=file, but can not find the .clang-format
- file to use.
- Use -fallback-style=none to skip formatting.
---ferror-limit=  - Set the maximum number of clang-format errors to
- emit before stopping (0 = no limit). Used only
- with --dry-run or -n
--i - Inplace edit s, if specified.
---length=- Format a range of this length (in bytes).
- Multiple ranges can be formatted by specifying
- several -offset and -length pairs.
- When only a single -offset is specified without
- -length, clang-format will format up to the end
- of the file.
- Can only be used with one input file.
---lines=   - : - format a range of
- lines (both 1-based).
- Multiple ranges can be formatted by specifying
- several -lines arguments.
- Can't be used with -offset and -length.
- Can only be used with one input file.
--n - Alias for --dry-run
---offset=- Format a range starting at this byte offset.
- Multiple ranges can be formatted by specifying
- several -offset and -length pairs.
- Can only be used with one input file.
---output-replacements-xml  - Output replacements as XML.
---sort-includes- If set, overrides the include sorting behavior
- determined by the SortIncludes style flag
---style=   - Coding style, currently supports:
-   LLVM, Google, Chromium, Mozilla, WebKit.
- Use -style=file to load style configuration from
- .clang-format file located in one of the parent
- directories of the source file (or current
- directory for stdin).
- Use -style=file: to load style
- configuration from a format file located at
- . This path can be absolute or
- relative to the working directory.
- Use -style="{key: value, ...}" to set specific
- parameters, e.g.:
-   -style="{BasedOnStyle: llvm, IndentWidth: 8}"
---verbose  - If set, shows the list of processed files
+--Werror   - If set, changes formatting warnings to errors
+--Wno-error=- If set don't error out on the specified warning type.
+  =unknown -   I

[PATCH] D121890: [clang-format] Copy help options to the doc directory.

2022-03-17 Thread sstwcw via Phabricator via cfe-commits
sstwcw added a comment.

If anyone's wondering why all the lines changed.  The `--qualifier-alignment` 
is too long so all the descriptions are moved to the right.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121890/new/

https://reviews.llvm.org/D121890

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121792: [AArch64][SVE] InstCombine llvm.aarch64.sve.sel to select

2022-03-17 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Why do we have llvm.aarch64.sve.sel if we are always going to replace it with a 
select? Why not remove llvm.aarch64.sve.sel entirely?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121792/new/

https://reviews.llvm.org/D121792

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121497: Lex: add support for `{,u}i128` Microsoft extension

2022-03-17 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a subscriber: vsapsai.
iains added a comment.

hmm that makes it quite hard to analyse what's going on ...
.. however, it seems that this is a clang-modules style build (I am more 
familiar with the C++20 modules stuff, so probably  @vsapsai will be able to 
throw more light on this).
however, I concur with @aaron.ballman that the original fail seems pretty fishy 
- at least for C++20 modules we do not do anything special in the pre-processor 
(with the exception of Header Units, but that code is not yet landed).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121497/new/

https://reviews.llvm.org/D121497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121890: [clang-format] Copy help options to the doc directory.

2022-03-17 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/docs/ClangFormat.rst:76
+--output-replacements-xml  - Output replacements as XML.
+--qualifier-alignment= - If set, overrides the qualifier alignment 
style determined by the QualifierAlignment style flag
+--sort-includes- If set, overrides the include sorting 
behavior determined by the SortIncludes style flag

Shouldn't long descriptions like this one be split into multiple lines and 
aligned with `-`?
Did you do it by hand or with some script?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121890/new/

https://reviews.llvm.org/D121890

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121792: [AArch64][SVE] InstCombine llvm.aarch64.sve.sel to select

2022-03-17 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm added a comment.

In D121792#3388585 , @dmgreen wrote:

> Why do we have llvm.aarch64.sve.sel if we are always going to replace it with 
> a select? Why not remove llvm.aarch64.sve.sel entirely?

I'm not the key decisionmaker here, but hopefully I can summarize the position 
and others can chime in if I'm mistaken or misdirecting.

1. You're right, and we've been discussing the possibility removing these 
intrinsics where they're unnecessary.
2. The intrinsics exist largely to support the ACLE.
3. There are a significant number of them, at the moment there is a 
straightforward correspondence between the C level and IR level.
4. Because of the correspondence, there is currently very little 
code/complexity per-intrinsic required in clang to support the ACLE.
5. Therefore, removing these intrinsics requires increasing the complexity of 
the frontend.
6. Some intrinsics will always be required.

Given these considerations, our current thinking is to have a future effort to 
see if removing intrinsics like this and lowering directly to clean IR is a net 
win in total. And to commit to doing this with a holistic view of the situation 
rather than doing it bit-by-bit and making a mess.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121792/new/

https://reviews.llvm.org/D121792

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119792: [Clang] [P2025] Analyze only potential scopes for NRVO

2022-03-17 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron updated this revision to Diff 416116.
Izaron added a comment.
Herald added a project: All.

Rebased the patch on top of D119927 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119792/new/

https://reviews.llvm.org/D119792

Files:
  clang/include/clang/Sema/Scope.h
  clang/lib/Sema/Scope.cpp
  clang/test/CodeGenCXX/nrvo.cpp

Index: clang/test/CodeGenCXX/nrvo.cpp
===
--- clang/test/CodeGenCXX/nrvo.cpp
+++ clang/test/CodeGenCXX/nrvo.cpp
@@ -167,81 +167,13 @@
 
 // CHECK-LABEL: @_Z5test3b(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[X:%.*]] = alloca [[CLASS_X:%.*]], align 1
-// CHECK-NEXT:br i1 [[B:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
-// CHECK:   if.then:
 // CHECK-NEXT:call void @_ZN1XC1Ev(%class.X* noundef nonnull align 1 dereferenceable(1) [[AGG_RESULT:%.*]]) #[[ATTR5]]
-// CHECK-NEXT:br label [[RETURN:%.*]]
-// CHECK:   if.end:
-// CHECK-NEXT:[[TMP0:%.*]] = getelementptr inbounds [[CLASS_X]], %class.X* [[X]], i32 0, i32 0
-// CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull [[TMP0]]) #[[ATTR5]]
-// CHECK-NEXT:call void @_ZN1XC1Ev(%class.X* noundef nonnull align 1 dereferenceable(1) [[X]]) #[[ATTR5]]
-// CHECK-NEXT:call void @_ZN1XC1ERKS_(%class.X* noundef nonnull align 1 dereferenceable(1) [[AGG_RESULT]], %class.X* noundef nonnull align 1 dereferenceable(1) [[X]]) #[[ATTR5]]
-// CHECK-NEXT:call void @_ZN1XD1Ev(%class.X* noundef nonnull align 1 dereferenceable(1) [[X]]) #[[ATTR5]]
-// CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull [[TMP0]]) #[[ATTR5]]
-// CHECK-NEXT:br label [[RETURN]]
-// CHECK:   return:
 // CHECK-NEXT:ret void
 //
-// CHECK-EH-03-LABEL: @_Z5test3b(
-// CHECK-EH-03-NEXT:  entry:
-// CHECK-EH-03-NEXT:[[X:%.*]] = alloca [[CLASS_X:%.*]], align 1
-// CHECK-EH-03-NEXT:br i1 [[B:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
-// CHECK-EH-03:   if.then:
-// CHECK-EH-03-NEXT:call void @_ZN1XC1Ev(%class.X* noundef nonnull align 1 dereferenceable(1) [[AGG_RESULT:%.*]])
-// CHECK-EH-03-NEXT:br label [[RETURN:%.*]]
-// CHECK-EH-03:   if.end:
-// CHECK-EH-03-NEXT:[[TMP0:%.*]] = getelementptr inbounds [[CLASS_X]], %class.X* [[X]], i32 0, i32 0
-// CHECK-EH-03-NEXT:call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull [[TMP0]]) #[[ATTR7]]
-// CHECK-EH-03-NEXT:call void @_ZN1XC1Ev(%class.X* noundef nonnull align 1 dereferenceable(1) [[X]])
-// CHECK-EH-03-NEXT:invoke void @_ZN1XC1ERKS_(%class.X* noundef nonnull align 1 dereferenceable(1) [[AGG_RESULT]], %class.X* noundef nonnull align 1 dereferenceable(1) [[X]])
-// CHECK-EH-03-NEXT:to label [[INVOKE_CONT:%.*]] unwind label [[LPAD:%.*]]
-// CHECK-EH-03:   invoke.cont:
-// CHECK-EH-03-NEXT:call void @_ZN1XD1Ev(%class.X* noundef nonnull align 1 dereferenceable(1) [[X]])
-// CHECK-EH-03-NEXT:call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull [[TMP0]]) #[[ATTR7]]
-// CHECK-EH-03-NEXT:br label [[RETURN]]
-// CHECK-EH-03:   lpad:
-// CHECK-EH-03-NEXT:[[TMP1:%.*]] = landingpad { i8*, i32 }
-// CHECK-EH-03-NEXT:cleanup
-// CHECK-EH-03-NEXT:invoke void @_ZN1XD1Ev(%class.X* noundef nonnull align 1 dereferenceable(1) [[X]])
-// CHECK-EH-03-NEXT:to label [[INVOKE_CONT1:%.*]] unwind label [[TERMINATE_LPAD:%.*]]
-// CHECK-EH-03:   invoke.cont1:
-// CHECK-EH-03-NEXT:call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull [[TMP0]]) #[[ATTR7]]
-// CHECK-EH-03-NEXT:resume { i8*, i32 } [[TMP1]]
-// CHECK-EH-03:   return:
-// CHECK-EH-03-NEXT:ret void
-// CHECK-EH-03:   terminate.lpad:
-// CHECK-EH-03-NEXT:[[TMP2:%.*]] = landingpad { i8*, i32 }
-// CHECK-EH-03-NEXT:catch i8* null
-// CHECK-EH-03-NEXT:[[TMP3:%.*]] = extractvalue { i8*, i32 } [[TMP2]], 0
-// CHECK-EH-03-NEXT:call void @__clang_call_terminate(i8* [[TMP3]]) #[[ATTR8]]
-// CHECK-EH-03-NEXT:unreachable
-//
-// CHECK-EH-11-LABEL: @_Z5test3b(
-// CHECK-EH-11-NEXT:  entry:
-// CHECK-EH-11-NEXT:[[X:%.*]] = alloca [[CLASS_X:%.*]], align 1
-// CHECK-EH-11-NEXT:br i1 [[B:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
-// CHECK-EH-11:   if.then:
-// CHECK-EH-11-NEXT:call void @_ZN1XC1Ev(%class.X* noundef nonnull align 1 dereferenceable(1) [[AGG_RESULT:%.*]])
-// CHECK-EH-11-NEXT:br label [[RETURN:%.*]]
-// CHECK-EH-11:   if.end:
-// CHECK-EH-11-NEXT:[[TMP0:%.*]] = getelementptr inbounds [[CLASS_X]], %class.X* [[X]], i32 0, i32 0
-// CHECK-EH-11-NEXT:call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull [[TMP0]]) #[[ATTR7]]
-// CHECK-EH-11-NEXT:call void @_ZN1XC1Ev(%class.X* noundef nonnull align 1 dereferenceable(1) [[X]])
-// CHECK-EH-11-NEXT:invoke void @_ZN1XC1ERKS_(%class.X* noundef nonnull align 1 dereferenceable(1) [[AGG_RESULT]], %class.X* noundef nonnull align 1 dereferenceable(1) [[X]])
-

[PATCH] D121816: [Clang][VE] Add vector mask intrinsics to clang

2022-03-17 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 added a comment.

Having timeout errors on lldb-aarch64-ubuntu builder...  I'm not sure what 
modification on this patch causes a such error.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121816/new/

https://reviews.llvm.org/D121816

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121816: [Clang][VE] Add vector mask intrinsics to clang

2022-03-17 Thread Simon Moll via Phabricator via cfe-commits
simoll added a comment.

In D121816#3388748 , @kaz7 wrote:

> Having timeout errors on lldb-aarch64-ubuntu builder...  I'm not sure what 
> modification on this patch causes a such error.

There's another commit tested in the failing run: 
https://lab.llvm.org/buildbot/#/builders/96/builds/20465


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121816/new/

https://reviews.llvm.org/D121816

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4e4f839 - [X86] Use the unaligned vector typedefs for the lddqu intrinsics pointer arguments (PR20670)

2022-03-17 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-03-17T10:42:29Z
New Revision: 4e4f839ac2a9002df504f1bed8383c2d7d72e86e

URL: 
https://github.com/llvm/llvm-project/commit/4e4f839ac2a9002df504f1bed8383c2d7d72e86e
DIFF: 
https://github.com/llvm/llvm-project/commit/4e4f839ac2a9002df504f1bed8383c2d7d72e86e.diff

LOG: [X86] Use the unaligned vector typedefs for the lddqu intrinsics pointer 
arguments (PR20670)

Extension to 4390c721cba09597037578100948bbc83cc41b16 - similar to the vanilla 
load/store intrinsics, _mm_lddqu_si128/_mm256_lddqu_si256 should take an 
unaligned pointer, but were using the aligned m128i/m256i types which can cause 
alignment warnings.

The existing sse3-builtins.c and avx-builtins.c tests in 
llvm-project\clang\test\CodeGen\X86 should cover this.

Differential Revision: https://reviews.llvm.org/D121815

Added: 


Modified: 
clang/lib/Headers/avxintrin.h
clang/lib/Headers/pmmintrin.h

Removed: 




diff  --git a/clang/lib/Headers/avxintrin.h b/clang/lib/Headers/avxintrin.h
index 17fe636911772..df2d1a2690d8e 100644
--- a/clang/lib/Headers/avxintrin.h
+++ b/clang/lib/Headers/avxintrin.h
@@ -3177,7 +3177,7 @@ _mm256_loadu_si256(__m256i_u const *__p)
 ///A pointer to a 256-bit integer vector containing integer values.
 /// \returns A 256-bit integer vector containing the moved values.
 static __inline __m256i __DEFAULT_FN_ATTRS
-_mm256_lddqu_si256(__m256i const *__p)
+_mm256_lddqu_si256(__m256i_u const *__p)
 {
   return (__m256i)__builtin_ia32_lddqu256((char const *)__p);
 }

diff  --git a/clang/lib/Headers/pmmintrin.h b/clang/lib/Headers/pmmintrin.h
index eda83567cd058..ee660e95d2744 100644
--- a/clang/lib/Headers/pmmintrin.h
+++ b/clang/lib/Headers/pmmintrin.h
@@ -35,7 +35,7 @@
 ///A pointer to a 128-bit integer vector containing integer values.
 /// \returns A 128-bit vector containing the moved values.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_lddqu_si128(__m128i const *__p)
+_mm_lddqu_si128(__m128i_u const *__p)
 {
   return (__m128i)__builtin_ia32_lddqu((char const *)__p);
 }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121815: [X86] Use the unaligned vector typedefs for the lddqu intrinsics pointer arguments (PR20670)

2022-03-17 Thread Simon Pilgrim via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4e4f839ac2a9: [X86] Use the unaligned vector typedefs for 
the lddqu intrinsics pointer… (authored by RKSimon).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121815/new/

https://reviews.llvm.org/D121815

Files:
  clang/lib/Headers/avxintrin.h
  clang/lib/Headers/pmmintrin.h


Index: clang/lib/Headers/pmmintrin.h
===
--- clang/lib/Headers/pmmintrin.h
+++ clang/lib/Headers/pmmintrin.h
@@ -35,7 +35,7 @@
 ///A pointer to a 128-bit integer vector containing integer values.
 /// \returns A 128-bit vector containing the moved values.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_lddqu_si128(__m128i const *__p)
+_mm_lddqu_si128(__m128i_u const *__p)
 {
   return (__m128i)__builtin_ia32_lddqu((char const *)__p);
 }
Index: clang/lib/Headers/avxintrin.h
===
--- clang/lib/Headers/avxintrin.h
+++ clang/lib/Headers/avxintrin.h
@@ -3177,7 +3177,7 @@
 ///A pointer to a 256-bit integer vector containing integer values.
 /// \returns A 256-bit integer vector containing the moved values.
 static __inline __m256i __DEFAULT_FN_ATTRS
-_mm256_lddqu_si256(__m256i const *__p)
+_mm256_lddqu_si256(__m256i_u const *__p)
 {
   return (__m256i)__builtin_ia32_lddqu256((char const *)__p);
 }


Index: clang/lib/Headers/pmmintrin.h
===
--- clang/lib/Headers/pmmintrin.h
+++ clang/lib/Headers/pmmintrin.h
@@ -35,7 +35,7 @@
 ///A pointer to a 128-bit integer vector containing integer values.
 /// \returns A 128-bit vector containing the moved values.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_lddqu_si128(__m128i const *__p)
+_mm_lddqu_si128(__m128i_u const *__p)
 {
   return (__m128i)__builtin_ia32_lddqu((char const *)__p);
 }
Index: clang/lib/Headers/avxintrin.h
===
--- clang/lib/Headers/avxintrin.h
+++ clang/lib/Headers/avxintrin.h
@@ -3177,7 +3177,7 @@
 ///A pointer to a 256-bit integer vector containing integer values.
 /// \returns A 256-bit integer vector containing the moved values.
 static __inline __m256i __DEFAULT_FN_ATTRS
-_mm256_lddqu_si256(__m256i const *__p)
+_mm256_lddqu_si256(__m256i_u const *__p)
 {
   return (__m256i)__builtin_ia32_lddqu256((char const *)__p);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121445: [Clang][CSKY] Add the CSKY target and compiler driver

2022-03-17 Thread Renato Golin via Phabricator via cfe-commits
rengolin added inline comments.



Comment at: clang/test/Driver/csky-arch-error.c:1
+// RUN: %clang -target csky-unknown-elf -march=csky -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CSKY %s

This will error out and fail the test. You need to add a `not` before `%clang`.

Check tests in `clang/test/Driver/` that has `not %clang` as their RUN lines 
and do the same.

And keep all the `not %clang` tests separate from the `%clang` tests.



Comment at: clang/test/Driver/csky-arch.c:28
+
+// CHECK-NOT: error: invalid arch name '
+// CSKY-TARGET: "-triple" "csky-unknown-unknown-elf"

If the RUN line fails (ex. on invalid arch name), the return value will be 
non-zero and the test will fail, so CHECKing for the absence of errors is no-op.



Comment at: clang/test/Driver/csky-cpus.c:12
+// RUN: %clang -target csky -### -c %s 2>&1 -mcpu=generic1 | FileCheck 
-check-prefix=FAIL-MCPU-NAME %s
+// FAIL-MCPU-NAME: error: the clang compiler does not support '-mcpu=generic1'
+

Same here, separate `not` tests.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121445/new/

https://reviews.llvm.org/D121445

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121445: [Clang][CSKY] Add the CSKY target and compiler driver

2022-03-17 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

I'm surprised these tests are passing for you. Perhaps you're not building or 
running them all.

To make sure you're running your tests, you need to build both clang and llvm 
(`-DLLVM_ENABLE_PROJECTS=clang`) and run ninja/make `check-all`.

You can also run `lit` directly on each test, but I can't remember how to do 
that now...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121445/new/

https://reviews.llvm.org/D121445

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121863: [clang][dataflow] Model the behavior of non-standard optional assignment

2022-03-17 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 416132.
sgatev marked 3 inline comments as done.
sgatev added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121863/new/

https://reviews.llvm.org/D121863

Files:
  
clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
@@ -30,13 +30,28 @@
 using ::testing::UnorderedElementsAre;
 
 // FIXME: Move header definitions in separate file(s).
+static constexpr char CSDtdDefHeader[] = R"(
+#ifndef CSTDDEF_H
+#define CSTDDEF_H
+
+namespace std {
+
+typedef decltype(sizeof(char)) size_t;
+
+using nullptr_t = decltype(nullptr);
+
+} // namespace std
+
+#endif // CSTDDEF_H
+)";
+
 static constexpr char StdTypeTraitsHeader[] = R"(
 #ifndef STD_TYPE_TRAITS_H
 #define STD_TYPE_TRAITS_H
 
-namespace std {
+#include "cstddef.h"
 
-typedef decltype(sizeof(char)) size_t;
+namespace std {
 
 template 
 struct integral_constant {
@@ -287,6 +302,9 @@
 template 
 using _And = decltype(__and_helper<_Pred...>(0));
 
+template 
+struct _Not : _BoolConstant {};
+
 struct __check_tuple_constructor_fail {
   static constexpr bool __enable_explicit_default() { return false; }
   static constexpr bool __enable_implicit_default() { return false; }
@@ -300,6 +318,150 @@
   }
 };
 
+template 
+struct __select_2nd {
+  typedef _Tp type;
+};
+template 
+typename __select_2nd() = declval<_Arg>())),
+  true_type>::type
+__is_assignable_test(int);
+template 
+false_type __is_assignable_test(...);
+template ::value || is_void<_Arg>::value>
+struct __is_assignable_imp
+: public decltype((__is_assignable_test<_Tp, _Arg>(0))) {};
+template 
+struct __is_assignable_imp<_Tp, _Arg, true> : public false_type {};
+template 
+struct is_assignable : public __is_assignable_imp<_Tp, _Arg> {};
+
+template 
+struct __libcpp_is_integral : public false_type {};
+template <>
+struct __libcpp_is_integral : public true_type {};
+template <>
+struct __libcpp_is_integral : public true_type {};
+template <>
+struct __libcpp_is_integral : public true_type {};
+template <>
+struct __libcpp_is_integral : public true_type {};
+template <>
+struct __libcpp_is_integral : public true_type {};
+template <>
+struct __libcpp_is_integral : public true_type {};  // NOLINT
+template <>
+struct __libcpp_is_integral : public true_type {};  // NOLINT
+template <>
+struct __libcpp_is_integral : public true_type {};
+template <>
+struct __libcpp_is_integral : public true_type {};
+template <>
+struct __libcpp_is_integral : public true_type {};  // NOLINT
+template <>
+struct __libcpp_is_integral : public true_type {};  // NOLINT
+template <>
+struct __libcpp_is_integral : public true_type {};  // NOLINT
+template <>// NOLINTNEXTLINE
+struct __libcpp_is_integral : public true_type {};
+template 
+struct is_integral
+: public __libcpp_is_integral::type> {};
+
+template 
+struct __libcpp_is_floating_point : public false_type {};
+template <>
+struct __libcpp_is_floating_point : public true_type {};
+template <>
+struct __libcpp_is_floating_point : public true_type {};
+template <>
+struct __libcpp_is_floating_point : public true_type {};
+template 
+struct is_floating_point
+: public __libcpp_is_floating_point::type> {};
+
+template 
+struct is_arithmetic
+: public integral_constant::value ||
+ is_floating_point<_Tp>::value> {};
+
+template 
+struct __libcpp_is_pointer : public false_type {};
+template 
+struct __libcpp_is_pointer<_Tp*> : public true_type {};
+template 
+struct is_pointer : public __libcpp_is_pointer::type> {
+};
+
+template 
+struct __libcpp_is_member_pointer : public false_type {};
+template 
+struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
+template 
+struct is_member_pointer
+: public __libcpp_is_member_pointer::type> {};
+
+template 
+struct __libcpp_union : public false_type {};
+template 
+struct is_union : public __libcpp_union::type> {};
+
+template 
+struct is_reference : false_type {};
+template 
+struct is_reference : true_type {};
+template 
+struct is_reference : true_type {};
+
+template 
+inline constexpr bool is_reference_v = is_reference::value;
+
+struct __two {
+  char __lx[2];
+};
+
+namespace __is_class_imp {
+template 
+char __test(int _Tp::*);
+template 
+__two __test(...);
+}  // namespace __is_c

[PATCH] D121863: [clang][dataflow] Model the behavior of non-standard optional assignment

2022-03-17 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev added inline comments.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:81
 
+auto isOptionalValueOrConversionAssignment() {
+  return cxxOperatorCallExpr(

xazax.hun wrote:
> While really like the convenience matchers will give us building data flow 
> analyses, I wonder whether a lot of duplicated work is happening in the 
> background. E.g. will we end up string comparing the class name of the parent 
> of the method in the matcher built by `optionalClass` whenever we process an 
> overloaded `operator=`?
> 
> In a handwritten implementation we would only do this once, store the address 
> of the canonical declaration somewhere and subsequent checks would only look 
> up the canonical declaration of the called method and do a pointer 
> comparison. 
> 
> In case this matcher approach is not that efficient, I wonder if it would be 
> possible to come up with some APIs where the matching is only done once and 
> subsequent transfer functions would only use the cached pointers to 
> declarations/types. In case the matchers are already doing something smart in 
> the background feel free to ignore this comment. 
That's a great point! Unfortunately, I'm not familiar with the implementation 
of matchers so I'll need to take a closer look/ask around to understand if such 
an optimization is already in place. Let me take a note of this for now. I 
suggest revising the APIs once we know more about the internals of matchers.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121863/new/

https://reviews.llvm.org/D121863

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121445: [Clang][CSKY] Add the CSKY target and compiler driver

2022-03-17 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

> You can also run lit directly on each test, but I can't remember how to do 
> that now...

If you're in the build dir:

  ./bin/llvm-lit ../llvm-project/clang/test/.. -a

(-a gives you full output of what happens)

Some tests are a bit odd when you do this but these clang tests are usually ok.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121445/new/

https://reviews.llvm.org/D121445

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121497: Lex: add support for `{,u}i128` Microsoft extension

2022-03-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D121497#3388024 , @compnerd wrote:

> I don't have an example module sadly.  It was something that I ran into with 
> Swift code import the WinSDK module defined in 
> https://github.com/apple/swift/blob/main/stdlib/public/Platform/winsdk.modulemap.

Could this be the reproducer? https://godbolt.org/z/YbbMse9a4


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121497/new/

https://reviews.llvm.org/D121497

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119470: [clang-tidy] Don't check decltype return types in `readability-const-return-type`

2022-03-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: 
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp:56-58
+AST_MATCHER(QualType, isLocalConstQualified) {
+  return Node.isLocalConstQualified();
+}

Izaron wrote:
> aaron.ballman wrote:
> > I think we might as well hit all the local qualifiers instead of just 
> > `const`, WDYT? e.g., `volatile` et al via `hasLocalQualifiers()`
> In this case the checker will complain on this code:
> ```
> const int i = 1;
> volatile decltype(i) n() {
>   return 12345;
> }
> ```
> ```
> warning: return type 'volatile decltype(i)' (aka 'const volatile int') is 
> 'const'-qualified at the top level, which may reduce code readability without 
> improving const correctness [readability-const-return-type]
> ```
> That wouldn't be the correct outcome.
> 
> I added the test for the snippet above.
Great, thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119470/new/

https://reviews.llvm.org/D119470

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 6043520 - [clang-tidy] Don't check decltype return types in `readability-const-return-type`

2022-03-17 Thread Evgeny Shulgin via cfe-commits

Author: Evgeny Shulgin
Date: 2022-03-17T14:27:09+03:00
New Revision: 6043520c207269ccdbfe70e63ab48118d5735deb

URL: 
https://github.com/llvm/llvm-project/commit/6043520c207269ccdbfe70e63ab48118d5735deb
DIFF: 
https://github.com/llvm/llvm-project/commit/6043520c207269ccdbfe70e63ab48118d5735deb.diff

LOG: [clang-tidy] Don't check decltype return types in 
`readability-const-return-type`

The checker removes `const`s that are superfluos and badly affect
readability. `decltype(auto)`/`decltype(expr)` are often const-qualified, but
have no effect on readability and usually can't stop being const-qualified
without significant code change.

Fixes https://github.com/llvm/llvm-project/issues/52890

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D119470

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
index 814d3f266c5c3..ec92226773781 100644
--- a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -53,6 +53,18 @@ findConstToRemove(const FunctionDecl *Def,
 
 namespace {
 
+AST_MATCHER(QualType, isLocalConstQualified) {
+  return Node.isLocalConstQualified();
+}
+
+AST_MATCHER(QualType, isTypeOfType) {
+  return isa(Node.getTypePtr());
+}
+
+AST_MATCHER(QualType, isTypeOfExprType) {
+  return isa(Node.getTypePtr());
+}
+
 struct CheckResult {
   // Source range of the relevant `const` token in the definition being 
checked.
   CharSourceRange ConstRange;
@@ -95,10 +107,14 @@ static CheckResult checkDef(const clang::FunctionDecl *Def,
 
 void ConstReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
   // Find all function definitions for which the return types are `const`
-  // qualified.
+  // qualified, ignoring decltype types.
+  auto NonLocalConstType = qualType(
+  unless(isLocalConstQualified()),
+  anyOf(decltypeType(), autoType(), isTypeOfType(), isTypeOfExprType()));
   Finder->addMatcher(
-  functionDecl(returns(isConstQualified()),
-   anyOf(isDefinition(), cxxMethodDecl(isPure(
+  functionDecl(
+  returns(allOf(isConstQualified(), unless(NonLocalConstType))),
+  anyOf(isDefinition(), cxxMethodDecl(isPure(
   .bind("func"),
   this);
 }

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
index 70da965275650..a8642746145b8 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-const-return-type %t
+// RUN: %check_clang_tidy -std=c++14 %s readability-const-return-type %t
 
 //  p# = positive test
 //  n# = negative test
@@ -285,3 +285,40 @@ class PVDerive : public PVBase {
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 
'const'-qualified at the top level, which may reduce code readability without 
improving const correctness
   // CHECK-NOT-FIXES: int getC() { return 1; }
 };
+
+// Don't warn about const auto types, because it may be impossible to make 
them non-const
+// without a significant semantics change. Since `auto` drops cv-qualifiers,
+// tests check `decltype(auto)`.
+decltype(auto) n16() {
+  static const int i = 42;
+  return i;
+}
+
+// Don't warn about `decltype()` types
+const int n17i = 1;
+decltype(n17i) n17() {
+  return 17;
+}
+
+// Do warn when on decltype types with the local const qualifier
+// `const decltype(auto)` won't compile, so check only `const decltype()`
+const decltype(n17i) n18() {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const decltype(n17i)
+  // CHECK-FIXES: decltype(n17i) n18() {
+  return 18;
+}
+
+// `volatile` modifier doesn't affect the checker
+volatile decltype(n17i) n19() {
+  return 19;
+}
+
+// Don't warn about `__typeof__()` types
+__typeof__(n17i) n20() {
+  return 20;
+}
+
+// Don't warn about `__typeof__(type)` types
+__typeof__(const int) n21() {
+  return 21;
+}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119470: [clang-tidy] Don't check decltype return types in `readability-const-return-type`

2022-03-17 Thread Evgeny Shulgin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6043520c2072: [clang-tidy] Don't check decltype return 
types in `readability-const-return… (authored by Izaron).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119470/new/

https://reviews.llvm.org/D119470

Files:
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-const-return-type %t
+// RUN: %check_clang_tidy -std=c++14 %s readability-const-return-type %t
 
 //  p# = positive test
 //  n# = negative test
@@ -285,3 +285,40 @@
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 
'const'-qualified at the top level, which may reduce code readability without 
improving const correctness
   // CHECK-NOT-FIXES: int getC() { return 1; }
 };
+
+// Don't warn about const auto types, because it may be impossible to make 
them non-const
+// without a significant semantics change. Since `auto` drops cv-qualifiers,
+// tests check `decltype(auto)`.
+decltype(auto) n16() {
+  static const int i = 42;
+  return i;
+}
+
+// Don't warn about `decltype()` types
+const int n17i = 1;
+decltype(n17i) n17() {
+  return 17;
+}
+
+// Do warn when on decltype types with the local const qualifier
+// `const decltype(auto)` won't compile, so check only `const decltype()`
+const decltype(n17i) n18() {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const decltype(n17i)
+  // CHECK-FIXES: decltype(n17i) n18() {
+  return 18;
+}
+
+// `volatile` modifier doesn't affect the checker
+volatile decltype(n17i) n19() {
+  return 19;
+}
+
+// Don't warn about `__typeof__()` types
+__typeof__(n17i) n20() {
+  return 20;
+}
+
+// Don't warn about `__typeof__(type)` types
+__typeof__(const int) n21() {
+  return 21;
+}
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -53,6 +53,18 @@
 
 namespace {
 
+AST_MATCHER(QualType, isLocalConstQualified) {
+  return Node.isLocalConstQualified();
+}
+
+AST_MATCHER(QualType, isTypeOfType) {
+  return isa(Node.getTypePtr());
+}
+
+AST_MATCHER(QualType, isTypeOfExprType) {
+  return isa(Node.getTypePtr());
+}
+
 struct CheckResult {
   // Source range of the relevant `const` token in the definition being 
checked.
   CharSourceRange ConstRange;
@@ -95,10 +107,14 @@
 
 void ConstReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
   // Find all function definitions for which the return types are `const`
-  // qualified.
+  // qualified, ignoring decltype types.
+  auto NonLocalConstType = qualType(
+  unless(isLocalConstQualified()),
+  anyOf(decltypeType(), autoType(), isTypeOfType(), isTypeOfExprType()));
   Finder->addMatcher(
-  functionDecl(returns(isConstQualified()),
-   anyOf(isDefinition(), cxxMethodDecl(isPure(
+  functionDecl(
+  returns(allOf(isConstQualified(), unless(NonLocalConstType))),
+  anyOf(isDefinition(), cxxMethodDecl(isPure(
   .bind("func"),
   this);
 }


Index: clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-const-return-type %t
+// RUN: %check_clang_tidy -std=c++14 %s readability-const-return-type %t
 
 //  p# = positive test
 //  n# = negative test
@@ -285,3 +285,40 @@
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness
   // CHECK-NOT-FIXES: int getC() { return 1; }
 };
+
+// Don't warn about const auto types, because it may be impossible to make them non-const
+// without a significant semantics change. Since `auto` drops cv-qualifiers,
+// tests check `decltype(auto)`.
+decltype(auto) n16() {
+  static const int i = 42;
+  return i;
+}
+
+// Don't warn about `decltype()` types
+const int n17i = 1;
+decltype(n17i) n17() {
+  return 17;
+}
+
+// Do warn when on decltype types with the local const qualifier
+// `const decltype(auto)` won't compile, so check only `const decltype()`
+const decltype(n17i) n18() {
+

[clang-tools-extra] 9e1f4f1 - [clang-tidy][run-clang-tidy.py] Add --config-file= option

2022-03-17 Thread Aaron Ballman via cfe-commits

Author: Shreyas Atre
Date: 2022-03-17T07:30:28-04:00
New Revision: 9e1f4f13984186984ba37513372c1b7e0c4ba4fd

URL: 
https://github.com/llvm/llvm-project/commit/9e1f4f13984186984ba37513372c1b7e0c4ba4fd
DIFF: 
https://github.com/llvm/llvm-project/commit/9e1f4f13984186984ba37513372c1b7e0c4ba4fd.diff

LOG: [clang-tidy][run-clang-tidy.py] Add --config-file= option

Link to the GitHub Issue: https://github.com/llvm/llvm-project/issues/53745

Added config_path variable within the python script which makes the
required call to the clang-tidy binary with --config-file option.
If the config_path is None then config will be used. No error is raised
if both are given but silently chooses config_path over config

Added: 


Modified: 
clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py 
b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
index 73edef494ab1f..ec1fd6679e2ab 100755
--- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -90,8 +90,8 @@ def make_absolute(f, directory):
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config,
-line_filter, use_color):
+extra_arg, extra_arg_before, quiet, config_path,
+config, line_filter, use_color):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if allow_enabling_alpha_checkers:
@@ -121,7 +121,9 @@ def get_tidy_invocation(f, clang_tidy_binary, checks, 
tmpdir, build_path,
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
-  if config:
+  if config_path:
+  start.append('--config-file=' + config_path)
+  elif config:
   start.append('-config=' + config)
   start.append(f)
   return start
@@ -192,8 +194,8 @@ def run_tidy(args, clang_tidy_binary, tmpdir, build_path, 
queue, lock,
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter,
- args.use_color)
+ args.quiet, args.config_path, args.config,
+ args.line_filter, args.use_color)
 
 proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
 output, err = proc.communicate()
@@ -225,7 +227,8 @@ def main():
   parser.add_argument('-checks', default=None,
   help='checks filter, when not specified, use clang-tidy '
   'default')
-  parser.add_argument('-config', default=None,
+  config_group = parser.add_mutually_exclusive_group()
+  config_group.add_argument('-config', default=None,
   help='Specifies a configuration in YAML/JSON format: '
   '  -config="{Checks: \'*\', '
   '   CheckOptions: [{key: x, '
@@ -233,6 +236,12 @@ def main():
   'When the value is empty, clang-tidy will '
   'attempt to find a file named .clang-tidy for '
   'each source file in its parent directories.')
+  config_group.add_argument('-config-file', default=None,
+  help='Specify the path of .clang-tidy or custom config '
+  'file: e.g. -config-file=/some/path/myTidyConfigFile. '
+  'This option internally works exactly the same way as '
+  '-config option after reading specified config file. '
+  'Use either -config-file or -config, not both.')
   parser.add_argument('-header-filter', default=None,
   help='regular expression matching the names of the '
   'headers to output diagnostics from. Diagnostics from '
@@ -295,8 +304,8 @@ def main():
  None, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter,
- args.use_color)
+ args.quiet, args.config_path, args.config,
+ args.line_filter, args.use_color)
 invocation.append('-list-checks')
 invocation.append('-')
 if args.quiet:



___
cfe-commits mailing list
cfe-

[PATCH] D120331: [clang-tidy][run-clang-tidy.py] Add --config-file= option

2022-03-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D120331#3384889 , @SAtacker wrote:

> Gentle reminder to commit on my behalf
> @JonasToth
> @alexfh   
> @aaron.ballman
> @njames93 
> @LegalizeAdulthood
>
> Thank you

Thanks for the reminder -- I've commit on your behalf in 
9e1f4f13984186984ba37513372c1b7e0c4ba4fd 
, thank 
you for the patch!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120331/new/

https://reviews.llvm.org/D120331

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121824: [clang] Do not crash on arrow operator on dependent type.

2022-03-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for looking at this. It seems an issue caused by 
https://reviews.llvm.org/D120812 (sorry), where we build a recovery-expr to 
model declrefexpr pointing to an invalid decl.




Comment at: clang/lib/Sema/TreeTransform.h:14709
 // -> is never a builtin operation.
+if (First->getType()->isDependentType())
+  return ExprError();

It looks like we are somehow doing a transformation on a dependent-type 
expression (I think it is the recoveryExpression) during the template 
instantiation, which leads to the crash.




Comment at: clang/test/SemaCXX/arrow-operator.cpp:79
+void foo() {
+  // x is dependent.
+  A& x = blah[7];  // expected-error {{use of undeclared identifier 
'blah'}} \

The AST nodes looks weird and inconsistent in the primary template and 
instantiated template.

VarDecl `x` AST node in the primary template look like (with a Valid bit!)

```
`-DeclStmt 
   `-VarDecl  x 'A &'
```

while in the instantiated template (with an **Invalid** bit!):
```
 `-DeclStmt
`-VarDecl invalid x 'A &'
```

The difference of valid bit results in two different forms of the expression 
`x->call()`  (a normal CXXMemberCallExpr vs. a dependent-type CallExpr wrapping 
a RecoveryExpr), I think this is likely the root cause of the crash.

If we invalidate the VarDecl x in the primary template for this case, the issue 
should be gone. This seems a reasonable fix to me -- a reference-type VarDecl 
is invalid, when it doesn't have an initializer (either 1. it is not written in 
the source code or 2. it is too malformed to preserve ).  Clang AST already 
does 1.  We're missing 2, I think it is in `Sema::ActOnInitializerError`.





Comment at: clang/test/SemaCXX/arrow-operator.cpp:81
+  A& x = blah[7];  // expected-error {{use of undeclared identifier 
'blah'}} \
+// expected-error {{declaration of reference variable 
'x' requires an initializer}}
+  x->call();

if we mark vardecl x invalid, I think the bogus `requires an initializer` 
diagnostic will be gone.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121824/new/

https://reviews.llvm.org/D121824

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118259: [AArch64] Adjust aarch64-neon-intrinsics-constrained test and un-XFAIL

2022-03-17 Thread John Brawn via Phabricator via cfe-commits
john.brawn added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118259/new/

https://reviews.llvm.org/D118259

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115620: [AArch64] Lowering and legalization of strict FP16

2022-03-17 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 416141.
john.brawn set the repository for this revision to rG LLVM Github Monorepo.
john.brawn added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Rebase and ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115620/new/

https://reviews.llvm.org/D115620

Files:
  clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/fp-intrinsics-fp16.ll
  llvm/test/CodeGen/AArch64/fp-intrinsics.ll

Index: llvm/test/CodeGen/AArch64/fp-intrinsics.ll
===
--- llvm/test/CodeGen/AArch64/fp-intrinsics.ll
+++ llvm/test/CodeGen/AArch64/fp-intrinsics.ll
@@ -1,5 +1,5 @@
-; RUN: llc -mtriple=aarch64-none-eabi %s -disable-strictnode-mutation -o - | FileCheck %s
-; RUN: llc -mtriple=aarch64-none-eabi -global-isel=true -global-isel-abort=2 -disable-strictnode-mutation %s -o - | FileCheck %s
+; RUN: llc -mtriple=aarch64-none-eabi %s -o - | FileCheck %s
+; RUN: llc -mtriple=aarch64-none-eabi -global-isel=true -global-isel-abort=2 %s -o - | FileCheck %s
 
 ; Check that constrained fp intrinsics are correctly lowered.
 
Index: llvm/test/CodeGen/AArch64/fp-intrinsics-fp16.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/fp-intrinsics-fp16.ll
@@ -0,0 +1,1173 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64-none-eabi %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NOFP16
+; RUN: llc -mtriple=aarch64-none-eabi -mattr=+fullfp16 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-FP16
+; RUN: llc -mtriple=aarch64-none-eabi -global-isel=true -global-isel-abort=2 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NOFP16
+; RUN: llc -mtriple=aarch64-none-eabi -global-isel=true -global-isel-abort=2 -mattr=+fullfp16 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-FP16
+
+; Check that constrained fp intrinsics are correctly lowered.
+
+
+; Half-precision intrinsics
+
+define half @add_f16(half %x, half %y) #0 {
+; CHECK-NOFP16-LABEL: add_f16:
+; CHECK-NOFP16:   // %bb.0:
+; CHECK-NOFP16-NEXT:fcvt s1, h1
+; CHECK-NOFP16-NEXT:fcvt s0, h0
+; CHECK-NOFP16-NEXT:fadd s0, s0, s1
+; CHECK-NOFP16-NEXT:fcvt h0, s0
+; CHECK-NOFP16-NEXT:ret
+;
+; CHECK-FP16-LABEL: add_f16:
+; CHECK-FP16:   // %bb.0:
+; CHECK-FP16-NEXT:fadd h0, h0, h1
+; CHECK-FP16-NEXT:ret
+  %val = call half @llvm.experimental.constrained.fadd.f16(half %x, half %y, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
+  ret half %val
+}
+
+define half @sub_f16(half %x, half %y) #0 {
+; CHECK-NOFP16-LABEL: sub_f16:
+; CHECK-NOFP16:   // %bb.0:
+; CHECK-NOFP16-NEXT:fcvt s1, h1
+; CHECK-NOFP16-NEXT:fcvt s0, h0
+; CHECK-NOFP16-NEXT:fsub s0, s0, s1
+; CHECK-NOFP16-NEXT:fcvt h0, s0
+; CHECK-NOFP16-NEXT:ret
+;
+; CHECK-FP16-LABEL: sub_f16:
+; CHECK-FP16:   // %bb.0:
+; CHECK-FP16-NEXT:fsub h0, h0, h1
+; CHECK-FP16-NEXT:ret
+  %val = call half @llvm.experimental.constrained.fsub.f16(half %x, half %y, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
+  ret half %val
+}
+
+define half @mul_f16(half %x, half %y) #0 {
+; CHECK-NOFP16-LABEL: mul_f16:
+; CHECK-NOFP16:   // %bb.0:
+; CHECK-NOFP16-NEXT:fcvt s1, h1
+; CHECK-NOFP16-NEXT:fcvt s0, h0
+; CHECK-NOFP16-NEXT:fmul s0, s0, s1
+; CHECK-NOFP16-NEXT:fcvt h0, s0
+; CHECK-NOFP16-NEXT:ret
+;
+; CHECK-FP16-LABEL: mul_f16:
+; CHECK-FP16:   // %bb.0:
+; CHECK-FP16-NEXT:fmul h0, h0, h1
+; CHECK-FP16-NEXT:ret
+  %val = call half @llvm.experimental.constrained.fmul.f16(half %x, half %y, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
+  ret half %val
+}
+
+define half @div_f16(half %x, half %y) #0 {
+; CHECK-NOFP16-LABEL: div_f16:
+; CHECK-NOFP16:   // %bb.0:
+; CHECK-NOFP16-NEXT:fcvt s1, h1
+; CHECK-NOFP16-NEXT:fcvt s0, h0
+; CHECK-NOFP16-NEXT:fdiv s0, s0, s1
+; CHECK-NOFP16-NEXT:fcvt h0, s0
+; CHECK-NOFP16-NEXT:ret
+;
+; CHECK-FP16-LABEL: div_f16:
+; CHECK-FP16:   // %bb.0:
+; CHECK-FP16-NEXT:fdiv h0, h0, h1
+; CHECK-FP16-NEXT:ret
+  %val = call half @llvm.experimental.constrained.fdiv.f16(half %x, half %y, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
+  ret half %val
+}
+
+define half @frem_f16(half %x, half %y) #0 {
+; CHECK-LABEL: frem_f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:.cfi_offset w30, -16
+; CHECK-NEXT:fcvt s1, h1
+; CHECK-NEXT:fcvt s0, h0
+; CHECK-NEXT:bl fmodf
+; CHECK-NEXT:fcvt h0, s0
+; CHECK-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; CHECK-NEXT:ret
+  %val = call 

[PATCH] D118259: [AArch64] Adjust aarch64-neon-intrinsics-constrained test and un-XFAIL

2022-03-17 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D118259#3343554 , @john.brawn 
wrote:

> In D118259#3275297 , @fhahn wrote:
>
>> Does this clang test actually need to check the generated assembly? 
>> Shouldn't it be enough to check that the correct intrinsics are generated?
>
> I could remove the CHECK-ASM checks, but the other xyz-constrained.c tests 
> (including non-aarch64 ones) all do this and it feels a bit weird to just do 
> that to this test.

I guess the question is if there is a convincing reason to check the assembly 
in this test? Unless it is required for the test, checking for assembly makes 
the test more fragile than they need to be. Also, is there any difference in 
the generated IR between X86 and AArch64? If not, the tests should probably be 
unified.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118259/new/

https://reviews.llvm.org/D118259

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121890: [clang-format] Copy help options to the doc directory.

2022-03-17 Thread sstwcw via Phabricator via cfe-commits
sstwcw added inline comments.



Comment at: clang/docs/ClangFormat.rst:76
+--output-replacements-xml  - Output replacements as XML.
+--qualifier-alignment= - If set, overrides the qualifier alignment 
style determined by the QualifierAlignment style flag
+--sort-includes- If set, overrides the include sorting 
behavior determined by the SortIncludes style flag

curdeius wrote:
> Shouldn't long descriptions like this one be split into multiple lines and 
> aligned with `-`?
> Did you do it by hand or with some script?
It was not split in the `-help` output.  I copied the output from a terminal by 
hand.  If you run `clang-format -help` from the latest git build in an 
80-column terminal you will see that output is all over the place.  The options 
that were broken into lines have hard line breaks lin 
`clang/tools/clang-format/ClangFormat.cpp`.  But now with the 
`--qualifier-alignment` option being too wide even those got pushed over 80 
columns.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121890/new/

https://reviews.llvm.org/D121890

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121556: [randstruct] Add randomize structure layout support

2022-03-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this new security feature! I like it and I think it's 
heading in the right direction.

Can you please add a release note for the new functionality?

This is missing tests for the Driver diagnostics, the Sema diagnostics 
(including existing diagnostics like writing the attribute on the wrong subject 
or giving it args when it doesn't expect them, wrong language mode, etc), and 
the CodeGen behavior, so those should be added. Also, the Windows pre-commit CI 
is failing:

  Failed Tests (7):
Clang-Unit :: 
AST/./ASTTests.exe/StructureLayoutRandomization.AnonymousStructsAndUnionsRetainFieldOrder
Clang-Unit :: 
AST/./ASTTests.exe/StructureLayoutRandomization.CheckAdjacentBitfieldsRemainAdjacentAfterRandomization
Clang-Unit :: 
AST/./ASTTests.exe/StructureLayoutRandomization.CheckVariableLengthArrayMemberRemainsAtEndOfStructure
Clang-Unit :: 
AST/./ASTTests.exe/StructureLayoutRandomization.MarkedRandomize
Clang-Unit :: 
AST/./ASTTests.exe/StructureLayoutRandomization.MultipleAttrsRandomize
Clang-Unit :: 
AST/./ASTTests.exe/StructureLayoutRandomization.RandstructDoesNotOverrideThePackedAttr
Clang-Unit :: 
AST/./ASTTests.exe/StructureLayoutRandomization.ZeroWidthBitfieldsSeparateAllocationUnits
   
  Testing Time: 676.49s
Skipped  : 4
Unsupported  :   202
Passed   : 29832
Expectedly Failed:31
Failed   : 7




Comment at: clang/include/clang/AST/Decl.h:2842
   mutable unsigned CachedFieldIndex : 30;
+  mutable unsigned OriginalFieldIndex : 30;
 

It's unfortunate that every field node in the AST is now going to be 4 bytes 
larger for this feature; I worry about the extra memory pressure from the 
additional overhead, so if there's a way for us to save some space here, I 
think it might be worth it. (I'm worried that our max template instantiation 
depth will shrink because of this.)



Comment at: clang/include/clang/AST/Decl.h:4067
+
+  void setIsRandomized(bool V) const { RecordDeclBits.IsRandomized = V; }
+

A setter that is marked `const` does not spark joy for me... Can we use 
friendship rather than mutability to solve this?



Comment at: clang/include/clang/AST/Randstruct.h:34
+
+extern std::string SEED;
+

Doing this with a global variable is unfortunate; it could make things harder 
when we multithread the frontend. Can we solve this without a global? (And if 
not, does this global need to be a `ManagedStatic`?)



Comment at: clang/include/clang/Basic/Attr.td:3938-3939
+def RandomizeLayout : InheritableAttr {
+  let Spellings = [GCC<"randomize_layout">, Declspec<"randomize_layout">,
+Keyword<"randomize_layout">];
+  let Subjects = SubjectList<[Record]>;

Microsoft does not implement this `__declspec`, correct? If they don't, we 
shouldn't either (even if GCC does) unless there's a *very* good reason to do 
so. That's Microsoft's design space we're encroaching on.

I'd also like to understand the justification for adding a new keyword for this.



Comment at: clang/include/clang/Basic/Attr.td:3948-3949
+def NoRandomizeLayout : InheritableAttr {
+  let Spellings = [GCC<"no_randomize_layout">, Declspec<"no_randomize_layout">,
+Keyword<"no_randomize_layout">];
+  let Subjects = SubjectList<[Record]>;

Same here.



Comment at: clang/include/clang/Basic/AttrDocs.td:6367
+program should be compiled with the same seed, but keep the seed safe
+otherwise.
+

I think it would help to explain the effects of this attribute in conjunction 
with structure packing techniques (the `packed` attribute and bit-fields) and 
whether any attempt is made to keep the structure packed or those fields 
together or not. I'd expect no such attempt is made, but people may want to 
know "attempts to pack this structure" and "randomize this structure layout" 
are not compatible. (We may want to diagnose in the case of seeing the `packed` 
attribute, in fact.)

We should also be more clear that the seed specified does not have to be 
numeric in nature (from the file or when directly on the command line).



Comment at: clang/lib/AST/DeclBase.cpp:28
 #include "clang/AST/ExternalASTSource.h"
+#include "clang/AST/Randstruct.h"
 #include "clang/AST/Stmt.h"

Is this include necessary?



Comment at: clang/lib/AST/Randstruct.cpp:72
+  // All of the Buckets produced by best-effort cache-line algorithm.
+  // TODO: Figure out a better initial size.
+  SmallVector, 16> Buckets;

This size seems as defensible as most others; do you plan to do more here, or 
should this comment be removed?



Comment at: clang/lib/AST/Randstruct.cpp:99
+
+if (FD->isBitField() && !FD->isZeroLengthBitField(Context)) {
+  // Start a bitfie

[PATCH] D120857: WIP [randstruct] Add randomize structure layout support

2022-03-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

This seems like a duplicate of https://reviews.llvm.org/D121556 -- should this 
review be abandoned?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120857/new/

https://reviews.llvm.org/D120857

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ab982ea - [Sema] add warning for tautological FP compare with literal

2022-03-17 Thread Sanjay Patel via cfe-commits

Author: Sanjay Patel
Date: 2022-03-17T08:22:30-04:00
New Revision: ab982eace6e4951a2986567d29f4d6be002c1ba7

URL: 
https://github.com/llvm/llvm-project/commit/ab982eace6e4951a2986567d29f4d6be002c1ba7
DIFF: 
https://github.com/llvm/llvm-project/commit/ab982eace6e4951a2986567d29f4d6be002c1ba7.diff

LOG: [Sema] add warning for tautological FP compare with literal

If we are equality comparing an FP literal with a value cast from a type
where the literal can't be represented, that's known true or false and
probably a programmer error.

Fixes issue #54222.
https://github.com/llvm/llvm-project/issues/54222

Note - I added the optimizer change with:
9397bdc67eb2
...and as discussed in the post-commit comments, that transform might be
too dangerous without this warning in place, so it was reverted to allow
this change first.

Differential Revision: https://reviews.llvm.org/D121306

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/floating-point-compare.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a0e3cabe89a9a..d457be1305cf7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -64,6 +64,9 @@ Bug Fixes
 
 Improvements to Clang's diagnostics
 ^^^
+- ``-Wliteral-range`` will warn on floating-point equality comparisons with
+  constants that are not representable in a casted value. For example,
+  ``(float) f == 0.1`` is always false.
 
 Non-comprehensive list of changes in this release
 -

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index eda47588680f4..e6b11c943a705 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -118,6 +118,10 @@ def warn_float_overflow : Warning<
 def warn_float_underflow : Warning<
   "magnitude of floating-point constant too small for type %0; minimum is %1">,
   InGroup;
+def warn_float_compare_literal : Warning<
+  "floating-point comparison is always %select{true|false}0; "
+  "constant cannot be represented exactly in type %1">,
+  InGroup;
 def warn_double_const_requires_fp64 : Warning<
   "double precision constant requires %select{cl_khr_fp64|cl_khr_fp64 and 
__opencl_c_fp64}0, "
   "casting to single precision">;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index e8b9bc2d7990c..fe8a1f371fe74 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12928,7 +12928,8 @@ class Sema final {
   const FunctionDecl *FD = nullptr);
 
 public:
-  void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS);
+  void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
+BinaryOperatorKind Opcode);
 
 private:
   void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2d14019cdbf18..2d2250771eb6e 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11436,12 +11436,40 @@ Sema::CheckReturnValExpr(Expr *RetValExp, QualType 
lhsType,
 CheckPPCMMAType(RetValExp->getType(), ReturnLoc);
 }
 
-//===--- CHECK: Floating-Point comparisons (-Wfloat-equal) ---===//
+/// Check for comparisons of floating-point values using == and !=. Issue a
+/// warning if the comparison is not likely to do what the programmer intended.
+void Sema::CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
+BinaryOperatorKind Opcode) {
+  // Match and capture subexpressions such as "(float) X == 0.1".
+  FloatingLiteral *FPLiteral;
+  CastExpr *FPCast;
+  auto getCastAndLiteral = [&FPLiteral, &FPCast](Expr *L, Expr *R) {
+FPLiteral = dyn_cast(L->IgnoreParens());
+FPCast = dyn_cast(R->IgnoreParens());
+return FPLiteral && FPCast;
+  };
+
+  if (getCastAndLiteral(LHS, RHS) || getCastAndLiteral(RHS, LHS)) {
+auto *SourceTy = FPCast->getSubExpr()->getType()->getAs();
+auto *TargetTy = FPLiteral->getType()->getAs();
+if (SourceTy && TargetTy && SourceTy->isFloatingPoint() &&
+TargetTy->isFloatingPoint()) {
+  bool Lossy;
+  llvm::APFloat TargetC = FPLiteral->getValue();
+  TargetC.convert(Context.getFloatTypeSemantics(QualType(SourceTy, 0)),
+  llvm::APFloat::rmNearestTiesToEven, &Lossy);
+  if (Lossy) {
+// If the literal cannot be represented in the source type, then a
+// check for == is always false and check for != is always true.
+Diag(Loc, diag::warn_float_

[PATCH] D121906: [clang-format] Indent import statements in JavaScript.

2022-03-17 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
sstwcw added a reviewer: clang-format.
sstwcw added a project: clang-format.
Herald added a project: All.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[clang-format] Indent import statements in JavaScript.

Take for example this piece of code found at
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import.

for (const link of document.querySelectorAll("nav > a")) {

  link.addEventListener("click", e => {
e.preventDefault();
  
import('/modules/my-module.js')
.then(module => {
  module.loadPageInto(main);
})
.catch(err => {
  main.textContent = err.message;
});
  });

}

Previously the import line would be unindented, looking like this.

for (const link of document.querySelectorAll("nav > a")) {

  link.addEventListener("click", e => {
e.preventDefault();

import('/modules/my-module.js')

.then(module => {
  module.loadPageInto(main);
})
.catch(err => {
  main.textContent = err.message;
});
  });

}

Actually we were going to fix this along with fixing Verilog import
statements.  But the patch got too big.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121906

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -1868,6 +1868,11 @@
   " myX} from 'm';");
   verifyFormat("import * as lib from 'some/module.js';");
   verifyFormat("var x = {import: 1};\nx.import = 2;");
+  // Ensure an import statement inside a block is at the correct level.
+  verifyFormat("function() {\n"
+   "  var x;\n"
+   "  import 'some/module.js';\n"
+   "}");
 
   verifyFormat("export function fn() {\n"
"  return 'fn';\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1431,8 +1431,10 @@
   if (Newlines)
 Indent = NewlineIndent;
 
-  // Preprocessor directives get indented before the hash only if specified
-  if (Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
+  // Preprocessor directives get indented before the hash only if specified. In
+  // Javascript import statements are indented like normal statements.
+  if (Style.Language != FormatStyle::LK_JavaScript &&
+  Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
   (Line.Type == LT_PreprocessorDirective ||
Line.Type == LT_ImportStatement))
 Indent = 0;
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -623,9 +623,11 @@
 
   unsigned Spaces = Current.SpacesRequiredBefore + ExtraSpaces;
 
-  // Indent preprocessor directives after the hash if required.
+  // Indent preprocessor directives after the hash if required. In Javascript
+  // import statements are indented like normal statements.
   int PPColumnCorrection = 0;
-  if (Style.IndentPPDirectives == FormatStyle::PPDIS_AfterHash &&
+  if (Style.Language != FormatStyle::LK_JavaScript &&
+  Style.IndentPPDirectives == FormatStyle::PPDIS_AfterHash &&
   Previous.is(tok::hash) && State.FirstIndent > 0 &&
   (State.Line->Type == LT_PreprocessorDirective ||
State.Line->Type == LT_ImportStatement)) {


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -1868,6 +1868,11 @@
   " myX} from 'm';");
   verifyFormat("import * as lib from 'some/module.js';");
   verifyFormat("var x = {import: 1};\nx.import = 2;");
+  // Ensure an import statement inside a block is at the correct level.
+  verifyFormat("function() {\n"
+   "  var x;\n"
+   "  import 'some/module.js';\n"
+   "}");
 
   verifyFormat("export function fn() {\n"
"  return 'fn';\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1431,8 +1431,10 @@
   if (Newlines)
 Indent = NewlineIndent;
 
-  // Preprocessor directives get indented before the hash only if specified
-  if (Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
+  /

[PATCH] D121306: [Sema] add warning for tautological FP compare with literal

2022-03-17 Thread Sanjay Patel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab982eace6e4: [Sema] add warning for tautological FP compare 
with literal (authored by spatel).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121306/new/

https://reviews.llvm.org/D121306

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/floating-point-compare.c

Index: clang/test/Sema/floating-point-compare.c
===
--- clang/test/Sema/floating-point-compare.c
+++ clang/test/Sema/floating-point-compare.c
@@ -12,6 +12,7 @@
   return x == x; // no-warning
 }
 
+// 0.0 can be represented exactly, so don't warn.
 int f4(float x) {
   return x == 0.0; // no-warning {{comparing}}
 }
@@ -20,6 +21,43 @@
   return x == __builtin_inf(); // no-warning
 }
 
-int f7(float x) {
-  return x == 3.14159; // expected-warning {{comparing}}
+// The literal is a double that can't be represented losslessly as a float.
+int tautological_FP_compare(float x) {
+  return x == 3.14159; // expected-warning {{floating-point comparison is always false}}
+}
+
+int tautological_FP_compare_inverse(float x) {
+  return x != 3.14159; // expected-warning {{floating-point comparison is always true}}
+}
+
+// The literal is a double that can be represented losslessly as a long double,
+// but this might not be the comparison what was intended.
+int not_tautological_FP_compare(long double f) {
+  return f == 0.1; // expected-warning {{comparing floating point with ==}}
+}
+
+int tautological_FP_compare_commute(float f) {
+  return 0.3 == f; // expected-warning {{floating-point comparison is always false}}
+}
+
+int tautological_FP_compare_commute_inverse(float f) {
+  return 0.3 != f; // expected-warning {{floating-point comparison is always true}}
+}
+
+int tautological_FP_compare_explicit_upcast(float f) {
+  return 0.3 == (double) f; // expected-warning {{floating-point comparison is always false}}
+}
+
+int tautological_FP_compare_explicit_downcast(double d) {
+  return 0.3 == (float) d; // expected-warning {{floating-point comparison is always false}}
+}
+
+int tautological_FP_compare_ignore_parens(float f) {
+  return f == (0.3); // expected-warning {{floating-point comparison is always false}}
+}
+
+#define CST 0.3
+
+int tautological_FP_compare_macro(float f) {
+  return f == CST; // expected-warning {{floating-point comparison is always false}}
 }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -12022,7 +12022,7 @@
 
   // Check for comparisons of floating point operands using != and ==.
   if (Type->hasFloatingRepresentation() && BinaryOperator::isEqualityOp(Opc))
-S.CheckFloatComparison(Loc, LHS.get(), RHS.get());
+S.CheckFloatComparison(Loc, LHS.get(), RHS.get(), Opc);
 
   // The result of comparisons is 'bool' in C++, 'int' in C.
   return S.Context.getLogicalOperationType();
@@ -12618,7 +12618,7 @@
   if (BinaryOperator::isEqualityOp(Opc) &&
   LHSType->hasFloatingRepresentation()) {
 assert(RHS.get()->getType()->hasFloatingRepresentation());
-CheckFloatComparison(Loc, LHS.get(), RHS.get());
+CheckFloatComparison(Loc, LHS.get(), RHS.get(), Opc);
   }
 
   // Return a signed type for the vector.
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11436,12 +11436,40 @@
 CheckPPCMMAType(RetValExp->getType(), ReturnLoc);
 }
 
-//===--- CHECK: Floating-Point comparisons (-Wfloat-equal) ---===//
+/// Check for comparisons of floating-point values using == and !=. Issue a
+/// warning if the comparison is not likely to do what the programmer intended.
+void Sema::CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
+BinaryOperatorKind Opcode) {
+  // Match and capture subexpressions such as "(float) X == 0.1".
+  FloatingLiteral *FPLiteral;
+  CastExpr *FPCast;
+  auto getCastAndLiteral = [&FPLiteral, &FPCast](Expr *L, Expr *R) {
+FPLiteral = dyn_cast(L->IgnoreParens());
+FPCast = dyn_cast(R->IgnoreParens());
+return FPLiteral && FPCast;
+  };
+
+  if (getCastAndLiteral(LHS, RHS) || getCastAndLiteral(RHS, LHS)) {
+auto *SourceTy = FPCast->getSubExpr()->getType()->getAs();
+auto *TargetTy = FPLiteral->getType()->getAs();
+if (SourceTy && TargetTy && SourceTy->isFloatingPoint() &&
+TargetTy->isFloatingPoint()) {
+  bool Lossy;
+  llvm::APFloat TargetC = FPLiteral->getValue();
+  TargetC.convert(Context.getFloatTypeSemantics(QualType(SourceTy, 0)

[PATCH] D121907: [clang-format] Use an enum for context types.

2022-03-17 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
sstwcw added a reviewer: clang-format.
sstwcw added a project: clang-format.
Herald added a project: All.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We currently have all those fields in AnnotatingParser::Context.  They
are not inherited from the Context object for the parent scope.  They
are exclusive.  Now they are replaced with an enum.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121907

Files:
  clang/lib/Format/TokenAnnotator.cpp

Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -113,8 +113,8 @@
 Contexts.back().IsExpression = false;
 // If there's a template keyword before the opening angle bracket, this is a
 // template parameter, not an argument.
-Contexts.back().InTemplateArgument =
-Left->Previous && Left->Previous->isNot(tok::kw_template);
+if (Left->Previous && Left->Previous->isNot(tok::kw_template))
+  Contexts.back().ContextType = Context::TemplateArgument;
 
 if (Style.Language == FormatStyle::LK_Java &&
 CurrentToken->is(tok::question))
@@ -288,7 +288,7 @@
 } else if (OpeningParen.Previous &&
OpeningParen.Previous->is(TT_ForEachMacro)) {
   // The first argument to a foreach macro is a declaration.
-  Contexts.back().IsForEachMacro = true;
+  Contexts.back().ContextType = Context::ForEachMacro;
   Contexts.back().IsExpression = false;
 } else if (OpeningParen.Previous && OpeningParen.Previous->MatchingParen &&
OpeningParen.Previous->MatchingParen->is(TT_ObjCBlockLParen)) {
@@ -558,7 +558,7 @@
 bool CppArrayTemplates =
 Style.isCpp() && Parent && Parent->is(TT_TemplateCloser) &&
 (Contexts.back().CanBeExpression || Contexts.back().IsExpression ||
- Contexts.back().InTemplateArgument);
+ Contexts.back().ContextType == Context::TemplateArgument);
 
 bool IsCpp11AttributeSpecifier = isCpp11AttributeSpecifier(*Left) ||
  Contexts.back().InCpp11AttributeSpecifier;
@@ -803,7 +803,7 @@
 if (Style.AlignArrayOfStructures != FormatStyle::AIAS_None) {
   if (OpeningBrace.ParentBracket == tok::l_brace &&
   couldBeInStructArrayInitializer() && CommaCount > 0)
-Contexts.back().InStructArrayInitializer = true;
+Contexts.back().ContextType = Context::StructArrayInitializer;
 }
 next();
 return true;
@@ -1157,16 +1157,22 @@
   parseTemplateDeclaration();
   break;
 case tok::comma:
-  if (Contexts.back().InCtorInitializer)
+  switch (Contexts.back().ContextType) {
+  case Context::CtorInitializer:
 Tok->setType(TT_CtorInitializerComma);
-  else if (Contexts.back().InInheritanceList)
+break;
+  case Context::InheritanceList:
 Tok->setType(TT_InheritanceComma);
-  else if (Contexts.back().FirstStartOfName &&
-   (Contexts.size() == 1 || startsWithInitStatement(Line))) {
-Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true;
-Line.IsMultiVariableDeclStmt = true;
+break;
+  default:
+if (Contexts.back().FirstStartOfName &&
+(Contexts.size() == 1 || startsWithInitStatement(Line))) {
+  Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true;
+  Line.IsMultiVariableDeclStmt = true;
+}
+break;
   }
-  if (Contexts.back().IsForEachMacro)
+  if (Contexts.back().ContextType == Context::ForEachMacro)
 Contexts.back().IsExpression = true;
   break;
 case tok::identifier:
@@ -1411,7 +1417,7 @@
 }
 
 for (const auto &ctx : Contexts)
-  if (ctx.InStructArrayInitializer)
+  if (ctx.ContextType == Context::StructArrayInitializer)
 return LT_ArrayOfStructInitializer;
 
 return LT_Other;
@@ -1488,14 +1494,27 @@
 FormatToken *FirstObjCSelectorName = nullptr;
 FormatToken *FirstStartOfName = nullptr;
 bool CanBeExpression = true;
-bool InTemplateArgument = false;
-bool InCtorInitializer = false;
-bool InInheritanceList = false;
 bool CaretFound = false;
-bool IsForEachMacro = false;
+// These two are not handled like the rest in ContextType because they are
+// not exclusive.
 bool InCpp11AttributeSpecifier = false;
 bool InCSharpAttributeSpecifier = false;
-bool InStructArrayInitializer = false;
+enum {
+  Unknown,
+  // Like the part after `:` in a constructor.
+  //   Context(...) : IsExpression(IsExpression)
+  CtorInitializer,
+  // Like in the parentheses in a foreach.
+  ForEachMacro,
+  // Like the inheritance list in a class declaration.
+  //   class Input : public IO
+  Inheritance

[PATCH] D121678: [pseudo] Split greatergreater token.

2022-03-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 416153.
hokein added a comment.
Herald added a project: clang-tools-extra.

rebase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121678/new/

https://reviews.llvm.org/D121678

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/Token.h
  clang-tools-extra/pseudo/lib/Lex.cpp
  clang-tools-extra/pseudo/lib/cxx.bnf
  clang-tools-extra/pseudo/unittests/TokenTest.cpp

Index: clang-tools-extra/pseudo/unittests/TokenTest.cpp
===
--- clang-tools-extra/pseudo/unittests/TokenTest.cpp
+++ clang-tools-extra/pseudo/unittests/TokenTest.cpp
@@ -171,6 +171,25 @@
 }));
 }
 
+TEST(TokenTest, SplitGreaterGreater) {
+  LangOptions Opts;
+  std::string Code = R"cpp(
+>> // split
+// >> with an escaped newline in the middle, split
+>\
+>
+>>= // not split
+)cpp";
+  TokenStream Split = stripComments(cook(lex(Code, Opts), Opts));
+  EXPECT_THAT(Split.tokens(), ElementsAreArray({
+  token(">", tok::greater),
+  token(">", tok::greater),
+  token(">", tok::greater),
+  token(">", tok::greater),
+  token(">>=", tok::greatergreaterequal),
+  }));
+}
+
 TEST(TokenTest, DropComments) {
   LangOptions Opts;
   std::string Code = R"cpp(
Index: clang-tools-extra/pseudo/lib/cxx.bnf
===
--- clang-tools-extra/pseudo/lib/cxx.bnf
+++ clang-tools-extra/pseudo/lib/cxx.bnf
@@ -13,6 +13,9 @@
 #  - the file merely describes the core C++ grammar. Preprocessor directives and
 #lexical conversions are omitted as we reuse clang's lexer and run a fake
 #preprocessor;
+#  - grammar rules with the >> token are adjusted, the greatergreater token is
+#split into two > tokens, to make the GLR parser aware of nested templates
+#and right shift operator;
 #
 # Guidelines:
 #   - non-terminals are lower_case; terminals (aka tokens) correspond to
@@ -96,7 +99,7 @@
 fold-operator := ^
 fold-operator := |
 fold-operator := <<
-fold-operator := >>
+fold-operator := greatergreater
 fold-operator := +=
 fold-operator := -=
 fold-operator := *=
@@ -202,7 +205,7 @@
 # expr.shift
 shift-expression := additive-expression
 shift-expression := shift-expression << additive-expression
-shift-expression := shift-expression >> additive-expression
+shift-expression := shift-expression greatergreater additive-expression
 # expr.spaceship
 compare-expression := shift-expression
 compare-expression := compare-expression <=> shift-expression
@@ -615,7 +618,7 @@
 operator-name := ^^
 operator-name := ||
 operator-name := <<
-operator-name := >>
+operator-name := greatergreater
 operator-name := <<=
 operator-name := >>=
 operator-name := ++
@@ -737,3 +740,8 @@
 module-keyword := IDENTIFIER
 import-keyword := IDENTIFIER
 export-keyword := IDENTIFIER
+
+#! greatergreater token -- clang lexer always lexes it as a single token, we
+#! split it into two tokens to make the GLR parser aware of the nested-template
+#! case.
+greatergreater := > >
\ No newline at end of file
Index: clang-tools-extra/pseudo/lib/Lex.cpp
===
--- clang-tools-extra/pseudo/lib/Lex.cpp
+++ clang-tools-extra/pseudo/lib/Lex.cpp
@@ -98,9 +98,21 @@
   Tok.Length = Text.size();
   Tok.Flags &= ~static_cast(LexFlags::NeedsCleaning);
 }
-// Cook raw_identifiers into identifier, keyword, etc.
-if (Tok.Kind == tok::raw_identifier)
+
+if (Tok.Kind == tok::raw_identifier) {
+  // Cook raw_identifiers into identifier, keyword, etc.
   Tok.Kind = Identifiers.get(Tok.text()).getTokenID();
+} else if (Tok.Kind == tok::greatergreater) {
+  // Split the greatergreater token.
+  // FIXME: split lessless token to support Cuda triple angle brackets <<<.
+  assert(Tok.text() == ">>");
+  Tok.Kind = tok::greater;
+  Tok.Length = 1;
+  Result.push(Tok);
+  // Line is wrong if the first greater is followed by an escaped newline!
+  Tok.Data = Tok.text().data() + 1;
+}
+
 Result.push(std::move(Tok));
   }
 
Index: clang-tools-extra/pseudo/include/clang-pseudo/Token.h
===
--- clang-tools-extra/pseudo/include/clang-pseudo/Token.h
+++ clang-tools-extra/pseudo/include/clang-pseudo/Token.h
@@ -180,7 +180,8 @@
   NeedsCleaning = 1 << 1,
 };
 
-/// Derives a token stream by decoding escapes and interpreting raw_identifiers.
+/// Derives a token stream by decoding escapes, interpreting raw_identifiers and
+/// splitting the greatergreater token.
 ///
 /// Tokens containing UCNs, escaped newlines, trigraphs etc are decoded and
 /// their backing data is owned by the returned stream.
___

[clang-tools-extra] f66d375 - [pseudo] Split greatergreater token.

2022-03-17 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-03-17T13:46:58+01:00
New Revision: f66d3758bda99e9f57bfdad168212feda18792ae

URL: 
https://github.com/llvm/llvm-project/commit/f66d3758bda99e9f57bfdad168212feda18792ae
DIFF: 
https://github.com/llvm/llvm-project/commit/f66d3758bda99e9f57bfdad168212feda18792ae.diff

LOG: [pseudo] Split greatergreater token.

For a >> token (a right shift operator, or a nested template?), the clang
lexer always returns a single greatergreater token, as a result,
the grammar-based GLR parser never try to parse the nested template
case.

We derive a token stream by always splitting the >> token, so that the
GLR parser is able to pursue both options during parsing (usually 1
path fails).

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D121678

Added: 


Modified: 
clang-tools-extra/pseudo/include/clang-pseudo/Token.h
clang-tools-extra/pseudo/lib/Lex.cpp
clang-tools-extra/pseudo/lib/cxx.bnf
clang-tools-extra/pseudo/unittests/TokenTest.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/Token.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/Token.h
index 24b6729151e61..4563477b2c4fe 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/Token.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/Token.h
@@ -180,7 +180,8 @@ enum class LexFlags : uint8_t {
   NeedsCleaning = 1 << 1,
 };
 
-/// Derives a token stream by decoding escapes and interpreting 
raw_identifiers.
+/// Derives a token stream by decoding escapes, interpreting raw_identifiers 
and
+/// splitting the greatergreater token.
 ///
 /// Tokens containing UCNs, escaped newlines, trigraphs etc are decoded and
 /// their backing data is owned by the returned stream.

diff  --git a/clang-tools-extra/pseudo/lib/Lex.cpp 
b/clang-tools-extra/pseudo/lib/Lex.cpp
index f5a239533c532..e99bf3a63e5e1 100644
--- a/clang-tools-extra/pseudo/lib/Lex.cpp
+++ b/clang-tools-extra/pseudo/lib/Lex.cpp
@@ -98,9 +98,21 @@ TokenStream cook(const TokenStream &Code, const LangOptions 
&LangOpts) {
   Tok.Length = Text.size();
   Tok.Flags &= ~static_cast(LexFlags::NeedsCleaning);
 }
-// Cook raw_identifiers into identifier, keyword, etc.
-if (Tok.Kind == tok::raw_identifier)
+
+if (Tok.Kind == tok::raw_identifier) {
+  // Cook raw_identifiers into identifier, keyword, etc.
   Tok.Kind = Identifiers.get(Tok.text()).getTokenID();
+} else if (Tok.Kind == tok::greatergreater) {
+  // Split the greatergreater token.
+  // FIXME: split lessless token to support Cuda triple angle brackets <<<.
+  assert(Tok.text() == ">>");
+  Tok.Kind = tok::greater;
+  Tok.Length = 1;
+  Result.push(Tok);
+  // Line is wrong if the first greater is followed by an escaped newline!
+  Tok.Data = Tok.text().data() + 1;
+}
+
 Result.push(std::move(Tok));
   }
 

diff  --git a/clang-tools-extra/pseudo/lib/cxx.bnf 
b/clang-tools-extra/pseudo/lib/cxx.bnf
index 2619ce1a43d81..45b2f616d20ac 100644
--- a/clang-tools-extra/pseudo/lib/cxx.bnf
+++ b/clang-tools-extra/pseudo/lib/cxx.bnf
@@ -13,6 +13,9 @@
 #  - the file merely describes the core C++ grammar. Preprocessor directives 
and
 #lexical conversions are omitted as we reuse clang's lexer and run a fake
 #preprocessor;
+#  - grammar rules with the >> token are adjusted, the greatergreater token is
+#split into two > tokens, to make the GLR parser aware of nested templates
+#and right shift operator;
 #
 # Guidelines:
 #   - non-terminals are lower_case; terminals (aka tokens) correspond to
@@ -96,7 +99,7 @@ fold-operator := %
 fold-operator := ^
 fold-operator := |
 fold-operator := <<
-fold-operator := >>
+fold-operator := greatergreater
 fold-operator := +=
 fold-operator := -=
 fold-operator := *=
@@ -202,7 +205,7 @@ additive-expression := additive-expression - 
multiplicative-expression
 # expr.shift
 shift-expression := additive-expression
 shift-expression := shift-expression << additive-expression
-shift-expression := shift-expression >> additive-expression
+shift-expression := shift-expression greatergreater additive-expression
 # expr.spaceship
 compare-expression := shift-expression
 compare-expression := compare-expression <=> shift-expression
@@ -615,7 +618,7 @@ operator-name := <=>
 operator-name := ^^
 operator-name := ||
 operator-name := <<
-operator-name := >>
+operator-name := greatergreater
 operator-name := <<=
 operator-name := >>=
 operator-name := ++
@@ -737,3 +740,8 @@ contextual-zero := NUMERIC_CONSTANT
 module-keyword := IDENTIFIER
 import-keyword := IDENTIFIER
 export-keyword := IDENTIFIER
+
+#! greatergreater token -- clang lexer always lexes it as a single token, we
+#! split it into two tokens to make the GLR parser aware of the nested-template
+#! case.
+greatergreater := > >

diff  --git a/clang-tools-extra/pseudo/unittests/TokenTest.cpp 
b/clang-tools-extra/pseu

[PATCH] D121678: [pseudo] Split greatergreater token.

2022-03-17 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf66d3758bda9: [pseudo] Split greatergreater token. (authored 
by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D121678?vs=416153&id=416154#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121678/new/

https://reviews.llvm.org/D121678

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/Token.h
  clang-tools-extra/pseudo/lib/Lex.cpp
  clang-tools-extra/pseudo/lib/cxx.bnf
  clang-tools-extra/pseudo/unittests/TokenTest.cpp

Index: clang-tools-extra/pseudo/unittests/TokenTest.cpp
===
--- clang-tools-extra/pseudo/unittests/TokenTest.cpp
+++ clang-tools-extra/pseudo/unittests/TokenTest.cpp
@@ -171,6 +171,25 @@
 }));
 }
 
+TEST(TokenTest, SplitGreaterGreater) {
+  LangOptions Opts;
+  std::string Code = R"cpp(
+>> // split
+// >> with an escaped newline in the middle, split
+>\
+>
+>>= // not split
+)cpp";
+  TokenStream Split = stripComments(cook(lex(Code, Opts), Opts));
+  EXPECT_THAT(Split.tokens(), ElementsAreArray({
+  token(">", tok::greater),
+  token(">", tok::greater),
+  token(">", tok::greater),
+  token(">", tok::greater),
+  token(">>=", tok::greatergreaterequal),
+  }));
+}
+
 TEST(TokenTest, DropComments) {
   LangOptions Opts;
   std::string Code = R"cpp(
Index: clang-tools-extra/pseudo/lib/cxx.bnf
===
--- clang-tools-extra/pseudo/lib/cxx.bnf
+++ clang-tools-extra/pseudo/lib/cxx.bnf
@@ -13,6 +13,9 @@
 #  - the file merely describes the core C++ grammar. Preprocessor directives and
 #lexical conversions are omitted as we reuse clang's lexer and run a fake
 #preprocessor;
+#  - grammar rules with the >> token are adjusted, the greatergreater token is
+#split into two > tokens, to make the GLR parser aware of nested templates
+#and right shift operator;
 #
 # Guidelines:
 #   - non-terminals are lower_case; terminals (aka tokens) correspond to
@@ -96,7 +99,7 @@
 fold-operator := ^
 fold-operator := |
 fold-operator := <<
-fold-operator := >>
+fold-operator := greatergreater
 fold-operator := +=
 fold-operator := -=
 fold-operator := *=
@@ -202,7 +205,7 @@
 # expr.shift
 shift-expression := additive-expression
 shift-expression := shift-expression << additive-expression
-shift-expression := shift-expression >> additive-expression
+shift-expression := shift-expression greatergreater additive-expression
 # expr.spaceship
 compare-expression := shift-expression
 compare-expression := compare-expression <=> shift-expression
@@ -615,7 +618,7 @@
 operator-name := ^^
 operator-name := ||
 operator-name := <<
-operator-name := >>
+operator-name := greatergreater
 operator-name := <<=
 operator-name := >>=
 operator-name := ++
@@ -737,3 +740,8 @@
 module-keyword := IDENTIFIER
 import-keyword := IDENTIFIER
 export-keyword := IDENTIFIER
+
+#! greatergreater token -- clang lexer always lexes it as a single token, we
+#! split it into two tokens to make the GLR parser aware of the nested-template
+#! case.
+greatergreater := > >
Index: clang-tools-extra/pseudo/lib/Lex.cpp
===
--- clang-tools-extra/pseudo/lib/Lex.cpp
+++ clang-tools-extra/pseudo/lib/Lex.cpp
@@ -98,9 +98,21 @@
   Tok.Length = Text.size();
   Tok.Flags &= ~static_cast(LexFlags::NeedsCleaning);
 }
-// Cook raw_identifiers into identifier, keyword, etc.
-if (Tok.Kind == tok::raw_identifier)
+
+if (Tok.Kind == tok::raw_identifier) {
+  // Cook raw_identifiers into identifier, keyword, etc.
   Tok.Kind = Identifiers.get(Tok.text()).getTokenID();
+} else if (Tok.Kind == tok::greatergreater) {
+  // Split the greatergreater token.
+  // FIXME: split lessless token to support Cuda triple angle brackets <<<.
+  assert(Tok.text() == ">>");
+  Tok.Kind = tok::greater;
+  Tok.Length = 1;
+  Result.push(Tok);
+  // Line is wrong if the first greater is followed by an escaped newline!
+  Tok.Data = Tok.text().data() + 1;
+}
+
 Result.push(std::move(Tok));
   }
 
Index: clang-tools-extra/pseudo/include/clang-pseudo/Token.h
===
--- clang-tools-extra/pseudo/include/clang-pseudo/Token.h
+++ clang-tools-extra/pseudo/include/clang-pseudo/Token.h
@@ -180,7 +180,8 @@
   NeedsCleaning = 1 << 1,
 };
 
-/// Derives a token stream by decoding escapes and interpreting raw_identifiers.
+/// Derives a token stream by decoding escapes, interpreting raw_identifiers and
+/// splitting the greatergreater token.
 ///

[PATCH] D121890: [clang-format] Copy help options to the doc directory.

2022-03-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay requested changes to this revision.
MyDeveloperDay added a comment.
This revision now requires changes to proceed.

1. Please log a github issue showing us what you are fixing.
2. Please add the main clang-formatter developers as reviewers and not the 
clang-format project (I think we see it but I like to see the individual 
reviewers so I know there opinion)
3. How about you change this so it autogenerates the rst so its never out of 
date.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121890/new/

https://reviews.llvm.org/D121890

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121757: [clang-format] Take out common code for parsing blocks

2022-03-17 Thread sstwcw via Phabricator via cfe-commits
sstwcw marked an inline comment as done.
sstwcw added a comment.

This patch is only intended to reduce the number of times the functionality 
gets implemented separately.  Any change in behavior would be unintended.  And 
we also use the `parseIndentedBlock` in Verilog stuff, so it's not just two 
places.  I will wait for the check-clang result to see what to do.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121757/new/

https://reviews.llvm.org/D121757

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121758: [clang-format] Add support for formatting Verilog code

2022-03-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Abandoned? huh? are you breaking it apart?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121758/new/

https://reviews.llvm.org/D121758

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] eb265e3 - [clangd] Re-enable clang-tidy's nolint blocks

2022-03-17 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-03-17T13:48:55+01:00
New Revision: eb265e3ba28dbac6d6c18674ae603428753559e9

URL: 
https://github.com/llvm/llvm-project/commit/eb265e3ba28dbac6d6c18674ae603428753559e9
DIFF: 
https://github.com/llvm/llvm-project/commit/eb265e3ba28dbac6d6c18674ae603428753559e9.diff

LOG: [clangd] Re-enable clang-tidy's nolint blocks

The previous inefficient implementation is polished.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D119701

Added: 


Modified: 
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp 
b/clang-tools-extra/clangd/ParsedAST.cpp
index c2239722737a3..295418c8434ab 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -467,7 +467,7 @@ ParsedAST::build(llvm::StringRef Filename, const 
ParseInputs &Inputs,
   if (IsInsideMainFile && CTContext->shouldSuppressDiagnostic(
   DiagLevel, Info, TidySuppressedErrors,
   /*AllowIO=*/false,
-  /*EnableNolintBlocks=*/false)) {
+  /*EnableNolintBlocks=*/true)) {
 // FIXME: should we expose the suppression error (invalid use of
 // NOLINT comments)?
 return DiagnosticsEngine::Ignored;

diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 7fd7babe68a75..a1b66b43a87b8 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -477,9 +477,8 @@ TEST(DiagnosticTest, ClangTidySuppressionComment) {
   #define BAD2 BAD
   double h = BAD2;  // NOLINT
   // NOLINTBEGIN
-  // FIXME: re-enable when NOLINTBEGIN suppresss block is enabled in 
clangd.
-  // double x = BAD2;
-  // double y = BAD2;
+  double x = BAD2;
+  double y = BAD2;
   // NOLINTEND
 
   // verify no crashes on unmatched nolints.



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119701: [clangd] Re-enable clang-tidy's nolint blocks

2022-03-17 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeb265e3ba28d: [clangd] Re-enable clang-tidy's nolint 
blocks (authored by hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119701/new/

https://reviews.llvm.org/D119701

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -477,9 +477,8 @@
   #define BAD2 BAD
   double h = BAD2;  // NOLINT
   // NOLINTBEGIN
-  // FIXME: re-enable when NOLINTBEGIN suppresss block is enabled in 
clangd.
-  // double x = BAD2;
-  // double y = BAD2;
+  double x = BAD2;
+  double y = BAD2;
   // NOLINTEND
 
   // verify no crashes on unmatched nolints.
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -467,7 +467,7 @@
   if (IsInsideMainFile && CTContext->shouldSuppressDiagnostic(
   DiagLevel, Info, TidySuppressedErrors,
   /*AllowIO=*/false,
-  /*EnableNolintBlocks=*/false)) {
+  /*EnableNolintBlocks=*/true)) {
 // FIXME: should we expose the suppression error (invalid use of
 // NOLINT comments)?
 return DiagnosticsEngine::Ignored;


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -477,9 +477,8 @@
   #define BAD2 BAD
   double h = BAD2;  // NOLINT
   // NOLINTBEGIN
-  // FIXME: re-enable when NOLINTBEGIN suppresss block is enabled in clangd.
-  // double x = BAD2;
-  // double y = BAD2;
+  double x = BAD2;
+  double y = BAD2;
   // NOLINTEND
 
   // verify no crashes on unmatched nolints.
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -467,7 +467,7 @@
   if (IsInsideMainFile && CTContext->shouldSuppressDiagnostic(
   DiagLevel, Info, TidySuppressedErrors,
   /*AllowIO=*/false,
-  /*EnableNolintBlocks=*/false)) {
+  /*EnableNolintBlocks=*/true)) {
 // FIXME: should we expose the suppression error (invalid use of
 // NOLINT comments)?
 return DiagnosticsEngine::Ignored;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121757: [clang-format] Take out common code for parsing blocks

2022-03-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Just an observation, I have this in my Day Job all the time..

1. Developer A develops a piece of code
2. Over the years the developers in our group learn that code and become 
familiar with it
3. Developer B arrives in our group, telling us we are doing it all wrong we 
don't understand, but they are going to refactor it for us and correct the 
error of our ways.
4. Now now one in our group understands the code, except Developer B
5. Developer B gets annoyed at our lack of understanding of his/her more 
masterful refactoring skills and disappears...
6. No one understands the code and everyone has to relearn the code. (Developer 
B's name is now mud!)

Refactoring is an important step, but in my view it shouldn't be the first 
contribution someone makes. I understand it you think its better, it possibly 
is.. but those of us who have been in here for years now no longer recognize 
the code and have to read it with a fine tooth combe again.

I personally don't see the code as being functional equal before or after, and 
I've kicked myself for not being more thorough in review when someone does 
this..that's probably my lack of understanding.

If you are fixing a bug, then ok, lets look at it, but just because you don't 
like the way it looks or you think there is repetition. If your an experienced 
contributor then maybe you'd have our trust...but otherwise we need to express 
caution here in my view. Just incase you chose to up and disappear.

Refactoring yes, but if its "Drive by" Refactoring, I'm not so keen.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121757/new/

https://reviews.llvm.org/D121757

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 30de15e - [pseudo] Tweak some docs, NFC

2022-03-17 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-03-17T13:58:42+01:00
New Revision: 30de15e100ccb8a53f73f8c826902d67eced50ec

URL: 
https://github.com/llvm/llvm-project/commit/30de15e100ccb8a53f73f8c826902d67eced50ec
DIFF: 
https://github.com/llvm/llvm-project/commit/30de15e100ccb8a53f73f8c826902d67eced50ec.diff

LOG: [pseudo] Tweak some docs, NFC

Consitently use the "nonterminal", "pseudoparser" terms.

Added: 


Modified: 
clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
clang-tools-extra/pseudo/lib/Grammar.cpp
clang-tools-extra/pseudo/lib/cxx.bnf
clang-tools-extra/pseudo/tool/ClangPseudo.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
index 7e94c4b89d854..106734b1b022a 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
@@ -1,4 +1,4 @@
-//===--- Grammar.h - grammar used by clang pseudo parser  *- 
C++-*-===//
+//===--- Grammar.h - grammar used by clang pseudoparser  -*- 
C++-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -17,7 +17,7 @@
 //
 //  A grammar formally describes a language, and it is constructed by a set of
 //  production rules. A rule is of BNF form (AAA := BBB CCC). A symbol is 
either
-//  non-terminal or terminal, identified by a SymbolID.
+//  nonterminal or terminal, identified by a SymbolID.
 //
 //  Notions about the BNF grammar:
 //  - "_" is the start symbol of the augmented grammar;
@@ -45,8 +45,8 @@
 
 namespace clang {
 namespace pseudo {
-// A SymbolID uniquely identifies a terminal/non-terminal symbol in a grammar.
-// Non-terminal IDs are indexes into a table of non-terminal symbols.
+// A SymbolID uniquely identifies a terminal/nonterminal symbol in a grammar.
+// nonterminal IDs are indexes into a table of nonterminal symbols.
 // Terminal IDs correspond to the clang TokenKind enum.
 using SymbolID = uint16_t;
 // SymbolID is only 12 bits wide.
@@ -120,11 +120,11 @@ class Grammar {
   // Returns the SymbolID of the start symbol '_'.
   SymbolID startSymbol() const { return StartSymbol; };
 
-  // Returns all rules of the given non-terminal symbol.
+  // Returns all rules of the given nonterminal symbol.
   llvm::ArrayRef rulesFor(SymbolID SID) const;
   const Rule &lookupRule(RuleID RID) const;
 
-  // Gets symbol (terminal or non-terminal) name.
+  // Gets symbol (terminal or nonterminal) name.
   // Terminals have names like "," (kw_comma) or "OPERATOR" (kw_operator).
   llvm::StringRef symbolName(SymbolID) const;
 
@@ -157,7 +157,7 @@ struct GrammarTable {
 
   struct Nonterminal {
 std::string Name;
-// Corresponding rules that construct the non-terminal, it is a [Start, 
End)
+// Corresponding rules that construct the nonterminal, it is a [Start, End)
 // index range of the Rules table.
 struct {
   RuleID Start;

diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
index c31a2621b2f88..d41fca0d4b5d2 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
@@ -18,10 +18,10 @@
 //
 //  Typically, based on the category of the grammar symbol, the LRTable is
 //  broken into two logically separate tables:
-//- ACTION table with terminals as columns -- e.g ACTION[S, a] specifies
+//- ACTION table with terminals as columns -- e.g. ACTION[S, a] specifies
 //  next action (shift/reduce/accept/error) on state S under a lookahead
 //  terminal a
-//- GOTO table with nonterminals as columns -- e.g. GOTO[S, X] specify
+//- GOTO table with nonterminals as columns -- e.g. GOTO[S, X] specifies
 //  the state which we transist to from the state S with the nonterminal X
 //
 //  LRTable is *performance-critial* as it is consulted frequently during a
@@ -161,7 +161,7 @@ class LRTable {
 
   // Index is nonterminal SymbolID, value is the offset into States/Actions
   // where the entries for this nonterminal begin.
-  // Give a non-terminal id, the corresponding half-open range of StateIdx is
+  // Give a nonterminal id, the corresponding half-open range of StateIdx is
   // [NontermIdx[id], NontermIdx[id+1]).
   std::vector NontermOffset;
   // Similar to NontermOffset, but for terminals, index is tok::TokenKind.

diff  --git a/clang-tools-extra/pseudo/lib/Grammar.cpp 
b/clang-tools-extra/pseudo/lib/Grammar.cpp
index c362a14a51e13..563390430f524 100644
--- a/clang-tools-extra/pseudo/lib/Grammar.cpp
+++ b/clang-tools-extra/pseudo/lib/Grammar.cpp
@@ -1,4 +1,4 @@
-//===--- Grammar.cpp - Grammar for clang pseudo parser  --*- 
C++-*

[PATCH] D121749: [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

2022-03-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:361
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound assignments
+like ``+=`` are aligned along with ``=``.

Is this wider than 80 chars?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121749/new/

https://reviews.llvm.org/D121749

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119792: [Clang] [P2025] Analyze only potential scopes for NRVO

2022-03-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

So P2025  has not successfully made it through 
EWG, so this would have to be under a 'flag'.  Also, I believe this will end up 
being applied to C++23, so it would have to be under a C++23 flag, even when we 
make it a default behavior.

I don't have a good feeling on the implementation (I've not looked well into 
this stuff), but those two are necessary.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119792/new/

https://reviews.llvm.org/D119792

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D117522: [clang-tidy] Add modernize-macro-to-enum check

2022-03-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:47
+CRLF,
+CRLFCR,
+  };

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > I'm a bit confused by this one as this is not a valid line ending (it's 
> > either three valid line endings or two valid line endings, depending on how 
> > you look at it). Can you explain why this is needed?
> It's a state machine, where the states are named for what we've seen so far 
> and we're looking for //two// consecutive line endings, not just one.  Does 
> it make sense now?
Thanks, I understood it was a state machine, but it's a confused one to me. 
`\r` was the line ending on Mac Classic, I've not seen it used outside of that 
platform (and I've not seen anyone write code for that platform in a long 
time). So, to me, the only valid combinations of line endings to worry about 
are: `LF LF`; `CRLF CRLF`; `CRLF LF`; `LF CRLF`.

`LF LF` returns false (Nothing -> LF -> return false)
`CRLF CRLF` returns false (Nothing -> CR -> CRLF -> CRLFCR -> return false)
`CRLF LF` returns true (Nothing -> CR -> CRLF -> LF -> finish loop)
`LF CRLF` returns true (Nothing -> LF -> CR -> CRLF -> finish loop)

(If you also intend to support Mac Classic line endings for some reason, this 
gets even more complicated.)



Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:106
+  int ConditionScopes;
+  unsigned int LastLine;
+  IncludeGuard GuardScanner;

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > Maybe not worth worrying about, but should this be a `uint64_t` to handle 
> > massive source files?
> I use the type returned by getSpellingLineNumber.
Sounds like a good enough reason to me, thanks!



Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:315
+  if (Info->isFunctionLike() || Info->isBuiltinMacro() ||
+  Info->tokens().empty() || Info->tokens().size() > 2)
+return;

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > We don't seem to have any tests for literal suffixes and I *think* those 
> > will show up here as additional tokens after the literal. e.g., `#define 
> > FOO +1ULL`, so I think the size check here may be a problem.
> On an earlier iteration I had some tests for literals with suffixes and the 
> suffix is included in the literal token.  I can add some test cases just to 
> make it clear what the behavior is when they are encountered.
Thanks, I'd appreciate adding the tests just to be sure we handle the case 
properly.



Comment at: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:318
+
+  // It can be +Lit, -Lit or just Lit.
+  Token Tok = Info->tokens().front();

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > It's worth pointing out that both of these are expressions that operate on 
> > a literal, and if we're going to allow expressions that operator on a 
> > literal, why only these two? e.g. why not allow `#define FOO ~0U` or 
> > `#define BAR FOO + 1`? Someday (not today), it would be nice for this to 
> > work on any expression that's a valid constant expression.
> A later enhancement can generalize to literal expressions (which are valid 
> initializers for an enumeration), but I wanted to cover the most common case 
> of simple negative integers in this first pass.
I'm less worried about the arbitrary constant expressions than I am about not 
supporting `~` because `~0U` is not uncommon in macros as a way to set all bits 
to 1. It's certainly more common than seeing a unary `+`, at least in my 
experience. However, an even more important use case that I should have thought 
of first is surrounding the value in parens (which is another common idiom with 
macros). e.g, `#define ONE (1)`

Some examples of this in the wild (search the files for `~0U`):

https://codesearch.isocpp.org/actcd19/main/l/linux/linux_4.15.17-1/drivers/gpu/drm/i915/gvt/handlers.c
https://codesearch.isocpp.org/actcd19/main/w/wine/wine_4.0-1/dlls/d3d8/d3d8_private.h
https://codesearch.isocpp.org/actcd19/main/q/qtwebengine-opensource-src/qtwebengine-opensource-src_5.11.3+dfsg-2/src/3rdparty/chromium/third_party/vulkan/include/vulkan/vulkan.h

(There's plenty of other examples to be found on the same site.)

I'm fine not completing the set in the initial patch, but the current behavior 
is a bit confusing (`+` is almost of negligible importance). I think `~` and 
parens need to be supported; I'd prefer in this patch, but I'm fine if it comes 
in a subsequent patch so long as those two are supported before we release.



Comment at: clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp:88-92
+CheckFactories.registerCheck(
+"modernize-use-equals-default");
 CheckFactories.registerCheck(
 "modernize-use-equals-delete");
+CheckFactories.registerCheck("modernize-use-nodiscard");
-

[PATCH] D121096: [C++20][Modules][HU 2/5] Support searching Header Units in user or system search paths.

2022-03-17 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 416162.
iains marked an inline comment as done.
iains added a comment.

match windows path delimiters in testcase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121096/new/

https://reviews.llvm.org/D121096

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/test/Modules/cxx20-hu-02.cpp
  clang/test/Modules/cxx20-hu-03.cpp

Index: clang/test/Modules/cxx20-hu-03.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-hu-03.cpp
@@ -0,0 +1,57 @@
+// Test check that processing headers as C++20 units allows #pragma once.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header hu-01.h \
+// RUN: -Werror -o hu-01.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header hu-02.h \
+// RUN: -fmodule-file=%t/hu-01.pcm -o hu-02.pcm
+
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only imports-01.cpp \
+// RUN: -fmodule-file=%t/hu-01.pcm
+
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only imports-02.cpp \
+// RUN: -fmodule-file=%t/hu-02.pcm
+
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only imports-03.cpp \
+// RUN: -fmodule-file=%t/hu-02.pcm
+
+//--- hu-01.h
+#pragma once
+struct HU {
+  int a;
+};
+// expected-no-diagnostics
+
+//--- hu-02.h
+export import "hu-01.h";
+// expected-no-diagnostics
+
+//--- imports-01.cpp
+import "hu-01.h";
+
+HU foo(int x) {
+  return {x};
+}
+// expected-no-diagnostics
+
+//--- imports-02.cpp
+import "hu-02.h";
+
+HU foo(int x) {
+  return {x};
+}
+// expected-no-diagnostics
+
+//--- imports-03.cpp
+import "hu-01.h";
+import "hu-02.h";
+
+HU foo(int x) {
+  return {x};
+}
+// expected-no-diagnostics
Index: clang/test/Modules/cxx20-hu-02.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-hu-02.cpp
@@ -0,0 +1,77 @@
+// Test generation and import of user and system C++20 Header Units.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// check user path
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -I user \
+// RUN: -xc++-user-header hu-01.h -o hu-01.pcm
+
+// RUN: %clang_cc1 -std=c++20 -module-file-info hu-01.pcm | \
+// RUN: FileCheck --check-prefix=CHECK-HU %s -DTDIR=%t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface imp-hu-01.cpp \
+// RUN:  -I user -fmodule-file=hu-01.pcm -o B.pcm -Rmodule-import \
+// RUN: 2>&1  | FileCheck --check-prefix=CHECK-IMP %s -DTDIR=%t
+
+// check system path
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -isystem system \
+// RUN: -xc++-system-header hu-02.h -o hu-02.pcm
+
+// RUN: %clang_cc1 -std=c++20 -module-file-info hu-02.pcm | \
+// RUN: FileCheck --check-prefix=CHECK-HU2 %s -DTDIR=%t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface imp-hu-02.cpp \
+// RUN:  -isystem system -fmodule-file=hu-02.pcm -o C.pcm \
+// RUN: -Rmodule-import 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-SYS-IMP %s -DTDIR=%t
+
+// check absolute path
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit  \
+// RUN: -xc++-header-unit-header %t/hu-03.h -o hu-03.pcm
+
+// RUN: %clang_cc1 -std=c++20 -module-file-info hu-03.pcm | \
+// RUN: FileCheck --check-prefix=CHECK-HU3 %s -DTDIR=%t
+
+//--- user/hu-01.h
+int foo(int);
+
+// CHECK-HU:  == C++20 Module structure ==
+// CHECK-HU-NEXT:  Header Unit 'user{{[/\\]}}hu-01.h' is the Primary Module at index #1
+
+//--- imp-hu-01.cpp
+export module B;
+import "hu-01.h";
+
+int bar(int x) {
+  return foo(x);
+}
+// CHECK-IMP: remark: importing module 'user{{[/\\]}}hu-01.h' from 'hu-01.pcm'
+// expected-no-diagnostics
+
+//--- system/hu-02.h
+int baz(int);
+
+// CHECK-HU2:  == C++20 Module structure ==
+// CHECK-HU2-NEXT:  Header Unit 'system{{[/\\]}}hu-02.h' is the Primary Module at index #1
+
+//--- imp-hu-02.cpp
+module;
+import ;
+
+export module C;
+
+int bar(int x) {
+  return baz(x);
+}
+// CHECK-SYS-IMP: remark: importing module 'system{{[/\\]}}hu-02.h' from 'hu-02.pcm'
+// expected-no-diagnostics
+
+//--- hu-03.h
+int curly(int);
+
+// CHECK-HU3:  == C++20 Module structure ==
+// CHECK-HU3-NEXT:  Header Unit '[[TDIR]]/hu-03.h' is the Primary Module at index #1
+// expected-no-diagnostics
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -798,7 +798,48 @@
&CI.getPreprocessor());
   HasBegunSourceFile = true;
 
-  // Initialize the main file entry.
+  // Handle C++20 header units.
+  // Here, the user has the option to specify that the header name should be
+  // looked up in the pre-processor search paths (and the main

[PATCH] D121096: [C++20][Modules][HU 2/5] Support searching Header Units in user or system search paths.

2022-03-17 Thread Iain Sandoe via Phabricator via cfe-commits
iains added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2855-2857
+  assert((DashX.getHeaderUnit() == InputKind::HeaderUnit_None ||
+  Inputs.size() == 1) &&
+ "Expected only one input file for header unit");

ChuanqiXu wrote:
> iains wrote:
> > ChuanqiXu wrote:
> > > So the compiler would crash if there is multiple inputs for header unit? 
> > > I feel it is not most friendly. How about emitting an error here?
> > well the driver is supposed to catch these problems (in the case of C++20 
> > modules mode it will generate several compile jobs, one per header).
> > 
> > I added an error for this tho.
> Oh, so if the compiler wouldn't crash in that case, I think the original 
> assertion is acceptable. And the current error is dead code, which is bad. 
> Let's take the original assertion.
actually, it does protect against the case that the frontend is called directly 
with XClang or so, so it's not dead code, and it is better for the compiler to 
emit a diagnostic rather than crash (if built with assertions).



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121096/new/

https://reviews.llvm.org/D121096

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118259: [AArch64] Adjust aarch64-neon-intrinsics-constrained test and un-XFAIL

2022-03-17 Thread John Brawn via Phabricator via cfe-commits
john.brawn added a comment.

llvm/test/CodeGen/AArch64/fp-intrinsics-vector.ll is testing the asm 
generation, so it probably is fine to remove that here so I will. This test is 
specifically testing arm_neon.h intrinsics though, so wouldn't make sense 
unifying with other architectures.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118259/new/

https://reviews.llvm.org/D118259

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121890: [clang-format] Copy help options to the doc directory.

2022-03-17 Thread sstwcw via Phabricator via cfe-commits
sstwcw marked an inline comment as done.
sstwcw added a comment.

The issue is #54418.

Actually I don't know who I should add as reviewers.  The patches for
clang-format don't always seem to have the same reviewers.  Who are the
main developers and how do you decide who you add each time?

I give up making the doc generated.  It would require either integrating
into the build process or writing a parser script like for the style
options.  Besides, that file is not entirely generated.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121890/new/

https://reviews.llvm.org/D121890

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121578: [RISCV][NFC] Add tests to address invalid arch dependencies.

2022-03-17 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.
This revision is now accepted and ready to land.
Herald added subscribers: s, arichardson.

Thanks, this looks good to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121578/new/

https://reviews.llvm.org/D121578

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121758: [clang-format] Add support for formatting Verilog code

2022-03-17 Thread sstwcw via Phabricator via cfe-commits
sstwcw added a comment.

Yes.  I am surprised that you asked since everyone asked me to break it apart.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121758/new/

https://reviews.llvm.org/D121758

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118370: [clang-tidy] bugprone-signal-handler: Message improvement and code refactoring.

2022-03-17 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:159-160
Itr != ItrE; ++Itr) {
 const auto *CallF = dyn_cast((*Itr)->getDecl());
-if (CallF && !isFunctionAsyncSafe(CallF)) {
-  assert(Itr.getPathLength() >= 2);
-  reportBug(CallF, findCallExpr(Itr.getPath(Itr.getPathLength() - 2), 
*Itr),
-/*DirectHandler=*/false);
-  reportHandlerCommon(Itr, SignalCall, HandlerDecl, HandlerExpr);
+if (CallF) {
+  unsigned int PathL = Itr.getPathLength();

balazske wrote:
> whisperity wrote:
> > 
> Is this code not too long to put in the condition section?
The formatter will break it up appropriately, no problem with that.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-posix.c:14
   printf("1234");
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'printf' may not be 
asynchronous-safe; calling it from a signal handler may be dangerous 
[bugprone-signal-handler]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: system call 'printf' may not be 
asynchronous-safe; calling it from a signal handler may be dangerous 
[bugprone-signal-handler]
 }

balazske wrote:
> whisperity wrote:
> > I'm not exactly sure we should call `printf` (and `memcpy`) a "system 
> > call". As far as I can see, in this patch, `isSystemCall()` boils down to 
> > //"declaration in file included as system header"//
> Call it "standard function"?
Yes, that would be better.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118370/new/

https://reviews.llvm.org/D118370

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121749: [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

2022-03-17 Thread sstwcw via Phabricator via cfe-commits
sstwcw added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:361
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound assignments
+like ``+=`` are aligned along with ``=``.

MyDeveloperDay wrote:
> Is this wider than 80 chars?
The comment in the source code is within 80 columns.  The python script 
prepended the option name.  It's the same case as line 1541.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121749/new/

https://reviews.llvm.org/D121749

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121749: [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

2022-03-17 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:361
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound assignments
+like ``+=`` are aligned along with ``=``.

sstwcw wrote:
> MyDeveloperDay wrote:
> > Is this wider than 80 chars?
> The comment in the source code is within 80 columns.  The python script 
> prepended the option name.  It's the same case as line 1541.
It is indeed. But it was already longer than 80 chars.
I'll have a look at the script to see how to fix this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121749/new/

https://reviews.llvm.org/D121749

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121749: [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

2022-03-17 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:361
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound assignments
+like ``+=`` are aligned along with ``=``.

curdeius wrote:
> sstwcw wrote:
> > MyDeveloperDay wrote:
> > > Is this wider than 80 chars?
> > The comment in the source code is within 80 columns.  The python script 
> > prepended the option name.  It's the same case as line 1541.
> It is indeed. But it was already longer than 80 chars.
> I'll have a look at the script to see how to fix this.
At the same time, does it really matter if it's auto-generated?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121749/new/

https://reviews.llvm.org/D121749

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120639: [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

2022-03-17 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.
This revision is now accepted and ready to land.

It would be good to have someone else who's reviewed earlier versions of this 
patch to confirm, but this LGTM. Thanks.

If you were editing it anyway, you could change "has passed" to "is passed" 
(though it's not a particularly important grammatical fix).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120639/new/

https://reviews.llvm.org/D120639

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116385: [clangd] Code action for creating an ObjC initializer

2022-03-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks, and sorry for the long delay.




Comment at: 
clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp:282
+   Anchor::Above}};
+  llvm::SmallVector> Edits;
+

Not sure I see the point of  using a SmallVector here instead of writing 
directly into Effect.ApplyEdits?



Comment at: 
clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp:295
+
+  if (Impl) {
+auto ImplReplacement = insertDecl(

Maybe a comment like:
```
// If we see the class implementation, add the initializer there too.
// FIXME: merging the edits is awkward, do this elsewhere
```

(I don't think we should fix it in this patch, but we should at some point)



Comment at: 
clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp:301
+
+if (!SM.isWrittenInSameFile(Interface->getLocation(),
+Impl->getLocation())) {

nit: I'd invert the condition here, to avoid the "else" block being a 
double-negative


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116385/new/

https://reviews.llvm.org/D116385

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121757: [clang-format] Take out common code for parsing blocks

2022-03-17 Thread sstwcw via Phabricator via cfe-commits
sstwcw added a comment.

For the new stuff I have the option of still adding the function 
`parseIndentedBlock` but only using it in new code.  Please be more blunt about 
whether I should close this revision and do it that way.  I guess I might have 
misunderstood you before from how you reacted when I closed the large patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121757/new/

https://reviews.llvm.org/D121757

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121911: [Clang] Add DriverKit support

2022-03-17 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan created this revision.
egorzhdan added a reviewer: arphaman.
Herald added a reviewer: aaron.ballman.
Herald added subscribers: dexonsmith, zzheng.
Herald added a project: All.
egorzhdan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is the second patch that upstreams the support for Apple's DriverKit.

The first patch: https://reviews.llvm.org/D118046.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121911

Files:
  clang/include/clang/Analysis/RetainSummaryManager.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Driver/Options.td
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Analysis/driverkit_base.h
  clang/test/Analysis/retain-release-driverkit.cpp
  clang/test/CodeGen/availability-check-driverkit.c
  clang/test/Driver/Inputs/DriverKit19.0.sdk/SDKSettings.plist
  clang/test/Driver/Inputs/DriverKit19.0.sdk/System/DriverKit/usr/include/.keep
  
clang/test/Driver/Inputs/basic_darwin_driverkit_sdk_usr_cxx_v1/System/DriverKit/usr/include/c++/v1/.keep
  
clang/test/Driver/Inputs/basic_darwin_driverkit_sdk_usr_cxx_v1/System/DriverKit/usr/lib/.keep
  clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.driverkit.a
  clang/test/Driver/darwin-ld-platform-version-driverkit.c
  clang/test/Driver/darwin-ld.c
  clang/test/Driver/darwin-version.c
  clang/test/Driver/debug-options.c
  clang/test/Driver/driverkit-arm64.c
  clang/test/Driver/driverkit-arm64e.c
  clang/test/Driver/driverkit-armv7k.s
  clang/test/Driver/driverkit-cplusplus.cpp
  clang/test/Driver/driverkit-exceptions.cpp
  clang/test/Driver/driverkit-framework.c
  clang/test/Driver/driverkit-rtti.cpp
  clang/test/Driver/driverkit-target-cpu.c
  clang/test/Driver/driverkit-version-min.c
  clang/test/Driver/incompatible_sysroot.c
  clang/test/Driver/instrprof-ld.c
  clang/test/Driver/pic.c
  clang/test/Driver/stack-protector.c
  clang/test/Frontend/darwin-version.c
  clang/test/Preprocessor/arm-target-features.c
  clang/test/Sema/attr-availability-driverkit.c

Index: clang/test/Sema/attr-availability-driverkit.c
===
--- /dev/null
+++ clang/test/Sema/attr-availability-driverkit.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 "-triple" "x86_64-apple-driverkit20.0" -fsyntax-only -verify %s
+
+void f0(int) __attribute__((availability(driverkit,introduced=19.0,deprecated=20.0))); // expected-note {{'f0' has been explicitly marked deprecated here}}
+void f1(int) __attribute__((availability(driverkit,introduced=20.0)));
+void f2(int) __attribute__((availability(driverkit,introduced=19.0,deprecated=20.0))); // expected-note {{'f2' has been explicitly marked deprecated here}}
+void f3(int) __attribute__((availability(driverkit,introduced=20.0)));
+void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(driverkit,introduced=19.0,deprecated=19.5,obsoleted=20.0))); // expected-note{{explicitly marked unavailable}}
+
+void f5(int) __attribute__((availability(driverkit,introduced=19.0))) __attribute__((availability(driverkit,deprecated=20.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}
+void f6(int) __attribute__((availability(driverkit,deprecated=20.0))); // expected-note {{'f6' has been explicitly marked deprecated here}}
+void f7(int) __attribute__((availability(driverkit,introduced=19.0)));
+
+void test() {
+  f0(0); // expected-warning{{'f0' is deprecated: first deprecated in DriverKit 20.0}}
+  f1(0);
+  f2(0); // expected-warning{{'f2' is deprecated: first deprecated in DriverKit 20.0}}
+  f3(0);
+  f4(0); // expected-error{{f4' is unavailable: obsoleted in DriverKit 20.0}}
+  f5(0); // expected-warning{{'f5' is deprecated: first deprecated in DriverKit 20.0}}
+  f6(0); // expected-warning{{'f6' is deprecated: first deprecated in DriverKit 20.0}}
+  f7(0);
+}
Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -834,6 +834,9 @@
 // CHECK-V82A: #define __ARM_FEATURE_QRDMX 1
 // CHECK-V82A: #define __ARM_FP 0xe
 
+// RUN: %clang -target armv7-apple-driverkit21.0 -x c %s -dM -E -o - | FileCheck -match-full-lines --check-prefix=CHECK-DRIVERKIT %s
+// CHECK-DRIVERKIT-NOT: #define __ARM_PCS_VFP 1
+
 // RUN: %

[clang] 799643f - [CGObjCGNU] Remove pointer element type uses

2022-03-17 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-17T14:53:34+01:00
New Revision: 799643f7f0bebbc4e45767cfea5e8e227af7ef9c

URL: 
https://github.com/llvm/llvm-project/commit/799643f7f0bebbc4e45767cfea5e8e227af7ef9c
DIFF: 
https://github.com/llvm/llvm-project/commit/799643f7f0bebbc4e45767cfea5e8e227af7ef9c.diff

LOG: [CGObjCGNU] Remove pointer element type uses

Added: 


Modified: 
clang/lib/CodeGen/CGObjCGNU.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 210bbf36d7bdf..0301076f26f46 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -107,6 +107,8 @@ class CGObjCGNU : public CGObjCRuntime {
   /// SEL is included in a header somewhere, in which case it will be whatever
   /// type is declared in that header, most likely {i8*, i8*}.
   llvm::PointerType *SelectorTy;
+  /// Element type of SelectorTy.
+  llvm::Type *SelectorElemTy;
   /// LLVM i8 type.  Cached here to avoid repeatedly getting it in all of the
   /// places where it's used
   llvm::IntegerType *Int8Ty;
@@ -128,6 +130,8 @@ class CGObjCGNU : public CGObjCRuntime {
   /// but if the runtime header declaring it is included then it may be a
   /// pointer to a structure.
   llvm::PointerType *IdTy;
+  /// Element type of IdTy.
+  llvm::Type *IdElemTy;
   /// Pointer to a pointer to an Objective-C object.  Used in the new ABI
   /// message lookup function and some GC-related functions.
   llvm::PointerType *PtrToIdTy;
@@ -313,14 +317,10 @@ class CGObjCGNU : public CGObjCRuntime {
   /// Ensures that the value has the required type, by inserting a bitcast if
   /// required.  This function lets us avoid inserting bitcasts that are
   /// redundant.
-  llvm::Value* EnforceType(CGBuilderTy &B, llvm::Value *V, llvm::Type *Ty) {
-if (V->getType() == Ty) return V;
-return B.CreateBitCast(V, Ty);
-  }
-  Address EnforceType(CGBuilderTy &B, Address V, llvm::Type *Ty) {
-if (V.getType() == Ty)
+  llvm::Value *EnforceType(CGBuilderTy &B, llvm::Value *V, llvm::Type *Ty) {
+if (V->getType() == Ty)
   return V;
-return B.CreateElementBitCast(V, Ty->getPointerElementType());
+return B.CreateBitCast(V, Ty);
   }
 
   // Some zeros used for GEPs in lots of places.
@@ -701,8 +701,8 @@ class CGObjCGCC : public CGObjCGNU {
   llvm::Value *LookupIMPSuper(CodeGenFunction &CGF, Address ObjCSuper,
   llvm::Value *cmd, MessageSendInfo &MSI) override 
{
 CGBuilderTy &Builder = CGF.Builder;
-llvm::Value *lookupArgs[] = {EnforceType(Builder, ObjCSuper,
-PtrToObjCSuperTy).getPointer(), cmd};
+llvm::Value *lookupArgs[] = {
+EnforceType(Builder, ObjCSuper.getPointer(), PtrToObjCSuperTy), cmd};
 return CGF.EmitNounwindRuntimeCall(MsgLookupSuperFn, lookupArgs);
   }
 
@@ -979,9 +979,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
 // Look for an existing one
 llvm::StringMap::iterator old = ObjCStrings.find(Str);
 if (old != ObjCStrings.end())
-  return ConstantAddress(
-  old->getValue(), old->getValue()->getType()->getPointerElementType(),
-  Align);
+  return ConstantAddress(old->getValue(), IdElemTy, Align);
 
 bool isNonASCII = SL->containsNonAscii();
 
@@ -1003,7 +1001,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
   auto *ObjCStr = llvm::ConstantExpr::getIntToPtr(
   llvm::ConstantInt::get(Int64Ty, str), IdTy);
   ObjCStrings[Str] = ObjCStr;
-  return ConstantAddress(ObjCStr, IdTy->getPointerElementType(), Align);
+  return ConstantAddress(ObjCStr, IdElemTy, Align);
 }
 
 StringRef StringClass = CGM.getLangOpts().ObjCConstantStringClass;
@@ -1117,7 +1115,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
 llvm::Constant *ObjCStr = llvm::ConstantExpr::getBitCast(ObjCStrGV, IdTy);
 ObjCStrings[Str] = ObjCStr;
 ConstantStrings.push_back(ObjCStr);
-return ConstantAddress(ObjCStr, IdTy->getPointerElementType(), Align);
+return ConstantAddress(ObjCStr, IdElemTy, Align);
   }
 
   void PushProperty(ConstantArrayBuilder &PropertiesArray,
@@ -1209,8 +1207,10 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
   llvm::Value *cmd, MessageSendInfo &MSI) override 
{
 // Don't access the slot unless we're trying to cache the result.
 CGBuilderTy &Builder = CGF.Builder;
-llvm::Value *lookupArgs[] = {CGObjCGNU::EnforceType(Builder, ObjCSuper,
-PtrToObjCSuperTy).getPointer(), cmd};
+llvm::Value *lookupArgs[] = {CGObjCGNU::EnforceType(Builder,
+ObjCSuper.getPointer(),
+PtrToObjCSuperTy),
+ cmd};
 return CGF.EmitNounwindRuntimeCall(MsgLookupSuperFn, lookupArgs);
   }
 
@@ -2171,8 +2171,10 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned 
ru

[PATCH] D118259: [AArch64] Adjust aarch64-neon-intrinsics-constrained test and un-XFAIL

2022-03-17 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

It's been a while, but I think the aarch64-neon-intrinsics-constrained.c test 
is trimmed down from the aarch64-neon-intrinsics.c test. Shouldn't the 
constrained and non-constrained end-to-end tests be treated the same?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118259/new/

https://reviews.llvm.org/D118259

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D117829: [Clang] Add integer add/mul reduction builtins

2022-03-17 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D117829#3386398 , @fhahn wrote:

> @RKSimon are you planning on pushing this patch through? From my perspective, 
> it looks good with splitting off `__builtin_reduce_mul` and adding a TODO to 
> also implement it for floating point types.

You mean handle add/mul in separate patches? I'm happy to continue with this, I 
just didn't want to make it more difficult for us to add fp support in the 
future - particularly if we do end up needing the scalar initial_value argument


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117829/new/

https://reviews.llvm.org/D117829

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-17 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 416168.
zahiraam marked an inline comment as done.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121122/new/

https://reviews.llvm.org/D121122

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/test/CodeGen/eval-method-fast-math.cpp

Index: clang/test/CodeGen/eval-method-fast-math.cpp
===
--- /dev/null
+++ clang/test/CodeGen/eval-method-fast-math.cpp
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -triple x86_64-linux-gnu -emit-llvm -o - %s  \
+// RUN: | FileCheck %s -check-prefixes=CHECK
+
+// RUN: %clang_cc1 -triple i386--linux -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-EXT
+
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -mreassociate -freciprocal-math -ffp-contract=fast \
+// RUN: -ffast-math -triple x86_64-linux-gnu \
+// RUN: -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+// RUN: %clang_cc1 -triple i386--linux -mreassociate -freciprocal-math \
+// RUN: -ffp-contract=fast -ffast-math -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+float a = 1.0f, b = 2.0f, c = 3.0f;
+#pragma float_control(precise, off)
+float res2 = a + b + c;
+int val3 = __FLT_EVAL_METHOD__;
+#pragma float_control(precise, on)
+float res3 = a + b + c;
+int val4 = __FLT_EVAL_METHOD__;
+
+// CHECK: @val3 = global i32 -1
+// CHECK: @val4 = global i32 0
+
+// CHECK-EXT: @val3 = global i32 -1
+// CHECK-EXT: @val4 = global i32 2
+
+// CHECK-FAST: @val3 = global i32 -1
+// CHECK-FAST: @val4 = global i32 -1
+
+float res;
+int add(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+int add_precise(float a, float b, float c) {
+#pragma float_control(precise, on)
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+#pragma float_control(precise, on)
+int add_precise_1(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int add_not_precise(float a, float b, float c) {
+  // Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+  // CHECK: fadd fast float
+  // CHECK: load float, float*
+  // CHECK: fadd fast float
+  // CHECK: float {{.*}}, float*
+  // CHECK: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+// Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+int add_not_precise_1(float a, float b, float c) {
+  // CHECK: fadd fast float
+  // CHECK: load float, float*
+  // CHECK: fadd fast float
+  // CHECK: float {{.*}}, float*
+  // CHECK: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int getFPEvalMethod() {
+  // CHECK: ret i32 0
+  return __FLT_EVAL_METHOD__;
+}
+
+float res1;
+int whatever(float a, float b, float c) {
+#pragma float_control(precise, off)
+  // CHECK: load float, float*
+  // CHECK: fadd fast float
+  // CHECK: store float {{.*}}, float*
+  // CHECK: store i32 -1
+  // CHECK: store i32 0
+  // CHECK: ret i32 -1
+  res1 = a + b + c;
+  int val1 = __FLT_EVAL_METHOD__;
+  {
+#pragma float_control(precise, on)
+int val2 = __FLT_EVAL_METHOD__;
+  }
+  return __FLT_EVAL_METHOD__;
+}
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -508,6 +508,13 @@
   case PFC_Precise:
 NewFPFeatures.setFPPreciseEnabled(true);
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+if (PP.getCurrentFPEvalMethod() ==
+LangOptions::FPEvalMethodKind::FEM_Indeterminable &&
+PP.getLastFPEvalPragmaLocation().isValid())
+  // A preceding `pragma float_control(precise,off)` has changed
+  // the value of the evaluation method.
+  // Set it back to its old value.
+  PP.setCurrentFPEvalMethod(SourceLocation(), PP.getLastFPEvalMethod());
 break;
   case PFC_NoPrecise:
 if (CurFPFeatures.getFPExceptionMode() == LangOptions::FPE_Strict)
@@ -517,6 +524,10 @@
 else
   NewFPFeatures.setFPPreciseEnabled(false);
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+PP.setLastFPEvalMethod(PP.getCurrentFPEvalMethod());
+// `AllowFPReassoc` or `AllowReciprocal` option is enabled.
+PP.setCurrentFPEvalMethod(
+Loc, LangOptions::FPEvalMethodKind::FEM_In

[PATCH] D121757: [clang-format] Take out common code for parsing blocks

2022-03-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D121757#3389218 , @sstwcw wrote:

> For the new stuff I have the option of still adding the function 
> `parseIndentedBlock` but only using it in new code.  Please be more blunt 
> about whether I should close this revision and do it that way.  I guess I 
> might have misunderstood you before from how you reacted when I closed the 
> large patch.

Ok being blunt.. the things you are asking to do, look noble, I just don't 
always understand the motivation? you are seemingly not fixing anything, you 
are not adding new tests, its just moving things around, but I don't know your 
commitment yet? are you hanging around? are you going to fix bugs?

I feel like the guidance for new developers is do a "good first issue", the 
reviewers have triaged the clang-format issues to try and identify what makes a 
good first issue for a new contributor

https://github.com/llvm/llvm-project/issues?q=is%3Aopen+label%3A%22good+first+issue%22+label%3Aclang-format

Ultimately if you don't have commit access your going to ask one of us to land 
this for you, as such we might need persuading, Certainly for me to do that for 
you I need to see a benefit otherwise its just change in my view.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121757/new/

https://reviews.llvm.org/D121757

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118259: [AArch64] Adjust aarch64-neon-intrinsics-constrained test and un-XFAIL

2022-03-17 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D118259#3389235 , @kpn wrote:

> It's been a while, but I think the aarch64-neon-intrinsics-constrained.c test 
> is trimmed down from the aarch64-neon-intrinsics.c test. Shouldn't the 
> constrained and non-constrained end-to-end tests be treated the same?

Are you referring to 
https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGen/aarch64-neon-intrinsics.c?
 This one doesn't check assembly.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118259/new/

https://reviews.llvm.org/D118259

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121736: Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO

2022-03-17 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM - but please hang around after you commit


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121736/new/

https://reviews.llvm.org/D121736

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118259: [AArch64] Adjust aarch64-neon-intrinsics-constrained test and un-XFAIL

2022-03-17 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In D118259#3389246 , @fhahn wrote:

> In D118259#3389235 , @kpn wrote:
>
>> It's been a while, but I think the aarch64-neon-intrinsics-constrained.c 
>> test is trimmed down from the aarch64-neon-intrinsics.c test. Shouldn't the 
>> constrained and non-constrained end-to-end tests be treated the same?
>
> Are you referring to 
> https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGen/aarch64-neon-intrinsics.c?
>  This one doesn't check assembly.

Ah, well, I guess that wasn't it, then. It's been a while, and I've been all 
over the place.

A clang-only test that just tests for the correct IR being emitted won't 
trigger the failures in the backend. An LLVM-only test that starts from that IR 
can show those failures, but it also runs the risk over time of getting out of 
sync with the IR emitted by clang. An end-to-end test will always be in sync, 
and it will show those failures that I ran into plus anything else that crops 
up over time. If there's another way, or if there is another approach, then it 
might be possible there's a way to get all the testing done without running 
into those issues. I just don't know what it is.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118259/new/

https://reviews.llvm.org/D118259

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bf1a998 - [CodeGen] Avoid some pointer element type accesses

2022-03-17 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-17T15:25:55+01:00
New Revision: bf1a99861c2e98cfd85792fdefe2ef9c7ec11f52

URL: 
https://github.com/llvm/llvm-project/commit/bf1a99861c2e98cfd85792fdefe2ef9c7ec11f52
DIFF: 
https://github.com/llvm/llvm-project/commit/bf1a99861c2e98cfd85792fdefe2ef9c7ec11f52.diff

LOG: [CodeGen] Avoid some pointer element type accesses

Added: 


Modified: 
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprScalar.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index a32411774312c..e54101f36d8fe 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2277,6 +2277,8 @@ static void emitPartialArrayDestroy(CodeGenFunction &CGF,
 llvm::Value *begin, llvm::Value *end,
 QualType type, CharUnits elementAlign,
 CodeGenFunction::Destroyer *destroyer) {
+  llvm::Type *elemTy = CGF.ConvertTypeForMem(type);
+
   // If the element type is itself an array, drill down.
   unsigned arrayDepth = 0;
   while (const ArrayType *arrayType = CGF.getContext().getAsArrayType(type)) {
@@ -2290,7 +2292,6 @@ static void emitPartialArrayDestroy(CodeGenFunction &CGF,
 llvm::Value *zero = llvm::ConstantInt::get(CGF.SizeTy, 0);
 
 SmallVector gepIndices(arrayDepth+1, zero);
-llvm::Type *elemTy = begin->getType()->getPointerElementType();
 begin = CGF.Builder.CreateInBoundsGEP(
 elemTy, begin, gepIndices, "pad.arraybegin");
 end = CGF.Builder.CreateInBoundsGEP(
@@ -2473,11 +2474,9 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, 
ParamValue Arg,
   assert(getContext().getTargetAddressSpace(SrcLangAS) ==
  CGM.getDataLayout().getAllocaAddrSpace());
   auto DestAS = getContext().getTargetAddressSpace(DestLangAS);
-  auto *T = V->getType()->getPointerElementType()->getPointerTo(DestAS);
-  DeclPtr =
-  Address::deprecated(getTargetHooks().performAddrSpaceCast(
-  *this, V, SrcLangAS, DestLangAS, T, true),
-  DeclPtr.getAlignment());
+  auto *T = DeclPtr.getElementType()->getPointerTo(DestAS);
+  DeclPtr = DeclPtr.withPointer(getTargetHooks().performAddrSpaceCast(
+  *this, V, SrcLangAS, DestLangAS, T, true));
 }
 
 // Push a destructor cleanup for this parameter if the ABI requires it.

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 6cd3cab70b78e..b0eeddd98fce6 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1852,8 +1852,7 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value 
*Value, Address Addr,
   if (const auto *ClangVecTy = Ty->getAs()) {
 auto *VecTy = dyn_cast(SrcTy);
 if (VecTy && ClangVecTy->isExtVectorBoolType()) {
-  auto *MemIntTy =
-  cast(Addr.getType()->getPointerElementType());
+  auto *MemIntTy = cast(Addr.getElementType());
   // Expand to the memory bit width.
   unsigned MemNumElems = MemIntTy->getPrimitiveSizeInBits();
   //  --> .

diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 18f0dacdb3c82..18a22b50f63e4 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2641,7 +2641,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const 
UnaryOperator *E, LValue LV,
   = CGF.getContext().getAsVariableArrayType(type)) {
   llvm::Value *numElts = CGF.getVLASize(vla).NumElts;
   if (!isInc) numElts = Builder.CreateNSWNeg(numElts, "vla.negsize");
-  llvm::Type *elemTy = value->getType()->getPointerElementType();
+  llvm::Type *elemTy = CGF.ConvertTypeForMem(vla->getElementType());
   if (CGF.getLangOpts().isSignedOverflowDefined())
 value = Builder.CreateGEP(elemTy, value, numElts, "vla.inc");
   else
@@ -3519,7 +3519,7 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF,
 // GEP indexes are signed, and scaling an index isn't permitted to
 // signed-overflow, so we use the same semantics for our explicit
 // multiply.  We suppress this if overflow is not undefined behavior.
-llvm::Type *elemTy = pointer->getType()->getPointerElementType();
+llvm::Type *elemTy = CGF.ConvertTypeForMem(vla->getElementType());
 if (CGF.getLangOpts().isSignedOverflowDefined()) {
   index = CGF.Builder.CreateMul(index, numElements, "vla.index");
   pointer = CGF.Builder.CreateGEP(elemTy, pointer, index, "add.ptr");



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121915: [RISCV][1/2]Add IR intrinsic for Zbb extension

2022-03-17 Thread Chang Hu via Phabricator via cfe-commits
joker881 created this revision.
joker881 added a reviewer: craig.topper.
Herald added subscribers: s, VincentWu, luke957, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, 
arichardson.
Herald added a project: All.
joker881 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, eopXD, 
MaskRay.
Herald added projects: clang, LLVM.

clz


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121915

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
  llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll

Index: llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll
===
--- llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll
+++ llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll
@@ -54,3 +54,14 @@
   %tmp = call i64 @llvm.riscv.orc.b.i64(i64 %a)
   ret i64 %tmp
 }
+
+declare i64 @llvm.riscv.clz.i64(i64)
+
+define i64 @clz64(i64 %a) nounwind {
+; RV64ZBB-LABEL: clz64:
+; RV64ZBB:   # %bb.0:
+; RV64ZBB-NEXT:clz a0, a0
+; RV64ZBB-NEXT:ret
+  %tmp = call i64 @llvm.riscv.clz.i64(i64 %a)
+  ret i64 %tmp
+}
Index: llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
===
--- llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
+++ llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
@@ -12,3 +12,13 @@
   %tmp = call i32 @llvm.riscv.orc.b.i32(i32 %a)
   ret i32 %tmp
 }
+declare i32 @llvm.riscv.clz.i32(i32)
+
+define i32 @clz(i32 %a) nounwind {
+; RV32ZBB-LABEL: clz:
+; RV32ZBB:   # %bb.0:
+; RV32ZBB-NEXT:clz a0, a0
+; RV32ZBB-NEXT:ret
+  %tmp = call i32 @llvm.riscv.clz.i32(i32 %a)
+  ret i32 %tmp
+}
Index: llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
@@ -1213,3 +1213,7 @@
 def : PatGprGpr;
 def : PatGprGpr;
 }
+let Predicates = [HasStdExtZbb] in {
+def : PatGpr;
+}
+
Index: llvm/include/llvm/IR/IntrinsicsRISCV.td
===
--- llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ -87,6 +87,7 @@
 
   // Zbb
   def int_riscv_orc_b : BitManipGPRIntrinsics;
+  def int_riscv_clz : BitManipGPRIntrinsics;
 
   // Zbc or Zbkc
   def int_riscv_clmul  : BitManipGPRGPRIntrinsics;
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -25,3 +25,27 @@
 long orc_b_64(long a) {
   return __builtin_riscv_orc_b_64(a);
 }
+
+// RV64ZBB-LABEL: @clz_32(
+// RV64ZBB-NEXT:  entry:
+// RV64ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV64ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV64ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.clz.i32(i32 [[TMP0]])
+// RV64ZBB-NEXT:ret i32 [[TMP1]]
+//
+int clz_32(int a) {
+  return __builtin_riscv_clz_32(a);
+}
+
+// RV64ZBB-LABEL: @clz_64(
+// RV64ZBB-NEXT:  entry:
+// RV64ZBB-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
+// RV64ZBB-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8
+// RV64ZBB-NEXT:[[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
+// RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.clz.i64(i64 [[TMP0]])
+// RV64ZBB-NEXT:ret i64 [[TMP1]]
+//
+long clz_64(long a) {
+  return __builtin_riscv_clz_64(a);
+}
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -13,3 +13,14 @@
 int orc_b_32(int a) {
   return __builtin_riscv_orc_b_32(a);
 }
+// RV32ZBB-LABEL: @clz_32(
+// RV32ZBB-NEXT:  entry:
+// RV32ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.clz.i32(i32 [[TMP0]])
+// RV32ZBB-NEXT:ret i32 [[TMP1]]
+//
+int clz_32(int a) {
+  return __builtin_riscv_clz_32(a);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ cl

[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-17 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 416180.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121122/new/

https://reviews.llvm.org/D121122

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/test/CodeGen/eval-method-fast-math.cpp

Index: clang/test/CodeGen/eval-method-fast-math.cpp
===
--- /dev/null
+++ clang/test/CodeGen/eval-method-fast-math.cpp
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -triple x86_64-linux-gnu -emit-llvm -o - %s  \
+// RUN: | FileCheck %s -check-prefixes=CHECK
+
+// RUN: %clang_cc1 -triple i386--linux -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-EXT
+
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -mreassociate -freciprocal-math -ffp-contract=fast \
+// RUN: -ffast-math -triple x86_64-linux-gnu \
+// RUN: -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+// RUN: %clang_cc1 -triple i386--linux -mreassociate -freciprocal-math \
+// RUN: -ffp-contract=fast -ffast-math -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+float a = 1.0f, b = 2.0f, c = 3.0f;
+#pragma float_control(precise, off)
+float res2 = a + b + c;
+int val3 = __FLT_EVAL_METHOD__;
+#pragma float_control(precise, on)
+float res3 = a + b + c;
+int val4 = __FLT_EVAL_METHOD__;
+
+// CHECK: @val3 = global i32 -1
+// CHECK: @val4 = global i32 0
+
+// CHECK-EXT: @val3 = global i32 -1
+// CHECK-EXT: @val4 = global i32 2
+
+// CHECK-FAST: @val3 = global i32 -1
+// CHECK-FAST: @val4 = global i32 -1
+
+float res;
+int add(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+int add_precise(float a, float b, float c) {
+#pragma float_control(precise, on)
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+#pragma float_control(precise, on)
+int add_precise_1(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int add_not_precise(float a, float b, float c) {
+  // Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+  // CHECK: fadd fast float
+  // CHECK: load float, float*
+  // CHECK: fadd fast float
+  // CHECK: float {{.*}}, float*
+  // CHECK: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+// Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+int add_not_precise_1(float a, float b, float c) {
+  // CHECK: fadd fast float
+  // CHECK: load float, float*
+  // CHECK: fadd fast float
+  // CHECK: float {{.*}}, float*
+  // CHECK: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int getFPEvalMethod() {
+  // CHECK: ret i32 0
+  return __FLT_EVAL_METHOD__;
+}
+
+float res1;
+int whatever(float a, float b, float c) {
+#pragma float_control(precise, off)
+  // CHECK: load float, float*
+  // CHECK: fadd fast float
+  // CHECK: store float {{.*}}, float*
+  // CHECK: store i32 -1
+  // CHECK: store i32 0
+  // CHECK: ret i32 -1
+  res1 = a + b + c;
+  int val1 = __FLT_EVAL_METHOD__;
+  {
+#pragma float_control(precise, on)
+int val2 = __FLT_EVAL_METHOD__;
+  }
+  return __FLT_EVAL_METHOD__;
+}
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -508,6 +508,13 @@
   case PFC_Precise:
 NewFPFeatures.setFPPreciseEnabled(true);
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+if (PP.getCurrentFPEvalMethod() ==
+LangOptions::FPEvalMethodKind::FEM_Indeterminable &&
+PP.getLastFPEvalPragmaLocation().isValid())
+  // A preceding `pragma float_control(precise,off)` has changed
+  // the value of the evaluation method.
+  // Set it back to its old value.
+  PP.setCurrentFPEvalMethod(SourceLocation(), PP.getLastFPEvalMethod());
 break;
   case PFC_NoPrecise:
 if (CurFPFeatures.getFPExceptionMode() == LangOptions::FPE_Strict)
@@ -517,6 +524,10 @@
 else
   NewFPFeatures.setFPPreciseEnabled(false);
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+PP.setLastFPEvalMethod(PP.getCurrentFPEvalMethod());
+// `AllowFPReassoc` or `AllowReciprocal` option is enabled.
+PP.setCurrentFPEvalMethod(
+Loc, LangOptions::FPEvalMethodKind::FEM_Indeterminable);
 break;
   case PFC_Exce

[PATCH] D121916: [clang-format] [doc] Add script to automatically update help output in ClangFormat.rst.

2022-03-17 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan.
Herald added a project: All.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121916

Files:
  clang/docs/ClangFormat.rst
  clang/docs/tools/dump_format_help.py
  clang/tools/clang-format/ClangFormat.cpp

Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -100,17 +100,16 @@
 "clang-format from an editor integration"),
cl::init(0), cl::cat(ClangFormatCategory));
 
-static cl::opt SortIncludes(
-"sort-includes",
-cl::desc("If set, overrides the include sorting behavior determined by the "
- "SortIncludes style flag"),
-cl::cat(ClangFormatCategory));
+static cl::opt
+SortIncludes("sort-includes",
+ cl::desc("If set, overrides the include sorting behavior\n"
+  "determined by the SortIncludes style flag"),
+ cl::cat(ClangFormatCategory));
 
 static cl::opt QualifierAlignment(
 "qualifier-alignment",
-cl::desc(
-"If set, overrides the qualifier alignment style determined by the "
-"QualifierAlignment style flag"),
+cl::desc("If set, overrides the qualifier alignment style\n"
+ "determined by the QualifierAlignment style flag"),
 cl::init(""), cl::cat(ClangFormatCategory));
 
 static cl::opt
@@ -148,8 +147,9 @@
 
 static cl::opt ErrorLimit(
 "ferror-limit",
-cl::desc("Set the maximum number of clang-format errors to emit before "
- "stopping (0 = no limit). Used only with --dry-run or -n"),
+cl::desc("Set the maximum number of clang-format errors to emit\n"
+ "before stopping (0 = no limit).\n"
+ "Used only with --dry-run or -n"),
 cl::init(0), cl::cat(ClangFormatCategory));
 
 static cl::opt
Index: clang/docs/tools/dump_format_help.py
===
--- /dev/null
+++ clang/docs/tools/dump_format_help.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python3
+# A tool to parse the FormatStyle struct from Format.h and update the
+# documentation in ../ClangFormatStyleOptions.rst automatically.
+# Run from the directory in which this file is located to update the docs.
+
+import os
+import re
+import subprocess
+import sys
+
+CLANG_DIR = os.path.join(os.path.dirname(__file__), '../..')
+DOC_FILE = os.path.join(CLANG_DIR, 'docs/ClangFormat.rst')
+
+
+def substitute(text, tag, contents):
+replacement = '\n.. START_%s\n\n%s\n\n.. END_%s\n' % (tag, contents, tag)
+pattern = r'\n\.\. START_%s\n.*\n\.\. END_%s\n' % (tag, tag)
+return re.sub(pattern, '%s', text, flags=re.S) % replacement
+
+
+def indent(text, columns, indent_first_line=True):
+indent_str = ' ' * columns
+s = re.sub(r'\n([^\n])', '\n' + indent_str + '\\1', text, flags=re.S)
+if not indent_first_line or s.startswith('\n'):
+return s
+return indent_str + s
+
+
+def get_help_output():
+args = ["clang-format", "--help"]
+cmd = subprocess.Popen(args, stdout=subprocess.PIPE,
+   stderr=subprocess.STDOUT)
+out, _ = cmd.communicate()
+out = out.decode(sys.stdout.encoding)
+return out
+
+
+def get_help_text():
+out = get_help_output()
+out = re.sub(r' clang-format\.exe ', ' clang-format ', out)
+
+out = '''.. code-block:: console
+
+$ clang-format -help
+''' + out
+out = indent(out, 2, indent_first_line=False)
+return out
+
+
+def validate(text, columns):
+for line in text.splitlines():
+if len(line) > columns:
+print('warning: line too long:\n', line, file=sys.stderr)
+
+
+help_text = get_help_text()
+validate(help_text, 95)
+
+with open(DOC_FILE) as f:
+contents = f.read()
+
+contents = substitute(contents, 'FORMAT_HELP', help_text)
+
+with open(DOC_FILE, 'wb') as output:
+output.write(contents.encode())
Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -13,6 +13,8 @@
 :program:`clang-format` is located in `clang/tools/clang-format` and can be used
 to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
 
+.. START_FORMAT_HELP
+
 .. code-block:: console
 
   $ clang-format -help
@@ -30,73 +32,76 @@
 
   Clang-format options:
 
---Werror   - If set, changes formatting warnings to errors
---Wno-error=- If set don't error out on the specified warning type.
-  =unknown -   If set, unknown format options are only warned about.
-   This can be used to enable formatting, even if the
-   

[PATCH] D121916: [clang-format] [doc] Add script to automatically update help output in ClangFormat.rst.

2022-03-17 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

This is an alternative to D121890 .
This patch goes a step further and adds a script to update the .rst file.
It isn't invoked during the build, one needs to run it manually (just as 
`dump_format_style.py`).

There's also a validation option, currently set to column width at 95 chars. I 
fixed some very long lines but did't try to fix everything (it would need 
changing help message which is used not only by clang-format).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121916/new/

https://reviews.llvm.org/D121916

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121916: [clang-format] [doc] Add script to automatically update help output in ClangFormat.rst.

2022-03-17 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 416185.
curdeius added a comment.

Update file comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121916/new/

https://reviews.llvm.org/D121916

Files:
  clang/docs/ClangFormat.rst
  clang/docs/tools/dump_format_help.py
  clang/tools/clang-format/ClangFormat.cpp

Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -100,17 +100,16 @@
 "clang-format from an editor integration"),
cl::init(0), cl::cat(ClangFormatCategory));
 
-static cl::opt SortIncludes(
-"sort-includes",
-cl::desc("If set, overrides the include sorting behavior determined by the "
- "SortIncludes style flag"),
-cl::cat(ClangFormatCategory));
+static cl::opt
+SortIncludes("sort-includes",
+ cl::desc("If set, overrides the include sorting behavior\n"
+  "determined by the SortIncludes style flag"),
+ cl::cat(ClangFormatCategory));
 
 static cl::opt QualifierAlignment(
 "qualifier-alignment",
-cl::desc(
-"If set, overrides the qualifier alignment style determined by the "
-"QualifierAlignment style flag"),
+cl::desc("If set, overrides the qualifier alignment style\n"
+ "determined by the QualifierAlignment style flag"),
 cl::init(""), cl::cat(ClangFormatCategory));
 
 static cl::opt
@@ -148,8 +147,9 @@
 
 static cl::opt ErrorLimit(
 "ferror-limit",
-cl::desc("Set the maximum number of clang-format errors to emit before "
- "stopping (0 = no limit). Used only with --dry-run or -n"),
+cl::desc("Set the maximum number of clang-format errors to emit\n"
+ "before stopping (0 = no limit).\n"
+ "Used only with --dry-run or -n"),
 cl::init(0), cl::cat(ClangFormatCategory));
 
 static cl::opt
Index: clang/docs/tools/dump_format_help.py
===
--- /dev/null
+++ clang/docs/tools/dump_format_help.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python3
+# A tool to parse the output of `clang-format --help` and update the
+# documentation in ../ClangFormat.rst automatically.
+
+import os
+import re
+import subprocess
+import sys
+
+CLANG_DIR = os.path.join(os.path.dirname(__file__), '../..')
+DOC_FILE = os.path.join(CLANG_DIR, 'docs/ClangFormat.rst')
+
+
+def substitute(text, tag, contents):
+replacement = '\n.. START_%s\n\n%s\n\n.. END_%s\n' % (tag, contents, tag)
+pattern = r'\n\.\. START_%s\n.*\n\.\. END_%s\n' % (tag, tag)
+return re.sub(pattern, '%s', text, flags=re.S) % replacement
+
+
+def indent(text, columns, indent_first_line=True):
+indent_str = ' ' * columns
+s = re.sub(r'\n([^\n])', '\n' + indent_str + '\\1', text, flags=re.S)
+if not indent_first_line or s.startswith('\n'):
+return s
+return indent_str + s
+
+
+def get_help_output():
+args = ["clang-format", "--help"]
+cmd = subprocess.Popen(args, stdout=subprocess.PIPE,
+   stderr=subprocess.STDOUT)
+out, _ = cmd.communicate()
+out = out.decode(sys.stdout.encoding)
+return out
+
+
+def get_help_text():
+out = get_help_output()
+out = re.sub(r' clang-format\.exe ', ' clang-format ', out)
+
+out = '''.. code-block:: console
+
+$ clang-format -help
+''' + out
+out = indent(out, 2, indent_first_line=False)
+return out
+
+
+def validate(text, columns):
+for line in text.splitlines():
+if len(line) > columns:
+print('warning: line too long:\n', line, file=sys.stderr)
+
+
+help_text = get_help_text()
+validate(help_text, 95)
+
+with open(DOC_FILE) as f:
+contents = f.read()
+
+contents = substitute(contents, 'FORMAT_HELP', help_text)
+
+with open(DOC_FILE, 'wb') as output:
+output.write(contents.encode())
Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -13,6 +13,8 @@
 :program:`clang-format` is located in `clang/tools/clang-format` and can be used
 to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
 
+.. START_FORMAT_HELP
+
 .. code-block:: console
 
   $ clang-format -help
@@ -30,73 +32,76 @@
 
   Clang-format options:
 
---Werror   - If set, changes formatting warnings to errors
---Wno-error=- If set don't error out on the specified warning type.
-  =unknown -   If set, unknown format options are only warned about.
-   This can be used to enable formatting, even if the
-   configuration contains unknown (newer) options.
-   Use with caution, as this might lead to dramatically
-   

[PATCH] D116385: [clangd] Code action for creating an ObjC initializer

2022-03-17 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 416186.
dgoldman marked 3 inline comments as done.
dgoldman added a comment.

Fixes for review


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116385/new/

https://reviews.llvm.org/D116385

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/ObjCMemberwiseInitializerTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ObjCMemberwiseInitializerTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/ObjCMemberwiseInitializerTests.cpp
@@ -0,0 +1,153 @@
+//===-- ObjCMemberwiseInitializerTests.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestTU.h"
+#include "TweakTesting.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TWEAK_TEST(ObjCMemberwiseInitializer);
+
+TEST_F(ObjCMemberwiseInitializerTest, TestAvailability) {
+  FileName = "TestTU.m";
+
+  // Ensure the action can't be triggered since arc is disabled.
+  EXPECT_UNAVAILABLE(R"cpp(
+@interface Fo^o
+@end
+  )cpp");
+
+  ExtraArgs.push_back("-fobjc-arc");
+
+  // Ensure the action can be initiated on the interface and implementation,
+  // but not on the forward declaration.
+  EXPECT_AVAILABLE(R"cpp(
+@interface Fo^o
+@end
+  )cpp");
+  EXPECT_AVAILABLE(R"cpp(
+@interface Foo
+@end
+
+@implementation F^oo
+@end
+  )cpp");
+  EXPECT_UNAVAILABLE("@class Fo^o;");
+
+  // Ensure that the action can be triggered on ivars and properties,
+  // including selecting both.
+  EXPECT_AVAILABLE(R"cpp(
+@interface Foo {
+  id _fi^eld;
+}
+@end
+  )cpp");
+  EXPECT_AVAILABLE(R"cpp(
+@interface Foo
+@property(nonatomic) id fi^eld;
+@end
+  )cpp");
+  EXPECT_AVAILABLE(R"cpp(
+@interface Foo {
+  id _fi^eld;
+}
+@property(nonatomic) id pr^op;
+@end
+  )cpp");
+
+  // Ensure that the action can't be triggered on property synthesis
+  // and methods.
+  EXPECT_UNAVAILABLE(R"cpp(
+@interface Foo
+@property(nonatomic) id prop;
+@end
+
+@implementation Foo
+@dynamic pr^op;
+@end
+  )cpp");
+  EXPECT_UNAVAILABLE(R"cpp(
+@interface Foo
+@end
+
+@implementation Foo
+- (void)fo^o {}
+@end
+  )cpp");
+}
+
+TEST_F(ObjCMemberwiseInitializerTest, Test) {
+  FileName = "TestTU.m";
+  ExtraArgs.push_back("-fobjc-arc");
+
+  const char *Input = R"cpp(
+@interface Foo {
+  id [[_field;
+}
+@property(nonatomic) id prop]];
+@property(nonatomic) id notSelected;
+@end)cpp";
+  const char *Output = R"cpp(
+@interface Foo {
+  id _field;
+}
+@property(nonatomic) id prop;
+@property(nonatomic) id notSelected;
+- (instancetype)initWithField:(id)field prop:(id)prop;
+
+@end)cpp";
+  EXPECT_EQ(apply(Input), Output);
+
+  Input = R"cpp(
+@interface Foo
+@property(nonatomic, nullable) id somePrettyLongPropertyName;
+@property(nonatomic, nonnull) id someReallyLongPropertyName;
+@end
+
+@implementation F^oo
+
+- (instancetype)init {
+  return self;
+}
+
+@end)cpp";
+  Output = R"cpp(
+@interface Foo
+@property(nonatomic, nullable) id somePrettyLongPropertyName;
+@property(nonatomic, nonnull) id someReallyLongPropertyName;
+- (instancetype)initWithSomePrettyLongPropertyName:(nullable id)somePrettyLongPropertyName someReallyLongPropertyName:(nonnull id)someReallyLongPropertyName;
+
+@end
+
+@implementation Foo
+
+- (instancetype)init {
+  return self;
+}
+
+- (instancetype)initWithSomePrettyLongPropertyName:(nullable id)somePrettyLongPropertyName someReallyLongPropertyName:(nonnull id)someReallyLongPropertyName {
+  self = [super init];
+  if (self) {
+_somePrettyLongPropertyName = somePrettyLongPropertyName;
+_someReallyLongPropertyName = someReallyLongPropertyName;
+  }
+  return self;
+}
+
+@end)cpp";
+  EXPECT_EQ(apply(Input), Output);
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -118,6 +118,7 @@
   tweaks/ExtractFunctionTests.cpp
   tweaks/ExtractVariableTests.cpp
   tweaks/ObjCLocalizeStringLiteralTests.cpp
+  tweaks/ObjCMemberwiseInitializerTests.cpp
   tweaks/PopulateSwitchTests.cpp
   tweaks/RawStringLiteralTests.cpp
   tweaks/RemoveUsingNamespaceTests.cpp
Index: clang-

[clang] cb2f2fe - [Clang] Added info about noinline/always_inline statement attributes to release notes

2022-03-17 Thread Dávid Bolvanský via cfe-commits

Author: Dávid Bolvanský
Date: 2022-03-17T16:29:23+01:00
New Revision: cb2f2fecc151999a7892a9d1325a34f85dabcecb

URL: 
https://github.com/llvm/llvm-project/commit/cb2f2fecc151999a7892a9d1325a34f85dabcecb
DIFF: 
https://github.com/llvm/llvm-project/commit/cb2f2fecc151999a7892a9d1325a34f85dabcecb.diff

LOG: [Clang] Added info about noinline/always_inline statement attributes to 
release notes

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D121896

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d457be1305cf7..21531bf72cd5b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -103,6 +103,9 @@ Attribute Changes in Clang
 attributes of 
diff erent kinds.
   - Emit error on GNU attributes for a nested namespace definition.
 
+- Statement attributes ``[[clang::noinline]]`` and  
``[[clang::always_inline]]``
+  can be used to control inlining decisions at callsites.
+
 Windows Support
 ---
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121896: [Clang] Added info about noinline/always_inline statement attributes to release notes

2022-03-17 Thread Dávid Bolvanský via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb2f2fecc151: [Clang] Added info about 
noinline/always_inline statement attributes to release… (authored by xbolva00).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121896/new/

https://reviews.llvm.org/D121896

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -103,6 +103,9 @@
 attributes of different kinds.
   - Emit error on GNU attributes for a nested namespace definition.
 
+- Statement attributes ``[[clang::noinline]]`` and  
``[[clang::always_inline]]``
+  can be used to control inlining decisions at callsites.
+
 Windows Support
 ---
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -103,6 +103,9 @@
 attributes of different kinds.
   - Emit error on GNU attributes for a nested namespace definition.
 
+- Statement attributes ``[[clang::noinline]]`` and  ``[[clang::always_inline]]``
+  can be used to control inlining decisions at callsites.
+
 Windows Support
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 1af5fbd - [clangd] Code action for creating an ObjC initializer

2022-03-17 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2022-03-17T11:31:14-04:00
New Revision: 1af5fbd5c605372963f78351f721fa28ee5ba60e

URL: 
https://github.com/llvm/llvm-project/commit/1af5fbd5c605372963f78351f721fa28ee5ba60e
DIFF: 
https://github.com/llvm/llvm-project/commit/1af5fbd5c605372963f78351f721fa28ee5ba60e.diff

LOG: [clangd] Code action for creating an ObjC initializer

The code action creates an initializer for the selected
ivars/properties, defaulting to all if only the interface/implementation
container is selected.

We add it based on the position of the first non initializer that we
see, and default to adding it where the @end token is.

We also use the ObjC parameter form of (nullable id) instead of
(id _Nullable) if the property has the nullable attribute.

Differential Revision: https://reviews.llvm.org/D116385

Added: 
clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
clang-tools-extra/clangd/unittests/tweaks/ObjCMemberwiseInitializerTests.cpp

Modified: 
clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
clang-tools-extra/clangd/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt 
b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
index caa69947c47fb..ae279781a6f52 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -22,6 +22,7 @@ add_clang_library(clangDaemonTweaks OBJECT
   ExtractFunction.cpp
   ExtractVariable.cpp
   ObjCLocalizeStringLiteral.cpp
+  ObjCMemberwiseInitializer.cpp
   PopulateSwitch.cpp
   RawStringLiteral.cpp
   RemoveUsingNamespace.cpp

diff  --git 
a/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
new file mode 100644
index 0..2f8f8f7863409
--- /dev/null
+++ b/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
@@ -0,0 +1,329 @@
+//===--- ObjCMemberwiseInitializer.cpp ---*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ParsedAST.h"
+#include "SourceCode.h"
+#include "refactor/InsertionPoint.h"
+#include "refactor/Tweak.h"
+#include "support/Logger.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/AST/PrettyPrinter.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+static std::string capitalize(std::string Message) {
+  if (!Message.empty())
+Message[0] = llvm::toUpper(Message[0]);
+  return Message;
+}
+
+static std::string getTypeStr(const QualType &OrigT, const Decl &D,
+  unsigned PropertyAttributes) {
+  QualType T = OrigT;
+  PrintingPolicy Policy(D.getASTContext().getLangOpts());
+  Policy.SuppressStrongLifetime = true;
+  std::string Prefix = "";
+  // If the nullability is specified via a property attribute, use the shorter
+  // `nullable` form for the method parameter.
+  if (PropertyAttributes & ObjCPropertyAttribute::kind_nullability) {
+if (auto Kind = AttributedType::stripOuterNullability(T)) {
+  switch (Kind.getValue()) {
+  case NullabilityKind::Nullable:
+Prefix = "nullable ";
+break;
+  case NullabilityKind::NonNull:
+Prefix = "nonnull ";
+break;
+  case NullabilityKind::Unspecified:
+Prefix = "null_unspecified ";
+break;
+  case NullabilityKind::NullableResult:
+T = OrigT;
+break;
+  }
+}
+  }
+  return Prefix + T.getAsString(Policy);
+}
+
+struct MethodParameter {
+  // Parameter name.
+  llvm::StringRef Name;
+
+  // Type of the parameter.
+  std::string Type;
+
+  // Assignment target (LHS).
+  std::string Assignee;
+
+  MethodParameter(const ObjCIvarDecl &ID) {
+// Convention maps `@property int foo` to ivar `int _foo`, so drop the
+// leading `_` if there is one.
+Name = ID.getName();
+Name.consume_front("_");
+Type = getTypeStr(ID.getType(), ID, ObjCPropertyAttribute::kind_noattr);
+Assignee = ID.getName().str();
+  }
+  MethodParameter(const ObjCPropertyDecl &PD) {
+Name = PD.getName();
+Type = getTypeStr(PD.getType(), PD, PD.getPropertyAttributes());
+if (const auto *ID = PD.getPropertyIvarDecl())
+  Assignee = 

[PATCH] D116385: [clangd] Code action for creating an ObjC initializer

2022-03-17 Thread David Goldman via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1af5fbd5c605: [clangd] Code action for creating an ObjC 
initializer (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116385/new/

https://reviews.llvm.org/D116385

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/ObjCMemberwiseInitializerTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ObjCMemberwiseInitializerTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/ObjCMemberwiseInitializerTests.cpp
@@ -0,0 +1,153 @@
+//===-- ObjCMemberwiseInitializerTests.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestTU.h"
+#include "TweakTesting.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TWEAK_TEST(ObjCMemberwiseInitializer);
+
+TEST_F(ObjCMemberwiseInitializerTest, TestAvailability) {
+  FileName = "TestTU.m";
+
+  // Ensure the action can't be triggered since arc is disabled.
+  EXPECT_UNAVAILABLE(R"cpp(
+@interface Fo^o
+@end
+  )cpp");
+
+  ExtraArgs.push_back("-fobjc-arc");
+
+  // Ensure the action can be initiated on the interface and implementation,
+  // but not on the forward declaration.
+  EXPECT_AVAILABLE(R"cpp(
+@interface Fo^o
+@end
+  )cpp");
+  EXPECT_AVAILABLE(R"cpp(
+@interface Foo
+@end
+
+@implementation F^oo
+@end
+  )cpp");
+  EXPECT_UNAVAILABLE("@class Fo^o;");
+
+  // Ensure that the action can be triggered on ivars and properties,
+  // including selecting both.
+  EXPECT_AVAILABLE(R"cpp(
+@interface Foo {
+  id _fi^eld;
+}
+@end
+  )cpp");
+  EXPECT_AVAILABLE(R"cpp(
+@interface Foo
+@property(nonatomic) id fi^eld;
+@end
+  )cpp");
+  EXPECT_AVAILABLE(R"cpp(
+@interface Foo {
+  id _fi^eld;
+}
+@property(nonatomic) id pr^op;
+@end
+  )cpp");
+
+  // Ensure that the action can't be triggered on property synthesis
+  // and methods.
+  EXPECT_UNAVAILABLE(R"cpp(
+@interface Foo
+@property(nonatomic) id prop;
+@end
+
+@implementation Foo
+@dynamic pr^op;
+@end
+  )cpp");
+  EXPECT_UNAVAILABLE(R"cpp(
+@interface Foo
+@end
+
+@implementation Foo
+- (void)fo^o {}
+@end
+  )cpp");
+}
+
+TEST_F(ObjCMemberwiseInitializerTest, Test) {
+  FileName = "TestTU.m";
+  ExtraArgs.push_back("-fobjc-arc");
+
+  const char *Input = R"cpp(
+@interface Foo {
+  id [[_field;
+}
+@property(nonatomic) id prop]];
+@property(nonatomic) id notSelected;
+@end)cpp";
+  const char *Output = R"cpp(
+@interface Foo {
+  id _field;
+}
+@property(nonatomic) id prop;
+@property(nonatomic) id notSelected;
+- (instancetype)initWithField:(id)field prop:(id)prop;
+
+@end)cpp";
+  EXPECT_EQ(apply(Input), Output);
+
+  Input = R"cpp(
+@interface Foo
+@property(nonatomic, nullable) id somePrettyLongPropertyName;
+@property(nonatomic, nonnull) id someReallyLongPropertyName;
+@end
+
+@implementation F^oo
+
+- (instancetype)init {
+  return self;
+}
+
+@end)cpp";
+  Output = R"cpp(
+@interface Foo
+@property(nonatomic, nullable) id somePrettyLongPropertyName;
+@property(nonatomic, nonnull) id someReallyLongPropertyName;
+- (instancetype)initWithSomePrettyLongPropertyName:(nullable id)somePrettyLongPropertyName someReallyLongPropertyName:(nonnull id)someReallyLongPropertyName;
+
+@end
+
+@implementation Foo
+
+- (instancetype)init {
+  return self;
+}
+
+- (instancetype)initWithSomePrettyLongPropertyName:(nullable id)somePrettyLongPropertyName someReallyLongPropertyName:(nonnull id)someReallyLongPropertyName {
+  self = [super init];
+  if (self) {
+_somePrettyLongPropertyName = somePrettyLongPropertyName;
+_someReallyLongPropertyName = someReallyLongPropertyName;
+  }
+  return self;
+}
+
+@end)cpp";
+  EXPECT_EQ(apply(Input), Output);
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -118,6 +118,7 @@
   tweaks/ExtractFunctionTests.cpp
   tweaks/ExtractVariableTests.cpp
   tweaks/ObjCLocalizeStringLiteralTests.cpp
+  tweaks/ObjCMemberwiseInitializerTests.cpp
   tweaks/Popula

[clang] 2edac9d - [CodeGen] Avoid some pointer element type accesses

2022-03-17 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-17T16:32:45+01:00
New Revision: 2edac9d962b9ee06d14a74886fb8aaa85d5256ee

URL: 
https://github.com/llvm/llvm-project/commit/2edac9d962b9ee06d14a74886fb8aaa85d5256ee
DIFF: 
https://github.com/llvm/llvm-project/commit/2edac9d962b9ee06d14a74886fb8aaa85d5256ee.diff

LOG: [CodeGen] Avoid some pointer element type accesses

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGObjC.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 4ca0a1f3c03de..4ac7b6e79ff3e 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17464,18 +17464,19 @@ Value *
 CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E) {
   auto MakeLdg = [&](unsigned IntrinsicID) {
 Value *Ptr = EmitScalarExpr(E->getArg(0));
-clang::CharUnits Align =
-CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
+QualType ArgType = E->getArg(0)->getType();
+clang::CharUnits Align = CGM.getNaturalPointeeTypeAlignment(ArgType);
+llvm::Type *ElemTy = ConvertTypeForMem(ArgType->getPointeeType());
 return Builder.CreateCall(
-CGM.getIntrinsic(IntrinsicID, {Ptr->getType()->getPointerElementType(),
-   Ptr->getType()}),
+CGM.getIntrinsic(IntrinsicID, {ElemTy, Ptr->getType()}),
 {Ptr, ConstantInt::get(Builder.getInt32Ty(), Align.getQuantity())});
   };
   auto MakeScopedAtomic = [&](unsigned IntrinsicID) {
 Value *Ptr = EmitScalarExpr(E->getArg(0));
+llvm::Type *ElemTy =
+ConvertTypeForMem(E->getArg(0)->getType()->getPointeeType());
 return Builder.CreateCall(
-CGM.getIntrinsic(IntrinsicID, {Ptr->getType()->getPointerElementType(),
-   Ptr->getType()}),
+CGM.getIntrinsic(IntrinsicID, {ElemTy, Ptr->getType()}),
 {Ptr, EmitScalarExpr(E->getArg(1))});
   };
   switch (BuiltinID) {
@@ -17681,20 +17682,22 @@ CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned 
BuiltinID, const CallExpr *E) {
   case NVPTX::BI__nvvm_atom_cta_cas_gen_l:
   case NVPTX::BI__nvvm_atom_cta_cas_gen_ll: {
 Value *Ptr = EmitScalarExpr(E->getArg(0));
+llvm::Type *ElemTy =
+ConvertTypeForMem(E->getArg(0)->getType()->getPointeeType());
 return Builder.CreateCall(
 CGM.getIntrinsic(
-Intrinsic::nvvm_atomic_cas_gen_i_cta,
-{Ptr->getType()->getPointerElementType(), Ptr->getType()}),
+Intrinsic::nvvm_atomic_cas_gen_i_cta, {ElemTy, Ptr->getType()}),
 {Ptr, EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2))});
   }
   case NVPTX::BI__nvvm_atom_sys_cas_gen_i:
   case NVPTX::BI__nvvm_atom_sys_cas_gen_l:
   case NVPTX::BI__nvvm_atom_sys_cas_gen_ll: {
 Value *Ptr = EmitScalarExpr(E->getArg(0));
+llvm::Type *ElemTy =
+ConvertTypeForMem(E->getArg(0)->getType()->getPointeeType());
 return Builder.CreateCall(
 CGM.getIntrinsic(
-Intrinsic::nvvm_atomic_cas_gen_i_sys,
-{Ptr->getType()->getPointerElementType(), Ptr->getType()}),
+Intrinsic::nvvm_atomic_cas_gen_i_sys, {ElemTy, Ptr->getType()}),
 {Ptr, EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2))});
   }
   case NVPTX::BI__nvvm_match_all_sync_i32p:

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 8331d1ba215e9..888243eef333e 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3936,7 +3936,9 @@ static void emitWritebackArg(CodeGenFunction &CGF, 
CallArgList &args,
   // because of the crazy ObjC compatibility rules.
 
   llvm::PointerType *destType =
-cast(CGF.ConvertType(CRE->getType()));
+  cast(CGF.ConvertType(CRE->getType()));
+  llvm::Type *destElemType =
+  CGF.ConvertTypeForMem(CRE->getType()->getPointeeType());
 
   // If the address is a constant null, just pass the appropriate null.
   if (isProvablyNull(srcAddr.getPointer())) {
@@ -3946,8 +3948,8 @@ static void emitWritebackArg(CodeGenFunction &CGF, 
CallArgList &args,
   }
 
   // Create the temporary.
-  Address temp = CGF.CreateTempAlloca(destType->getPointerElementType(),
-  CGF.getPointerAlign(), "icr.temp");
+  Address temp =
+  CGF.CreateTempAlloca(destElemType, CGF.getPointerAlign(), "icr.temp");
   // Loading an l-value can introduce a cleanup if the l-value is __weak,
   // and that cleanup will be conditional if we can't prove that the l-value
   // isn't null, so we need to register a dominating point so that the cleanups
@@ -3957,8 +3959,8 @@ static void emitWritebackArg(CodeGenFunction &CGF, 
CallArgList &args,
   // Zero-initialize it if we're not doing a copy-initialization.
   bool shouldCopy = CRE->shouldCopy();
   if (!shouldCopy) {
-llvm::Value *null =

[clang] 6c0af92 - [CodeGen] Avoid some pointer element type accesses

2022-03-17 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-17T16:36:14+01:00
New Revision: 6c0af92612d0730a039226d67cfa08f4d6db5be9

URL: 
https://github.com/llvm/llvm-project/commit/6c0af92612d0730a039226d67cfa08f4d6db5be9
DIFF: 
https://github.com/llvm/llvm-project/commit/6c0af92612d0730a039226d67cfa08f4d6db5be9.diff

LOG: [CodeGen] Avoid some pointer element type accesses

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CodeGenFunction.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 888243eef333e..0b3d1d0b467f0 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3513,8 +3513,7 @@ void CodeGenFunction::EmitFunctionEpilog(const 
CGFunctionInfo &FI,
   --EI;
   llvm::Value *ArgStruct = &*EI;
   llvm::Value *SRet = Builder.CreateStructGEP(
-  EI->getType()->getPointerElementType(), ArgStruct,
-  RetAI.getInAllocaFieldIndex());
+  FI.getArgStruct(), ArgStruct, RetAI.getInAllocaFieldIndex());
   llvm::Type *Ty =
   cast(SRet)->getResultElementType();
   RV = Builder.CreateAlignedLoad(Ty, SRet, getPointerAlign(), "sret");

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 3089cdc4e4a92..eabebd9c3ed37 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9990,6 +9990,7 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const 
OMPDeclareMapperDecl *D,
   cast(cast(D->getMapperVarRef())->getDecl());
   SourceLocation Loc = D->getLocation();
   CharUnits ElementSize = C.getTypeSizeInChars(Ty);
+  llvm::Type *ElemTy = CGM.getTypes().ConvertTypeForMem(Ty);
 
   // Prepare mapper function arguments and attributes.
   ImplicitParamDecl HandleArg(C, /*DC=*/nullptr, Loc, /*Id=*/nullptr,
@@ -10044,8 +10045,7 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const 
OMPDeclareMapperDecl *D,
   Size, MapperCGF.Builder.getInt64(ElementSize.getQuantity()));
   llvm::Value *PtrBegin = MapperCGF.Builder.CreateBitCast(
   BeginIn, CGM.getTypes().ConvertTypeForMem(PtrTy));
-  llvm::Value *PtrEnd = MapperCGF.Builder.CreateGEP(
-  PtrBegin->getType()->getPointerElementType(), PtrBegin, Size);
+  llvm::Value *PtrEnd = MapperCGF.Builder.CreateGEP(ElemTy, PtrBegin, Size);
   llvm::Value *MapType = MapperCGF.EmitLoadOfScalar(
   MapperCGF.GetAddrOfLocalVar(&TypeArg), /*Volatile=*/false,
   C.getPointerType(Int64Ty), Loc);
@@ -10077,10 +10077,10 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const 
OMPDeclareMapperDecl *D,
   llvm::PHINode *PtrPHI = MapperCGF.Builder.CreatePHI(
   PtrBegin->getType(), 2, "omp.arraymap.ptrcurrent");
   PtrPHI->addIncoming(PtrBegin, EntryBB);
-  Address PtrCurrent =
-  Address::deprecated(PtrPHI, MapperCGF.GetAddrOfLocalVar(&BeginArg)
-  .getAlignment()
-  .alignmentOfArrayElement(ElementSize));
+  Address PtrCurrent(PtrPHI, ElemTy,
+ MapperCGF.GetAddrOfLocalVar(&BeginArg)
+ .getAlignment()
+ .alignmentOfArrayElement(ElementSize));
   // Privatize the declared variable of mapper to be the current array element.
   CodeGenFunction::OMPPrivateScope Scope(MapperCGF);
   Scope.addPrivate(MapperVarDecl, PtrCurrent);
@@ -10202,7 +10202,6 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const 
OMPDeclareMapperDecl *D,
 
   // Update the pointer to point to the next element that needs to be mapped,
   // and check whether we have mapped all elements.
-  llvm::Type *ElemTy = PtrPHI->getType()->getPointerElementType();
   llvm::Value *PtrNext = MapperCGF.Builder.CreateConstGEP1_32(
   ElemTy, PtrPHI, /*Idx0=*/1, "omp.arraymap.next");
   PtrPHI->addIncoming(PtrNext, LastBB);

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 50ad336e73f52..dc9bc78a867bf 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1104,7 +1104,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
 llvm::Function::arg_iterator EI = CurFn->arg_end();
 --EI;
 llvm::Value *Addr = Builder.CreateStructGEP(
-EI->getType()->getPointerElementType(), &*EI, Idx);
+CurFnInfo->getArgStruct(), &*EI, Idx);
 llvm::Type *Ty =
 cast(Addr)->getResultElementType();
 ReturnValuePointer = Address(Addr, Ty, getPointerAlign());



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121915: [RISCV] CLZ Instruction

2022-03-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

These were intentionally not added because llvm has generic leading and 
trailing zero builtins. __builtin_clz and __builtin_ctz


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121915/new/

https://reviews.llvm.org/D121915

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118935: [SYCL] Disallow explicit casts between mismatching address spaces

2022-03-17 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added a comment.
Herald added a project: All.

Hi, what is the rationale here? This reuses the logic that was written for 
OpenCL mode, but in OpenCL mode, it was made an error with the idea that a new 
keyword `addrspace_cast` could be used in those cases where the user actually 
wants an address space cast. Here, in SYCL mode, it's just made an error with 
no way out for the user that I can see if they actually want this. Is this 
really correct?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118935/new/

https://reviews.llvm.org/D118935

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121097: [C++20][Modules][HU 3/5] Emit module macros for header units.

2022-03-17 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 416194.
iains marked 4 inline comments as done.
iains added a comment.
Herald added a subscriber: dexonsmith.

address review comments, match windows path separators in tests.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121097/new/

https://reviews.llvm.org/D121097

Files:
  clang/include/clang/Basic/Module.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/cxx20-hu-04.cpp

Index: clang/test/Modules/cxx20-hu-04.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-hu-04.cpp
@@ -0,0 +1,105 @@
+// Test macro preservation in C++20 Header Units.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header hu-01.h \
+// RUN: -o hu-01.pcm
+
+// RUN: %clang_cc1 -std=c++20 -module-file-info hu-01.pcm | \
+// RUN: FileCheck --check-prefix=CHECK-HU %s -DTDIR=%t
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header hu-02.h \
+// RUN: -DFOO -fmodule-file=hu-01.pcm -o hu-02.pcm  -Rmodule-import 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-IMP %s -DTDIR=%t
+
+// RUN: %clang_cc1 -std=c++20 -module-file-info hu-02.pcm | \
+// RUN: FileCheck --check-prefix=CHECK-HU2 %s -DTDIR=%t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface importer-01.cpp \
+// RUN:  -fmodule-file=hu-02.pcm -o B.pcm -DTDIR=%t -verify
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface importer-02.cpp \
+// RUN:  -fmodule-file=hu-02.pcm -o C.pcm -DTDIR=%t -Rmodule-import 2>&1 | \
+// RUN:  FileCheck --check-prefix=CHECK-IMP-HU2 %s -DTDIR=%t
+
+//--- hu-01.h
+#ifndef __GUARD
+#define __GUARD
+
+int baz(int);
+#define FORTYTWO 42
+
+#define SHOULD_NOT_BE_DEFINED -1
+#undef SHOULD_NOT_BE_DEFINED
+
+#endif // __GUARD
+// expected-no-diagnostics
+
+// CHECK-HU:  == C++20 Module structure ==
+// CHECK-HU-NEXT:  Header Unit './hu-01.h' is the Primary Module at index #1
+
+//--- hu-02.h
+export import "hu-01.h";
+#if !defined(FORTYTWO) || FORTYTWO != 42
+#error FORTYTWO missing in hu-02
+#endif
+
+#ifndef __GUARD
+#error __GUARD missing in hu-02
+#endif
+
+#ifdef SHOULD_NOT_BE_DEFINED
+#error SHOULD_NOT_BE_DEFINED is visible
+#endif
+
+#define KAP 6174
+
+#ifdef FOO
+#define FOO_BRANCH(X) (X) + 1
+inline int foo(int x) {
+  if (x == FORTYTWO)
+return FOO_BRANCH(x);
+  return FORTYTWO;
+}
+#else
+#define BAR_BRANCH(X) (X) + 2
+inline int bar(int x) {
+  if (x == FORTYTWO)
+return BAR_BRANCH(x);
+  return FORTYTWO;
+}
+#endif
+
+// CHECK-IMP: remark: importing module './hu-01.h' from 'hu-01.pcm'
+// CHECK-HU2:  == C++20 Module structure ==
+// CHECK-HU2-NEXT:  Header Unit './hu-02.h' is the Primary Module at index #2
+// CHECK-HU2-NEXT:   Exports:
+// CHECK-HU2-NEXT:Header Unit './hu-01.h' is at index #1
+// expected-no-diagnostics
+
+//--- importer-01.cpp
+export module B;
+import "hu-02.h";
+
+int success(int x) {
+  return foo(FORTYTWO + x + KAP);
+}
+
+int fail(int x) {
+  return bar(FORTYTWO + x + KAP); // expected-error {{use of undeclared identifier 'bar'}}
+  // expected-note@* {{'baz' declared here}}
+}
+
+//--- importer-02.cpp
+export module C;
+import "hu-02.h";
+
+int success(int x) {
+  return foo(FORTYTWO + x + KAP);
+}
+
+// CHECK-IMP-HU2: remark: importing module './hu-02.h' from 'hu-02.pcm'
+// CHECK-IMP-HU2: remark: importing module './hu-01.h' into './hu-02.h' from '[[TDIR]]{{[/\\]}}hu-01.pcm'
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -2353,13 +2353,22 @@
 uint64_t StartOffset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
 assert((StartOffset >> 32) == 0 && "Macro identifiers offset too large");
 
-// Emit the macro directives in reverse source order.
-for (; MD; MD = MD->getPrevious()) {
-  // Once we hit an ignored macro, we're done: the rest of the chain
-  // will all be ignored macros.
-  if (shouldIgnoreMacro(MD, IsModule, PP))
-break;
-
+// Write out any exported module macros.
+bool EmittedModuleMacros = false;
+// C+=20 Header Units are compiled module interfaces, but they preserve
+// macros that are live (i.e. have a defined value) at the end of the
+// compilation.  So when writing a header unit, we preserve only the final
+// value of each macro (and discard any that are undefined).  Header units
+// do not have sub-modules (although they might import other header units).
+// PCH files, conversely, retain the history of each macro's define/undef
+// and of leaf macros in sub modules.
+if (IsModule && WritingModule->isHeaderUnit()) {
+  // This is for the main TU when it is a C++20 header unit.
+  // We preserve the final state of defined macro

[PATCH] D121097: [C++20][Modules][HU 3/5] Emit module macros for header units.

2022-03-17 Thread Iain Sandoe via Phabricator via cfe-commits
iains added inline comments.



Comment at: clang/include/clang/Serialization/ASTWriter.h:127-128
 
+  /// The module is a header unit.
+  bool IsHeaderUnit = false;
+

ChuanqiXu wrote:
> I think the member is redundant. I thought we could use 
> `WritingModule->isHeaderUnit()` to replace it.
yeah we can do this - I added a "isHeaderUnit()" method to Module.h to do this.



Comment at: clang/lib/Serialization/ASTWriter.cpp:2358-2378
+bool EmittedModuleMacros = false;
+if (IsHeaderUnit) {
+  // This is for the main TU when it is a C++20 header unit.
+  // We preserve the final state of defined macros, and we do not emit ones
+  // that are undefined.
+  if (!MD || shouldIgnoreMacro(MD, IsModule, PP) ||
+  MD->getKind() == MacroDirective::MD_Undefine)

ChuanqiXu wrote:
> Is it possible to merge the implementation with the following for PCH? It 
> looks like there are some redundancies.
Well, that was what I had originally, I actually split it out as it is now 
because the difference in the logic around which macros are written out was 
making the code pretty confusing to read.  If there's a strong feeling about 
this, perhaps we can see if there's some way to factor it (perhaps with some 
place-holder vars).



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121097/new/

https://reviews.llvm.org/D121097

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6e1e99d - [CodeGen] Avoid pointer element type access for blocks

2022-03-17 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-17T16:56:31+01:00
New Revision: 6e1e99dc07f4f847a5dc8ad80d25ecce40690489

URL: 
https://github.com/llvm/llvm-project/commit/6e1e99dc07f4f847a5dc8ad80d25ecce40690489
DIFF: 
https://github.com/llvm/llvm-project/commit/6e1e99dc07f4f847a5dc8ad80d25ecce40690489.diff

LOG: [CodeGen] Avoid pointer element type access for blocks

Pass the block struct type down to the TargetInfo hooks.

Added: 


Modified: 
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGOpenCLRuntime.cpp
clang/lib/CodeGen/CGOpenCLRuntime.h
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/CodeGen/TargetInfo.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 08f0bf6923147..abb777456f484 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1105,7 +1105,7 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const 
CGBlockInfo &blockInfo) {
 
   if (IsOpenCL) {
 CGM.getOpenCLRuntime().recordBlockInfo(blockInfo.BlockExpression, InvokeFn,
-   result);
+   result, blockInfo.StructureType);
   }
 
   return result;
@@ -1401,7 +1401,8 @@ static llvm::Constant *buildGlobalBlock(CodeGenModule 
&CGM,
   if (CGM.getContext().getLangOpts().OpenCL)
 CGM.getOpenCLRuntime().recordBlockInfo(
 blockInfo.BlockExpression,
-cast(blockFn->stripPointerCasts()), Result);
+cast(blockFn->stripPointerCasts()), Result,
+literal->getValueType());
   return Result;
 }
 

diff  --git a/clang/lib/CodeGen/CGOpenCLRuntime.cpp 
b/clang/lib/CodeGen/CGOpenCLRuntime.cpp
index 2496782d95d8f..ab8de7ecf50c4 100644
--- a/clang/lib/CodeGen/CGOpenCLRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenCLRuntime.cpp
@@ -148,13 +148,14 @@ static const BlockExpr *getBlockExpr(const Expr *E) {
 /// corresponding block expression.
 void CGOpenCLRuntime::recordBlockInfo(const BlockExpr *E,
   llvm::Function *InvokeF,
-  llvm::Value *Block) {
+  llvm::Value *Block, llvm::Type *BlockTy) 
{
   assert(EnqueuedBlockMap.find(E) == EnqueuedBlockMap.end() &&
  "Block expression emitted twice");
   assert(isa(InvokeF) && "Invalid invoke function");
   assert(Block->getType()->isPointerTy() && "Invalid block literal type");
   EnqueuedBlockMap[E].InvokeFunc = InvokeF;
   EnqueuedBlockMap[E].BlockArg = Block;
+  EnqueuedBlockMap[E].BlockTy = BlockTy;
   EnqueuedBlockMap[E].Kernel = nullptr;
 }
 
@@ -179,8 +180,7 @@ CGOpenCLRuntime::emitOpenCLEnqueuedBlock(CodeGenFunction 
&CGF, const Expr *E) {
   }
 
   auto *F = CGF.getTargetHooks().createEnqueuedBlockKernel(
-  CGF, EnqueuedBlockMap[Block].InvokeFunc,
-  EnqueuedBlockMap[Block].BlockArg->stripPointerCasts());
+  CGF, EnqueuedBlockMap[Block].InvokeFunc, 
EnqueuedBlockMap[Block].BlockTy);
 
   // The common part of the post-processing of the kernel goes here.
   F->addFnAttr(llvm::Attribute::NoUnwind);

diff  --git a/clang/lib/CodeGen/CGOpenCLRuntime.h 
b/clang/lib/CodeGen/CGOpenCLRuntime.h
index 55515ab375786..900644b3b93bd 100644
--- a/clang/lib/CodeGen/CGOpenCLRuntime.h
+++ b/clang/lib/CodeGen/CGOpenCLRuntime.h
@@ -46,6 +46,7 @@ class CGOpenCLRuntime {
 llvm::Function *InvokeFunc; /// Block invoke function.
 llvm::Function *Kernel; /// Enqueued block kernel.
 llvm::Value *BlockArg;  /// The first argument to enqueued block 
kernel.
+llvm::Type *BlockTy;/// Type of the block argument.
   };
   /// Maps block expression to block information.
   llvm::DenseMap EnqueuedBlockMap;
@@ -93,7 +94,7 @@ class CGOpenCLRuntime {
   /// \param InvokeF invoke function emitted for the block expression.
   /// \param Block block literal emitted for the block expression.
   void recordBlockInfo(const BlockExpr *E, llvm::Function *InvokeF,
-   llvm::Value *Block);
+   llvm::Value *Block, llvm::Type *BlockTy);
 
   /// \return LLVM block invoke function emitted for an expression derived from
   /// the block expression.

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 765250540d380..de4a6f610867b 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -9214,7 +9214,7 @@ class AMDGPUTargetCodeGenInfo : public TargetCodeGenInfo {
   llvm::Function *
   createEnqueuedBlockKernel(CodeGenFunction &CGF,
 llvm::Function *BlockInvokeFunc,
-llvm::Value *BlockLiteral) const override;
+llvm::Type *BlockTy) const override;
   bool shouldEmitStaticExternCAliases() const override;
   void setCUDAKernelCallingConvention(const FunctionType *&FT) const override;
 };
@@ -11461,7 +11461,7 @@ const TargetCodeGenInfo 
&Cod

[PATCH] D121749: [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

2022-03-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:361
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound assignments
+like ``+=`` are aligned along with ``=``.

curdeius wrote:
> curdeius wrote:
> > sstwcw wrote:
> > > MyDeveloperDay wrote:
> > > > Is this wider than 80 chars?
> > > The comment in the source code is within 80 columns.  The python script 
> > > prepended the option name.  It's the same case as line 1541.
> > It is indeed. But it was already longer than 80 chars.
> > I'll have a look at the script to see how to fix this.
> At the same time, does it really matter if it's auto-generated?
It should not matter, especially because it’s also a non-source file.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121749/new/

https://reviews.llvm.org/D121749

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116385: [clangd] Code action for creating an ObjC initializer

2022-03-17 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests: http://45.33.8.238/linux/71327/step_9.txt

Please take a look and revert for now if it takes a while to fix


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116385/new/

https://reviews.llvm.org/D116385

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >