[PATCH] D100046: [AArch64] ACLE: Fix issue for mismatching enum types with builtins.

2021-04-12 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 336760.
sdesmalen added a comment.

Removed `forgetBuiltin` and the code using it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100046

Files:
  clang/include/clang/Basic/Builtins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/Basic/Builtins.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfh.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdech.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecp.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qinch.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincp.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincw.c

Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincw.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincw.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincw.c
@@ -1,6 +1,8 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null
 #include 
 
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincp.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincp.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincp.c
@@ -1,6 +1,8 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null
 #include 
 
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qinch.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qinch.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qinch.c
@@ -1,6 +1,8 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null
 #include 
 
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincd.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_

[PATCH] D100046: [AArch64] ACLE: Fix issue for mismatching enum types with builtins.

2021-04-12 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

Thanks for taking time from your weekend to look into this @tambre, much 
appreciated!




Comment at: clang/lib/Sema/SemaDecl.cpp:10953-10967
 if (unsigned BuiltinID = NewFD->getBuiltinID()) {
   ASTContext::GetBuiltinTypeError Error;
   LookupNecessaryTypesForBuiltin(S, BuiltinID);
   QualType T = Context.GetBuiltinType(BuiltinID, Error);
   // If the type of the builtin differs only in its exception
   // specification, that's OK.
   // FIXME: If the types do differ in this way, it would be better to

tambre wrote:
> This whole block is unnecessary since D77491 and should've been removed, but 
> seems I missed it. Reverting/forgetting builtins was problematic and the 
> attribute-based approach solved those deficiencies.
> 
> Delete this whole block and also remove `forgetBuiltin()`. The 
> builtin-related code in `ActOnFunctionDeclarator()` handles everything 
> necessary. No tests break and the SVE ones will pass. :)
Awesome! I had indeed noticed commenting it out didn't fail any tests and 
wondered if removing it entirely was the way to go. Good to hear you confirming 
that!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100046

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


[PATCH] D100046: [AArch64] ACLE: Fix issue for mismatching enum types with builtins.

2021-04-12 Thread Raul Tambre via Phabricator via cfe-commits
tambre accepted this revision.
tambre added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM! Probably worth mentioning what I had in my comment in the commit 
message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100046

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


[clang] 6e51991 - [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-04-12 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2021-04-12T09:44:17+02:00
New Revision: 6e5199104914c2415092315388ed09fbd9d629f7

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

LOG: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

The function did not handle every case. In some cases this
caused assertion failure.
After the fix the function returns DependentTy if the exact
return type can not be determined.

It seems that clang itself does not call the function in the
affected cases but some checker or other code may call it.

Reviewed By: hokein

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

Added: 


Modified: 
clang/lib/AST/Expr.cpp
clang/unittests/Tooling/SourceCodeTest.cpp

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index eccb42eeb7e74..a4a70befbdb31 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1391,8 +1391,15 @@ QualType CallExpr::getCallReturnType(const ASTContext 
&Ctx) const {
 if (isa(Callee->IgnoreParens()))
   return Ctx.VoidTy;
 
+if (isa(Callee->IgnoreParens()))
+  return Ctx.DependentTy;
+
 // This should never be overloaded and so should never return null.
 CalleeType = Expr::findBoundMemberType(Callee);
+assert(!CalleeType.isNull());
+  } else if (CalleeType->isDependentType() ||
+ CalleeType->isSpecificPlaceholderType(BuiltinType::Overload)) {
+return Ctx.DependentTy;
   }
 
   const FunctionType *FnType = CalleeType->castAs();

diff  --git a/clang/unittests/Tooling/SourceCodeTest.cpp 
b/clang/unittests/Tooling/SourceCodeTest.cpp
index eb652cf030644..badc6f88fc0af 100644
--- a/clang/unittests/Tooling/SourceCodeTest.cpp
+++ b/clang/unittests/Tooling/SourceCodeTest.cpp
@@ -621,4 +621,71 @@ int c = BAR 3.0;
   };
   Visitor.runOver(Code);
 }
+
+TEST(SourceCodeTest, GetCallReturnType_Dependent) {
+  llvm::Annotations Code{R"cpp(
+template
+void templ(const T& t, F f) {}
+
+template
+void templ1(const T& t, F f) {
+  $test1[[f(t)]];
+}
+
+int f_overload(int) { return 1; }
+int f_overload(double) { return 2; }
+
+void f1() {
+  int i = 0;
+  templ(i, [](const auto &p) {
+$test2[[f_overload(p)]];
+  });
+}
+
+struct A {
+  void f_overload(int);
+  void f_overload(double);
+};
+
+void f2() {
+ int i = 0;
+ templ(i, [](const auto &p) {
+   A a;
+   $test3[[a.f_overload(p)]];
+ });
+}
+)cpp"};
+
+  llvm::Annotations::Range R1 = Code.range("test1");
+  llvm::Annotations::Range R2 = Code.range("test2");
+  llvm::Annotations::Range R3 = Code.range("test3");
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [&R1, &R2, &R3](CallExpr *Expr, ASTContext *Context) {
+unsigned Begin = Context->getSourceManager().getFileOffset(
+Expr->getSourceRange().getBegin());
+unsigned End = Context->getSourceManager().getFileOffset(
+Expr->getSourceRange().getEnd());
+llvm::Annotations::Range R{Begin, End + 1};
+
+QualType CalleeType = Expr->getCallee()->getType();
+if (R == R1) {
+  ASSERT_TRUE(CalleeType->isDependentType());
+  EXPECT_EQ(Expr->getCallReturnType(*Context), Context->DependentTy);
+} else if (R == R2) {
+  ASSERT_FALSE(CalleeType->isDependentType());
+  
ASSERT_TRUE(CalleeType->isSpecificPlaceholderType(BuiltinType::Overload));
+  ASSERT_TRUE(isa(Expr->getCallee()));
+  EXPECT_EQ(Expr->getCallReturnType(*Context), Context->DependentTy);
+} else if (R == R3) {
+  ASSERT_FALSE(CalleeType->isDependentType());
+  ASSERT_TRUE(
+  CalleeType->isSpecificPlaceholderType(BuiltinType::BoundMember));
+  ASSERT_TRUE(isa(Expr->getCallee()));
+  EXPECT_EQ(Expr->getCallReturnType(*Context), Context->DependentTy);
+}
+  };
+  Visitor.runOver(Code.code(), CallsVisitor::Lang_CXX14);
+}
+
 } // end anonymous namespace



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


[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-04-12 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
balazske marked an inline comment as done.
Closed by commit rG6e5199104914: [clang][AST] Handle overload callee type in 
CallExpr::getCallReturnType. (authored by balazske).

Changed prior to commit:
  https://reviews.llvm.org/D95244?vs=336333&id=336764#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

Files:
  clang/lib/AST/Expr.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp


Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -621,4 +621,71 @@
   };
   Visitor.runOver(Code);
 }
+
+TEST(SourceCodeTest, GetCallReturnType_Dependent) {
+  llvm::Annotations Code{R"cpp(
+template
+void templ(const T& t, F f) {}
+
+template
+void templ1(const T& t, F f) {
+  $test1[[f(t)]];
+}
+
+int f_overload(int) { return 1; }
+int f_overload(double) { return 2; }
+
+void f1() {
+  int i = 0;
+  templ(i, [](const auto &p) {
+$test2[[f_overload(p)]];
+  });
+}
+
+struct A {
+  void f_overload(int);
+  void f_overload(double);
+};
+
+void f2() {
+ int i = 0;
+ templ(i, [](const auto &p) {
+   A a;
+   $test3[[a.f_overload(p)]];
+ });
+}
+)cpp"};
+
+  llvm::Annotations::Range R1 = Code.range("test1");
+  llvm::Annotations::Range R2 = Code.range("test2");
+  llvm::Annotations::Range R3 = Code.range("test3");
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [&R1, &R2, &R3](CallExpr *Expr, ASTContext *Context) {
+unsigned Begin = Context->getSourceManager().getFileOffset(
+Expr->getSourceRange().getBegin());
+unsigned End = Context->getSourceManager().getFileOffset(
+Expr->getSourceRange().getEnd());
+llvm::Annotations::Range R{Begin, End + 1};
+
+QualType CalleeType = Expr->getCallee()->getType();
+if (R == R1) {
+  ASSERT_TRUE(CalleeType->isDependentType());
+  EXPECT_EQ(Expr->getCallReturnType(*Context), Context->DependentTy);
+} else if (R == R2) {
+  ASSERT_FALSE(CalleeType->isDependentType());
+  
ASSERT_TRUE(CalleeType->isSpecificPlaceholderType(BuiltinType::Overload));
+  ASSERT_TRUE(isa(Expr->getCallee()));
+  EXPECT_EQ(Expr->getCallReturnType(*Context), Context->DependentTy);
+} else if (R == R3) {
+  ASSERT_FALSE(CalleeType->isDependentType());
+  ASSERT_TRUE(
+  CalleeType->isSpecificPlaceholderType(BuiltinType::BoundMember));
+  ASSERT_TRUE(isa(Expr->getCallee()));
+  EXPECT_EQ(Expr->getCallReturnType(*Context), Context->DependentTy);
+}
+  };
+  Visitor.runOver(Code.code(), CallsVisitor::Lang_CXX14);
+}
+
 } // end anonymous namespace
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1391,8 +1391,15 @@
 if (isa(Callee->IgnoreParens()))
   return Ctx.VoidTy;
 
+if (isa(Callee->IgnoreParens()))
+  return Ctx.DependentTy;
+
 // This should never be overloaded and so should never return null.
 CalleeType = Expr::findBoundMemberType(Callee);
+assert(!CalleeType.isNull());
+  } else if (CalleeType->isDependentType() ||
+ CalleeType->isSpecificPlaceholderType(BuiltinType::Overload)) {
+return Ctx.DependentTy;
   }
 
   const FunctionType *FnType = CalleeType->castAs();


Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -621,4 +621,71 @@
   };
   Visitor.runOver(Code);
 }
+
+TEST(SourceCodeTest, GetCallReturnType_Dependent) {
+  llvm::Annotations Code{R"cpp(
+template
+void templ(const T& t, F f) {}
+
+template
+void templ1(const T& t, F f) {
+  $test1[[f(t)]];
+}
+
+int f_overload(int) { return 1; }
+int f_overload(double) { return 2; }
+
+void f1() {
+  int i = 0;
+  templ(i, [](const auto &p) {
+$test2[[f_overload(p)]];
+  });
+}
+
+struct A {
+  void f_overload(int);
+  void f_overload(double);
+};
+
+void f2() {
+ int i = 0;
+ templ(i, [](const auto &p) {
+   A a;
+   $test3[[a.f_overload(p)]];
+ });
+}
+)cpp"};
+
+  llvm::Annotations::Range R1 = Code.range("test1");
+  llvm::Annotations::Range R2 = Code.range("test2");
+  llvm::Annotations::Range R3 = Code.range("test3");
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [&R1, &R2, &R3](CallExpr *Expr, ASTContext *Context) {
+unsigned Begin = Context->getSourceManager().getFileOffset(
+Expr->getSourceRange().getBegin());
+unsigned End = Context->getSourceManager().getFileOffset(
+Expr->getSourceRange().getEnd());
+llvm::Annotations::Range R{Begin, End + 1};
+
+QualType CalleeType = Expr->getCallee()->getType();
+if (R == R1) {
+  ASSERT_TRUE(CalleeType->isDependentType());
+  EXPECT_EQ(Expr->

[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-04-12 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: clang/lib/AST/Expr.cpp:1386
   QualType CalleeType = Callee->getType();
+
   if (const auto *FnTypePtr = CalleeType->getAs()) {

hokein wrote:
> nit: looks like an accident change, remove it.
Fixed in the committed code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

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


[PATCH] D100046: [AArch64] ACLE: Fix issue for mismatching enum types with builtins.

2021-04-12 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

Summary also looks good. 👍
You probably don't need to wait for more approvals.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100046

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


[clang] 62fa9b9 - [DebugInfo] Fix the mismatching between C++ language tags and Dwarf versions.

2021-04-12 Thread via cfe-commits

Author: Esme-Yi
Date: 2021-04-12T07:42:54Z
New Revision: 62fa9b9388aa114e3b1a58bbdbcd966ae3492ba5

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

LOG: [DebugInfo] Fix the mismatching between C++ language tags and Dwarf 
versions.

Summary: The tags DW_LANG_C_plus_plus_14 and DW_LANG_C_plus_plus_11, introduced 
in Dwarf-5, are unexpected in previous versions. Fixing the mismathing doesn't 
have any drawbacks for any other debuggers, but helps dbx.

Reviewed By: aprantl, shchenz

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

Added: 
clang/test/CodeGenCXX/debug-info-programming-language.cpp

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/Modules/ModuleDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index d20b309b476de..290cdbf8c4e34 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -568,9 +568,9 @@ void CGDebugInfo::CreateCompileUnit() {
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
-else if (LO.CPlusPlus14)
+else if (LO.CPlusPlus14 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
-else if (LO.CPlusPlus11)
+else if (LO.CPlusPlus11 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
 else
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;

diff  --git a/clang/test/CodeGenCXX/debug-info-programming-language.cpp 
b/clang/test/CodeGenCXX/debug-info-programming-language.cpp
new file mode 100644
index 0..82a6db6445f36
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -dwarf-version=5  -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF5 %s
+// RUN: %clang_cc1 -dwarf-version=3  -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF3 %s
+
+int main() {
+  return 0;
+}
+
+// CHECK-DWARF5: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-DWARF3: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,

diff  --git a/clang/test/Modules/ModuleDebugInfo.cpp 
b/clang/test/Modules/ModuleDebugInfo.cpp
index 3121719e55a66..836f0d28fb2a2 100644
--- a/clang/test/Modules/ModuleDebugInfo.cpp
+++ b/clang/test/Modules/ModuleDebugInfo.cpp
@@ -23,7 +23,7 @@
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 
 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
-// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11,
+// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
 // CHECK-SAME:isOptimized: false,
 // CHECK-NOT: splitDebugFilename:
 // CHECK-SAME:dwoId:



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


[clang] 731bf28 - [OpenCL] Accept .rgba in OpenCL 3.0

2021-04-12 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-04-12T09:30:06+01:00
New Revision: 731bf28a6092286dde6972803b35c026e32bd6b1

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

LOG: [OpenCL] Accept .rgba in OpenCL 3.0

The .rgba vector component accessors are supported in OpenCL C 3.0.

Previously, the diagnostic would check `OpenCLVersion` for version 2.2
(value 220) and report those accessors are an OpenCL 2.2 feature.
However, there is no "OpenCL C version 2.2", so change the check and
diagnostic text to 3.0 only.

A spurious `OpenCLVersion` argument was passed into the diagnostic;
remove that.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExprMember.cpp
clang/test/SemaOpenCL/ext_vectors.cl

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 5c27902da2502..af7eea06f6f5b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10005,9 +10005,9 @@ def err_opencl_enqueue_kernel_blocks_no_args : Error<
 def err_opencl_builtin_expected_type : Error<
   "illegal call to %0, expected %1 argument type">;
 
-// OpenCL v2.2 s2.1.2.3 - Vector Component Access
+// OpenCL v3.0 s6.3.7 - Vector Components
 def ext_opencl_ext_vector_type_rgba_selector: ExtWarn<
-  "vector component name '%0' is an OpenCL version 2.2 feature">,
+  "vector component name '%0' is an OpenCL C version 3.0 feature">,
   InGroup;
 
 def err_openclcxx_placement_new : Error<

diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 0663c0d277259..d8b66639db8cd 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -338,13 +338,12 @@ CheckExtVectorComponent(Sema &S, QualType baseType, 
ExprValueKind &VK,
   compStr++;
 } while (*compStr && (Idx = vecType->getPointAccessorIdx(*compStr)) != -1);
 
-// Emit a warning if an rgba selector is used earlier than OpenCL 2.2
+// Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
-  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 220) {
+  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
-  << StringRef(DiagBegin, 1)
-  << S.getLangOpts().OpenCLVersion << SourceRange(CompLoc);
+<< StringRef(DiagBegin, 1) << SourceRange(CompLoc);
   }
 }
   } else {

diff  --git a/clang/test/SemaOpenCL/ext_vectors.cl 
b/clang/test/SemaOpenCL/ext_vectors.cl
index 3b2dd6d719d68..f8af230078f1a 100644
--- a/clang/test/SemaOpenCL/ext_vectors.cl
+++ b/clang/test/SemaOpenCL/ext_vectors.cl
@@ -1,11 +1,20 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
 void test_ext_vector_accessors(float4 V) {
   V = V.wzyx;
-  V = V.abgr; // expected-warning {{vector component name 'a' is an OpenCL 
version 2.2 feature}}
-  V = V.xyzr; // expected-warning {{vector component name 'r' is an OpenCL 
version 2.2 feature}} \
-  // expected-error {{illegal vector component name 'r'}}
+
+  V = V.abgr;
+#if (__OPENCL_C_VERSION__ < 300)
+  // expected-warning@-2 {{vector component name 'a' is an OpenCL C version 
3.0 feature}}
+#endif
+
+  V = V.xyzr;
+  // expected-error@-1 {{illegal vector component name 'r'}}
+#if (__OPENCL_C_VERSION__ < 300)
+  // expected-warning@-3 {{vector component name 'r' is an OpenCL C version 
3.0 feature}}
+#endif
 }



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


[PATCH] D99969: [OpenCL] Accept .rgba in OpenCL 3.0

2021-04-12 Thread Sven van Haastregt 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 rG731bf28a6092: [OpenCL] Accept .rgba in OpenCL 3.0 (authored 
by svenvh).

Changed prior to commit:
  https://reviews.llvm.org/D99969?vs=335557&id=336773#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99969

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/SemaOpenCL/ext_vectors.cl


Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -1,11 +1,20 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
 void test_ext_vector_accessors(float4 V) {
   V = V.wzyx;
-  V = V.abgr; // expected-warning {{vector component name 'a' is an OpenCL 
version 2.2 feature}}
-  V = V.xyzr; // expected-warning {{vector component name 'r' is an OpenCL 
version 2.2 feature}} \
-  // expected-error {{illegal vector component name 'r'}}
+
+  V = V.abgr;
+#if (__OPENCL_C_VERSION__ < 300)
+  // expected-warning@-2 {{vector component name 'a' is an OpenCL C version 
3.0 feature}}
+#endif
+
+  V = V.xyzr;
+  // expected-error@-1 {{illegal vector component name 'r'}}
+#if (__OPENCL_C_VERSION__ < 300)
+  // expected-warning@-3 {{vector component name 'r' is an OpenCL C version 
3.0 feature}}
+#endif
 }
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -338,13 +338,12 @@
   compStr++;
 } while (*compStr && (Idx = vecType->getPointAccessorIdx(*compStr)) != -1);
 
-// Emit a warning if an rgba selector is used earlier than OpenCL 2.2
+// Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
-  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 220) {
+  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
-  << StringRef(DiagBegin, 1)
-  << S.getLangOpts().OpenCLVersion << SourceRange(CompLoc);
+<< StringRef(DiagBegin, 1) << SourceRange(CompLoc);
   }
 }
   } else {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10005,9 +10005,9 @@
 def err_opencl_builtin_expected_type : Error<
   "illegal call to %0, expected %1 argument type">;
 
-// OpenCL v2.2 s2.1.2.3 - Vector Component Access
+// OpenCL v3.0 s6.3.7 - Vector Components
 def ext_opencl_ext_vector_type_rgba_selector: ExtWarn<
-  "vector component name '%0' is an OpenCL version 2.2 feature">,
+  "vector component name '%0' is an OpenCL C version 3.0 feature">,
   InGroup;
 
 def err_openclcxx_placement_new : Error<


Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -1,11 +1,20 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
 void test_ext_vector_accessors(float4 V) {
   V = V.wzyx;
-  V = V.abgr; // expected-warning {{vector component name 'a' is an OpenCL version 2.2 feature}}
-  V = V.xyzr; // expected-warning {{vector component name 'r' is an OpenCL version 2.2 feature}} \
-  // expected-error {{illegal vector component name 'r'}}
+
+  V = V.abgr;
+#if (__OPENCL_C_VERSION__ < 300)
+  // expected-warning@-2 {{vector component name 'a' is an OpenCL C version 3.0 feature}}
+#endif
+
+  V = V.xyzr;
+  // expected-error@-1 {{illegal vector component name 'r'}}
+#if (__OPENCL_C_VERSION__ < 300)
+  // expected-warning@-3 {{vector component name 'r' is an OpenCL C version 3.0 feature}}
+#endif
 }
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -338,13 +338,12 @@
   compStr++;
 } while (*compStr && (Idx = vecType->getPointAccessorIdx(*compStr)) != -1);
 
-// Emit a warning if an rgba select

[PATCH] D99565: [X86] Support replacing aligned vector moves with unaligned moves when avx is enabled.

2021-04-12 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 added a comment.

In D99565#2678073 , @craig.topper 
wrote:

> I think I wouldn't mind if we just didn't emit aligned loads/store 
> instructions for AVX/AVX512 from isel and other places in the compiler in the 
> first place. As noted, if the load gets folded the alignment check doesn't 
> happen. That would reduce the size of the isel tables and remove branches, 
> reducing complexity of the compiler. Adding a new step and a command line to 
> undo the earlier decision increases complexity.
>
> The counter argument to that is that the alignment check has found bugs in 
> the vectorizer on more than one occasion that I know of.

Can I understand that if we implement it in isel, you will no longer oppose 
this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99565

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


[clang] eae3b2a - [clang][cli] Fix round-trip of OPT_plugin_arg

2021-04-12 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2021-03-30T18:33:10+01:00
New Revision: eae3b2a715d7fd1aea0ce1c78ac7a04957b72728

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

LOG: [clang][cli] Fix round-trip of OPT_plugin_arg

The test Frontend/plugin-delayed-template.cpp is failing when asserts
are enabled because it hits an assertion in denormalizeStringImpl when
trying to round-trip OPT_plugin_arg. Fix this by adjusting how the
option is handled, as the first part is joined to -plugin-arg and the
second is separate.

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 490672bf93ab5..b18bc0b284ee5 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -211,6 +211,7 @@ static void denormalizeStringImpl(SmallVectorImpl &Args,
   switch (OptClass) {
   case Option::SeparateClass:
   case Option::JoinedOrSeparateClass:
+  case Option::JoinedAndSeparateClass:
 Args.push_back(Spelling);
 Args.push_back(SA(Value));
 break;
@@ -2477,9 +2478,13 @@ static void GenerateFrontendArgs(const FrontendOptions 
&Opts,
 
   GenerateProgramAction();
 
-  for (const auto &PluginArgs : Opts.PluginArgs)
+  for (const auto &PluginArgs : Opts.PluginArgs) {
+Option Opt = getDriverOptTable().getOption(OPT_plugin_arg);
+const char *Spelling =
+SA(Opt.getPrefix() + Opt.getName() + PluginArgs.first);
 for (const auto &PluginArg : PluginArgs.second)
-  GenerateArg(Args, OPT_plugin_arg, PluginArgs.first + PluginArg, SA);
+  denormalizeString(Args, Spelling, SA, Opt.getKind(), 0, PluginArg);
+  }
 
   for (const auto &Ext : Opts.ModuleFileExtensions)
 if (auto *TestExt = dyn_cast_or_null(Ext.get()))



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


[clang] 6bf806b - [AArch64] ACLE: Fix issue for mismatching enum types with builtins.

2021-04-12 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2021-04-12T11:16:28+01:00
New Revision: 6bf806b3e2fddf79fa0326df1da341de9da35d08

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

LOG: [AArch64] ACLE: Fix issue for mismatching enum types with builtins.

This patch fixes an issue with the SVE prefetch and qinc/qdec intrinsics
that take an `enum` argument, but where the builtin prototype encodes
these as `int`. Some code in SemaDecl found the mismatch and chose
to forget about the builtin altogether, which meant that any future
code using that builtin would fail. The code that forgets about the
builtin was actually obsolete after D77491 and should have been removed.
This patch now removes that code.

This patch also fixes another issue with the SVE prefetch intrinsic
when built with C++, where the builtin didn't accept the correct
pointer type, which should be `const void *`.

Reviewed By: tambre

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

Added: 


Modified: 
clang/include/clang/Basic/Builtins.h
clang/include/clang/Basic/arm_sve.td
clang/lib/Basic/Builtins.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfb.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfd.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfh.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfw.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecb.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecd.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdech.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecp.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecw.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincb.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincd.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qinch.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincp.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincw.c

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.h 
b/clang/include/clang/Basic/Builtins.h
index efd6cb897293e..eefe549b4fa88 100644
--- a/clang/include/clang/Basic/Builtins.h
+++ b/clang/include/clang/Basic/Builtins.h
@@ -179,10 +179,6 @@ class Context {
strchr(getRecord(ID).Type, 'A') != nullptr;
   }
 
-  /// Completely forget that the given ID was ever considered a builtin,
-  /// e.g., because the user provided a conflicting signature.
-  void forgetBuiltin(unsigned ID, IdentifierTable &Table);
-
   /// If this is a library function that comes from a specific
   /// header, retrieve that header name.
   const char *getHeaderName(unsigned ID) const {

diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 19a42e79c36ab..a073a8bab28e9 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -668,16 +668,16 @@ let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
 // Prefetches
 
 // Prefetch (Scalar base)
-def SVPRFB : MInst<"svprfb", "vPcJ", "c", [IsPrefetch], MemEltTyInt8,  
"aarch64_sve_prf">;
-def SVPRFH : MInst<"svprfh", "vPcJ", "s", [IsPrefetch], MemEltTyInt16, 
"aarch64_sve_prf">;
-def SVPRFW : MInst<"svprfw", "vPcJ", "i", [IsPrefetch], MemEltTyInt32, 
"aarch64_sve_prf">;
-def SVPRFD : MInst<"svprfd", "vPcJ", "l", [IsPrefetch], MemEltTyInt64, 
"aarch64_sve_prf">;
+def SVPRFB : MInst<"svprfb", "vPQJ", "c", [IsPrefetch], MemEltTyInt8,  
"aarch64_sve_prf">;
+def SVPRFH : MInst<"svprfh", "vPQJ", "s", [IsPrefetch], MemEltTyInt16, 
"aarch64_sve_prf">;
+def SVPRFW : MInst<"svprfw", "vPQJ", "i", [IsPrefetch], MemEltTyInt32, 
"aarch64_sve_prf">;
+def SVPRFD : MInst<"svprfd", "vPQJ", "l", [IsPrefetch], MemEltTyInt64, 
"aarch64_sve_prf">;
 
 // Prefetch (Scalar base, VL displacement)
-def SVPRFB_VNUM : MInst<"svprfb_vnum", "vPclJ", "c", [IsPrefetch], 
MemEltTyInt8,  "aarch64_sve_prf">;
-def SVPRFH_VNUM : MInst<"svprfh_vnum", "vPclJ", "s", [IsPrefetch], 
MemEltTyInt16, "aarch64_sve_prf">;
-def SVPRFW_VNUM : MInst<"svprfw_vnum", "vPclJ", "i", [IsPrefetch], 
MemEltTyInt32, "aarch64_sve_prf">;
-def SVPRFD_VNUM : MInst<"svprfd_vnum", "vPclJ", "l", [IsPrefetch], 
MemEltTyInt64, "aarch64_sve_prf">;
+def SVPRFB_VNUM : MInst<"svprfb_vnum", "vPQlJ", "c", [IsPrefetch], 
MemEltTyInt8,  "aarch64_sve_prf">;
+def SVPRFH_VNUM : MInst<"svprfh_vnum", "vPQlJ", "s", [IsPrefetch], 
MemEltTyInt16, "aarch64_sve_prf">;
+def SVPRFW_VNUM : MInst<"svprfw_vnum", "vPQlJ", "i", [IsPrefetch], 
MemEltTyInt32, "aarch64_sve_prf">;
+def SVPRFD_VNUM : MInst<"svprfd_vnum", "vPQlJ", "l", [IsPrefetch], 
MemEltTyInt64, "aarch64_sve_prf">;
 
 // Prefetch (Vector bases)
 def SVPRFB_GATHER_BASES : MInst<"svprfb_gather[_{2}base]", "vPdJ", "UiUl", 
[IsGatherPrefetc

[PATCH] D100046: [AArch64] ACLE: Fix issue for mismatching enum types with builtins.

2021-04-12 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6bf806b3e2fd: [AArch64] ACLE: Fix issue for mismatching enum 
types with builtins. (authored by sdesmalen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100046

Files:
  clang/include/clang/Basic/Builtins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/Basic/Builtins.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfh.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_prfw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdech.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecp.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qinch.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincp.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincw.c

Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincw.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincw.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincw.c
@@ -1,6 +1,8 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null
 #include 
 
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincp.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincp.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincp.c
@@ -1,6 +1,8 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null
 #include 
 
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qinch.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qinch.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qinch.c
@@ -1,6 +1,8 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null
 #include 
 
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincd.c
==

[PATCH] D100294: [AArch64][SVE] Fix dup/dupq intrinsics for C++.

2021-04-12 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
Herald added subscribers: psnobl, kristof.beyls, tschuett.
Herald added a reviewer: efriedma.
sdesmalen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch changes the builtin prototype to use 'b' (boolean) instead
of the default integer element type. That fixes the dup/dupq intrinsics
when compiling with C++.

This patch also fixes one of the defines for __ARM_FEATURE_SVE2_BITPERM.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100294

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -362,6 +362,9 @@
   if (isVoid())
 return "v";
 
+  if (isScalarPredicate())
+return "b";
+
   if (isVoidPointer())
 S += "v";
   else if (!isFloatingPoint())
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
@@ -1,6 +1,8 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ 
%s | FileCheck %s
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null
 #include 
 
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c
@@ -1,6 +1,8 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ 
%s | FileCheck %s
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - -x c++ %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null
 #include 
 
Index: clang/include/clang/Basic/arm_sve.td
===
--- clang/include/clang/Basic/arm_sve.td
+++ clang/include/clang/Basic/arm_sve.td
@@ -2073,7 +2073,7 @@
 def SVSM4EKEY : SInst<"svsm4ekey[_{d}]", "ddd", "Ui", MergeNone, 
"aarch64_sve_sm4ekey", [IsOverloadNone]>;
 }
 
-let ArchGuard = "__ARM_FEATURE_SVE2_BITPERM" in {
+let ArchGuard = "defined (__ARM_FEATURE_SVE2_BITPERM)" in {
 def SVBDEP   : SInst<"svbdep[_{d}]",   "ddd", "UcUsUiUl", MergeNone, 
"aarch64_sve_bdep_x">;
 def SVBDEP_N : SInst<"svbdep[_n_{d}]", "dda", "UcUsUiUl", MergeNone, 
"aarch64_sve_bdep_x">;
 def SVBEXT   : SInst<"svbext[_{d}]",   "ddd", "UcUsUiUl", MergeNone, 
"aarch64_sve_bext_x">;


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -362,6 +362,9 @@
   if (isVoid())
 return "v";
 
+  if (isScalarPredicate())
+return "b";
+
   if (isVoidPointer())
 S += "v";
   else if (!isFloatingPoint())
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
@@ -1,6 +1,8 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-r

[PATCH] D97196: [clang-tidy] Add new check 'bugprone-unhandled-exception-at-new'.

2021-04-12 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Ping.
The check now handles only check of allocation failure at `new`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97196

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


[PATCH] D90835: [RFC][clang-tidy] Ignore diagnostics due to macro expansion from not-interested headers

2021-04-12 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

I think there is no sense to invent another HeaderFilterRegex like option to 
control which headers should be excluded. HeaderFilterRegex should be good 
enough because if you would like to see warning from the header, most probably 
you can fix code in the header or at least add a suppression.

To be on a safe side I'm going to put this feature behind a configuration flag 
and send diff for review soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90835

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


[clang] c965e14 - Revert "[DebugInfo] Fix the mismatching between C++ language tags and Dwarf versions."

2021-04-12 Thread via cfe-commits

Author: Esme-Yi
Date: 2021-04-12T10:36:46Z
New Revision: c965e14a12955355ead9ea093989a8fcbf03a8c1

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

LOG: Revert "[DebugInfo] Fix the mismatching between C++ language tags and 
Dwarf versions."

This reverts commit 62fa9b9388aa114e3b1a58bbdbcd966ae3492ba5.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/Modules/ModuleDebugInfo.cpp

Removed: 
clang/test/CodeGenCXX/debug-info-programming-language.cpp



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 290cdbf8c4e34..d20b309b476de 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -568,9 +568,9 @@ void CGDebugInfo::CreateCompileUnit() {
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
-else if (LO.CPlusPlus14 && CGM.getCodeGenOpts().DwarfVersion >= 5)
+else if (LO.CPlusPlus14)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
-else if (LO.CPlusPlus11 && CGM.getCodeGenOpts().DwarfVersion >= 5)
+else if (LO.CPlusPlus11)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
 else
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;

diff  --git a/clang/test/CodeGenCXX/debug-info-programming-language.cpp 
b/clang/test/CodeGenCXX/debug-info-programming-language.cpp
deleted file mode 100644
index 82a6db6445f36..0
--- a/clang/test/CodeGenCXX/debug-info-programming-language.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// RUN: %clang_cc1 -dwarf-version=5  -emit-llvm -triple %itanium_abi_triple %s 
-o - \
-// RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
-// RUN: | FileCheck --check-prefix=CHECK-DWARF5 %s
-// RUN: %clang_cc1 -dwarf-version=3  -emit-llvm -triple %itanium_abi_triple %s 
-o - \
-// RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
-// RUN: | FileCheck --check-prefix=CHECK-DWARF3 %s
-
-int main() {
-  return 0;
-}
-
-// CHECK-DWARF5: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
-// CHECK-DWARF3: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,

diff  --git a/clang/test/Modules/ModuleDebugInfo.cpp 
b/clang/test/Modules/ModuleDebugInfo.cpp
index 836f0d28fb2a2..3121719e55a66 100644
--- a/clang/test/Modules/ModuleDebugInfo.cpp
+++ b/clang/test/Modules/ModuleDebugInfo.cpp
@@ -23,7 +23,7 @@
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 
 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
-// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
+// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11,
 // CHECK-SAME:isOptimized: false,
 // CHECK-NOT: splitDebugFilename:
 // CHECK-SAME:dwoId:



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


[PATCH] D99250: [DebugInfo] Fix the mismatching of C++ language tags and Dwarf versions.

2021-04-12 Thread EsmeYi 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 rG62fa9b9388aa: [DebugInfo] Fix the mismatching between C++ 
language tags and Dwarf versions. (authored by Esme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99250

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-programming-language.cpp
  clang/test/Modules/ModuleDebugInfo.cpp


Index: clang/test/Modules/ModuleDebugInfo.cpp
===
--- clang/test/Modules/ModuleDebugInfo.cpp
+++ clang/test/Modules/ModuleDebugInfo.cpp
@@ -23,7 +23,7 @@
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 
 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
-// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11,
+// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
 // CHECK-SAME:isOptimized: false,
 // CHECK-NOT: splitDebugFilename:
 // CHECK-SAME:dwoId:
Index: clang/test/CodeGenCXX/debug-info-programming-language.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -dwarf-version=5  -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF5 %s
+// RUN: %clang_cc1 -dwarf-version=3  -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF3 %s
+
+int main() {
+  return 0;
+}
+
+// CHECK-DWARF5: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-DWARF3: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -568,9 +568,9 @@
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
-else if (LO.CPlusPlus14)
+else if (LO.CPlusPlus14 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
-else if (LO.CPlusPlus11)
+else if (LO.CPlusPlus11 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
 else
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;


Index: clang/test/Modules/ModuleDebugInfo.cpp
===
--- clang/test/Modules/ModuleDebugInfo.cpp
+++ clang/test/Modules/ModuleDebugInfo.cpp
@@ -23,7 +23,7 @@
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 
 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
-// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11,
+// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
 // CHECK-SAME:isOptimized: false,
 // CHECK-NOT: splitDebugFilename:
 // CHECK-SAME:dwoId:
Index: clang/test/CodeGenCXX/debug-info-programming-language.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -dwarf-version=5  -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF5 %s
+// RUN: %clang_cc1 -dwarf-version=3  -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF3 %s
+
+int main() {
+  return 0;
+}
+
+// CHECK-DWARF5: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-DWARF3: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -568,9 +568,9 @@
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
-else if (LO.CPlusPlus14)
+else if (LO.CPlusPlus14 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
-else if (LO.CPlusPlus11)
+else if (LO.CPlusPlus11 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
 else
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
___
cfe-commits mailing list
cfe-c

[PATCH] D99250: [DebugInfo] Fix the mismatching of C++ language tags and Dwarf versions.

2021-04-12 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

This change has caused a test failure in lldb. On our Arm bots: 
http://lab.llvm.org:8011/#/builders/96/builds/6582
Also on Linux x86_64: http://lab.llvm.org:8011/#/builders/68/builds/10277

Not windows though because 
`test/API/commands/frame/language/TestGuessLanguage.py` is an expected failure 
there already.

Is there a mapping in lldb that needs to be updated as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99250

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


[PATCH] D99250: [DebugInfo] Fix the mismatching of C++ language tags and Dwarf versions.

2021-04-12 Thread EsmeYi via Phabricator via cfe-commits
Esme added a comment.

In D99250#2682598 , @DavidSpickett 
wrote:

> This change has caused a test failure in lldb. On our Arm bots: 
> http://lab.llvm.org:8011/#/builders/96/builds/6582
> Also on Linux x86_64: http://lab.llvm.org:8011/#/builders/68/builds/10277
>
> Not windows though because 
> `test/API/commands/frame/language/TestGuessLanguage.py` is an expected 
> failure there already.
>
> Is there a mapping in lldb that needs to be updated as well?

I've reproduced the failure, but I couldn't solve it immediately because I'm 
not familiar with lldb. I'll revert the patch first. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99250

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


[PATCH] D93543: clang-tidy: Leave the possibility of opting out having coloured diagnostic messages.

2021-04-12 Thread Andi via Phabricator via cfe-commits
Abpostelnicu updated this revision to Diff 336797.
Abpostelnicu added a comment.

Add `-use-color` argument to make it sane with `clang-tidy --use-color` 
argument.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93543

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


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -80,10 +80,14 @@
 
 
 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):
+header_filter, use_color,
+allow_enabling_alpha_checkers, extra_arg,
+extra_arg_before, quiet, config):
   """Gets a command line for clang-tidy."""
-  start = [clang_tidy_binary, '--use-color']
+  start = [clang_tidy_binary]
+  # Only if we are connected to a tty we can check for enabling color mode
+  if os.isatty(sys.stdout.fileno()) and use_color:
+start.append('--use-color')
   if allow_enabling_alpha_checkers:
 start.append('-allow-enabling-analyzer-alpha-checkers')
   if header_filter is not None:
@@ -163,6 +167,7 @@
 name = queue.get()
 invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
  tmpdir, build_path, args.header_filter,
+ args.use_color,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
  args.quiet, args.config)
@@ -204,6 +209,8 @@
   'When the value is empty, clang-tidy will '
   'attempt to find a file named .clang-tidy for '
   'each source file in its parent directories.')
+  parser.add_argument('-use-color', action='store_true',
+  help='Enables diagnostic message colors.')
   parser.add_argument('-header-filter', default=None,
   help='regular expression matching the names of the '
   'headers to output diagnostics from. Diagnostics from '


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -80,10 +80,14 @@
 
 
 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):
+header_filter, use_color,
+allow_enabling_alpha_checkers, extra_arg,
+extra_arg_before, quiet, config):
   """Gets a command line for clang-tidy."""
-  start = [clang_tidy_binary, '--use-color']
+  start = [clang_tidy_binary]
+  # Only if we are connected to a tty we can check for enabling color mode
+  if os.isatty(sys.stdout.fileno()) and use_color:
+start.append('--use-color')
   if allow_enabling_alpha_checkers:
 start.append('-allow-enabling-analyzer-alpha-checkers')
   if header_filter is not None:
@@ -163,6 +167,7 @@
 name = queue.get()
 invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
  tmpdir, build_path, args.header_filter,
+ args.use_color,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
  args.quiet, args.config)
@@ -204,6 +209,8 @@
   'When the value is empty, clang-tidy will '
   'attempt to find a file named .clang-tidy for '
   'each source file in its parent directories.')
+  parser.add_argument('-use-color', action='store_true',
+  help='Enables diagnostic message colors.')
   parser.add_argument('-header-filter', default=None,
   help='regular expression matching the names of the '
   'headers to output diagnostics from. Diagnostics from '
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] dff922f - Reland [DebugInfo] Fix the mismatching between C++ language tags and Dwarf versions.""

2021-04-12 Thread via cfe-commits

Author: Esme-Yi
Date: 2021-04-12T11:05:55Z
New Revision: dff922f39b9bf49b243f6f00c7c9a2e3de77e20e

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

LOG: Reland [DebugInfo] Fix the mismatching between C++ language tags and Dwarf 
versions.""

This reverts commit c965e14a12955355ead9ea093989a8fcbf03a8c1.

Added: 
clang/test/CodeGenCXX/debug-info-programming-language.cpp

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/Modules/ModuleDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index d20b309b476de..290cdbf8c4e34 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -568,9 +568,9 @@ void CGDebugInfo::CreateCompileUnit() {
   if (LO.CPlusPlus) {
 if (LO.ObjC)
   LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
-else if (LO.CPlusPlus14)
+else if (LO.CPlusPlus14 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
-else if (LO.CPlusPlus11)
+else if (LO.CPlusPlus11 && CGM.getCodeGenOpts().DwarfVersion >= 5)
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
 else
   LangTag = llvm::dwarf::DW_LANG_C_plus_plus;

diff  --git a/clang/test/CodeGenCXX/debug-info-programming-language.cpp 
b/clang/test/CodeGenCXX/debug-info-programming-language.cpp
new file mode 100644
index 0..82a6db6445f36
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -dwarf-version=5  -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF5 %s
+// RUN: %clang_cc1 -dwarf-version=3  -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF3 %s
+
+int main() {
+  return 0;
+}
+
+// CHECK-DWARF5: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-DWARF3: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,

diff  --git a/clang/test/Modules/ModuleDebugInfo.cpp 
b/clang/test/Modules/ModuleDebugInfo.cpp
index 3121719e55a66..836f0d28fb2a2 100644
--- a/clang/test/Modules/ModuleDebugInfo.cpp
+++ b/clang/test/Modules/ModuleDebugInfo.cpp
@@ -23,7 +23,7 @@
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 
 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
-// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11,
+// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
 // CHECK-SAME:isOptimized: false,
 // CHECK-NOT: splitDebugFilename:
 // CHECK-SAME:dwoId:



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


[PATCH] D100297: [AArch64][SVE] Always use overloaded methods instead of preprocessor macro.

2021-04-12 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
Herald added subscribers: psnobl, kristof.beyls, tschuett.
Herald added a reviewer: efriedma.
sdesmalen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes a subtle issue where:

  svprf(pg, ptr, SV_ALL /*is sv_pattern instead of sv_prfop*/)

would be quietly accepted. With this change, the function declaration
guards that the third parameter is a `enum sv_prfop`. Previously `svprf`
would map directly to `__builtin_sve_svprfb`, which accepts the enum
operand as a signed integer and only checks that the incoming range is
valid, meaning that SV_ALL would be discarded as being outside the valid
immediate range, but would have allowed SV_VL1 without issuing a warning
(C) or error (C++).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100297

Files:
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecb.c
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -919,26 +919,22 @@
 }
 
 void Intrinsic::emitIntrinsic(raw_ostream &OS) const {
-  // Use the preprocessor to 
-  if (getClassKind() != ClassG || getProto().size() <= 1) {
-OS << "#define " << mangleName(getClassKind())
-   << "(...) __builtin_sve_" << mangleName(ClassS)
-   << "(__VA_ARGS__)\n";
-  } else {
-std::string FullName = mangleName(ClassS);
-std::string ProtoName = mangleName(ClassG);
+  bool IsOverloaded = getClassKind() == ClassG && getProto().size() > 1;
 
-OS << "__aio __attribute__((__clang_arm_builtin_alias("
-   << "__builtin_sve_" << FullName << ")))\n";
+  std::string FullName = mangleName(ClassS);
+  std::string ProtoName = mangleName(getClassKind());
 
-OS << getTypes()[0].str() << " " << ProtoName << "(";
-for (unsigned I = 0; I < getTypes().size() - 1; ++I) {
-  if (I != 0)
-OS << ", ";
-  OS << getTypes()[I + 1].str();
-}
-OS << ");\n";
+  OS << (IsOverloaded ? "__aio " : "__ai ")
+ << "__attribute__((__clang_arm_builtin_alias("
+ << "__builtin_sve_" << FullName << ")))\n";
+
+  OS << getTypes()[0].str() << " " << ProtoName << "(";
+  for (unsigned I = 0; I < getTypes().size() - 1; ++I) {
+if (I != 0)
+  OS << ", ";
+OS << getTypes()[I + 1].str();
   }
+  OS << ");\n";
 }
 
 
//===--===//
@@ -1204,6 +1200,8 @@
   OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
+  OS << "#define __ai static __inline__ __attribute__((__always_inline__, "
+"__nodebug__))\n\n";
   OS << "#define __aio static __inline__ __attribute__((__always_inline__, "
 "__nodebug__, __overloadable__))\n\n";
 
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecb.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecb.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecb.c
@@ -105,3 +105,9 @@
   // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid 
range [1, 16]}}
   return SVE_ACLE_FUNC(svqdecb_pat,_n_u64,,)(op, SV_VL7, 17);
 }
+
+uint64_t test_svqdecb_svprfop(uint64_t op)
+{
+  // expected-warning@+1 {{implicit conversion from enumeration type 'enum 
svprfop' to different enumeration type 'enum svpattern'}}
+  return SVE_ACLE_FUNC(svqdecb_pat,_n_u64,,)(op, SV_PLDL1KEEP, 1);
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfb.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfb.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_prfb.c
@@ -25,3 +25,9 @@
   // expected-error-re@+1 {{argument value {{.*}} is outside the valid range 
[0, 13]}}
   return svprfb_vnum(pg, base, 0, -1);
 }
+
+void test_svprfb_svpattern(svbool_t pg, const void *base)
+{
+  // expected-warning@+1 {{implicit conversion from enumeration type 'enum 
svpattern' to different enumeration type 'enum svprfop'}}
+  return svprfb(pg, base, SV_VL1);
+}


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -919,26 +919,22 @@
 }
 
 void Intrinsic::emitIntrinsic(raw_ostream &OS) const {
-  // Use the preprocessor to 
-  if (getClassKind() != ClassG || getProto().size() <= 1) {
-OS << "#define " << mangleName(getClassKind())
-   << "(...) __builtin_sve_" << mangleName(ClassS)
-   << "(__VA_ARGS__)\n";
-  } else {
-std::string FullName = mangleName(ClassS);
-std::string ProtoName = mangleName(ClassG);
+  bool IsOverloaded = getClassKind() == Class

[PATCH] D100298: [Clang][Coroutine][DebugInfo] Follow-up: reduce a tests ordering requirements

2021-04-12 Thread Jeremy Morse via Phabricator via cfe-commits
jmorse created this revision.
jmorse added a reviewer: dongAxis1944.
Herald added subscribers: ChuanqiXu, lxfind.
jmorse requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Hi,

The test added in D97533  (and modified by 
this patch) has some overly strict printed metadata ordering requirements, 
specifically the interleaving of DILocalVariable nodes and DILocation nodes. 
Unfortunately our downstream changes alter this order, which causes us trouble.

The patch below reduces the need for ordering: it picks out the DILocalVariable 
nodes being sought, in any order (CHECK-DAG), and doesn't examine any 
DILocations. The subsequent CHECK-NOTs are what's important: the test seeks to 
ensure a duplicate set of DILocalVariables aren't emitted in the same scope.

I've tested that this fails before 3a6a80b641bcf 
 and 
passes afterwards.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100298

Files:
  clang/test/CodeGenCoroutines/coro-dwarf.cpp


Index: clang/test/CodeGenCoroutines/coro-dwarf.cpp
===
--- clang/test/CodeGenCoroutines/coro-dwarf.cpp
+++ clang/test/CodeGenCoroutines/coro-dwarf.cpp
@@ -63,15 +63,9 @@
 }
 
 // CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "f_coro", linkageName: 
"_Z6f_coroi8MoveOnly11MoveAndCopy"
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "val", arg: 1, scope: ![[SP]], 
file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 17, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "moParam", arg: 2, scope: 
![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 31, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: 
![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 52, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 61, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 6, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 0, scope: ![[SP]])
+// CHECK-DAG: !{{[0-9]+}} = !DILocalVariable(name: "val", arg: 1, scope: 
![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
+// CHECK-DAG: !{{[0-9]+}} = !DILocalVariable(name: "moParam", arg: 2, scope: 
![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
+// CHECK-DAG: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: 
![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
 // CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "val", scope: ![[SP]], 
type: !{{[0-9]+}}, flags: DIFlagArtificial)
 // CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "moParam", scope: ![[SP]], 
type: !{{[0-9]+}}, flags: DIFlagArtificial)
 // CHECK-NOT:: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", scope: ![[SP]], 
type: !{{[0-9]+}}, flags: DIFlagArtificial)


Index: clang/test/CodeGenCoroutines/coro-dwarf.cpp
===
--- clang/test/CodeGenCoroutines/coro-dwarf.cpp
+++ clang/test/CodeGenCoroutines/coro-dwarf.cpp
@@ -63,15 +63,9 @@
 }
 
 // CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "f_coro", linkageName: "_Z6f_coroi8MoveOnly11MoveAndCopy"
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "val", arg: 1, scope: ![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 17, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "moParam", arg: 2, scope: ![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 31, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: ![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 52, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 61, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 6, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 0, scope: ![[SP]])
+// CHECK-DAG: !{{[0-9]+}} = !DILocalVariable(name: "val", arg: 1, scope: ![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
+// CHECK-DAG: !{{[0-9]+}} = !DILocalVariable(name: "moParam", arg: 2, scope: ![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
+// CHECK-DAG: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: ![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
 // CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "val", scope: ![[SP]], type: !{{[0-9]+}}, flags: DIFlagArtificial)
 // CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "moParam", scope: ![[SP]], type: !{{[0-9]+}}, flags: DIFlagArtificial)
 // CHECK-NOT:: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", scope: ![[SP]], type: !{{[0-9]+}}, flags: DIFlagArtificial)
___
cfe-commits mailing list
c

[PATCH] D97533: [Clang][Coroutine][DebugInfo] remove useless debug info for coroutine parameters

2021-04-12 Thread Jeremy Morse via Phabricator via cfe-commits
jmorse added a comment.

NB, while I flagged that CHECK-NEXT added too much ordering, I forgot that 
CHECK still requires some ordering. It causes us some difficulties downstream; 
there's a follow-up patch here D100298  for 
consideration.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97533

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


[PATCH] D99231: [AST] Add introspection support for more base nodes

2021-04-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 336804.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99231

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -30,7 +30,10 @@
 std::map
 FormatExpected(const MapType &Accessors) {
   std::map Result;
-  llvm::transform(Accessors,
+  llvm::transform(llvm::make_filter_range(Accessors,
+  [](const auto &Accessor) {
+return Accessor.first.isValid();
+  }),
   std::inserter(Result, Result.end()),
   [](const auto &Accessor) {
 return std::make_pair(
@@ -126,11 +129,9 @@
   UnorderedElementsAre(
   STRING_LOCATION_PAIR(MethodDecl, getBeginLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getBodyRBrace()),
-  STRING_LOCATION_PAIR(MethodDecl, getEllipsisLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getInnerLocStart()),
   STRING_LOCATION_PAIR(MethodDecl, getLocation()),
   STRING_LOCATION_PAIR(MethodDecl, getOuterLocStart()),
-  STRING_LOCATION_PAIR(MethodDecl, getPointOfInstantiation()),
   STRING_LOCATION_PAIR(MethodDecl, getTypeSpecEndLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getTypeSpecStartLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getEndLoc(;
@@ -145,3 +146,741 @@
   STRING_LOCATION_PAIR(MethodDecl, getReturnTypeSourceRange()),
   STRING_LOCATION_PAIR(MethodDecl, getSourceRange(;
 }
+
+TEST(Introspection, SourceLocations_NNS) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+namespace ns
+{
+  struct A {
+  void foo();
+};
+}
+void ns::A::foo() {}
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(nestedNameSpecifierLoc().bind("nns"))), TU, Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *NNS = BoundNodes[0].getNodeAs("nns");
+
+  auto Result = NodeIntrospection::GetLocations(NNS);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  EXPECT_THAT(
+  ExpectedLocations,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(NNS, getBeginLoc()),
+   STRING_LOCATION_PAIR(NNS, getEndLoc()),
+   STRING_LOCATION_PAIR(NNS, getLocalBeginLoc()),
+   STRING_LOCATION_PAIR(NNS, getLocalEndLoc(;
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(
+  ExpectedRanges,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(NNS, getLocalSourceRange()),
+   STRING_LOCATION_PAIR(NNS, getSourceRange(;
+}
+
+TEST(Introspection, SourceLocations_TA_Type) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+template
+  struct A {
+  void foo();
+};
+
+void foo()
+{
+  A a;
+}
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(templateArgumentLoc().bind("ta"))), TU, Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *TA = BoundNodes[0].getNodeAs("ta");
+
+  auto Result = NodeIntrospection::GetLocations(TA);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  EXPECT_THAT(ExpectedLocations,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(TA, getLocation(;
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(ExpectedRanges,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(TA, getSourceRange(;
+}
+
+TEST(Introspection, SourceLocations_TA_Decl) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+template
+void test2() {}
+void doNothing() {}
+void test() {
+test2();
+}
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescend

[PATCH] D99231: [AST] Add introspection support for more base nodes

2021-04-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:2270
   SourceLocation getEllipsisLoc() const {
-assert(isPackExpansion() && "Initializer is not a pack expansion");
+if (!isPackExpansion())
+  return {};

njames93 wrote:
> I'm not sure about this change, but I'm guessing there's not a nice way to 
> predicate these kinds of things
Yep.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99231

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


[PATCH] D99262: [analyzer] Fix dead store checker false positive

2021-04-12 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D99262#2673842 , @vsavchenko wrote:

> Support nested init lists

Thanks for addressing the nested lists! (And sorry for the late reply, I was on 
vacation)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99262

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


[PATCH] D99565: [X86] Support replacing aligned vector moves with unaligned moves when avx is enabled.

2021-04-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I'm still uncomfortable with changing current status quo, even though i 
obviously don't get to cast the final vote here.

One should not use aligned loads in hope that they will cause an exception to 
detect address misalignment.
That's UBSan's job. `-fsanitize=undefined`/`-fsanitize=aligment` *should* catch 
it.
If it does not do so in your particular case, please file a bug, i would like 
to take a look.

Likewise, i don't think one should do overaligned loads and hope that they will 
just work.
UB is UB. The code will still be miscompiled, but you've just hidden your 
warning.

Likewise, even if unaligned loads can be always used, i would personally find 
it pretty surprising
to suddenly see unaliged loads instead of aligned ones.
Also, isn't that only possible/so when AVX is avaliable?
What happens without AVX? Do so anyways at the perfomance's cost?
Or back to exceptions?

Should this process in any form other than the UBSan changes,
i would like to first see a RFC on llvm-dev.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99565

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


[PATCH] D99568: [clang][invocation] Fix copy constructor, add copy assignment to CompilerInvocation

2021-04-12 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99568

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


[PATCH] D100276: [clang] p1099 using enum part 1

2021-04-12 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:12144
   NameInfo.getName().getNameKind() != DeclarationName::CXXConstructorName) 
{
+// FIXME: 2021-04-07: When was this hack needed?  Can it be deleted now?
 // HACK: Work around a bug in libstdc++'s detection of ::gets. Sometimes

I noticed this in passing.  I have found it useful to add dates in such 
workaround comments -- having found really old ones in GCC that have been 
obsolete for like 15 years or more :)  Which  version(s) of libstdc++ got this 
wrong?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100276

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


[PATCH] D100276: [clang] p1099 using enum part 1

2021-04-12 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:12144
   NameInfo.getName().getNameKind() != DeclarationName::CXXConstructorName) 
{
+// FIXME: 2021-04-07: When was this hack needed?  Can it be deleted now?
 // HACK: Work around a bug in libstdc++'s detection of ::gets. Sometimes

urnathan wrote:
> I noticed this in passing.  I have found it useful to add dates in such 
> workaround comments -- having found really old ones in GCC that have been 
> obsolete for like 15 years or more :)  Which  version(s) of libstdc++ got 
> this wrong?
to answer my own question:
f501cc313e9e0 (Richard Smith 2012-10-05 01:46:25 +

Workaround for libstdc++4.6  bug: make comment more explicit about 
what's going on, per Sean Silva's suggestion.

the last 4.6 release was GCC 4.6.4 in 2013-04-12

so (a) probably removable but I've not checked if/when libstdc++ fixed the 
problem, and (b) should be treated as a separate issue, of course.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100276

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


[PATCH] D99231: [AST] Add introspection support for more base nodes

2021-04-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 336813.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99231

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/unittests/Introspection/IntrospectionTest.cpp

Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- clang/unittests/Introspection/IntrospectionTest.cpp
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -30,7 +30,10 @@
 std::map
 FormatExpected(const MapType &Accessors) {
   std::map Result;
-  llvm::transform(Accessors,
+  llvm::transform(llvm::make_filter_range(Accessors,
+  [](const auto &Accessor) {
+return Accessor.first.isValid();
+  }),
   std::inserter(Result, Result.end()),
   [](const auto &Accessor) {
 return std::make_pair(
@@ -126,11 +129,9 @@
   UnorderedElementsAre(
   STRING_LOCATION_PAIR(MethodDecl, getBeginLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getBodyRBrace()),
-  STRING_LOCATION_PAIR(MethodDecl, getEllipsisLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getInnerLocStart()),
   STRING_LOCATION_PAIR(MethodDecl, getLocation()),
   STRING_LOCATION_PAIR(MethodDecl, getOuterLocStart()),
-  STRING_LOCATION_PAIR(MethodDecl, getPointOfInstantiation()),
   STRING_LOCATION_PAIR(MethodDecl, getTypeSpecEndLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getTypeSpecStartLoc()),
   STRING_LOCATION_PAIR(MethodDecl, getEndLoc(;
@@ -145,3 +146,741 @@
   STRING_LOCATION_PAIR(MethodDecl, getReturnTypeSourceRange()),
   STRING_LOCATION_PAIR(MethodDecl, getSourceRange(;
 }
+
+TEST(Introspection, SourceLocations_NNS) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+namespace ns
+{
+  struct A {
+  void foo();
+};
+}
+void ns::A::foo() {}
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(nestedNameSpecifierLoc().bind("nns"))), TU, Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *NNS = BoundNodes[0].getNodeAs("nns");
+
+  auto Result = NodeIntrospection::GetLocations(NNS);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  EXPECT_THAT(
+  ExpectedLocations,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(NNS, getBeginLoc()),
+   STRING_LOCATION_PAIR(NNS, getEndLoc()),
+   STRING_LOCATION_PAIR(NNS, getLocalBeginLoc()),
+   STRING_LOCATION_PAIR(NNS, getLocalEndLoc(;
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(
+  ExpectedRanges,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(NNS, getLocalSourceRange()),
+   STRING_LOCATION_PAIR(NNS, getSourceRange(;
+}
+
+TEST(Introspection, SourceLocations_TA_Type) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+template
+  struct A {
+  void foo();
+};
+
+void foo()
+{
+  A a;
+}
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescendant(templateArgumentLoc().bind("ta"))), TU, Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *TA = BoundNodes[0].getNodeAs("ta");
+
+  auto Result = NodeIntrospection::GetLocations(TA);
+
+  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
+return;
+  }
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  EXPECT_THAT(ExpectedLocations,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(TA, getLocation(;
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(ExpectedRanges,
+  UnorderedElementsAre(STRING_LOCATION_PAIR(TA, getSourceRange(;
+}
+
+TEST(Introspection, SourceLocations_TA_Decl) {
+  auto AST =
+  buildASTFromCode(R"cpp(
+template
+void test2() {}
+void doNothing() {}
+void test() {
+test2();
+}
+)cpp",
+   "foo.cpp", std::make_shared());
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  decl(hasDescend

[PATCH] D99262: [analyzer] Fix dead store checker false positive

2021-04-12 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D99262#2682803 , @martong wrote:

> In D99262#2673842 , @vsavchenko 
> wrote:
>
>> Support nested init lists
>
> Thanks for addressing the nested lists! (And sorry for the late reply, I was 
> on vacation)

Hey, thanks for taking your time and reviewing it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99262

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


[PATCH] D100225: [Clang][AArch64] Coerce integer return values through an undef vector

2021-04-12 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

After reading the summary/intent of the patch, I thought the same thing as 
@rjmccall. Simply returning an i32 for the above example and removing the 
rounding-up seems right to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100225

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


[clang] bcbea2a - [NFC] Remove redundant string copy

2021-04-12 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-04-12T15:13:59+01:00
New Revision: bcbea2ab84df87983fa9b30e94ea25eda0eb2338

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

LOG: [NFC] Remove redundant string copy

Added: 


Modified: 
clang/include/clang/AST/TextNodeDumper.h

Removed: 




diff  --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index 15ca348f47667..0955c494a74ad 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -69,10 +69,8 @@ class TextTreeStructure {
   return;
 }
 
-// We need to capture an owning-string in the lambda because the lambda
-// is invoked in a deferred manner.
-std::string LabelStr(Label);
-auto DumpWithIndent = [this, DoAddChild, LabelStr](bool IsLastChild) {
+auto DumpWithIndent = [this, DoAddChild,
+   Label(Label.str())](bool IsLastChild) {
   // Print out the appropriate tree structure and work out the prefix for
   // children of this node. For instance:
   //
@@ -89,8 +87,8 @@ class TextTreeStructure {
 OS << '\n';
 ColorScope Color(OS, ShowColors, IndentColor);
 OS << Prefix << (IsLastChild ? '`' : '|') << '-';
-if (!LabelStr.empty())
-  OS << LabelStr << ": ";
+if (!Label.empty())
+  OS << Label << ": ";
 
 this->Prefix.push_back(IsLastChild ? ' ' : '|');
 this->Prefix.push_back(' ');



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


[PATCH] D98798: Produce warning for performing pointer arithmetic on a null pointer.

2021-04-12 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser updated this revision to Diff 336828.
jamieschmeiser added a comment.

Fix indenting.


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

https://reviews.llvm.org/D98798

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/pointer-addition.c


Index: clang/test/Sema/pointer-addition.c
===
--- clang/test/Sema/pointer-addition.c
+++ clang/test/Sema/pointer-addition.c
@@ -29,4 +29,7 @@
   // Cases that don't match the GNU inttoptr idiom get a different warning.
   f = (char*)0 - i; // expected-warning {{performing pointer arithmetic on a 
null pointer has undefined behavior}}
   int *g = (int*)0 + i; // expected-warning {{performing pointer arithmetic on 
a null pointer has undefined behavior}}
+  f = (char*)((char*)0 - f); // expected-warning {{performing pointer 
arithmetic on a null pointer has undefined behavior}}
+  f = (char*)(f - (char*)0); // expected-warning {{performing pointer 
arithmetic on a null pointer has undefined behavior}}
+  f = (char*)((char*)0 - (char*)0); // expected-warning {{performing pointer 
arithmetic on a null pointer has undefined behavior}} expected-warning 
{{performing pointer arithmetic on a null pointer has undefined behavior}}
 }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -10720,7 +10720,17 @@
LHS.get(), RHS.get()))
 return QualType();
 
-  // FIXME: Add warnings for nullptr - ptr.
+  bool LHSIsNullPtr = LHS.get()->IgnoreParenCasts()->isNullPointerConstant(
+  Context, Expr::NPC_ValueDependentIsNotNull);
+  bool RHSIsNullPtr = RHS.get()->IgnoreParenCasts()->isNullPointerConstant(
+  Context, Expr::NPC_ValueDependentIsNotNull);
+
+  // Subtracting nullptr or from nullptr should produce
+  // a warning expect nullptr - nullptr is valid in C++ [expr.add]p7
+  if (LHSIsNullPtr && (!getLangOpts().CPlusPlus || !RHSIsNullPtr))
+diagnoseArithmeticOnNullPointer(*this, Loc, LHS.get(), false);
+  if (RHSIsNullPtr && (!getLangOpts().CPlusPlus || !LHSIsNullPtr))
+diagnoseArithmeticOnNullPointer(*this, Loc, RHS.get(), false);
 
   // The pointee type may have zero size.  As an extension, a structure or
   // union may have zero size or an array may have zero length.  In this


Index: clang/test/Sema/pointer-addition.c
===
--- clang/test/Sema/pointer-addition.c
+++ clang/test/Sema/pointer-addition.c
@@ -29,4 +29,7 @@
   // Cases that don't match the GNU inttoptr idiom get a different warning.
   f = (char*)0 - i; // expected-warning {{performing pointer arithmetic on a null pointer has undefined behavior}}
   int *g = (int*)0 + i; // expected-warning {{performing pointer arithmetic on a null pointer has undefined behavior}}
+  f = (char*)((char*)0 - f); // expected-warning {{performing pointer arithmetic on a null pointer has undefined behavior}}
+  f = (char*)(f - (char*)0); // expected-warning {{performing pointer arithmetic on a null pointer has undefined behavior}}
+  f = (char*)((char*)0 - (char*)0); // expected-warning {{performing pointer arithmetic on a null pointer has undefined behavior}} expected-warning {{performing pointer arithmetic on a null pointer has undefined behavior}}
 }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -10720,7 +10720,17 @@
LHS.get(), RHS.get()))
 return QualType();
 
-  // FIXME: Add warnings for nullptr - ptr.
+  bool LHSIsNullPtr = LHS.get()->IgnoreParenCasts()->isNullPointerConstant(
+  Context, Expr::NPC_ValueDependentIsNotNull);
+  bool RHSIsNullPtr = RHS.get()->IgnoreParenCasts()->isNullPointerConstant(
+  Context, Expr::NPC_ValueDependentIsNotNull);
+
+  // Subtracting nullptr or from nullptr should produce
+  // a warning expect nullptr - nullptr is valid in C++ [expr.add]p7
+  if (LHSIsNullPtr && (!getLangOpts().CPlusPlus || !RHSIsNullPtr))
+diagnoseArithmeticOnNullPointer(*this, Loc, LHS.get(), false);
+  if (RHSIsNullPtr && (!getLangOpts().CPlusPlus || !LHSIsNullPtr))
+diagnoseArithmeticOnNullPointer(*this, Loc, RHS.get(), false);
 
   // The pointee type may have zero size.  As an extension, a structure or
   // union may have zero size or an array may have zero length.  In this
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100298: [Clang][Coroutine][DebugInfo] Follow-up: reduce a tests ordering requirements

2021-04-12 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

I am not 100% convinced this has the desired effect.  I believe what it does is:

- Search for the first occurrence of each of "val" "moParam" and "mcParam"
- After the last of the above occurrences, ensure there are no other 
occurrences of "val" "moParam" or "mcParam"

That is, it wouldn't fail on input of

  "val"
  "val"
  "moParam"
  "mcParam"

...because the second appearance of "val" is before the last text matched by 
one of the DAG directives.

I think really what you want is to specify the three variable names using 
{{--implicit-check-not}} on the FileCheck command, which (I am pretty sure) 
will apply to everything not explicitly matched by a CHECK directive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100298

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


[PATCH] D98070: [clang-tidy] Add option to ignore macros in readability-function-cognitive-complexity check.

2021-04-12 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 336831.
massberg added a comment.

Add test with global IgnoreMacros=true and 
readability-function-cognitive-complexity.IgnoreMacros unset.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98070

Files:
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
@@ -10,9 +10,27 @@
 // RUN:   value: 5}, \
 // RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
 // RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=IGNORE-MACROS %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: readability-function-cognitive-complexity.IgnoreMacros, \
+// RUN:   value: "true"}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=GLOBAL-IGNORE-MACROS %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: IgnoreMacros, \
+// RUN:   value: "true"}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
 
 void func_of_complexity_4() {
   // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-GLOBAL-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
   if (1) {
 if (1) {
 }
@@ -34,9 +52,44 @@
 void function_with_macro() {
   // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 0) [readability-function-cognitive-complexity]
   // CHECK-NOTES-THRESHOLD5: :[[@LINE-2]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 5) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'function_with_macro' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-GLOBAL-IGNORE-MACROS: :[[@LINE-4]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 0) [readability-function-cognitive-complexity]
 
   MacroOfComplexity10;
 
   if (1) {
   }
 }
+
+#define noop \
+  {}
+
+#define SomeMacro(x) \
+  if (1) {   \
+x;   \
+  }
+
+void func_macro_1() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_macro_1' has cognitive complexity of 2 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_macro_1' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-GLOBAL-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'func_macro_1' has cognitive complexity of 2 (threshold 0) [readability-function-cognitive-complexity]
+
+  if (1) {
+  }
+  SomeMacro(noop);
+}
+
+void func_macro_2() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_macro_2' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_macro_2' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-GLOBAL-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'func_macro_2' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+
+  if (1) {
+  }
+  // Note that if the IgnoreMacro option is set to 'true', currently also macro
+  // arguments are ignored. Optimally, mac

[clang-tools-extra] 63bc9e4 - [clangd] Provide a way to disable external index

2021-04-12 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-04-12T16:43:23+02:00
New Revision: 63bc9e443502ab6def2dec0b5ffe64a522f801cc

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

LOG: [clangd] Provide a way to disable external index

Users can reset any external index set by previous fragments by
putting a `None` for the external block, e.g:

```
Index:
  External: None
```

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

Added: 


Modified: 
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index 7064edd76b8f4..fe6f4d7fa6e8e 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -70,7 +70,7 @@ struct Config {
   enum class BackgroundPolicy { Build, Skip };
   /// Describes an external index configuration.
   struct ExternalIndexSpec {
-enum { File, Server } Kind;
+enum { None, File, Server } Kind;
 /// This is one of:
 /// - Address of a clangd-index-server, in the form of "ip:port".
 /// - Absolute path to an index produced by clangd-indexer.

diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index 1185eb7255b4c..a5745727dca78 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -329,10 +329,11 @@ struct FragmentCompiler {
 }
 #endif
 // Make sure exactly one of the Sources is set.
-unsigned SourceCount =
-External.File.hasValue() + External.Server.hasValue();
+unsigned SourceCount = External.File.hasValue() +
+   External.Server.hasValue() + *External.IsNone;
 if (SourceCount != 1) {
-  diag(Error, "Exactly one of File or Server must be set.", BlockRange);
+  diag(Error, "Exactly one of File, Server or None must be set.",
+   BlockRange);
   return;
 }
 Config::ExternalIndexSpec Spec;
@@ -346,20 +347,29 @@ struct FragmentCompiler {
   if (!AbsPath)
 return;
   Spec.Location = std::move(*AbsPath);
+} else {
+  assert(*External.IsNone);
+  Spec.Kind = Config::ExternalIndexSpec::None;
 }
-// Make sure MountPoint is an absolute path with forward slashes.
-if (!External.MountPoint)
-  External.MountPoint.emplace(FragmentDirectory);
-if ((**External.MountPoint).empty()) {
-  diag(Error, "A mountpoint is required.", BlockRange);
-  return;
+if (Spec.Kind != Config::ExternalIndexSpec::None) {
+  // Make sure MountPoint is an absolute path with forward slashes.
+  if (!External.MountPoint)
+External.MountPoint.emplace(FragmentDirectory);
+  if ((**External.MountPoint).empty()) {
+diag(Error, "A mountpoint is required.", BlockRange);
+return;
+  }
+  auto AbsPath = makeAbsolute(std::move(*External.MountPoint), 
"MountPoint",
+  llvm::sys::path::Style::posix);
+  if (!AbsPath)
+return;
+  Spec.MountPoint = std::move(*AbsPath);
 }
-auto AbsPath = makeAbsolute(std::move(*External.MountPoint), "MountPoint",
-llvm::sys::path::Style::posix);
-if (!AbsPath)
-  return;
-Spec.MountPoint = std::move(*AbsPath);
 Out.Apply.push_back([Spec(std::move(Spec))](const Params &P, Config &C) {
+  if (Spec.Kind == Config::ExternalIndexSpec::None) {
+C.Index.External.reset();
+return;
+  }
   if (P.Path.empty() || !pathStartsWith(Spec.MountPoint, P.Path,
 llvm::sys::path::Style::posix))
 return;

diff  --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
index 1365ed4c1037c..6b58b88dfd490 100644
--- a/clang-tools-extra/clangd/ConfigFragment.h
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -173,6 +173,9 @@ struct Fragment {
 /// usually prepared using clangd-indexer.
 /// Exactly one source (File/Server) should be configured.
 struct ExternalBlock {
+  /// Whether the block is explicitly set to `None`. Can be used to clear
+  /// any external index specified before.
+  Located IsNone = false;
   /// Path to an index file generated by clangd-indexer. Relative paths may
   /// be used, if config fragment is associated with a directory.
   llvm::Optional> File;

diff  --git a/clang-tools-extra/clangd/ConfigYAML.cpp 
b/clang-tools-extra/clangd/ConfigYAML.cpp
index d50c01168a8dd..f573

[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-04-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/AST/Type.h:493
+   // Default is a superset of SYCL address spaces.
+   (A == LangAS::Default &&
+(B == LangAS::sycl_private || B == LangAS::sycl_local ||

bader wrote:
> Anastasia wrote:
> > Ok if you allow implicit conversions both ways then this condition should 
> > be extended to also contain all named address spaces in `A` and `Default` 
> > in `B`. But actually, could you simplify by checking that you have 
> > `Default` on either side, so something like 
> > 
> > 
> > ```
> > (A == LangAS::Default || B == LangAS::Default)
> > ```
> > ?
> > Ok if you allow implicit conversions both ways then this condition should 
> > be extended to also contain all named address spaces in `A` and `Default` 
> > in `B`. But actually, could you simplify by checking that you have 
> > `Default` on either side, so something like 
> > 
> > 
> > ```
> > (A == LangAS::Default || B == LangAS::Default)
> > ```
> > ?
> 
> According to the comment above `isAddressSpaceSupersetOf` function definition.
> ```
>   /// Returns true if address space A is equal to or a superset of B.
> ```
> 
> `(A == LangAS::Default || B == LangAS::Default)` <- this change makes 
> `Default` address space a superset of all address spaces including OpenCL, 
> which we were trying to avoid with adding SYCL address spaces. Another 
> problem with this code is that make `Default` a **sub-set** of named address 
> spaces (like `sycl_local`), which is not right.
> If I understand it correctly defining "isSupersSetOf" relation is enough for 
> the rest of framework to enable conversions. Am I right?
> (A == LangAS::Default || B == LangAS::Default) <- this change makes Default 
> address space a superset of all address spaces including OpenCL.

I see, yes this will break pretty much everything unless we guard by SYCL mode. 
But I don't think it is good to go this route though.

> Another problem with this code is that make Default a sub-set of named 
> address spaces (like sycl_local), which is not right.

Well, if you need implicit conversions to work both ways as you have written in 
the documentation then you don't really have a true super-/subsets between the 
named address spaces and the default one. They appear to be equivalent.

```
SYCL mode enables both explicit and implicit conversion to/from the default 
address space from/to
the address space-attributed type.
```

So do you actually need something like this to work?

```
int * genptr = ...;
__private int * privptr = genptr:
```





Comment at: clang/lib/AST/ItaniumMangle.cpp:2379
   unsigned TargetAS = Context.getASTContext().getTargetAddressSpace(AS);
-  if (TargetAS != 0)
+  if (TargetAS != 0 || Context.getASTContext().getLangOpts().SYCLIsDevice)
 ASString = "AS" + llvm::utostr(TargetAS);

bader wrote:
> Anastasia wrote:
> > Any reason not to use OpenCL mangling? If you do then you might be able to 
> > link against libraries compiled for OpenCL. Also you will get more stable 
> > naming i.e. it would not differ from target to target. 
> > Any reason not to use OpenCL mangling? If you do then you might be able to 
> > link against libraries compiled for OpenCL. Also you will get more stable 
> > naming i.e. it would not differ from target to target. 
> 
> I'm not sure I understand your suggestion. Could you elaborate on "OpenCL 
> mangling", please?
> 
> Let me clarify the problem this change addresses. The test case covering it 
> is located in 
> `clang/test/CodeGenSYCL/address-space-parameter-conversions.cpp` lines 86-91.
> 
> ```
> template 
> void tmpl(T t) {}
> 
> int *NoAS;
> __attribute__((opencl_private)) int *PRIV;
> 
> tmpl(PRIV);
> // CHECK-DAG: [[PRIV_LOAD5:%[a-zA-Z0-9]+]] = load i32*, i32* addrspace(4)* 
> [[PRIV]].ascast
> // CHECK-DAG: call spir_func void [[PRIV_TMPL:@[a-zA-Z0-9_]+]](i32* 
> [[PRIV_LOAD5]])
> tmpl(NoAS);
> // CHECK-DAG: [[NoAS_LOAD5:%[a-zA-Z0-9]+]] = load i32 addrspace(4)*, i32 
> addrspace(4)* addrspace(4)* [[NoAS]].ascast
> // CHECK-DAG: call spir_func void [[GEN_TMPL:@[a-zA-Z0-9_]+]](i32 
> addrspace(4)* [[NoAS_LOAD5]])
> ```
> Clang has separate code paths for mangling types w/ and w/o address space 
> attributes (i.e. using `Default` address space).
> 
> Address space is not mangled if there is no AS attribute (`Default`) or if 
> address space attribute is maps to `0` target address space. SPIR target maps 
> `*_private` address space to `0`, which causes name conflict for the example 
> above.
> 
> This change for SYCL compiler enables mangling for non-default address space 
> attributes regardless of their mapping to target address space.
It's just that all language address spaces are mangled with the source spelling 
in Italium ABI right now, if you check the `else` statement. I don't think it 
is part of the official spec yet but it might be better to stick to the same 
pa

[PATCH] D98070: [clang-tidy] Add option to ignore macros in readability-function-cognitive-complexity check.

2021-04-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

K, thx.




Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst:31
+   any macro arguments are ignored, even if they should count to the 
complexity.
+   Default is `false`.
+

I'd add something about this option being not guaranteed to forward-compatible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98070

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-04-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/CodeGenSYCL/address-space-parameter-conversions.cpp:80
+  // Ensure that we still get 3 different template instantiations.
+  tmpl(GLOB);
+  // CHECK-DAG: [[GLOB_LOAD4:%[a-zA-Z0-9]+]] = load i32 addrspace(1)*, i32 
addrspace(1)* addrspace(4)* [[GLOB]].ascast

bader wrote:
> Anastasia wrote:
> > What functionality in the patch does this test?
> > What functionality in the patch does this test?
> 
> As I mentioned in the comment for clang/lib/AST/ItaniumMangle.cpp, there was 
> a problem with instantiating templates for parameters which differs only by 
> address space attribute. Lines 79-91 cover mangling changes.
You are not testing the mangling though?



Comment at: clang/test/CodeGenSYCL/address-space-parameter-conversions.cpp:124
+
+template 
+__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {

bader wrote:
> Anastasia wrote:
> > Does this test anything from the patch?
> > Does this test anything from the patch?
> 
> It's the same case as for `address-space-cond-op.cpp` test. This function 
> defines an entry point for the device code. If it's not called, SYCL device 
> compiler won't emit any LLVM IR output. I uploaded the final version of the 
> test, which assumes that SYCL device compiler code generation part is in 
> place. I would prefer to keep it instead of adding it back with my next 
> patch. Is this okay?
If you are not testing any logic from this patch let's leave it out because it 
is hard to navigate in the large review.



Comment at: clang/test/CodeGenSYCL/address-spaces-struct.cpp:1
+// RUN: %clang_cc1 -triple spir64-unknown-linux-sycldevice -fsycl 
-fsycl-is-device -disable-llvm-passes -emit-llvm -x c++ %s -o - | FileCheck %s
+

bader wrote:
> Anastasia wrote:
> > What do you test in this file?
> > What do you test in this file?
> 
> This test was added to cover a bug in CodeGen with incompatible address 
> spaces between pointers to a struct and its members.
> As we replaced CodeGen changes with SPIR target callbacks I think it's not 
> needed anymore. I removed this test.
> 
> BTW, the same applies to clang/test/CodeGenSYCL/address-space-cond-op.cpp. 
> Should we remove it as well?
Yeah if it is not testing anything in your patch then it's better to remove it.



Comment at: clang/test/SemaSYCL/address-space-parameter-conversions.cpp:25
+
+  bar(*NoAS);
+  bar2(*NoAS);

bader wrote:
> Anastasia wrote:
> > Btw you don't seem to be testing the reverse conversion i.e. from named to 
> > `Default`.
> > Btw you don't seem to be testing the reverse conversion i.e. from named to 
> > `Default`.
> 
> Don't `bar2(*GLOB);`, `bar2(*LOC);`, `bar2(*PRIV);` cover this conversion?
Sorry I mean from `Default` to named AS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D100266: [RISCV][Clang] Add vmv and vfmv series intrinsic functions.

2021-04-12 Thread Zakk Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:1001
+["x", "Uv", "UvUe"]]>;
+}
 

Jim wrote:
> I am not sure that indent is needed inside let expression. In some cases, it 
> don't have indent.
I keep the indent because it seems like no rule for it.

ref. 
https://github.com/llvm-project/llvm/blob/master/lib/Target/AArch64/AArch64InstrInfo.td#L705-L735


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100266

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


[PATCH] D97683: [clang-tidy] Add include to misc-uniqueptr-reset-release

2021-04-12 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, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97683

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


[PATCH] D97196: [clang-tidy] Add new check 'bugprone-unhandled-exception-at-new'.

2021-04-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp:28-30
+// Generic catch handler should match anything.
+if (CatchS->getCaughtType().isNull())
+  return true;

I think this should move above the call to `InnertMatcher.matches()` so that 
the inner matcher doesn't have to worry quite as much about getting null types.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-exception-at-new.rst:7
+Finds calls to ``new`` that may throw ``std::bad_alloc`` exception and
+the exception handler is missing.
+

This isn't quite accurate -- if the exception handler is missing or doesn't 
handle either `std::bad_alloc` or `std::exception`.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-exception-at-new.rst:17
+
+Calls to ``new`` can throw exception of type ``bad_alloc`` that should be
+handled by the code. Alternatively the nonthrowing form of ``new`` can be





Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp:20
+using badalloc3 = std::bad_alloc &;
+
+void *operator new(std::size_t, int, int);

Another interesting test case would be when the user subclasses 
`std::bad_alloc` and throws errors of the subclass type from the allocation 
function which are in/correctly caught.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp:20
+
+void f1() noexcept {
+  int *I1 = new int;

aaron.ballman wrote:
> It would be useful to also have a test with a function-try-block to ensure 
> those are handled properly.
Still missing this test -- you should add one like:
```
void func() try {
  int *i = new int;
} catch (const std::bad_alloc &) {
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97196

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


[PATCH] D99250: [DebugInfo] Fix the mismatching of C++ language tags and Dwarf versions.

2021-04-12 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a subscriber: omjavaid.
DavidSpickett added a comment.

Ah, @omjavaid already put in a fix. I think you can just reland the change now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99250

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


[PATCH] D100310: Add field designated initializers logic in Tooling/Rename

2021-04-12 Thread Daniele Castagna via Phabricator via cfe-commits
dcastagna created this revision.
Herald added a subscriber: jfb.
dcastagna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

clang Tooling, and more specifically Refactoring/Rename, have support
code to extract source locations given a Unified Symbol Resolution set.
This support code is used by clang-rename and other tools that might not
be in the tree.

Currently field designated initializer are not supported.
So, renaming S::a to S::b in this code:

  S s = { .a = 10 };

will not extract the field designated initializer for a (the 'a' after the
dot).

This CL adds support for field designated initialized to RecursiveSymbolVisitor
and RenameLocFinder that is used in createRenameAtomicChanges.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100310

Files:
  clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  clang/unittests/Rename/RenameClassTest.cpp


Index: clang/unittests/Rename/RenameClassTest.cpp
===
--- clang/unittests/Rename/RenameClassTest.cpp
+++ clang/unittests/Rename/RenameClassTest.cpp
@@ -780,6 +780,27 @@
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, FieldDesignatedInitializers) {
+  std::string Before = R"(
+  struct S {
+int a;
+  };
+  void foo() {
+S s = { .a = 10 };
+s.a = 20;
+  })";
+  std::string Expected = R"(
+  struct S {
+int b;
+  };
+  void foo() {
+S s = { .b = 10 };
+s.b = 20;
+  })";
+  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");
+  CompareSnippets(Expected, After);
+}
+
 // FIXME: investigate why the test fails when adding a new USR to the USRSet.
 TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {
   std::string Before = R"(
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -226,6 +226,24 @@
 return true;
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl* Decl = D.getField();
+if (isInUSRSet(Decl)) {
+auto StartLoc = D.getFieldLoc();
+auto EndLoc = D.getFieldLoc();
+RenameInfos.push_back({StartLoc, EndLoc,
+  /*FromDecl=*/nullptr,
+  /*Context=*/nullptr,
+  /*Specifier=*/nullptr,
+  /*IgnorePrefixQualifiers=*/true});
+}
+  }
+}
+return true;
+  }
+
   bool VisitCXXConstructorDecl(const CXXConstructorDecl *CD) {
 // Fix the constructor initializer when renaming class members.
 for (const auto *Initializer : CD->inits()) {
Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
===
--- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
+++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
@@ -122,6 +122,17 @@
 return BaseType::TraverseNestedNameSpecifierLoc(NNS);
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (!visit(Decl, D.getFieldLoc(), D.getFieldLoc()))
+  return false;
+  }
+}
+return true;
+  }
+
 private:
   const SourceManager &SM;
   const LangOptions &LangOpts;


Index: clang/unittests/Rename/RenameClassTest.cpp
===
--- clang/unittests/Rename/RenameClassTest.cpp
+++ clang/unittests/Rename/RenameClassTest.cpp
@@ -780,6 +780,27 @@
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, FieldDesignatedInitializers) {
+  std::string Before = R"(
+  struct S {
+int a;
+  };
+  void foo() {
+S s = { .a = 10 };
+s.a = 20;
+  })";
+  std::string Expected = R"(
+  struct S {
+int b;
+  };
+  void foo() {
+S s = { .b = 10 };
+s.b = 20;
+  })";
+  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");
+  CompareSnippets(Expected, After);
+}
+
 // FIXME: investigate why the test fails when adding a new USR to the USRSet.
 TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {
   std::string Before = R"(
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/l

[PATCH] D100294: [AArch64][SVE] Fix dup/dupq intrinsics for C++.

2021-04-12 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin accepted this revision.
kmclaughlin added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100294

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


[PATCH] D98070: [clang-tidy] Add option to ignore macros in readability-function-cognitive-complexity check.

2021-04-12 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 336848.
massberg added a comment.

Add note that the new IgnoreMarcos options isn't guaranteed to be forward 
compatible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98070

Files:
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
@@ -10,9 +10,27 @@
 // RUN:   value: 5}, \
 // RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
 // RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=IGNORE-MACROS %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: readability-function-cognitive-complexity.IgnoreMacros, \
+// RUN:   value: "true"}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=GLOBAL-IGNORE-MACROS %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: IgnoreMacros, \
+// RUN:   value: "true"}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
 
 void func_of_complexity_4() {
   // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-GLOBAL-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
   if (1) {
 if (1) {
 }
@@ -34,9 +52,44 @@
 void function_with_macro() {
   // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 0) [readability-function-cognitive-complexity]
   // CHECK-NOTES-THRESHOLD5: :[[@LINE-2]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 5) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'function_with_macro' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-GLOBAL-IGNORE-MACROS: :[[@LINE-4]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 0) [readability-function-cognitive-complexity]
 
   MacroOfComplexity10;
 
   if (1) {
   }
 }
+
+#define noop \
+  {}
+
+#define SomeMacro(x) \
+  if (1) {   \
+x;   \
+  }
+
+void func_macro_1() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_macro_1' has cognitive complexity of 2 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_macro_1' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-GLOBAL-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'func_macro_1' has cognitive complexity of 2 (threshold 0) [readability-function-cognitive-complexity]
+
+  if (1) {
+  }
+  SomeMacro(noop);
+}
+
+void func_macro_2() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_macro_2' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_macro_2' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-GLOBAL-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'func_macro_2' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+
+  if (1) {
+  }
+  // Note that if the IgnoreMacro option is set to 'true', currently also macro
+  // arguments are ignored. Optimally, macros should be treat

[PATCH] D100282: [Coroutines] Move CoroEarly pass to before AlwaysInliner

2021-04-12 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 336850.
lxfind added a comment.

Set the attributes in Clang instead of CoroEarly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100282

Files:
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/test/CodeGenCoroutines/coro-always-inline-resume.cpp
  clang/test/CodeGenCoroutines/coro-always-inline.cpp
  llvm/lib/Transforms/Coroutines/CoroEarly.cpp
  llvm/test/Transforms/Coroutines/coro-debug-O2.ll
  llvm/test/Transforms/Coroutines/coro-debug-frame-variable.ll
  llvm/test/Transforms/Coroutines/coro-split-01.ll
  llvm/test/Transforms/Coroutines/coro-split-recursive.ll
  llvm/test/Transforms/Coroutines/ex0.ll
  llvm/test/Transforms/Coroutines/ex1.ll
  llvm/test/Transforms/Coroutines/ex2.ll
  llvm/test/Transforms/Coroutines/ex3.ll
  llvm/test/Transforms/Coroutines/ex4.ll
  llvm/test/Transforms/Coroutines/ex5.ll
  llvm/test/Transforms/Coroutines/phi-coro-end.ll
  llvm/test/Transforms/Coroutines/restart-trigger.ll

Index: llvm/test/Transforms/Coroutines/restart-trigger.ll
===
--- llvm/test/Transforms/Coroutines/restart-trigger.ll
+++ llvm/test/Transforms/Coroutines/restart-trigger.ll
@@ -12,7 +12,7 @@
 ; CHECK:  CoroSplit: Processing coroutine 'f' state: 0
 ; CHECK-NEXT: CoroSplit: Processing coroutine 'f' state: 1
 
-define void @f() {
+define void @f() "coroutine.presplit"="0" {
   %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
   %size = call i32 @llvm.coro.size.i32()
   %alloc = call i8* @malloc(i32 %size)
Index: llvm/test/Transforms/Coroutines/phi-coro-end.ll
===
--- llvm/test/Transforms/Coroutines/phi-coro-end.ll
+++ llvm/test/Transforms/Coroutines/phi-coro-end.ll
@@ -2,7 +2,7 @@
 ; RUN: opt < %s -O2 -enable-coroutines -S | FileCheck %s
 ; RUN: opt < %s -aa-pipeline=basic-aa -passes='default' -enable-coroutines -S | FileCheck %s
 
-define i8* @f(i32 %n) {
+define i8* @f(i32 %n) "coroutine.presplit"="0" {
 entry:
   %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
   %size = call i32 @llvm.coro.size.i32()
Index: llvm/test/Transforms/Coroutines/ex5.ll
===
--- llvm/test/Transforms/Coroutines/ex5.ll
+++ llvm/test/Transforms/Coroutines/ex5.ll
@@ -2,7 +2,7 @@
 ; RUN: opt < %s -O2 -enable-coroutines -preserve-alignment-assumptions-during-inlining=false -S | FileCheck %s
 ; RUN: opt < %s -aa-pipeline=basic-aa -passes='default' -enable-coroutines -preserve-alignment-assumptions-during-inlining=false -S | FileCheck %s
 
-define i8* @f(i32 %n) {
+define i8* @f(i32 %n) "coroutine.presplit"="0" {
 entry:
   %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
   %size = call i32 @llvm.coro.size.i32()
Index: llvm/test/Transforms/Coroutines/ex4.ll
===
--- llvm/test/Transforms/Coroutines/ex4.ll
+++ llvm/test/Transforms/Coroutines/ex4.ll
@@ -2,7 +2,7 @@
 ; RUN: opt < %s -O2 -enable-coroutines -S | FileCheck %s
 ; RUN: opt < %s -passes='default' -enable-coroutines -S | FileCheck %s
 
-define i8* @f(i32 %n) {
+define i8* @f(i32 %n) "coroutine.presplit"="0" {
 entry:
   %promise = alloca i32
   %pv = bitcast i32* %promise to i8*
Index: llvm/test/Transforms/Coroutines/ex3.ll
===
--- llvm/test/Transforms/Coroutines/ex3.ll
+++ llvm/test/Transforms/Coroutines/ex3.ll
@@ -2,7 +2,7 @@
 ; RUN: opt < %s -O2 -enable-coroutines -S | FileCheck %s
 ; RUN: opt < %s -aa-pipeline=basic-aa -passes='default' -enable-coroutines -S | FileCheck %s
 
-define i8* @f(i32 %n) {
+define i8* @f(i32 %n) "coroutine.presplit"="0" {
 entry:
   %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
   %size = call i32 @llvm.coro.size.i32()
Index: llvm/test/Transforms/Coroutines/ex2.ll
===
--- llvm/test/Transforms/Coroutines/ex2.ll
+++ llvm/test/Transforms/Coroutines/ex2.ll
@@ -2,7 +2,7 @@
 ; RUN: opt < %s -O2 -enable-coroutines -S | FileCheck %s
 ; RUN: opt < %s -passes='default' -enable-coroutines -S | FileCheck %s
 
-define i8* @f(i32 %n) {
+define i8* @f(i32 %n) "coroutine.presplit"="0" {
 entry:
   %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
   %need.dyn.alloc = call i1 @llvm.coro.alloc(token %id)
Index: llvm/test/Transforms/Coroutines/ex1.ll
===
--- llvm/test/Transforms/Coroutines/ex1.ll
+++ llvm/test/Transforms/Coroutines/ex1.ll
@@ -2,7 +2,7 @@
 ; RUN: opt < %s -O2 -enable-coroutines -preserve-alignment-assumptions-during-inlining=false -S | FileCheck %s
 ; RUN: opt < %s -aa-pipeline=basic-aa -passes='default' -enable-coroutines -preserve-alignment-assumptions-during-inlining=false -S | FileCheck %s
 
-d

[PATCH] D99683: [HIP] Support ThinLTO

2021-04-12 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D99683#2677357 , @yaxunl wrote:

> Any other concerns? Thanks.

I have some concerns around the fragility of this, for the reasons I mentioned 
earlier where it may not always be able to import everything needed.

> We will document the limitation of thinLTO support of HIP toolchain and 
> recommend users not to use thinLTO in those corner cases.

Where will this be documented?

My concern is that we start getting bugs filed for these corner cases, and it 
burns a bunch of someone's time to dig in only to discover that it is an 
unsupported corner case. Since we can detect in the function importer when we 
cannot import something successfully, I think it would therefore be worthwhile 
to issue a hard error with a meaningful error message in the AMDGPU case.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4421
+// Only AMDGPU supports device-side LTO
+if (IsUsingLTO && (!IsDeviceOffloadAction || Triple.isAMDGPU())) {
   Args.AddLastArg(CmdArgs, options::OPT_flto, options::OPT_flto_EQ);

Should there be an error (or is there one already) emitted somewhere if LTO is 
requested along with device offloading and this isn't AMDGPU?


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

https://reviews.llvm.org/D99683

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


[PATCH] D98070: [clang-tidy] Add option to ignore macros in readability-function-cognitive-complexity check.

2021-04-12 Thread Jens Massberg via Phabricator via cfe-commits
massberg marked an inline comment as done.
massberg added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst:31
+   any macro arguments are ignored, even if they should count to the 
complexity.
+   Default is `false`.
+

lebedev.ri wrote:
> I'd add something about this option being not guaranteed to 
> forward-compatible.
I have added a note, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98070

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


[PATCH] D100310: Add field designated initializers logic in Tooling/Rename

2021-04-12 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

I can't argue with this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100310

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


[PATCH] D99683: [HIP] Support ThinLTO

2021-04-12 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson requested changes to this revision.
tejohnson added a comment.
This revision now requires changes to proceed.

To do what I suggested in the prior comment, you'd probably want to add a new 
index-wide flag (since we don't read IR in the thin link). See for example how 
EnableSplitLTOUnit is set and used. You could add a flag like ForceImportAll or 
something like that. Then you don't necessarily even need to bump up the 
importing threshold or add the new import-noinline flag. Just key off of that 
in the importer to try to force import everything. If something cannot be 
imported, fail with a clear error.


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

https://reviews.llvm.org/D99683

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


[PATCH] D100148: [Driver] Fix compiler-rt lookup for x32

2021-04-12 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

Hi! Can we get this patch merged as-is or do we need anything else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100148

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


[PATCH] D98070: [clang-tidy] Add option to ignore macros in readability-function-cognitive-complexity check.

2021-04-12 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG with a couple of nits.




Comment at: 
clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:230
+  explicit FunctionASTVisitor(const bool IgnoreMacros)
+  : IgnoreMacros(IgnoreMacros){};
+

nit: Please remove the semicolon and clang-format.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst:31
+   any macro arguments are ignored, even if they should count to the 
complexity.
+   As this might change in the future, this option isn't guarantueed to be
+   forward-compatible. Default is `false`.

typo: "guarantueed" -> "guaranteed".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98070

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


[clang] 38cf112 - Allow applying attributes to subset of allowed subjects.

2021-04-12 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2021-04-12T09:33:33-07:00
New Revision: 38cf112a6bc8502ff8cce6ef524cf04c07f90f96

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

LOG: Allow applying attributes to subset of allowed subjects.

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

Added: 


Modified: 
clang/lib/Sema/SemaAttr.cpp
clang/test/Parser/pragma-attribute.cpp
clang/test/Sema/pragma-attribute-strict-subjects.c

Removed: 




diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 88c050b01e3f..67e553a3b259 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -875,12 +875,33 @@ void Sema::ActOnPragmaAttributeAttribute(
 }
 Rules.clear();
   } else {
-for (const auto &Rule : StrictSubjectMatchRuleSet) {
-  if (Rules.erase(Rule.first)) {
+// Each rule in Rules must be a strict subset of the attribute's
+// SubjectMatch rules.  I.e. we're allowed to use
+// `apply_to=variables(is_global)` on an attrubute with SubjectList<[Var]>,
+// but should not allow `apply_to=variables` on an attribute which has
+// `SubjectList<[GlobalVar]>`.
+for (const auto &StrictRule : StrictSubjectMatchRuleSet) {
+  // First, check for exact match.
+  if (Rules.erase(StrictRule.first)) {
 // Add the rule to the set of attribute receivers only if it's 
supported
 // in the current language mode.
-if (Rule.second)
-  SubjectMatchRules.push_back(Rule.first);
+if (StrictRule.second)
+  SubjectMatchRules.push_back(StrictRule.first);
+  }
+}
+// Check remaining rules for subset matches.
+auto RulesToCheck = Rules;
+for (const auto &Rule : RulesToCheck) {
+  attr::SubjectMatchRule MatchRule = attr::SubjectMatchRule(Rule.first);
+  if (auto ParentRule = getParentAttrMatcherRule(MatchRule)) {
+if (llvm::any_of(StrictSubjectMatchRuleSet,
+ [ParentRule](const auto &StrictRule) {
+   return StrictRule.first == *ParentRule &&
+  StrictRule.second; // IsEnabled
+ })) {
+  SubjectMatchRules.push_back(MatchRule);
+  Rules.erase(MatchRule);
+}
   }
 }
   }

diff  --git a/clang/test/Parser/pragma-attribute.cpp 
b/clang/test/Parser/pragma-attribute.cpp
index 9d28832a902e..4644bc18359e 100644
--- a/clang/test/Parser/pragma-attribute.cpp
+++ b/clang/test/Parser/pragma-attribute.cpp
@@ -195,3 +195,12 @@ _Pragma("clang attribute pop");
 #pragma clang attribute pop
 #pragma clang attribute push([[clang::uninitialized]], apply_to = 
any(variable(is_parameter), variable(unless(is_parameter // expected-error 
{{attribute 'uninitialized' can't be applied to 'variable(is_parameter)', and 
'variable(unless(is_parameter))'}}
 #pragma clang attribute pop
+// We're allowed to apply attributes to subsets of allowed subjects.
+#pragma clang attribute push([[clang::no_destroy]], apply_to = variable)
+#pragma clang attribute pop
+#pragma clang attribute push([[clang::no_destroy]], apply_to = 
variable(is_thread_local))
+#pragma clang attribute pop
+#pragma clang attribute push([[clang::no_destroy]], apply_to = 
variable(is_global))
+#pragma clang attribute pop
+#pragma clang attribute push([[clang::no_destroy]], apply_to = 
any(variable(is_parameter), variable(unless(is_parameter
+#pragma clang attribute pop

diff  --git a/clang/test/Sema/pragma-attribute-strict-subjects.c 
b/clang/test/Sema/pragma-attribute-strict-subjects.c
index 42e3e20e766a..4f37c271ce34 100644
--- a/clang/test/Sema/pragma-attribute-strict-subjects.c
+++ b/clang/test/Sema/pragma-attribute-strict-subjects.c
@@ -55,9 +55,9 @@
 // expected-error@-1 {{attribute 'abi_tag' can't be applied to 'enum'}}
 #pragma clang attribute pop
 
-#pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = 
any(enum_constant, function, record(unless(is_union)), variable, 
variable(is_parameter)))
+#pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = 
any(enum_constant, function, record(unless(is_union)), variable, 
variable(is_parameter), enum))
 // FIXME: comma in this diagnostic is wrong.
-// expected-error@-2 {{attribute 'abi_tag' can't be applied to 
'enum_constant', and 'variable(is_parameter)'}}
+// expected-error@-2 {{attribute 'abi_tag' can't be applied to 
'enum_constant', and 'enum'}}
 #pragma clang attribute pop
 
 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = 
any(function, record(unless(is_union)), enum))



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


[PATCH] D100136: Allow applying attributes to subset of allowed subjects.

2021-04-12 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG38cf112a6bc8: Allow applying attributes to subset of allowed 
subjects. (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100136

Files:
  clang/lib/Sema/SemaAttr.cpp
  clang/test/Parser/pragma-attribute.cpp
  clang/test/Sema/pragma-attribute-strict-subjects.c


Index: clang/test/Sema/pragma-attribute-strict-subjects.c
===
--- clang/test/Sema/pragma-attribute-strict-subjects.c
+++ clang/test/Sema/pragma-attribute-strict-subjects.c
@@ -55,9 +55,9 @@
 // expected-error@-1 {{attribute 'abi_tag' can't be applied to 'enum'}}
 #pragma clang attribute pop
 
-#pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = 
any(enum_constant, function, record(unless(is_union)), variable, 
variable(is_parameter)))
+#pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = 
any(enum_constant, function, record(unless(is_union)), variable, 
variable(is_parameter), enum))
 // FIXME: comma in this diagnostic is wrong.
-// expected-error@-2 {{attribute 'abi_tag' can't be applied to 
'enum_constant', and 'variable(is_parameter)'}}
+// expected-error@-2 {{attribute 'abi_tag' can't be applied to 
'enum_constant', and 'enum'}}
 #pragma clang attribute pop
 
 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = 
any(function, record(unless(is_union)), enum))
Index: clang/test/Parser/pragma-attribute.cpp
===
--- clang/test/Parser/pragma-attribute.cpp
+++ clang/test/Parser/pragma-attribute.cpp
@@ -195,3 +195,12 @@
 #pragma clang attribute pop
 #pragma clang attribute push([[clang::uninitialized]], apply_to = 
any(variable(is_parameter), variable(unless(is_parameter // expected-error 
{{attribute 'uninitialized' can't be applied to 'variable(is_parameter)', and 
'variable(unless(is_parameter))'}}
 #pragma clang attribute pop
+// We're allowed to apply attributes to subsets of allowed subjects.
+#pragma clang attribute push([[clang::no_destroy]], apply_to = variable)
+#pragma clang attribute pop
+#pragma clang attribute push([[clang::no_destroy]], apply_to = 
variable(is_thread_local))
+#pragma clang attribute pop
+#pragma clang attribute push([[clang::no_destroy]], apply_to = 
variable(is_global))
+#pragma clang attribute pop
+#pragma clang attribute push([[clang::no_destroy]], apply_to = 
any(variable(is_parameter), variable(unless(is_parameter
+#pragma clang attribute pop
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -875,12 +875,33 @@
 }
 Rules.clear();
   } else {
-for (const auto &Rule : StrictSubjectMatchRuleSet) {
-  if (Rules.erase(Rule.first)) {
+// Each rule in Rules must be a strict subset of the attribute's
+// SubjectMatch rules.  I.e. we're allowed to use
+// `apply_to=variables(is_global)` on an attrubute with SubjectList<[Var]>,
+// but should not allow `apply_to=variables` on an attribute which has
+// `SubjectList<[GlobalVar]>`.
+for (const auto &StrictRule : StrictSubjectMatchRuleSet) {
+  // First, check for exact match.
+  if (Rules.erase(StrictRule.first)) {
 // Add the rule to the set of attribute receivers only if it's 
supported
 // in the current language mode.
-if (Rule.second)
-  SubjectMatchRules.push_back(Rule.first);
+if (StrictRule.second)
+  SubjectMatchRules.push_back(StrictRule.first);
+  }
+}
+// Check remaining rules for subset matches.
+auto RulesToCheck = Rules;
+for (const auto &Rule : RulesToCheck) {
+  attr::SubjectMatchRule MatchRule = attr::SubjectMatchRule(Rule.first);
+  if (auto ParentRule = getParentAttrMatcherRule(MatchRule)) {
+if (llvm::any_of(StrictSubjectMatchRuleSet,
+ [ParentRule](const auto &StrictRule) {
+   return StrictRule.first == *ParentRule &&
+  StrictRule.second; // IsEnabled
+ })) {
+  SubjectMatchRules.push_back(MatchRule);
+  Rules.erase(MatchRule);
+}
   }
 }
   }


Index: clang/test/Sema/pragma-attribute-strict-subjects.c
===
--- clang/test/Sema/pragma-attribute-strict-subjects.c
+++ clang/test/Sema/pragma-attribute-strict-subjects.c
@@ -55,9 +55,9 @@
 // expected-error@-1 {{attribute 'abi_tag' can't be applied to 'enum'}}
 #pragma clang attribute pop
 
-#pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(enum_constant, function, record(unless(is_union)), variable, variable(is_parameter)))
+#pragma clang attribute push (__att

[PATCH] D98070: [clang-tidy] Add option to ignore macros in readability-function-cognitive-complexity check.

2021-04-12 Thread Alexander Kornienko 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 rG8a944d82cd14: [clang-tidy] Add option to ignore macros in 
readability-function-cognitive… (authored by massberg, committed by alexfh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98070

Files:
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
@@ -10,9 +10,27 @@
 // RUN:   value: 5}, \
 // RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
 // RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=IGNORE-MACROS %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: readability-function-cognitive-complexity.IgnoreMacros, \
+// RUN:   value: "true"}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=GLOBAL-IGNORE-MACROS %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: IgnoreMacros, \
+// RUN:   value: "true"}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
 
 void func_of_complexity_4() {
   // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-GLOBAL-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
   if (1) {
 if (1) {
 }
@@ -34,9 +52,44 @@
 void function_with_macro() {
   // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 0) [readability-function-cognitive-complexity]
   // CHECK-NOTES-THRESHOLD5: :[[@LINE-2]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 5) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'function_with_macro' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-GLOBAL-IGNORE-MACROS: :[[@LINE-4]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 0) [readability-function-cognitive-complexity]
 
   MacroOfComplexity10;
 
   if (1) {
   }
 }
+
+#define noop \
+  {}
+
+#define SomeMacro(x) \
+  if (1) {   \
+x;   \
+  }
+
+void func_macro_1() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_macro_1' has cognitive complexity of 2 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_macro_1' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-GLOBAL-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'func_macro_1' has cognitive complexity of 2 (threshold 0) [readability-function-cognitive-complexity]
+
+  if (1) {
+  }
+  SomeMacro(noop);
+}
+
+void func_macro_2() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_macro_2' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_macro_2' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-GLOBAL-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'func_macro_2' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+
+  if (1) {
+  }
+  // Note that if t

[clang-tools-extra] 8a944d8 - [clang-tidy] Add option to ignore macros in readability-function-cognitive-complexity check.

2021-04-12 Thread Alexander Kornienko via cfe-commits

Author: Jens Massberg
Date: 2021-04-12T18:46:12+02:00
New Revision: 8a944d82cd14001a92ef088229041ee0fb1fd1e6

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

LOG: [clang-tidy] Add option to ignore macros in 
readability-function-cognitive-complexity check.

(this was originally part of https://reviews.llvm.org/D96281 and has been split 
off into its own patch)

If a macro is used within a function, the code inside the macro
doesn't make the code less readable. Instead, for a reader a macro is
more like a function that is called. Thus the code inside a macro
shouldn't increase the complexity of the function in which it is called.
Thus the flag 'IgnoreMacros' is added. If set to 'true' code inside
macros isn't considered during analysis.

This isn't perfect, as now the code of a macro isn't considered at all,
even if it has a high cognitive complexity itself. It might be better if
a macro is considered in the analysis like a function and gets its own
cognitive complexity. Implementing such an analysis seems to be very
complex (if possible at all with the given AST), so we give the user the
option to either ignore macros completely or to let the expanded code
count to the calling function's complexity.

See the code example from vgeof (originally added as note in 
https://reviews.llvm.org/D96281)

   bool doStuff(myClass* objectPtr){
 if(objectPtr == nullptr){
 LOG_WARNING("empty object");
 return false;
 }
 if(objectPtr->getAttribute() == nullptr){
 LOG_WARNING("empty object");
 return false;
 }
 use(objectPtr->getAttribute());
 }

The LOG_WARNING macro itself might have a high complexity, but it do not make 
the
the function more complex to understand like e.g. a 'printf'.

By default 'IgnoreMacros' is set to 'false', which is the original behavior of 
the check.

Reviewed By: lebedev.ri, alexfh

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

Added: 


Modified: 

clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h

clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst

clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
index 94ff38dcec05..0e931c708e4a 100644
--- 
a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
@@ -213,6 +213,9 @@ class FunctionASTVisitor final
 : public RecursiveASTVisitor {
   using Base = RecursiveASTVisitor;
 
+  // If set to true, macros are ignored during analysis.
+  const bool IgnoreMacros;
+
   // The current nesting level (increased by Criteria::IncrementNesting).
   unsigned short CurrentNestingLevel = 0;
 
@@ -223,6 +226,9 @@ class FunctionASTVisitor final
   std::stack> BinaryOperatorsStack;
 
 public:
+  explicit FunctionASTVisitor(const bool IgnoreMacros)
+  : IgnoreMacros(IgnoreMacros){};
+
   bool traverseStmtWithIncreasedNestingLevel(Stmt *Node) {
 ++CurrentNestingLevel;
 bool ShouldContinue = Base::TraverseStmt(Node);
@@ -364,6 +370,9 @@ class FunctionASTVisitor final
 if (!Node)
   return Base::TraverseStmt(Node);
 
+if (IgnoreMacros && Node->getBeginLoc().isMacroID())
+  return true;
+
 // Three following switch()'es have huge duplication, but it is better to
 // keep them separate, to simplify comparing them with the Specification.
 
@@ -493,12 +502,14 @@ 
FunctionCognitiveComplexityCheck::FunctionCognitiveComplexityCheck(
 StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   Threshold(Options.get("Threshold", CognitiveComplexity::DefaultLimit)),
-  DescribeBasicIncrements(Options.get("DescribeBasicIncrements", true)) {}
+  DescribeBasicIncrements(Options.get("DescribeBasicIncrements", true)),
+  IgnoreMacros(Options.get("IgnoreMacros", false)) {}
 
 void FunctionCognitiveComplexityCheck::storeOptions(
 ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "Threshold", Threshold);
   Options.store(Opts, "DescribeBasicIncrements", DescribeBasicIncrements);
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
 void FunctionCognitiveComplexityCheck::registerMatchers(MatchFinder *Finder) {
@@ -513,7 +524,7 @@ void 
FunctionCognitiveComplexityCheck::registerMatchers(MatchFinder *Finder) {
 void FunctionCognitiveComplexityCheck::check(
 const MatchFi

[clang-tools-extra] 8883cb3 - Fix nits.

2021-04-12 Thread Alexander Kornienko via cfe-commits

Author: Alexander Kornienko
Date: 2021-04-12T18:46:13+02:00
New Revision: 8883cb3e4004aebddf9bd0f92ea47ba897397794

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

LOG: Fix nits.

Added: 


Modified: 

clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp

clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
index 0e931c708e4a..9f53a5578b0a 100644
--- 
a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
@@ -227,7 +227,7 @@ class FunctionASTVisitor final
 
 public:
   explicit FunctionASTVisitor(const bool IgnoreMacros)
-  : IgnoreMacros(IgnoreMacros){};
+  : IgnoreMacros(IgnoreMacros) {}
 
   bool traverseStmtWithIncreasedNestingLevel(Stmt *Node) {
 ++CurrentNestingLevel;

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
index 5337a2997d37..79f6bf4ddf4f 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
@@ -28,7 +28,7 @@ Options
 
If set to `true`, the check will ignore code inside macros. Note, that also
any macro arguments are ignored, even if they should count to the 
complexity.
-   As this might change in the future, this option isn't guarantueed to be
+   As this might change in the future, this option isn't guaranteed to be
forward-compatible. Default is `false`.
 
 Building blocks



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


[PATCH] D100085: [X86] Support -march=rocketlake

2021-04-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100085

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


[PATCH] D100310: Add field designated initializers logic in Tooling/Rename

2021-04-12 Thread Daniele Castagna via Phabricator via cfe-commits
dcastagna updated this revision to Diff 336878.
dcastagna added a comment.

Fixed clang-format pre-merge lints


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100310

Files:
  clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  clang/unittests/Rename/RenameClassTest.cpp


Index: clang/unittests/Rename/RenameClassTest.cpp
===
--- clang/unittests/Rename/RenameClassTest.cpp
+++ clang/unittests/Rename/RenameClassTest.cpp
@@ -780,6 +780,27 @@
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, FieldDesignatedInitializers) {
+  std::string Before = R"(
+  struct S {
+int a;
+  };
+  void foo() {
+S s = { .a = 10 };
+s.a = 20;
+  })";
+  std::string Expected = R"(
+  struct S {
+int b;
+  };
+  void foo() {
+S s = { .b = 10 };
+s.b = 20;
+  })";
+  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");
+  CompareSnippets(Expected, After);
+}
+
 // FIXME: investigate why the test fails when adding a new USR to the USRSet.
 TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {
   std::string Before = R"(
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -226,6 +226,24 @@
 return true;
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (isInUSRSet(Decl)) {
+  auto StartLoc = D.getFieldLoc();
+  auto EndLoc = D.getFieldLoc();
+  RenameInfos.push_back({StartLoc, EndLoc,
+/*FromDecl=*/nullptr,
+/*Context=*/nullptr,
+/*Specifier=*/nullptr,
+/*IgnorePrefixQualifiers=*/true});
+}
+  }
+}
+return true;
+  }
+
   bool VisitCXXConstructorDecl(const CXXConstructorDecl *CD) {
 // Fix the constructor initializer when renaming class members.
 for (const auto *Initializer : CD->inits()) {
Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
===
--- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
+++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
@@ -122,6 +122,17 @@
 return BaseType::TraverseNestedNameSpecifierLoc(NNS);
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (!visit(Decl, D.getFieldLoc(), D.getFieldLoc()))
+  return false;
+  }
+}
+return true;
+  }
+
 private:
   const SourceManager &SM;
   const LangOptions &LangOpts;


Index: clang/unittests/Rename/RenameClassTest.cpp
===
--- clang/unittests/Rename/RenameClassTest.cpp
+++ clang/unittests/Rename/RenameClassTest.cpp
@@ -780,6 +780,27 @@
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, FieldDesignatedInitializers) {
+  std::string Before = R"(
+  struct S {
+int a;
+  };
+  void foo() {
+S s = { .a = 10 };
+s.a = 20;
+  })";
+  std::string Expected = R"(
+  struct S {
+int b;
+  };
+  void foo() {
+S s = { .b = 10 };
+s.b = 20;
+  })";
+  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");
+  CompareSnippets(Expected, After);
+}
+
 // FIXME: investigate why the test fails when adding a new USR to the USRSet.
 TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {
   std::string Before = R"(
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -226,6 +226,24 @@
 return true;
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (isInUSRSet(Decl)) {
+  auto StartLoc = D.getFieldLoc();
+  auto EndLoc = D.getFieldLoc();
+  RenameInfos.push_back({StartLoc, EndLoc,
+/*FromDecl=*/nullptr,
+/*Context=

[PATCH] D100266: [RISCV][Clang] Add vmv and vfmv series intrinsic functions.

2021-04-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100266

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


[PATCH] D99790: [CGCall] Annotate `this` argument with alignment

2021-04-12 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 added a comment.

+1 on eagerly awaiting a fix. a 3% regression on astar (AArch64, LTO) bisects 
to @lebedev.ri 's revert: 
https://reviews.llvm.org/rG6270b3a1eafaba4279e021418c5a2c5a35abc002 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99790

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


[PATCH] D100161: Redistribute energy for Corpus

2021-04-12 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a subscriber: metzman.
morehouse added a comment.

Thanks for sharing your data.  Took a quick look and seems promising.

I would like to try this on FuzzBench before accepting the patch though.  
FuzzBench has a very nice experimental framework for evaluating changes like 
this.

> It seems that FuzzBench does not accept this parallel mode evaluation.

I talked to @metzman who manages FuzzBench.  Sounds like you're correct, 
FuzzBench uses only one worker process in fork mode.  @metzman said we could 
probably run a special experiment with more workers to evaluate this patch.

Another approach that might be worth doing, is to make the patch effective even 
for a single worker.  For example, maybe we randomly pick from a subset of the 
corpus for that single worker.

Also, I'm curious how the number of fork-mode workers affects efficacy.  I can 
imagine with lots of workers that this patch could perform much worse.  
Specifically if we have a small number of corpus elements per worker, the 
crossover mutation becomes quite limited.




Comment at: compiler-rt/lib/fuzzer/FuzzerFork.cpp:143
   for (size_t i = 0; i < CorpusSubsetSize; i++) {
-auto &SF = Files[Rand->SkewTowardsLast(Files.size())];
-Seeds += (Seeds.empty() ? "" : ",") + SF;
-CollectDFT(SF);
+size_t j = Rand->SkewTowardsLast(AverageSize);
+size_t m = j + StartIndex;

Does keeping this skew within each subset of the corpus help?  Would a 
uniform-random approach change efficacy?



Comment at: compiler-rt/lib/fuzzer/FuzzerFork.cpp:150
+}
+else  {
+auto &SF = Files[Rand->SkewTowardsLast(Files.size())];

So we would still use the current strategy on the rare occasion when we get an 
`m` index past the end of `Files`.  I imagine there's always some cases where 
the original strategy will be beneficial at least for the crossover mutation.  
Maybe we could make the probability of using the current strategy more 
explicit. Something like

```
if (RandInt(100) < 90)
  // Use new strategy
else
  // Use old strategy
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100161

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


[PATCH] D100161: Redistribute energy for Corpus

2021-04-12 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

Also, the descriptions states:

> Divide the corpus into n parts according to size.

Is it really according to size?  IIUC when there are multiple worker processes, 
any new coverage they have simply gets appended to `Files`.  So `Files` is not 
necessarily sorted by size.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100161

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


[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-12 Thread Josh Haberman via Phabricator via cfe-commits
haberman updated this revision to Diff 336894.
haberman added a comment.

- Switch to isa<> for type check.
- Merge branch 'main' into musttail


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99517

Files:
  clang/include/clang/AST/IgnoreExpr.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/EHScopeStack.h
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/CodeGen/attr-musttail.cpp
  clang/test/Sema/attr-musttail.c
  clang/test/Sema/attr-musttail.cpp
  clang/test/Sema/attr-musttail.m

Index: clang/test/Sema/attr-musttail.m
===
--- /dev/null
+++ clang/test/Sema/attr-musttail.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-objc-root-class -verify %s
+
+void TestObjcBlock(void) {
+  void (^x)(void) = ^(void) {
+__attribute__((musttail)) return TestObjcBlock(); // expected-error{{'musttail' attribute cannot be used from a block}}
+  };
+  __attribute__((musttail)) return x();
+}
+
+void ReturnsVoid(void);
+void TestObjcBlockVar(void) {
+  __block int i = 0;  // expected-note{{jump exits scope of __block variable}}
+  __attribute__((musttail)) return ReturnsVoid(); // expected-error{{cannot perform a tail call from this return statement}}
+}
+
+__attribute__((objc_root_class))
+@interface TestObjcClass
+@end
+
+@implementation TestObjcClass
+
+- (void)testObjCMethod {
+  __attribute__((musttail)) return ReturnsVoid(); // expected-error{{'musttail' attribute cannot be used from an Objective-C function}}
+}
+
+@end
Index: clang/test/Sema/attr-musttail.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-musttail.cpp
@@ -0,0 +1,201 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fms-extensions -fcxx-exceptions -fopenmp %s
+
+int ReturnsInt1();
+int Func1() {
+  [[clang::musttail]] ReturnsInt1();  // expected-error {{'musttail' attribute only applies to return statements}}
+  [[clang::musttail(1, 2)]] return ReturnsInt1(); // expected-error {{'musttail' attribute takes no arguments}}
+  [[clang::musttail]] return 5;   // expected-error {{'musttail' attribute requires that the return value is the result of a function call}}
+  [[clang::musttail]] return ReturnsInt1();
+}
+
+void NoFunctionCall() {
+  [[clang::musttail]] return; // expected-error {{'musttail' attribute requires that the return value is the result of a function call}}
+}
+
+[[clang::musttail]] static int int_val = ReturnsInt1(); // expected-error {{'musttail' attribute cannot be applied to a declaration}}
+
+void NoParams(); // expected-note {{target function has different number of parameters (expected 1 but has 0)}}
+void TestParamArityMismatch(int x) {
+  [[clang::musttail]] return NoParams(); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+void LongParam(long x); // expected-note {{target function has type mismatch at 1st parameter (expected 'long' but has 'int')}}
+void TestParamTypeMismatch(int x) {
+  [[clang::musttail]] return LongParam(x); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+long ReturnsLong(); // expected-note {{target function has different return type ('int' expected but has 'long')}}
+int TestReturnTypeMismatch() {
+  [[clang::musttail]] return ReturnsLong(); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+struct Struct1 {
+  void MemberFunction(); // expected-note {{target function is a member of different class (expected 'void' but has 'Struct1')}}
+};
+void TestNonMemberToMember() {
+  Struct1 st;
+  [[clang::musttail]] return st.MemberFunction(); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+void ReturnsVoid(); // expected-note {{target function is a member of different class (expected 'Struct2' but has 'void')}}
+struct Struct2 {
+  void TestMemberToNonMember() {
+[[clang::musttail]] return ReturnsVoid(); // expected-error{{'musttail' attribute requires that caller and callee have compatible function signatures}}
+  }
+};
+
+class HasNonTrivialDestructor {
+public:
+  ~HasNonTrivialDestructor() {}
+  int ReturnsInt();
+};
+
+void ReturnsVoid2();
+void TestNonTrivialDestructorInScope() {

[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-12 Thread Josh Haberman via Phabricator via cfe-commits
haberman marked an inline comment as done.
haberman added inline comments.



Comment at: clang/lib/Sema/SemaStmt.cpp:697-699
+  } else if (VD && dyn_cast(VD->getType())) {
+// Call is: obj->*method_ptr or obj.*method_ptr
+const auto *MPT = VD->getType()->castAs();

aaron.ballman wrote:
> I'm not certain if I should take a shower after writing that code or not, but 
> it's one potential way not to perform the cast twice.
> 
> If that code is too odious for others, we should at least change the 
> `dyn_cast<>` in the `else if` to be an `isa<>`.
I changed `dyn_cast<>` to `isa<>`. If @rsmith concurs about the 
`dyn_cast_or_null<>` variant I'll switch to that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99517

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


[clang] 0a92aff - Replace uses of std::iterator with explicit using

2021-04-12 Thread Fangrui Song via cfe-commits

Author: Hamza Sood
Date: 2021-04-12T10:47:14-07:00
New Revision: 0a92aff721f43406691e38a0965fd0c917121d09

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

LOG: Replace uses of std::iterator with explicit using

This patch removes all uses of `std::iterator`, which was deprecated in C++17.
While this isn't currently an issue while compiling LLVM, it's useful for those 
using LLVM as a library.

For some reason there're a few places that were seemingly able to use `std` 
functions unqualified, which no longer works after this patch. I've updated 
those places, but I'm not really sure why it worked in the first place.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/include/clang/AST/StmtIterator.h
clang/include/clang/Rewrite/Core/RewriteRope.h
llvm/include/llvm/ADT/BreadthFirstIterator.h
llvm/include/llvm/ADT/CoalescingBitVector.h
llvm/include/llvm/ADT/DepthFirstIterator.h
llvm/include/llvm/ADT/EquivalenceClasses.h
llvm/include/llvm/ADT/ImmutableSet.h
llvm/include/llvm/ADT/IntervalMap.h
llvm/include/llvm/ADT/PostOrderIterator.h
llvm/include/llvm/ADT/SparseMultiSet.h
llvm/include/llvm/ADT/iterator.h
llvm/include/llvm/Analysis/AliasSetTracker.h
llvm/include/llvm/Analysis/MemorySSA.h
llvm/include/llvm/Analysis/RegionIterator.h
llvm/include/llvm/CodeGen/MachineRegisterInfo.h
llvm/include/llvm/CodeGen/ScheduleDAG.h
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
llvm/include/llvm/IR/CFG.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/include/llvm/IR/GetElementPtrTypeIterator.h
llvm/include/llvm/IR/Metadata.h
llvm/include/llvm/IR/Module.h
llvm/include/llvm/IR/Value.h
llvm/include/llvm/IR/ValueMap.h
llvm/include/llvm/Object/ELFTypes.h
llvm/include/llvm/Object/SymbolicFile.h
llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
llvm/include/llvm/ProfileData/InstrProfReader.h
llvm/include/llvm/Support/LineIterator.h
llvm/include/llvm/Support/TargetRegistry.h
llvm/include/llvm/Support/YAMLParser.h
llvm/include/llvm/TextAPI/ArchitectureSet.h
llvm/include/llvm/Transforms/Scalar/GVNExpression.h
llvm/lib/Analysis/CFGPrinter.cpp
llvm/tools/llvm-objdump/MachODump.cpp
polly/include/polly/Support/VirtualInstruction.h

Removed: 




diff  --git a/clang/include/clang/AST/StmtIterator.h 
b/clang/include/clang/AST/StmtIterator.h
index bcdb0df829fba..e98408c51a505 100644
--- a/clang/include/clang/AST/StmtIterator.h
+++ b/clang/include/clang/AST/StmtIterator.h
@@ -74,14 +74,17 @@ class StmtIteratorBase {
 };
 
 template 
-class StmtIteratorImpl : public StmtIteratorBase,
- public std::iterator {
+class StmtIteratorImpl : public StmtIteratorBase {
 protected:
   StmtIteratorImpl(const StmtIteratorBase& RHS) : StmtIteratorBase(RHS) {}
 
 public:
+  using iterator_category = std::forward_iterator_tag;
+  using value_type = REFERENCE;
+  using 
diff erence_type = std::ptr
diff _t;
+  using pointer = REFERENCE;
+  using reference = REFERENCE;
+
   StmtIteratorImpl() = default;
   StmtIteratorImpl(Stmt **s) : StmtIteratorBase(s) {}
   StmtIteratorImpl(Decl **dgi, Decl **dge) : StmtIteratorBase(dgi, dge) {}

diff  --git a/clang/include/clang/Rewrite/Core/RewriteRope.h 
b/clang/include/clang/Rewrite/Core/RewriteRope.h
index 039927c48b08a..8fa7af245eb81 100644
--- a/clang/include/clang/Rewrite/Core/RewriteRope.h
+++ b/clang/include/clang/Rewrite/Core/RewriteRope.h
@@ -83,8 +83,7 @@ namespace clang {
   /// over bytes that are in a RopePieceBTree.  This first iterates over bytes
   /// in a RopePiece, then iterates over RopePiece's in a RopePieceBTreeLeaf,
   /// then iterates over RopePieceBTreeLeaf's in a RopePieceBTree.
-  class RopePieceBTreeIterator :
-  public std::iterator {
+  class RopePieceBTreeIterator {
 /// CurNode - The current B+Tree node that we are inspecting.
 const void /*RopePieceBTreeLeaf*/ *CurNode = nullptr;
 
@@ -96,6 +95,12 @@ namespace clang {
 unsigned CurChar = 0;
 
   public:
+using iterator_category = std::forward_iterator_tag;
+using value_type = const char;
+using 
diff erence_type = std::ptr
diff _t;
+using pointer = value_type *;
+using reference = value_type &;
+
 RopePieceBTreeIterator() = default;
 RopePieceBTreeIterator(const void /*RopePieceBTreeNode*/ *N);
 

diff  --git a/llvm/include/llvm/ADT/BreadthFirstIterator.h 
b/llvm/include/llvm/ADT/BreadthFirstIterator.h
index e97d76680db8d..e8af66d7527eb 100644
--- a/llvm/include/llvm/ADT/BreadthFirstIterator.h
+++ b/llvm/include/llvm/ADT/BreadthFirstIterator.h
@@ -44,11 +44,15 @@ template ::NodeRef>,

[PATCH] D67586: Replace uses of std::iterator with explicit using

2021-04-12 Thread Fangrui Song 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 rG0a92aff721f4: Replace uses of std::iterator with explicit 
using (authored by hamzasood, committed by MaskRay).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67586?vs=336673&id=336898#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67586

Files:
  clang/include/clang/AST/StmtIterator.h
  clang/include/clang/Rewrite/Core/RewriteRope.h
  llvm/include/llvm/ADT/BreadthFirstIterator.h
  llvm/include/llvm/ADT/CoalescingBitVector.h
  llvm/include/llvm/ADT/DepthFirstIterator.h
  llvm/include/llvm/ADT/EquivalenceClasses.h
  llvm/include/llvm/ADT/ImmutableSet.h
  llvm/include/llvm/ADT/IntervalMap.h
  llvm/include/llvm/ADT/PostOrderIterator.h
  llvm/include/llvm/ADT/SparseMultiSet.h
  llvm/include/llvm/ADT/iterator.h
  llvm/include/llvm/Analysis/AliasSetTracker.h
  llvm/include/llvm/Analysis/MemorySSA.h
  llvm/include/llvm/Analysis/RegionIterator.h
  llvm/include/llvm/CodeGen/MachineRegisterInfo.h
  llvm/include/llvm/CodeGen/ScheduleDAG.h
  llvm/include/llvm/CodeGen/SelectionDAGNodes.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
  llvm/include/llvm/IR/CFG.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/include/llvm/IR/GetElementPtrTypeIterator.h
  llvm/include/llvm/IR/Metadata.h
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/IR/Value.h
  llvm/include/llvm/IR/ValueMap.h
  llvm/include/llvm/Object/ELFTypes.h
  llvm/include/llvm/Object/SymbolicFile.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/include/llvm/Support/LineIterator.h
  llvm/include/llvm/Support/TargetRegistry.h
  llvm/include/llvm/Support/YAMLParser.h
  llvm/include/llvm/TextAPI/ArchitectureSet.h
  llvm/include/llvm/Transforms/Scalar/GVNExpression.h
  llvm/lib/Analysis/CFGPrinter.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  polly/include/polly/Support/VirtualInstruction.h

Index: polly/include/polly/Support/VirtualInstruction.h
===
--- polly/include/polly/Support/VirtualInstruction.h
+++ polly/include/polly/Support/VirtualInstruction.h
@@ -167,12 +167,10 @@
 };
 
 /// An iterator for virtual operands.
-class VirtualOperandIterator
-: public std::iterator {
+class VirtualOperandIterator {
   friend class VirtualInstruction;
   friend class VirtualUse;
 
-  using super = std::iterator;
   using Self = VirtualOperandIterator;
 
   ScopStmt *User;
@@ -182,8 +180,11 @@
   : User(User), U(U) {}
 
 public:
-  using pointer = typename super::pointer;
-  using reference = typename super::reference;
+  using iterator_category = std::forward_iterator_tag;
+  using value_type = VirtualUse;
+  using difference_type = std::ptrdiff_t;
+  using pointer = value_type *;
+  using reference = value_type &;
 
   inline bool operator==(const Self &that) const {
 assert(this->User == that.User);
Index: llvm/tools/llvm-objdump/MachODump.cpp
===
--- llvm/tools/llvm-objdump/MachODump.cpp
+++ llvm/tools/llvm-objdump/MachODump.cpp
@@ -466,7 +466,7 @@
 
   if (isExtern) {
 symbol_iterator SI = O->symbol_begin();
-advance(SI, Val);
+std::advance(SI, Val);
 S = unwrapOrError(SI->getName(), FileName);
   } else {
 section_iterator SI = O->section_begin();
@@ -478,7 +478,7 @@
 uint32_t I = Val - 1;
 while (I != 0 && SI != O->section_end()) {
   --I;
-  advance(SI, 1);
+  std::advance(SI, 1);
 }
 if (SI == O->section_end()) {
   Fmt << Val << " (?,?)";
Index: llvm/lib/Analysis/CFGPrinter.cpp
===
--- llvm/lib/Analysis/CFGPrinter.cpp
+++ llvm/lib/Analysis/CFGPrinter.cpp
@@ -286,8 +286,7 @@
   };
   /// The post order traversal iteration is done to know the status of
   /// isHiddenBasicBlock for all the successors on the current BB.
-  for_each(po_begin(&F->getEntryBlock()), po_end(&F->getEntryBlock()),
-   evaluateBB);
+  llvm::for_each(post_order(&F->getEntryBlock()), evaluateBB);
 }
 
 bool DOTGraphTraits::isNodeHidden(const BasicBlock *Node,
Index: llvm/include/llvm/Transforms/Scalar/GVNExpression.h
===
--- llvm/include/llvm/Transforms/Scalar/GVNExpression.h
+++ llvm/include/llvm/Transforms/Scalar/GVNExpression.h
@@ -240,14 +240,19 @@
   }
 };
 
-class op_inserter
-: public std::iterator {
+class op_inserter {
 private:
   using Container = BasicExpression;
 
   Container *BE;
 
 public:
+  using iterator_category = std::output_iterator_tag;
+  using value_type = void;
+  using difference_type = void;
+  using pointer = void;
+  using reference = void;

[PATCH] D100310: Add field designated initializers logic in Tooling/Rename

2021-04-12 Thread Daniele Castagna via Phabricator via cfe-commits
dcastagna updated this revision to Diff 336900.
dcastagna added a comment.

Actually run git clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100310

Files:
  clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  clang/unittests/Rename/RenameClassTest.cpp


Index: clang/unittests/Rename/RenameClassTest.cpp
===
--- clang/unittests/Rename/RenameClassTest.cpp
+++ clang/unittests/Rename/RenameClassTest.cpp
@@ -780,6 +780,27 @@
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, FieldDesignatedInitializers) {
+  std::string Before = R"(
+  struct S {
+int a;
+  };
+  void foo() {
+S s = { .a = 10 };
+s.a = 20;
+  })";
+  std::string Expected = R"(
+  struct S {
+int b;
+  };
+  void foo() {
+S s = { .b = 10 };
+s.b = 20;
+  })";
+  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");
+  CompareSnippets(Expected, After);
+}
+
 // FIXME: investigate why the test fails when adding a new USR to the USRSet.
 TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {
   std::string Before = R"(
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -226,6 +226,24 @@
 return true;
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (isInUSRSet(Decl)) {
+  auto StartLoc = D.getFieldLoc();
+  auto EndLoc = D.getFieldLoc();
+  RenameInfos.push_back({StartLoc, EndLoc,
+/*FromDecl=*/nullptr,
+/*Context=*/nullptr,
+/*Specifier=*/nullptr,
+/*IgnorePrefixQualifiers=*/true});
+}
+  }
+}
+return true;
+  }
+
   bool VisitCXXConstructorDecl(const CXXConstructorDecl *CD) {
 // Fix the constructor initializer when renaming class members.
 for (const auto *Initializer : CD->inits()) {
Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
===
--- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
+++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
@@ -122,6 +122,17 @@
 return BaseType::TraverseNestedNameSpecifierLoc(NNS);
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (!visit(Decl, D.getFieldLoc(), D.getFieldLoc()))
+  return false;
+  }
+}
+return true;
+  }
+
 private:
   const SourceManager &SM;
   const LangOptions &LangOpts;


Index: clang/unittests/Rename/RenameClassTest.cpp
===
--- clang/unittests/Rename/RenameClassTest.cpp
+++ clang/unittests/Rename/RenameClassTest.cpp
@@ -780,6 +780,27 @@
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, FieldDesignatedInitializers) {
+  std::string Before = R"(
+  struct S {
+int a;
+  };
+  void foo() {
+S s = { .a = 10 };
+s.a = 20;
+  })";
+  std::string Expected = R"(
+  struct S {
+int b;
+  };
+  void foo() {
+S s = { .b = 10 };
+s.b = 20;
+  })";
+  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");
+  CompareSnippets(Expected, After);
+}
+
 // FIXME: investigate why the test fails when adding a new USR to the USRSet.
 TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {
   std::string Before = R"(
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -226,6 +226,24 @@
 return true;
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (isInUSRSet(Decl)) {
+  auto StartLoc = D.getFieldLoc();
+  auto EndLoc = D.getFieldLoc();
+  RenameInfos.push_back({StartLoc, EndLoc,
+/*FromDecl=*/nullptr,
+/*Context=*/nul

[PATCH] D100148: [Driver] Fix compiler-rt lookup for x32

2021-04-12 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added a comment.

In D100148#2683325 , @glaubitz wrote:

> Hi! Can we get this patch merged as-is or do we need anything else?

Sorry, miscommunication. I was thinking you could use this to update D99988 
 to actually build the relevant compiler-rt 
bits for x32, and then once both that and this are ready, both can be submitted 
at the same time. The reason for that is that this is not useful by itself, and 
if it turns out that D99988  actually requires 
some other clang change as well that we are not seeing yet, it will be easier 
to update this if it has not been pushed yet. Do you think it would be better 
to push this first?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100148

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-04-12 Thread Alexey Bader via Phabricator via cfe-commits
bader marked an inline comment as done.
bader added inline comments.



Comment at: clang/include/clang/AST/Type.h:488
(A == LangAS::opencl_global && (B == LangAS::opencl_global_device ||
B == LangAS::opencl_global_host)) ||
// Consider pointer size address spaces to be equivalent to default.

BTW, we need enable `global_device` and `global_host` attributes from 
https://reviews.llvm.org/D82174 for SYCL USM feature. I have following question 
regarding this: should I create a follow-up patch or we can enable all 
attributes for SYCL at once?



Comment at: clang/test/CodeGenSYCL/convergent.cpp:2
 // RUN: %clang_cc1 -fsycl-is-device -emit-llvm -disable-llvm-passes \
-// RUN:  -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | \
 // RUN:   FileCheck %s

Anastasia wrote:
> Is this change related? I thought we are not adding the environment component 
> after all...
> 
>  
> Is this change related? I thought we are not adding the environment component 
> after all...

While I was removing `-sycldevice` environment component from the patch, I 
noticed that one of the committed tests already uses it.
https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGenSYCL/convergent.cpp#L2

Do you want to me to create a separate review request for this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D100148: [Driver] Fix compiler-rt lookup for x32

2021-04-12 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

In D100148#2683710 , @hvdijk wrote:

> In D100148#2683325 , @glaubitz 
> wrote:
>
>> Hi! Can we get this patch merged as-is or do we need anything else?
>
> Sorry, miscommunication. I was thinking you could use this to update D99988 
>  to actually build the relevant compiler-rt 
> bits for x32, and then once both that and this are ready, both can be 
> submitted at the same time. The reason for that is that this is not useful by 
> itself, and if it turns out that D99988  
> actually requires some other clang change as well that we are not seeing yet, 
> it will be easier to update this if it has not been pushed yet. Do you think 
> it would be better to push this first?

Understood. However, I'm not really sure what else we need. Do we just take the 
architecture definition from here to pass the proper flags to the compiler or 
do we also need to add
some x32-specific code?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100148

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


[PATCH] D100148: [Driver] Fix compiler-rt lookup for x32

2021-04-12 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added a comment.

In D100148#2683748 , @glaubitz wrote:

> Understood. However, I'm not really sure what else we need. Do we just take 
> the architecture definition from here to pass the proper flags to the 
> compiler or do we also need to add
> some x32-specific code?

My personal opinion: I would say to enable the compiler-rt bits that are 
already correct for x32, which should only require passing the proper flags. 
Beyond the libsanitizer bits, I do not know which other bits, if any, might 
already be correct for x32 though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100148

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


[PATCH] D99732: [AST] Pick last tentative definition as the acting definition

2021-04-12 Thread Benson Chu via Phabricator via cfe-commits
pestctrl added a comment.

Ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99732

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


[PATCH] D100187: [OPENMP]Fix PR49115: Incorrect results for scan directive.

2021-04-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 336909.
ABataev added a comment.

Rebase + fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100187

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_for_scan_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp

Index: clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp
===
--- clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp
+++ clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp
@@ -18,10 +18,15 @@
   static float a[10];
   static double b;
 
-  // CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+  // CHECK: call i8* @llvm.stacksave()
+  // CHECK: [[A_BUF_SIZE:%.+]] = mul nuw i64 10, [[NUM_ELEMS:%[^,]+]]
+
+  // float a_buffer[10][n];
+  // CHECK: [[A_BUF:%.+]] = alloca float, i64 [[A_BUF_SIZE]],
+  // CHECK: [[B_BUF:%.+]] = alloca double, i64 10,
+
   // CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
 
-  // CHECK: call i8* @llvm.stacksave()
   // CHECK: [[A_BUF_SIZE:%.+]] = mul nuw i64 10, [[NUM_ELEMS:%[^,]+]]
 
   // float a_buffer[10][n];
@@ -29,6 +34,9 @@
 
   // double b_buffer[10];
   // CHECK: [[B_BUF:%.+]] = alloca double, i64 10,
+  // CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+  // CHECK: call void @llvm.stackrestore(i8*
+
 #pragma omp parallel for simd reduction(inscan, +:a[:n], b)
   for (int i = 0; i < 10; ++i) {
 // CHECK: call void @__kmpc_for_static_init_4(
@@ -42,8 +50,8 @@
 // a_buffer[i][0..n] = a_priv[[0..n];
 // CHECK: [[BASE_IDX_I:%.+]] = load i32, i32* [[IV_ADDR:%.+]],
 // CHECK: [[BASE_IDX:%.+]] = zext i32 [[BASE_IDX_I]] to i64
-// CHECK: [[IDX:%.+]] = mul nsw i64 [[BASE_IDX]], [[NUM_ELEMS]]
-// CHECK: [[A_BUF_IDX:%.+]] = getelementptr inbounds float, float* [[A_BUF]], i64 [[IDX]]
+// CHECK: [[IDX:%.+]] = mul nsw i64 [[BASE_IDX]], [[NUM_ELEMS:%.+]]
+// CHECK: [[A_BUF_IDX:%.+]] = getelementptr inbounds float, float* [[A_BUF:%.+]], i64 [[IDX]]
 // CHECK: [[A_PRIV:%.+]] = getelementptr inbounds [10 x float], [10 x float]* [[A_PRIV_ADDR:%.+]], i64 0, i64 0
 // CHECK: [[BYTES:%.+]] = mul nuw i64 [[NUM_ELEMS:%.+]], 4
 // CHECK: [[DEST:%.+]] = bitcast float* [[A_BUF_IDX]] to i8*
@@ -51,7 +59,7 @@
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}[[DEST]], i8* {{.*}}[[SRC]], i64 [[BYTES]], i1 false)
 
 // b_buffer[i] = b_priv;
-// CHECK: [[B_BUF_IDX:%.+]] = getelementptr inbounds double, double* [[B_BUF]], i64 [[BASE_IDX]]
+// CHECK: [[B_BUF_IDX:%.+]] = getelementptr inbounds double, double* [[B_BUF:%.+]], i64 [[BASE_IDX]]
 // CHECK: [[B_PRIV:%.+]] = load double, double* [[B_PRIV_ADDR]],
 // CHECK: store double [[B_PRIV]], double* [[B_BUF_IDX]],
 // CHECK: br label %[[LOOP_CONTINUE:.+]]
@@ -158,17 +166,8 @@
 // CHECK: [[LOOP_CONTINUE]]:
 // CHECK: call void @llvm.stackrestore(i8* %
 // CHECK: call void @__kmpc_for_static_fini(
-// CHECK: call void @llvm.stackrestore(i8*
   }
 
-  // CHECK: call i8* @llvm.stacksave()
-  // CHECK: [[A_BUF_SIZE:%.+]] = mul nuw i64 10, [[NUM_ELEMS:%[^,]+]]
-
-  // float a_buffer[10][n];
-  // CHECK: [[A_BUF:%.+]] = alloca float, i64 [[A_BUF_SIZE]],
-
-  // double b_buffer[10];
-  // CHECK: [[B_BUF:%.+]] = alloca double, i64 10,
 #pragma omp parallel for simd reduction(inscan, +:a[:n], b)
   for (int i = 0; i < 10; ++i) {
 // CHECK: call void @__kmpc_for_static_init_4(
@@ -185,8 +184,8 @@
 // a_buffer[i][0..n] = a_priv[[0..n];
 // CHECK: [[BASE_IDX_I:%.+]] = load i32, i32* [[IV_ADDR:%.+]],
 // CHECK: [[BASE_IDX:%.+]] = zext i32 [[BASE_IDX_I]] to i64
-// CHECK: [[IDX:%.+]] = mul nsw i64 [[BASE_IDX]], [[NUM_ELEMS]]
-// CHECK: [[A_BUF_IDX:%.+]] = getelementptr inbounds float, float* [[A_BUF]], i64 [[IDX]]
+// CHECK: [[IDX:%.+]] = mul nsw i64 [[BASE_IDX]], [[NUM_ELEMS:%.+]]
+// CHECK: [[A_BUF_IDX:%.+]] = getelementptr inbounds float, float* [[A_BUF:%.+]], i64 [[IDX]]
 // CHECK: [[A_PRIV:%.+]] = getelementptr inbounds [10 x float], [10 x float]* [[A_PRIV_ADDR:%.+]], i64 0, i64 0
 // CHECK: [[BYTES:%.+]] = mul nuw i64 [[NUM_ELEMS:%.+]], 4
 // CHECK: [[DEST:%.+]] = bitcast float* [[A_BUF_IDX]] to i8*
@@ -194,7 +193,7 @@
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}[[DEST]], i8* {{.*}}[[SRC]], i64 [[BYTES]], i1 false)
 
 // b_buffer[i] = b_priv;
-// CHECK: [[B_BUF_IDX:%.+]] = getelementptr inbounds double, double* [[B_BUF]], i64 [[BASE_IDX]]
+// CHECK: [[B_BUF_IDX:%.+]] = getelementptr inbounds double, double* [[B_BUF:%.+]], i64 [[BASE_IDX]]
 // CHECK: [[B_PRIV:%.+]] = load double, double* [[B_PRIV_ADDR]],
 // CHECK: store double [[B_PRIV]], double* [[B_BUF_IDX]],
 // CHECK: br label %[[LOOP_CON

[PATCH] D99568: [clang][invocation] Fix copy constructor, add copy assignment to CompilerInvocation

2021-04-12 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D99568#2682815 , @jansvoboda11 
wrote:

> Ping.

Thanks for the ping; I'd completely missed your follow-up. Just fixing 
AnalyzerOptions for now sounds great.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99568

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


[PATCH] D100310: Add field designated initializers logic in Tooling/Rename

2021-04-12 Thread Daniele Castagna via Phabricator via cfe-commits
dcastagna updated this revision to Diff 336912.
dcastagna added a comment.

clang-format again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100310

Files:
  clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  clang/unittests/Rename/RenameClassTest.cpp


Index: clang/unittests/Rename/RenameClassTest.cpp
===
--- clang/unittests/Rename/RenameClassTest.cpp
+++ clang/unittests/Rename/RenameClassTest.cpp
@@ -780,6 +780,27 @@
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, FieldDesignatedInitializers) {
+  std::string Before = R"(
+  struct S {
+int a;
+  };
+  void foo() {
+S s = { .a = 10 };
+s.a = 20;
+  })";
+  std::string Expected = R"(
+  struct S {
+int b;
+  };
+  void foo() {
+S s = { .b = 10 };
+s.b = 20;
+  })";
+  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");
+  CompareSnippets(Expected, After);
+}
+
 // FIXME: investigate why the test fails when adding a new USR to the USRSet.
 TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {
   std::string Before = R"(
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -226,6 +226,24 @@
 return true;
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (isInUSRSet(Decl)) {
+  auto StartLoc = D.getFieldLoc();
+  auto EndLoc = D.getFieldLoc();
+  RenameInfos.push_back({StartLoc, EndLoc,
+ /*FromDecl=*/nullptr,
+ /*Context=*/nullptr,
+ /*Specifier=*/nullptr,
+ /*IgnorePrefixQualifiers=*/true});
+}
+  }
+}
+return true;
+  }
+
   bool VisitCXXConstructorDecl(const CXXConstructorDecl *CD) {
 // Fix the constructor initializer when renaming class members.
 for (const auto *Initializer : CD->inits()) {
Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
===
--- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
+++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
@@ -122,6 +122,17 @@
 return BaseType::TraverseNestedNameSpecifierLoc(NNS);
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (!visit(Decl, D.getFieldLoc(), D.getFieldLoc()))
+  return false;
+  }
+}
+return true;
+  }
+
 private:
   const SourceManager &SM;
   const LangOptions &LangOpts;


Index: clang/unittests/Rename/RenameClassTest.cpp
===
--- clang/unittests/Rename/RenameClassTest.cpp
+++ clang/unittests/Rename/RenameClassTest.cpp
@@ -780,6 +780,27 @@
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, FieldDesignatedInitializers) {
+  std::string Before = R"(
+  struct S {
+int a;
+  };
+  void foo() {
+S s = { .a = 10 };
+s.a = 20;
+  })";
+  std::string Expected = R"(
+  struct S {
+int b;
+  };
+  void foo() {
+S s = { .b = 10 };
+s.b = 20;
+  })";
+  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");
+  CompareSnippets(Expected, After);
+}
+
 // FIXME: investigate why the test fails when adding a new USR to the USRSet.
 TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {
   std::string Before = R"(
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -226,6 +226,24 @@
 return true;
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (isInUSRSet(Decl)) {
+  auto StartLoc = D.getFieldLoc();
+  auto EndLoc = D.getFieldLoc();
+  RenameInfos.push_back({StartLoc, EndLoc,
+ /*FromDecl=*/nullptr,
+ /*Context=*/nullptr,

[clang-tools-extra] fc1e146 - Fix documentation typo.

2021-04-12 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-04-12T11:39:08-07:00
New Revision: fc1e146e4412334d6c70173c345a698a01b122b8

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

LOG: Fix documentation typo.

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/modernize-use-nodiscard.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/modernize-use-nodiscard.rst 
b/clang-tools-extra/docs/clang-tidy/checks/modernize-use-nodiscard.rst
index 3048db8682a0..1f5639cdb88b 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize-use-nodiscard.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize-use-nodiscard.rst
@@ -41,8 +41,8 @@ transforms to:
 
 .. code-block:: c++
 
-[[nodiscard] bool empty() const;
-[[nodiscard] bool empty(int i) const;
+[[nodiscard]] bool empty() const;
+[[nodiscard]] bool empty(int i) const;
 
 Options
 ---



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


Re: [PATCH] D100310: Add field designated initializers logic in Tooling/Rename

2021-04-12 Thread Justin Lebar via cfe-commits
I guess you need me or Michael to push this.  Happy to do so once you're
happy with it.

On Mon, Apr 12, 2021 at 11:33 AM Daniele Castagna via Phabricator <
revi...@reviews.llvm.org> wrote:

> dcastagna updated this revision to Diff 336912.
> dcastagna added a comment.
>
> clang-format again
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D100310/new/
>
> https://reviews.llvm.org/D100310
>
> Files:
>   clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
>   clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
>   clang/unittests/Rename/RenameClassTest.cpp
>
>
> Index: clang/unittests/Rename/RenameClassTest.cpp
> ===
> --- clang/unittests/Rename/RenameClassTest.cpp
> +++ clang/unittests/Rename/RenameClassTest.cpp
> @@ -780,6 +780,27 @@
>CompareSnippets(Expected, After);
>  }
>
> +TEST_F(ClangRenameTest, FieldDesignatedInitializers) {
> +  std::string Before = R"(
> +  struct S {
> +int a;
> +  };
> +  void foo() {
> +S s = { .a = 10 };
> +s.a = 20;
> +  })";
> +  std::string Expected = R"(
> +  struct S {
> +int b;
> +  };
> +  void foo() {
> +S s = { .b = 10 };
> +s.b = 20;
> +  })";
> +  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");
> +  CompareSnippets(Expected, After);
> +}
> +
>  // FIXME: investigate why the test fails when adding a new USR to the
> USRSet.
>  TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {
>std::string Before = R"(
> Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
> ===
> --- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
> +++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
> @@ -226,6 +226,24 @@
>  return true;
>}
>
> +  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
> +for (const DesignatedInitExpr::Designator &D : E->designators()) {
> +  if (D.isFieldDesignator() && D.getField()) {
> +const FieldDecl *Decl = D.getField();
> +if (isInUSRSet(Decl)) {
> +  auto StartLoc = D.getFieldLoc();
> +  auto EndLoc = D.getFieldLoc();
> +  RenameInfos.push_back({StartLoc, EndLoc,
> + /*FromDecl=*/nullptr,
> + /*Context=*/nullptr,
> + /*Specifier=*/nullptr,
> + /*IgnorePrefixQualifiers=*/true});
> +}
> +  }
> +}
> +return true;
> +  }
> +
>bool VisitCXXConstructorDecl(const CXXConstructorDecl *CD) {
>  // Fix the constructor initializer when renaming class members.
>  for (const auto *Initializer : CD->inits()) {
> Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
> ===
> --- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
> +++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
> @@ -122,6 +122,17 @@
>  return BaseType::TraverseNestedNameSpecifierLoc(NNS);
>}
>
> +  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
> +for (const DesignatedInitExpr::Designator &D : E->designators()) {
> +  if (D.isFieldDesignator() && D.getField()) {
> +const FieldDecl *Decl = D.getField();
> +if (!visit(Decl, D.getFieldLoc(), D.getFieldLoc()))
> +  return false;
> +  }
> +}
> +return true;
> +  }
> +
>  private:
>const SourceManager &SM;
>const LangOptions &LangOpts;
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99903: [Clang][Sema] better -Wcast-function-type diagnose for pointer parameters and parameters with cv-qualifiers

2021-04-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99903

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


[PATCH] D100310: Add field designated initializers logic in Tooling/Rename

2021-04-12 Thread Daniele Castagna via Phabricator via cfe-commits
dcastagna added a comment.

Thank you Justin.
I'm happy with this now that I finally managed to get rid of the lint errors.
Let's wait for Micheal's opinion or until tomorrow and then we can push it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100310

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


[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-04-12 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

Sorry, I think I've lost track of some context while I was on vacation.  I 
don't understand why several of the tests are now unsupported on Windows.  Some 
of those seem like important tests.

If canonicalizing the file names to the platform's native style creates new 
test failures, then I think we need to wonder whether canonicalization is the 
right solution (and whether it's done at the right point.  If it is, then I 
think we need to find a way to make these tests work cross-platform.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99580

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


[clang] 06c8b29 - Enable creation of large response file on z/OS

2021-04-12 Thread Abhina Sreeskantharajan via cfe-commits

Author: Sean Perry
Date: 2021-04-12T15:06:05-04:00
New Revision: 06c8b29d23ac2e3a44f2a2f3af85b15dc8aab3c2

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

LOG: Enable creation of large response file on z/OS

Most text processing commands (eg. grep, awk) have a maximum line length limit 
on z/OS.  The current method of using cc -E & grep fails on z/OS because of 
this limit.  I'm changing the command to create the long line in the response 
file to use python.  This avoids the possibility of any tools blocking the 
generation of the large response file.  This also eliminates the need for the 
extra file.

Reviewed By: abhina.sreeskantharajan

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

Added: 


Modified: 
clang/test/Driver/response-file.c

Removed: 
clang/test/Driver/Inputs/gen-response.c



diff  --git a/clang/test/Driver/Inputs/gen-response.c 
b/clang/test/Driver/Inputs/gen-response.c
deleted file mode 100644
index 84ffb40dbece5..0
--- a/clang/test/Driver/Inputs/gen-response.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define M -DTEST
-#define M1 M M M M M M M M M M
-#define M2 M1 M1 M1 M1 M1 M1 M1 M1 M1 M1
-#define M3 M2 M2 M2 M2 M2 M2 M2 M2 M2 M2
-#define M4 M3 M3 M3 M3 M3 M3 M3 M3 M3 M3
-#define M5 M4 M4 M4 M4 M4 M4 M4 M4 M4 M4
-#define TEXT M5 M5 M5
-TEXT

diff  --git a/clang/test/Driver/response-file.c 
b/clang/test/Driver/response-file.c
index a7c5966c98d1d..bd374cc15907b 100644
--- a/clang/test/Driver/response-file.c
+++ b/clang/test/Driver/response-file.c
@@ -13,7 +13,7 @@
 // But there's no guarantee that we actually will (the system limit could be
 // *huge*), so just check that invoking cc1 succeeds under these conditions.
 //
-// RUN: %clang -E %S/Inputs/gen-response.c | grep DTEST > %t.1.txt
+// RUN: %python  -c 'print(*("-DTEST" for x in range(30)))' >%t.1.txt
 // RUN: %clang -E @%t.1.txt %s -v 2>&1 | FileCheck %s -check-prefix=LONG
 // LONG: extern int it_works;
 



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


[PATCH] D100197: Enable creation of large response file on z/OS

2021-04-12 Thread Abhina Sree via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG06c8b29d23ac: Enable creation of large response file on z/OS 
(authored by SeanP, committed by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100197

Files:
  clang/test/Driver/Inputs/gen-response.c
  clang/test/Driver/response-file.c


Index: clang/test/Driver/response-file.c
===
--- clang/test/Driver/response-file.c
+++ clang/test/Driver/response-file.c
@@ -13,7 +13,7 @@
 // But there's no guarantee that we actually will (the system limit could be
 // *huge*), so just check that invoking cc1 succeeds under these conditions.
 //
-// RUN: %clang -E %S/Inputs/gen-response.c | grep DTEST > %t.1.txt
+// RUN: %python  -c 'print(*("-DTEST" for x in range(30)))' >%t.1.txt
 // RUN: %clang -E @%t.1.txt %s -v 2>&1 | FileCheck %s -check-prefix=LONG
 // LONG: extern int it_works;
 
Index: clang/test/Driver/Inputs/gen-response.c
===
--- clang/test/Driver/Inputs/gen-response.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define M -DTEST
-#define M1 M M M M M M M M M M
-#define M2 M1 M1 M1 M1 M1 M1 M1 M1 M1 M1
-#define M3 M2 M2 M2 M2 M2 M2 M2 M2 M2 M2
-#define M4 M3 M3 M3 M3 M3 M3 M3 M3 M3 M3
-#define M5 M4 M4 M4 M4 M4 M4 M4 M4 M4 M4
-#define TEXT M5 M5 M5
-TEXT


Index: clang/test/Driver/response-file.c
===
--- clang/test/Driver/response-file.c
+++ clang/test/Driver/response-file.c
@@ -13,7 +13,7 @@
 // But there's no guarantee that we actually will (the system limit could be
 // *huge*), so just check that invoking cc1 succeeds under these conditions.
 //
-// RUN: %clang -E %S/Inputs/gen-response.c | grep DTEST > %t.1.txt
+// RUN: %python  -c 'print(*("-DTEST" for x in range(30)))' >%t.1.txt
 // RUN: %clang -E @%t.1.txt %s -v 2>&1 | FileCheck %s -check-prefix=LONG
 // LONG: extern int it_works;
 
Index: clang/test/Driver/Inputs/gen-response.c
===
--- clang/test/Driver/Inputs/gen-response.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define M -DTEST
-#define M1 M M M M M M M M M M
-#define M2 M1 M1 M1 M1 M1 M1 M1 M1 M1 M1
-#define M3 M2 M2 M2 M2 M2 M2 M2 M2 M2 M2
-#define M4 M3 M3 M3 M3 M3 M3 M3 M3 M3 M3
-#define M5 M4 M4 M4 M4 M4 M4 M4 M4 M4 M4
-#define TEXT M5 M5 M5
-TEXT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 661cc71 - [PassManager][PhaseOrdering] lower expects before running simplifyCFG

2021-04-12 Thread Sanjay Patel via cfe-commits

Author: Sanjay Patel
Date: 2021-04-12T15:07:53-04:00
New Revision: 661cc71a1c50081389d73b2baae02f51df670ba1

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

LOG: [PassManager][PhaseOrdering] lower expects before running simplifyCFG

Retry of 330619a3a623 that includes a clang test update.

Original commit message:

If we run passes before lowering llvm.expect intrinsics to metadata,
then those passes have no way to act on the hints provided by llvm.expect.
SimplifyCFG is the known offender, and we made it smarter about profile
metadata in D98898 .

In the motivating example from https://llvm.org/PR49336 , this means we
were ignoring the recommended method for a programmer to tell the compiler
that a compare+branch is expensive. This change appears to solve that case -
the metadata survives to the backend, the compare order is as expected in IR,
and the backend does not do anything to reverse it.

We make the same change to the old pass manager to keep things synchronized.

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

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-pgo.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
llvm/test/Other/opt-O2-pipeline.ll
llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
llvm/test/Other/opt-O3-pipeline.ll
llvm/test/Other/opt-Os-pipeline.ll
llvm/test/Transforms/PhaseOrdering/expect.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 1e9d5d4d2629c..398b65116bbd7 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -31,6 +31,7 @@
 ; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
 ; CHECK-O: Running pass: InferFunctionAttrsPass
 ; CHECK-O: Starting {{.*}}Function pass manager run.
+; CHECK-O: Running pass: LowerExpectIntrinsicPass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Running analysis: AssumptionAnalysis on main
@@ -38,7 +39,6 @@
 ; CHECK-O: Running analysis: DominatorTreeAnalysis on main
 ; CHECK-O: Running pass: EarlyCSEPass on main
 ; CHECK-O: Running analysis: TargetLibraryAnalysis on main
-; CHECK-O: Running pass: LowerExpectIntrinsicPass on main
 ; CHECK-O3: Running pass: CallSiteSplittingPass on main
 ; CHECK-O: Finished {{.*}}Function pass manager run.
 ; CHECK-O: Running pass: LowerTypeTestsPass

diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 6307e468e7017..75ba9da4214d7 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -1066,10 +1066,12 @@ 
PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
   // Create an early function pass manager to cleanup the output of the
   // frontend.
   FunctionPassManager EarlyFPM(DebugLogging);
+  // Lower llvm.expect to metadata before attempting transforms.
+  // Compare/branch metadata may alter the behavior of passes like SimplifyCFG.
+  EarlyFPM.addPass(LowerExpectIntrinsicPass());
   EarlyFPM.addPass(SimplifyCFGPass());
   EarlyFPM.addPass(SROA());
   EarlyFPM.addPass(EarlyCSEPass());
-  EarlyFPM.addPass(LowerExpectIntrinsicPass());
   if (PTO.Coroutines)
 EarlyFPM.addPass(CoroEarlyPass());
   if (Level == OptimizationLevel::O3)

diff  --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp 
b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index 2c80a16febeff..19e212f738ade 100644
--- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -316,10 +316,12 @@ void PassManagerBuilder::populateFunctionPassManager(
 
   addInitialAliasAnalysisPasses(FPM);
 
+  // Lower llvm.expect to metadata before attempting transforms.
+  // Compare/branch metadata may alter the behavior of passes like SimplifyCFG.
+  FPM.add(createLowerExpectIntrinsicPass());
   FPM.add(createCFGSimplificationPass());
   FPM.add(createSROAPass());
   FPM.add(createEarlyCSEPass());
-  FPM.add(createLowerExpectIntrinsicPass());
 }
 
 // Do PGO instrumentation generation or use pass as the option specified.

diff  --git a/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll 
b/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
index 5a0531017

[PATCH] D93822: [clang-tidy] Add check for implicit widening of multiplication result

2021-04-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

FWIW, it looks like tests are still failing on Windows according to the CI 
pipeline.




Comment at: 
clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp:126
+  QualType SizeTy = IndexExprType->isSignedIntegerType() ? SSizeTy : USizeTy;
+  // FIXME: is there a way to actually get the QualType for size_t/ssize_t?
+  StringRef TyAsString =

lebedev.ri wrote:
> aaron.ballman wrote:
> > You already are using the way?
> No, that's not it, because `SizeTy.getAsString()` will not be 
> `size_t`/`ssize_t`, but `long`/etc.
Ah, I see what you mean now, thanks.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp:130
+  StringRef TyAsString =
+  IndexExprType->isSignedIntegerType() ? "ssize_t" : "size_t";
+

aaron.ballman wrote:
> One thing that's awkward about this is that there's no portable `ssize_t` 
> type -- that's a POSIX type but it doesn't exist on all platforms (like 
> Windows). We shouldn't print out a typecast that's going to cause compile 
> errors, but we also shouldn't use the underlying type for `ssize_t` as that 
> may be incorrect for other target architectures.
I'm still not quite certain what to do about this. Would it make sense to use 
the underlying type on platforms that don't have `ssize_t`? Relatedly, if we're 
going to suggest this as a replacement, we should also insert an include for 
the correct header file.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-char.cpp:10
+
+long t0(char a, char b) {
+  return a * b;

lebedev.ri wrote:
> aaron.ballman wrote:
> > Can you also test the fixit behavior in addition to the diagnostic behavior 
> > (at least one test for each kind of fix-it)?
> I would love to do that, but as we have briefly talked with @njames93,
> fix-it testing in clang-tidy, as compared to clang proper,
> is rudimentary. I basically can not add tests here.
> As far as i can see, it doesn't want to apply fix-its, because there are two 
> of them.
> 
> So this is the best i can do, take it or leave it. /s
Ah, thank you for clarifying the issue that the two fixits make it hard to test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93822

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


[PATCH] D100057: Remove warning "suggest braces" for aggregate initialization of an empty class with an aggregate base class.

2021-04-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Thanks, I think this makes sense as a generalization of the existing "idiomatic 
aggregate initialization" rule. Some suggested cleanups but otherwise LGTM.




Comment at: clang/lib/Sema/SemaInit.cpp:1001
 /// the braces in aggregate initialization.
 static bool isIdiomaticBraceElisionEntity(const InitializedEntity &Entity) {
   // Recursive initialization of the one and only field within an aggregate

I wonder if it'd be clearer to replace the one base and no fields check and the 
one field and no bases check with something like:

```
  // Brace elision is idiomatic if we're initializing the only direct subobject 
of
  // an aggregate of record type.
  if (Entity.getKind() == InitializedEntity::EK_Base ||
  Entity.getKind() == InitializedEntity::EK_Member) {
auto *ParentRD = Entity.getParent()->getType()->getAsRecordDecl();
unsigned Subobjects = std::distance(ParentRD->field_begin(), 
ParentRD->field_end());
if (auto *CXXRD = dyn_cast(ParentRD))
  Subobjects += CXXRD->getNumBases();
return Subobjects == 1;
  }
```

This'd be linear in the number of fields instead of constant-time, but I 
suspect that doesn't matter in practice. Aggregate initialization is linear in 
the number of fields regardless.

(No strong preference here; take this or leave it.)



Comment at: clang/lib/Sema/SemaInit.cpp:1017-1021
+if (CXXRecordDecl *CXXRD = dyn_cast(ParentRD)) {
+  if (CXXRD->getNumBases() == 1) {
+return ParentRD->field_begin() == ParentRD->field_end();
+  }
+}

Some minor simplifications. (We can `cast` rather than `dyn_cast`ing here 
because we're initializing a base class, so the parent *must* be a C++ class 
type.)



Comment at: clang/lib/Sema/SemaInit.cpp:1025
 
-  auto FieldIt = ParentRD->field_begin();
-  assert(FieldIt != ParentRD->field_end() &&
- "no fields but have initializer for member?");
-  return ++FieldIt == ParentRD->field_end();
+  // Allows elide brace initialization for aggregates with one member.
+  if (Entity.getKind() == InitializedEntity::EK_Member) {




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

https://reviews.llvm.org/D100057

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


[PATCH] D100310: Add field designated initializers logic in Tooling/Rename

2021-04-12 Thread Michael Kuperstein via Phabricator via cfe-commits
mkuper added a comment.

I defer to Justin, he knows AST much better than I do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100310

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


[clang] 7dd6068 - [clang-rename] Handle designated initializers.

2021-04-12 Thread Justin Lebar via cfe-commits

Author: Daniele Castagna
Date: 2021-04-12T13:15:14-07:00
New Revision: 7dd60688992526bb7ee0c7846e9abd591fc3e297

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

LOG: [clang-rename] Handle designated initializers.

clang Tooling, and more specifically Refactoring/Rename, have support
code to extract source locations given a Unified Symbol Resolution set.
This support code is used by clang-rename and other tools that might not
be in the tree.

Currently field designated initializer are not supported.
So, renaming S::a to S::b in this code:

  S s = { .a = 10 };

will not extract the field designated initializer for a (the 'a' after the
dot).

This patch adds support for field designated initialized to
RecursiveSymbolVisitor and RenameLocFinder that is used in
createRenameAtomicChanges.

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

Added: 


Modified: 
clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
clang/unittests/Rename/RenameClassTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h 
b/clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
index c0f995d85c14c..63d46abc20347 100644
--- a/clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
+++ b/clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
@@ -122,6 +122,17 @@ class RecursiveSymbolVisitor
 return BaseType::TraverseNestedNameSpecifierLoc(NNS);
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (!visit(Decl, D.getFieldLoc(), D.getFieldLoc()))
+  return false;
+  }
+}
+return true;
+  }
+
 private:
   const SourceManager &SM;
   const LangOptions &LangOpts;

diff  --git a/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp 
b/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
index 6a08c7fd52475..aecfffcbef1fa 100644
--- a/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ b/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -226,6 +226,24 @@ class RenameLocFinder : public 
RecursiveASTVisitor {
 return true;
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (isInUSRSet(Decl)) {
+  auto StartLoc = D.getFieldLoc();
+  auto EndLoc = D.getFieldLoc();
+  RenameInfos.push_back({StartLoc, EndLoc,
+ /*FromDecl=*/nullptr,
+ /*Context=*/nullptr,
+ /*Specifier=*/nullptr,
+ /*IgnorePrefixQualifiers=*/true});
+}
+  }
+}
+return true;
+  }
+
   bool VisitCXXConstructorDecl(const CXXConstructorDecl *CD) {
 // Fix the constructor initializer when renaming class members.
 for (const auto *Initializer : CD->inits()) {

diff  --git a/clang/unittests/Rename/RenameClassTest.cpp 
b/clang/unittests/Rename/RenameClassTest.cpp
index 1c00ad7912e73..1b008987a16d3 100644
--- a/clang/unittests/Rename/RenameClassTest.cpp
+++ b/clang/unittests/Rename/RenameClassTest.cpp
@@ -780,6 +780,27 @@ TEST_F(RenameClassTest, UsingAlias) {
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, FieldDesignatedInitializers) {
+  std::string Before = R"(
+  struct S {
+int a;
+  };
+  void foo() {
+S s = { .a = 10 };
+s.a = 20;
+  })";
+  std::string Expected = R"(
+  struct S {
+int b;
+  };
+  void foo() {
+S s = { .b = 10 };
+s.b = 20;
+  })";
+  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");
+  CompareSnippets(Expected, After);
+}
+
 // FIXME: investigate why the test fails when adding a new USR to the USRSet.
 TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {
   std::string Before = R"(



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


[PATCH] D100310: Add field designated initializers logic in Tooling/Rename

2021-04-12 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7dd606889925: [clang-rename] Handle designated initializers. 
(authored by dcastagna, committed by jlebar).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100310

Files:
  clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  clang/unittests/Rename/RenameClassTest.cpp


Index: clang/unittests/Rename/RenameClassTest.cpp
===
--- clang/unittests/Rename/RenameClassTest.cpp
+++ clang/unittests/Rename/RenameClassTest.cpp
@@ -780,6 +780,27 @@
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, FieldDesignatedInitializers) {
+  std::string Before = R"(
+  struct S {
+int a;
+  };
+  void foo() {
+S s = { .a = 10 };
+s.a = 20;
+  })";
+  std::string Expected = R"(
+  struct S {
+int b;
+  };
+  void foo() {
+S s = { .b = 10 };
+s.b = 20;
+  })";
+  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");
+  CompareSnippets(Expected, After);
+}
+
 // FIXME: investigate why the test fails when adding a new USR to the USRSet.
 TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {
   std::string Before = R"(
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -226,6 +226,24 @@
 return true;
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (isInUSRSet(Decl)) {
+  auto StartLoc = D.getFieldLoc();
+  auto EndLoc = D.getFieldLoc();
+  RenameInfos.push_back({StartLoc, EndLoc,
+ /*FromDecl=*/nullptr,
+ /*Context=*/nullptr,
+ /*Specifier=*/nullptr,
+ /*IgnorePrefixQualifiers=*/true});
+}
+  }
+}
+return true;
+  }
+
   bool VisitCXXConstructorDecl(const CXXConstructorDecl *CD) {
 // Fix the constructor initializer when renaming class members.
 for (const auto *Initializer : CD->inits()) {
Index: clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
===
--- clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
+++ clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
@@ -122,6 +122,17 @@
 return BaseType::TraverseNestedNameSpecifierLoc(NNS);
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (!visit(Decl, D.getFieldLoc(), D.getFieldLoc()))
+  return false;
+  }
+}
+return true;
+  }
+
 private:
   const SourceManager &SM;
   const LangOptions &LangOpts;


Index: clang/unittests/Rename/RenameClassTest.cpp
===
--- clang/unittests/Rename/RenameClassTest.cpp
+++ clang/unittests/Rename/RenameClassTest.cpp
@@ -780,6 +780,27 @@
   CompareSnippets(Expected, After);
 }
 
+TEST_F(ClangRenameTest, FieldDesignatedInitializers) {
+  std::string Before = R"(
+  struct S {
+int a;
+  };
+  void foo() {
+S s = { .a = 10 };
+s.a = 20;
+  })";
+  std::string Expected = R"(
+  struct S {
+int b;
+  };
+  void foo() {
+S s = { .b = 10 };
+s.b = 20;
+  })";
+  std::string After = runClangRenameOnCode(Before, "S::a", "S::b");
+  CompareSnippets(Expected, After);
+}
+
 // FIXME: investigate why the test fails when adding a new USR to the USRSet.
 TEST_F(ClangRenameTest, DISABLED_NestedTemplates) {
   std::string Before = R"(
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -226,6 +226,24 @@
 return true;
   }
 
+  bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
+for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  if (D.isFieldDesignator() && D.getField()) {
+const FieldDecl *Decl = D.getField();
+if (isInUSRSet(Decl)) {
+  auto StartLoc = D.getFieldLoc();
+  auto EndLoc = D.getFieldLoc();
+  RenameInfos.push_back({StartLoc, EndLoc,
+

[PATCH] D100124: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX redux.sync instructions

2021-04-12 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsNVPTX.def:460-468
+TARGET_BUILTIN(__nvvm_redux_sync_add_s32, "SiSii", "", SM_80)
+TARGET_BUILTIN(__nvvm_redux_sync_min_s32, "SiSii", "", SM_80)
+TARGET_BUILTIN(__nvvm_redux_sync_max_s32, "SiSii", "", SM_80)
+TARGET_BUILTIN(__nvvm_redux_sync_add_u32, "UiUii", "", SM_80)
+TARGET_BUILTIN(__nvvm_redux_sync_min_u32, "UiUii", "", SM_80)
+TARGET_BUILTIN(__nvvm_redux_sync_max_u32, "UiUii", "", SM_80)
+TARGET_BUILTIN(__nvvm_redux_sync_and_b32, "iii", "", SM_80)

steffenlarsen wrote:
> tra wrote:
> > Instead of creating one builtin per integer variant, can we use a more 
> > generic builtin `__nvvm_redux_sync_add_i`, similar to how we handle 
> > `__nvvm_atom_add_gen_i` ?
> > 
> What gives me pause is that a for atomic minimum there are both 
> `__nvvm_atom_min_gen_i` and `__nvvm_atom_min_gen_ui` to distinguish between 
> signed and unsigned. What makes the difference?
> 
> That noted, I'll happily rename the builtins to be more in line with the 
> other builtins. `__nvvm_redux_sync_*_i` and `__nvvm_redux_sync_*_ui` maybe?
> What gives me pause is that a for atomic minimum there are both 
> __nvvm_atom_min_gen_i and __nvvm_atom_min_gen_ui to distinguish between 
> signed and unsigned. What makes the difference?

Good point. We do not need unsigned variant for `add`.  We do need explicit 
signed and unsigned variants ad LLVM IR integer types do not take signedness 
into account, and the underlying min/max instructions do.  Maybe, rename 
min_i/min_ui -> min/umin as LLVM does with atomics? 

We may skip the `_i` suffix on logical ops as they only apply to integers 
anyways.




Comment at: llvm/include/llvm/IR/IntrinsicsNVVM.td:4103
+// redux.sync.add.u32 dst, src, membermask;
+def int_nvvm_redux_sync_add_u32 : GCCBuiltin<"__nvvm_redux_sync_add_u32">,
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],

steffenlarsen wrote:
> tra wrote:
> > This could also be consolidated into an overloaded intrinsic operating on 
> > `llvm_anyint_ty`
> I am having a look at other uses of this, but I'm having difficulty wrapping 
> my head around how to map these overloads to the PTX instructions in 
> llvm/lib/Target/NVPTX/NVPTXIntrinsics.td. Though it would be nice, it just 
> seems overly complicated to get a signed and an unsigned 32-bit integer 
> version of each of these intrinsics.
Considering that `redux` only supports 32-bit integers, we do not need to get 
into it.
`llvm_i32_ty` will do for now. We'll cross the bridge if/when we get to support 
multiple integer types.




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

https://reviews.llvm.org/D100124

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


[PATCH] D100251: [IR][sanitizer] Set nounwind on module ctor/dtor, additionally set uwtable if -fasynchronous-unwind-tables

2021-04-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

> -fno-exceptions -fno-asynchronous-unwind-tables -g produces .debug_frame
> while
> -fno-exceptions -fno-asynchronous-unwind-tables -g -fsanitize=address 
> produces .eh_frame.

Does this patch change that behavior?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100251

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


[PATCH] D100251: [IR][sanitizer] Set nounwind on module ctor/dtor, additionally set uwtable if -fasynchronous-unwind-tables

2021-04-12 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D100251#2684074 , @nickdesaulniers 
wrote:

>> -fno-exceptions -fno-asynchronous-unwind-tables -g produces .debug_frame
>> while
>> -fno-exceptions -fno-asynchronous-unwind-tables -g -fsanitize=address 
>> produces .eh_frame.
>
> Does this patch change that behavior?

Yes. I consider `-fno-exceptions -fno-asynchronous-unwind-tables -g 
-fsanitize=address` producing `.eh_frame` is a bug. This patch will fix it.

`-fsanitize=address` can be replaced with many other instrumentations 
(-fsanitize=memory, -fprofile-arcs, -fsanitize-coverage=trace-pc-guard, ...)
This patch fixes the various sanitizers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100251

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


[PATCH] D100251: [IR][sanitizer] Set nounwind on module ctor/dtor, additionally set uwtable if -fasynchronous-unwind-tables

2021-04-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D100251#2684083 , @MaskRay wrote:

> In D100251#2684074 , 
> @nickdesaulniers wrote:
>
>>> -fno-exceptions -fno-asynchronous-unwind-tables -g produces .debug_frame
>>> while
>>> -fno-exceptions -fno-asynchronous-unwind-tables -g -fsanitize=address 
>>> produces .eh_frame.
>>
>> Does this patch change that behavior?
>
> Yes. I consider `-fno-exceptions -fno-asynchronous-unwind-tables -g 
> -fsanitize=address` producing `.eh_frame` is a bug. This patch will fix it 
> and match GCC.

SGTM; please make that clearer though in the description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100251

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


[PATCH] D100343: [AST][NFC] Remove temporary ASTTU file from Introspection generation.

2021-04-12 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added a reviewer: steveire.
Herald added a subscriber: mgorny.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We can use the Preprocessor to remap this file, cleaning up the cmake code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100343

Files:
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp


Index: clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
===
--- clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
+++ clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
@@ -14,6 +14,7 @@
 #include "clang/Driver/Tool.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CommandLine.h"
@@ -30,10 +31,6 @@
 "I", cl::desc("Include directories to use while compiling"),
 cl::value_desc("directory"), cl::Required, cl::OneOrMore, cl::Prefix);
 
-static cl::opt
-AstHeaderFile("astheader", cl::desc("AST header to parse API from"),
-  cl::Required, cl::value_desc("AST header file"));
-
 static cl::opt
 SkipProcessing("skip-processing",
cl::desc("Avoid processing the AST header file"),
@@ -86,7 +83,7 @@
   [](const std::string &IncDir) { return "-I" + IncDir; });
 
   Args.push_back("-fsyntax-only");
-  Args.push_back(AstHeaderFile);
+  Args.push_back("ASTTU.cpp");
 
   std::vector Argv(Args.size(), nullptr);
   llvm::transform(Args, Argv.begin(),
@@ -102,9 +99,7 @@
   // Don't output diagnostics, because common scenarios such as
   // cross-compiling fail with diagnostics.  This is not fatal, but
   // just causes attempts to use the introspection API to return no data.
-  std::string Str;
-  llvm::raw_string_ostream OS(Str);
-  TextDiagnosticPrinter DiagnosticPrinter(OS, &*DiagOpts);
+  TextDiagnosticPrinter DiagnosticPrinter(llvm::nulls(), &*DiagOpts);
   DiagnosticsEngine Diagnostics(
   IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts,
   &DiagnosticPrinter, false);
@@ -133,6 +128,9 @@
 
   auto Invocation = std::make_unique();
   CompilerInvocation::CreateFromArgs(*Invocation, CC1Args, Diagnostics);
+  Invocation->getPreprocessorOpts().addRemappedFile(
+  "ASTTU.cpp",
+  MemoryBuffer::getMemBuffer("#include \"clang/AST/AST.h\"").release());
 
   CompilerInstance Compiler(std::make_shared());
   Compiler.setInvocation(std::move(Invocation));
Index: clang/lib/Tooling/CMakeLists.txt
===
--- clang/lib/Tooling/CMakeLists.txt
+++ clang/lib/Tooling/CMakeLists.txt
@@ -62,10 +62,6 @@
 
   set(skip_expensive_processing 
$,$>>)
 
-  file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTTU.cpp
-CONTENT "
-#include 
-")
 
   set(implicitDirs)
   foreach(implicitDir ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
@@ -75,12 +71,11 @@
   add_custom_command(
   COMMENT Generate ASTNodeAPI.json
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
-  DEPENDS clang-ast-dump clang-resource-headers 
${CMAKE_CURRENT_BINARY_DIR}/ASTTU.cpp
+  DEPENDS clang-ast-dump clang-resource-headers
   COMMAND
   $
 # Skip this in debug mode because parsing AST.h is too slow
 --skip-processing=${skip_expensive_processing}
---astheader=${CMAKE_CURRENT_BINARY_DIR}/ASTTU.cpp
 -I ${CMAKE_BINARY_DIR}/lib/clang/${CLANG_VERSION}/include
 -I ${CMAKE_SOURCE_DIR}/../clang/include
 -I ${CMAKE_BINARY_DIR}/tools/clang/include


Index: clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
===
--- clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
+++ clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
@@ -14,6 +14,7 @@
 #include "clang/Driver/Tool.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CommandLine.h"
@@ -30,10 +31,6 @@
 "I", cl::desc("Include directories to use while compiling"),
 cl::value_desc("directory"), cl::Required, cl::OneOrMore, cl::Prefix);
 
-static cl::opt
-AstHeaderFile("astheader", cl::desc("AST header to parse API from"),
-  cl::Required, cl::value_desc("AST header file"));
-
 static cl::opt
 SkipProcessing("skip-processing",
cl::desc("Avoid processing the AST header file"),
@@ -86,7 +83,7 @@
   [](const std::string &IncDir) { return "-I" + IncDir; });
 
   Args.push_back("-fsyntax-only");
-  Args.push_back(AstHeaderFile);
+  Args.push_back("ASTTU.cpp");
 
   std::vector Argv(Args.size(), nullptr);
   llvm::transform(Args, Argv.begin

  1   2   >