[PATCH] D84222: [AST][RecoveryExpr] Error-dependent expression should not be treat as a nullptr pointer constant.

2020-07-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/test/AST/ast-dump-recovery.c:51
+  // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
+  ptr = some_func(); // should not crash
+}

For references, the crash stacktrace is like below, the cause is that we run 
into the 
[codepath](https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaExpr.cpp#L9373-L9384).

```
can't implicitly cast lvalue to rvalue with this cast kind: NullToPointer
UNREACHABLE executed at llvm-project/clang/lib/Sema/Sema.cpp:545!
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: ./bin/clang -cc1 -fsyntax-only -ast-dump 
-frecovery-ast /tmp/t.c 
1.  /tmp/t.c:78:20: current parser token ';'
2.  /tmp/t.c:71:16: parsing function body 'NoCrash'
#13 0x03e75e59 clang::Sema::ImpCastExprToType(clang::Expr*, 
clang::QualType, clang::CastKind, clang::ExprValueKind, 
llvm::SmallVector const*, 
clang::Sema::CheckedConversionKind) llvm-project/clang/lib/Sema/Sema.cpp:582:16
#14 0x04132c06 
clang::Sema::CheckSingleAssignmentConstraints(clang::QualType, 
clang::ActionResult&, bool, bool, bool) 
llvm-project/clang/lib/Sema/SemaExpr.cpp:9374:13
#15 0x041420f6 clang::Sema::CheckAssignmentOperands(clang::Expr*, 
clang::ActionResult&, clang::SourceLocation, 
clang::QualType) llvm-project/clang/lib/Sema/SemaExpr.cpp:12759:9
#16 0x0411e348 clang::Sema::CreateBuiltinBinOp(clang::SourceLocation, 
clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) 
llvm-project/clang/lib/Sema/SemaExpr.cpp:0:16
#17 0x041060ba clang::Sema::ActOnBinOp(clang::Scope*, 
clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*) 
llvm-project/clang/lib/Sema/SemaExpr.cpp:14170:1
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84222



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


[PATCH] D84222: [AST][RecoveryExpr] Error-dependent expression should not be treat as a nullptr pointer constant.

2020-07-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 279433.
hokein marked an inline comment as done.
hokein added a comment.

dump cast kind.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84222

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/AST/ast-dump-recovery.c


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -39,3 +39,14 @@
   // CHECK-NEXT:  `-DeclRefExpr {{.*}} 'a' 'const int'
   static int foo = a++; // verify no crash on local static var decl.
 }
+
+void test2() {
+  int* ptr;
+  // FIXME: the top-level expr should be a binary operator.
+  // CHECK:  ImplicitCastExpr {{.*}} contains-errors 
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors lvalue
+  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'ptr' 'int *'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}}
+  // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
+  ptr = some_func(); // should not crash
+}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -539,8 +539,10 @@
   if (VK == VK_RValue && !E->isRValue()) {
 switch (Kind) {
 default:
-  llvm_unreachable("can't implicitly cast lvalue to rvalue with this cast "
-   "kind");
+  llvm_unreachable(("can't implicitly cast lvalue to rvalue with this cast 
"
+"kind: " +
+std::string(CastExpr::getCastKindName(Kind)))
+   .c_str());
 case CK_Dependent:
 case CK_LValueToRValue:
 case CK_ArrayToPointerDecay:
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3744,7 +3744,8 @@
 case NPC_NeverValueDependent:
   llvm_unreachable("Unexpected value dependent expression!");
 case NPC_ValueDependentIsNull:
-  if (isTypeDependent() || getType()->isIntegralType(Ctx))
+  if ((!containsErrors() && isTypeDependent()) ||
+  getType()->isIntegralType(Ctx))
 return NPCK_ZeroExpression;
   else
 return NPCK_NotNull;


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -39,3 +39,14 @@
   // CHECK-NEXT:  `-DeclRefExpr {{.*}} 'a' 'const int'
   static int foo = a++; // verify no crash on local static var decl.
 }
+
+void test2() {
+  int* ptr;
+  // FIXME: the top-level expr should be a binary operator.
+  // CHECK:  ImplicitCastExpr {{.*}} contains-errors 
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors lvalue
+  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'ptr' 'int *'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}}
+  // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
+  ptr = some_func(); // should not crash
+}
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -539,8 +539,10 @@
   if (VK == VK_RValue && !E->isRValue()) {
 switch (Kind) {
 default:
-  llvm_unreachable("can't implicitly cast lvalue to rvalue with this cast "
-   "kind");
+  llvm_unreachable(("can't implicitly cast lvalue to rvalue with this cast "
+"kind: " +
+std::string(CastExpr::getCastKindName(Kind)))
+   .c_str());
 case CK_Dependent:
 case CK_LValueToRValue:
 case CK_ArrayToPointerDecay:
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3744,7 +3744,8 @@
 case NPC_NeverValueDependent:
   llvm_unreachable("Unexpected value dependent expression!");
 case NPC_ValueDependentIsNull:
-  if (isTypeDependent() || getType()->isIntegralType(Ctx))
+  if ((!containsErrors() && isTypeDependent()) ||
+  getType()->isIntegralType(Ctx))
 return NPCK_ZeroExpression;
   else
 return NPCK_NotNull;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83759: [clangd] Port lit tests to Windows

2020-07-20 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added a comment.

What do you think of this patch? I'm not sure if Windows is important OS for 
developers, and that some of these changes might be awkward to maintain, but 
maybe we can enable `background-index.test` at least?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83759



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


[Differential] D82739: [clangd] Improve heuristic resolution of dependent types in TargetFinder

2020-07-20 Thread Nathan Ridge via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9946dcd3e9c7: [clangd] Improve heuristic resolution of 
dependent types in TargetFinder (authored by nridge).

Changed prior to commit:
  https://reviews.llvm.org/D82739?vs=276916&id=279037#toc

Repository:
  rG LLVM Github Monorepo

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


  https://reviews.llvm.org/D82739

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -561,6 +561,74 @@
   EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char *)");
 }
 
+TEST_F(TargetDeclTest, DependentExprs) {
+  Flags = {"-fno-delayed-template-parsing"};
+
+  // Heuristic resolution of method of dependent field
+  Code = R"cpp(
+struct A { void foo() {} };
+template 
+struct B {
+  A a;
+  void bar() {
+this->a.[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  // Similar to above but base expression involves a function call.
+  Code = R"cpp(
+struct A {
+  void foo() {}
+};
+struct B {
+  A getA();
+};
+template 
+struct C {
+  B c;
+  void bar() {
+this->c.getA().[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  // Similar to above but uses a function pointer.
+  Code = R"cpp(
+struct A {
+  void foo() {}
+};
+struct B {
+  using FPtr = A(*)();
+  FPtr fptr;
+};
+template 
+struct C {
+  B c;
+  void bar() {
+this->c.fptr().[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  // Base expression involves a member access into this.
+  Code = R"cpp(
+struct Bar {
+  int ;
+};
+template  struct Foo {
+  Bar func(int);
+  void test() {
+func(1).[[]];
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "int ");
+}
+
 TEST_F(TargetDeclTest, ObjC) {
   Flags = {"-xobjective-c"};
   Code = R"cpp(
@@ -718,36 +786,37 @@
 
 TEST_F(FindExplicitReferencesTest, All) {
   std::pair Cases[] =
-  {// Simple expressions.
-   {R"cpp(
+  {
+  // Simple expressions.
+  {R"cpp(
 int global;
 int func();
 void foo(int param) {
   $0^global = $1^param + $2^func();
 }
 )cpp",
-"0: targets = {global}\n"
-"1: targets = {param}\n"
-"2: targets = {func}\n"},
-   {R"cpp(
+   "0: targets = {global}\n"
+   "1: targets = {param}\n"
+   "2: targets = {func}\n"},
+  {R"cpp(
 struct X { int a; };
 void foo(X x) {
   $0^x.$1^a = 10;
 }
 )cpp",
-"0: targets = {x}\n"
-"1: targets = {X::a}\n"},
-   {R"cpp(
+   "0: targets = {x}\n"
+   "1: targets = {X::a}\n"},
+  {R"cpp(
 // error-ok: testing with broken code
 int bar();
 int foo() {
   return $0^bar() + $1^bar(42);
 }
 )cpp",
-"0: targets = {bar}\n"
-"1: targets = {bar}\n"},
-   // Namespaces and aliases.
-   {R"cpp(
+   "0: targets = {bar}\n"
+   "1: targets = {bar}\n"},
+  // Namespaces and aliases.
+  {R"cpp(
   namespace ns {}
   namespace alias = ns;
   void foo() {
@@ -755,19 +824,19 @@
 using namespace $1^alias;
   }
 )cpp",
-"0: targets = {ns}\n"
-"1: targets = {alias}\n"},
-   // Using declarations.
-   {R"cpp(
+   "0: targets = {ns}\n"
+   "1: targets = {alias}\n"},
+  // Using declarations.
+  {R"cpp(
   namespace ns { int global; }
   void foo() {
 using $0^ns::$1^global;
   }
 )cpp",
-"0: targets = {ns}\n"
-"1: targets = {ns::global}, qualifier = 'ns::'\n"},
-   // Simple types.
-   {R"cpp(
+   "0: targets = {ns}\n"
+   "1: targets = {ns::global}, qualifier = 'ns::'\n"},
+  // Simple types.
+  {R"cpp(
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
@@ -776,13 +845,13 @@
static_cast<$4^Struct*>(0);
  }
)cpp"

[Differential] D83492: [OpenMP] Use common interface to access GPU Grid Values

2020-07-20 Thread Saiyedul Islam 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 rGfc7d2908ab38: [OpenMP] Use common interface to access GPU 
Grid Values (authored by saiislam).

Repository:
  rG LLVM Github Monorepo

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


  https://reviews.llvm.org/D83492

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp



Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Cuda.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
 
 using namespace clang;
@@ -195,11 +196,9 @@
 /// code.  For all practical purposes this is fine because the configuration
 /// is the same for all known NVPTX architectures.
 enum MachineConfiguration : unsigned {
-  WarpSize = 32,
-  /// Number of bits required to represent a lane identifier, which is
-  /// computed as log_2(WarpSize).
-  LaneIDBits = 5,
-  LaneIDMask = WarpSize - 1,
+  /// See "llvm/Frontend/OpenMP/OMPGridValues.h" for various related target
+  /// specific Grid Values like GV_Warp_Size, GV_Warp_Size_Log2,
+  /// and GV_Warp_Size_Log2_Mask.
 
   /// Global memory alignment for performance.
   GlobalMemoryAlignment = 128,
@@ -431,6 +430,7 @@
 assert(!GlobalizedRD &&
"Record for globalized variables is built already.");
 ArrayRef EscapedDeclsForParallel, EscapedDeclsForTeams;
+unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
 if (IsInTTDRegion)
   EscapedDeclsForTeams = EscapedDecls.getArrayRef();
 else
@@ -634,6 +634,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXWarpID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDBits =
+  CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size_Log2);
   return Bld.CreateAShr(getNVPTXThreadID(CGF), LaneIDBits, "nvptx_warp_id");
 }
 
@@ -642,6 +644,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXLaneID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDMask = CGF.getContext().getTargetInfo().getGridValue(
+  llvm::omp::GV_Warp_Size_Log2_Mask);
   return Bld.CreateAnd(getNVPTXThreadID(CGF), Bld.getInt32(LaneIDMask),
"nvptx_lane_id");
 }
@@ -2058,6 +2062,7 @@
   const RecordDecl *GlobalizedRD = nullptr;
   llvm::SmallVector LastPrivatesReductions;
   llvm::SmallDenseMap MappedDeclsFields;
+  unsigned WarpSize = CGM.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
   // Globalize team reductions variable unconditionally in all modes.
   if (getExecutionMode() != CGOpenMPRuntimeGPU::EM_SPMD)
 getTeamsReductionVars(CGM.getContext(), D, LastPrivatesReductions);
@@ -3233,6 +3238,7 @@
   "__openmp_nvptx_data_transfer_temporary_storage";
   llvm::GlobalVariable *TransferMedium =
   M.getGlobalVariable(TransferMediumName);
+  unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
   if (!TransferMedium) {
 auto *Ty = llvm::ArrayType::get(CGM.Int32Ty, WarpSize);
 unsigned SharedAddressSpace = C.getTargetAddressSpace(LangAS::cuda_shared);


Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Cuda.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
 
 using namespace clang;
@@ -195,11 +196,9 @@
 /// code.  For all practical purposes this is fine because the configuration
 /// is the same for all known NVPTX architectures.
 enum MachineConfiguration : unsigned {
-  WarpSize = 32,
-  /// Number of bits required to represent a lane identifier, which is
-  /// computed as log_2(WarpSize).
-  LaneIDBits = 5,
-  LaneIDMask = WarpSize - 1,
+  /// See "llvm/Frontend/OpenMP/OMPGridValues.h" for various related target
+  /// specific Grid Values like GV_Warp_Size, GV_Warp_Size_Log2,
+  /// and GV_Warp_Size_Log2_Mask.
 
   /// Global memory alignment for performance.
   GlobalMemoryAlignment = 128,
@@ -431,6 +430,7 @@
 assert(!GlobalizedRD &&
"Record for globalized variables is built already.");
 ArrayRef EscapedDeclsForParallel, EscapedDeclsForTeams;
+unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
 if (IsInTTDRegion)
   EscapedDeclsForTeams = EscapedDecls.getArrayRef();
 else
@@ -634,6 +634,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXWarpID(CodeGenFunct

[PATCH] D84221: [OpenMP] Add missing RUN lines for OpenMP 4.5

2020-07-20 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

Can you add test with version string 50 also?
So, tests should be there for version 45, version 50, and default version. It 
will ensure that this test doesn't silently stops testing for 50 when we 
upgrade to the next version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84221



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


[PATCH] D82994: [RFC] Instrumenting Clang/LLVM with Perfetto

2020-07-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: llvm/cmake/modules/AddPerfetto.cmake:9
+  ExternalProject_Add(perfetto_git
+  GIT_REPOSITORY https://github.com/google/perfetto.git
+  GIT_TAG releases/v4.x

nickdesaulniers wrote:
> lebedev.ri wrote:
> > nickdesaulniers wrote:
> > > lebedev.ri wrote:
> > > > I have concerns about this.
> > > > It really should use system-provided version via `find_package()`
> > > > At worst, the sources should be bundled into the tree like it's already 
> > > > done in some rare cases.
> > > Not that I'm very good with CMake, but this seems to suggest that 
> > > `ExternalProject_Add` may not compose well with `find_package`: 
> > > https://stackoverflow.com/questions/6351609/cmake-linking-to-library-downloaded-from-externalproject-add
> > What i am saying is that any code that fetches anything from internet 
> > during cmake/build time is just plain broken.
> > perfetto should be provided by system package and we should link to it just 
> > like we link to zlib/etc.
> That's how GTest is fetched.  See: 
> llvm/utils/benchmark/cmake/HandleGTest.cmake.
> That's how GTest is fetched.

No, it's not. That cmake file is never ever executed by LLVM's cmake.
LLVM's gtest is bundled in `llvm/utils/unittest/googletest`,
much like googlebenchmark is bundled in `llvm/utils/benchmark`,
etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82994



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


[PATCH] D84222: [AST][RecoveryExpr] Error-dependent expression should not be treat as a nullptr pointer constant.

2020-07-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If an expression is contains-error and its type is unknown (dependent), we
don't treat it as a null pointer constant.

Fix a recovery-ast crash on C.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84222

Files:
  clang/lib/AST/Expr.cpp
  clang/test/AST/ast-dump-recovery.c


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -39,3 +39,14 @@
   // CHECK-NEXT:  `-DeclRefExpr {{.*}} 'a' 'const int'
   static int foo = a++; // verify no crash on local static var decl.
 }
+
+void test2() {
+  int* ptr;
+  // FIXME: the top-level expr should be a binary operator.
+  // CHECK:  ImplicitCastExpr {{.*}} contains-errors 
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors lvalue
+  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'ptr' 'int *'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}}
+  // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
+  ptr = some_func(); // should not crash
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3744,7 +3744,8 @@
 case NPC_NeverValueDependent:
   llvm_unreachable("Unexpected value dependent expression!");
 case NPC_ValueDependentIsNull:
-  if (isTypeDependent() || getType()->isIntegralType(Ctx))
+  if ((!containsErrors() && isTypeDependent()) ||
+  getType()->isIntegralType(Ctx))
 return NPCK_ZeroExpression;
   else
 return NPCK_NotNull;


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -39,3 +39,14 @@
   // CHECK-NEXT:  `-DeclRefExpr {{.*}} 'a' 'const int'
   static int foo = a++; // verify no crash on local static var decl.
 }
+
+void test2() {
+  int* ptr;
+  // FIXME: the top-level expr should be a binary operator.
+  // CHECK:  ImplicitCastExpr {{.*}} contains-errors 
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors lvalue
+  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'ptr' 'int *'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}}
+  // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
+  ptr = some_func(); // should not crash
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3744,7 +3744,8 @@
 case NPC_NeverValueDependent:
   llvm_unreachable("Unexpected value dependent expression!");
 case NPC_ValueDependentIsNull:
-  if (isTypeDependent() || getType()->isIntegralType(Ctx))
+  if ((!containsErrors() && isTypeDependent()) ||
+  getType()->isIntegralType(Ctx))
 return NPCK_ZeroExpression;
   else
 return NPCK_NotNull;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84221: [OpenMP] Add missing RUN lines for OpenMP 4.5

2020-07-20 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal created this revision.
pdhaliwal added reviewers: saiislam, ABataev, jdoerfert.
Herald added subscribers: cfe-commits, sstefan1, guansong, yaxunl.
Herald added a project: clang.

This was missed when default version was upgraded to 5.0 (part of D81098 
)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84221

Files:
  clang/test/OpenMP/target_map_codegen.cpp

Index: clang/test/OpenMP/target_map_codegen.cpp
===
--- clang/test/OpenMP/target_map_codegen.cpp
+++ clang/test/OpenMP/target_map_codegen.cpp
@@ -14,6 +14,20 @@
 // RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  %s  --check-prefix CK1 --check-prefix CK1-32
 
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  %s  --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-version=45 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s  --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=45 -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  %s  --check-prefix CK1 --check-prefix CK1-32
+
 // RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
@@ -21,6 +35,7 @@
 // RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
 #ifdef CK1
 
 class B {
@@ -89,6 +104,13 @@
 // RUN: %clang_cc1 -DCK2 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | Fil

[clang-tools-extra] 9946dcd - [clangd] Improve heuristic resolution of dependent types in TargetFinder

2020-07-20 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2020-07-21T02:03:06-04:00
New Revision: 9946dcd3e9c7e8c7383265b82cc250c72a444f24

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

LOG: [clangd] Improve heuristic resolution of dependent types in TargetFinder

 * Try to apply heuristic resolution recursively to the base
   expression of a CXXDependentScopeMemberExpr.

 * Try to apply heuristic resolution recursively to the callee
   expression in a call expression.

Fixes https://github.com/clangd/clangd/issues/441

Subscribers: ilya-biryukov, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index c2887f3306fa..bc4002c42623 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -59,24 +59,32 @@ nodeToString(const ast_type_traits::DynTypedNode &N) {
 }
 
 // Helper function for getMembersReferencedViaDependentName()
-// which takes a dependent type `T` and heuristically
+// which takes a possibly-dependent type `T` and heuristically
 // resolves it to a CXXRecordDecl in which we can try name lookup.
 CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
   assert(T);
-  if (const auto *ICNT = T->getAs()) {
+
+  if (const auto *RT = T->getAs())
+return dyn_cast(RT->getDecl());
+
+  if (const auto *ICNT = T->getAs())
 T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
-  }
+  if (!T)
+return nullptr;
+
   const auto *TST = T->getAs();
   if (!TST)
 return nullptr;
+
   const ClassTemplateDecl *TD = dyn_cast_or_null(
   TST->getTemplateName().getAsTemplateDecl());
   if (!TD)
 return nullptr;
+
   return TD->getTemplatedDecl();
 }
 
-// Given a dependent type and a member name, heuristically resolve the
+// Given a tag-decl type and a member name, heuristically resolve the
 // name to one or more declarations.
 // The current heuristic is simply to look up the name in the primary
 // template. This is a heuristic because the template could potentially
@@ -154,6 +162,10 @@ const Type *getPointeeType(const Type *T) {
   return FirstArg.getAsType().getTypePtrOrNull();
 }
 
+// Forward declaration, needed as this function is mutually recursive
+// with resolveDependentExprToDecls.
+const Type *resolveDependentExprToType(const Expr *E);
+
 // Try to heuristically resolve a dependent expression `E` to one
 // or more declarations that it likely references.
 std::vector resolveDependentExprToDecls(const Expr *E) {
@@ -163,6 +175,15 @@ std::vector 
resolveDependentExprToDecls(const Expr *E) {
 if (ME->isArrow()) {
   BaseType = getPointeeType(BaseType);
 }
+if (const auto *BT = BaseType->getAs()) {
+  // If BaseType is the type of a dependent expression, it's just
+  // represented as BultinType::Dependent which gives us no information. We
+  // can get further by analyzing the depedent expression.
+  Expr *Base = ME->isImplicitAccess() ? nullptr : ME->getBase();
+  if (Base && BT->getKind() == BuiltinType::Dependent) {
+BaseType = resolveDependentExprToType(Base);
+  }
+}
 return getMembersReferencedViaDependentName(
 BaseType, [ME](ASTContext &) { return ME->getMember(); },
 /*IsNonstaticMember=*/true);
@@ -173,9 +194,38 @@ std::vector 
resolveDependentExprToDecls(const Expr *E) {
 [RE](ASTContext &) { return RE->getDeclName(); },
 /*IsNonstaticMember=*/false);
   }
+  if (const auto *CE = dyn_cast(E)) {
+const auto *CalleeType = resolveDependentExprToType(CE->getCallee());
+if (!CalleeType)
+  return {};
+if (const auto *FnTypePtr = CalleeType->getAs())
+  CalleeType = FnTypePtr->getPointeeType().getTypePtr();
+if (const FunctionType *FnType = CalleeType->getAs()) {
+  if (const auto *D =
+  resolveTypeToRecordDecl(FnType->getReturnType().getTypePtr())) {
+return {D};
+  }
+}
+  }
+  if (const auto *ME = dyn_cast(E)) {
+return {ME->getMemberDecl()};
+  }
   return {};
 }
 
+// Try to heuristically resolve the type of a dependent expression `E`.
+const Type *resolveDependentExprToType(const Expr *E) {
+  std::vector Decls = resolveDependentExprToDecls(E);
+  if (Decls.size() != 1) // Names an overload set -- just bail.
+return nullptr;
+  if (const auto *TD = dyn_cast(Decls[0])) {
+return TD->getTypeForDecl();
+  } else if (const auto *VD = dyn_cast(Decls[0])) {
+return VD->getType().getTypePtrOrNull();
+  }
+  return nullptr;
+}
+
 const NamedDecl *getTemplatePattern(con

[PATCH] D82739: [clangd] Improve heuristic resolution of dependent types in TargetFinder

2020-07-20 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9946dcd3e9c7: [clangd] Improve heuristic resolution of 
dependent types in TargetFinder (authored by nridge).

Changed prior to commit:
  https://reviews.llvm.org/D82739?vs=279426&id=279427#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82739

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -561,6 +561,74 @@
   EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char *)");
 }
 
+TEST_F(TargetDeclTest, DependentExprs) {
+  Flags = {"-fno-delayed-template-parsing"};
+
+  // Heuristic resolution of method of dependent field
+  Code = R"cpp(
+struct A { void foo() {} };
+template 
+struct B {
+  A a;
+  void bar() {
+this->a.[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  // Similar to above but base expression involves a function call.
+  Code = R"cpp(
+struct A {
+  void foo() {}
+};
+struct B {
+  A getA();
+};
+template 
+struct C {
+  B c;
+  void bar() {
+this->c.getA().[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  // Similar to above but uses a function pointer.
+  Code = R"cpp(
+struct A {
+  void foo() {}
+};
+struct B {
+  using FPtr = A(*)();
+  FPtr fptr;
+};
+template 
+struct C {
+  B c;
+  void bar() {
+this->c.fptr().[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  // Base expression involves a member access into this.
+  Code = R"cpp(
+struct Bar {
+  int ;
+};
+template  struct Foo {
+  Bar func(int);
+  void test() {
+func(1).[[]];
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "int ");
+}
+
 TEST_F(TargetDeclTest, ObjC) {
   Flags = {"-xobjective-c"};
   Code = R"cpp(
@@ -718,36 +786,37 @@
 
 TEST_F(FindExplicitReferencesTest, All) {
   std::pair Cases[] =
-  {// Simple expressions.
-   {R"cpp(
+  {
+  // Simple expressions.
+  {R"cpp(
 int global;
 int func();
 void foo(int param) {
   $0^global = $1^param + $2^func();
 }
 )cpp",
-"0: targets = {global}\n"
-"1: targets = {param}\n"
-"2: targets = {func}\n"},
-   {R"cpp(
+   "0: targets = {global}\n"
+   "1: targets = {param}\n"
+   "2: targets = {func}\n"},
+  {R"cpp(
 struct X { int a; };
 void foo(X x) {
   $0^x.$1^a = 10;
 }
 )cpp",
-"0: targets = {x}\n"
-"1: targets = {X::a}\n"},
-   {R"cpp(
+   "0: targets = {x}\n"
+   "1: targets = {X::a}\n"},
+  {R"cpp(
 // error-ok: testing with broken code
 int bar();
 int foo() {
   return $0^bar() + $1^bar(42);
 }
 )cpp",
-"0: targets = {bar}\n"
-"1: targets = {bar}\n"},
-   // Namespaces and aliases.
-   {R"cpp(
+   "0: targets = {bar}\n"
+   "1: targets = {bar}\n"},
+  // Namespaces and aliases.
+  {R"cpp(
   namespace ns {}
   namespace alias = ns;
   void foo() {
@@ -755,19 +824,19 @@
 using namespace $1^alias;
   }
 )cpp",
-"0: targets = {ns}\n"
-"1: targets = {alias}\n"},
-   // Using declarations.
-   {R"cpp(
+   "0: targets = {ns}\n"
+   "1: targets = {alias}\n"},
+  // Using declarations.
+  {R"cpp(
   namespace ns { int global; }
   void foo() {
 using $0^ns::$1^global;
   }
 )cpp",
-"0: targets = {ns}\n"
-"1: targets = {ns::global}, qualifier = 'ns::'\n"},
-   // Simple types.
-   {R"cpp(
+   "0: targets = {ns}\n"
+   "1: targets = {ns::global}, qualifier = 'ns::'\n"},
+  // Simple types.
+  {R"cpp(
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
@@ -776,13 +845,13 @@
static_cast<$4^Struct*>(0);
  }
)cpp",
-"0: targets = {Struct}\n"
-"1: targets = {x}, decl\n"
-"2: targets = {Typedef}\n"
-"3: targets = {y}, decl\

[PATCH] D82739: [clangd] Improve heuristic resolution of dependent types in TargetFinder

2020-07-20 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 279426.
nridge marked 5 inline comments as done.
nridge added a comment.

Address remaining comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82739

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -548,6 +548,74 @@
   EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char *)");
 }
 
+TEST_F(TargetDeclTest, DependentExprs) {
+  Flags = {"-fno-delayed-template-parsing"};
+
+  // Heuristic resolution of method of dependent field
+  Code = R"cpp(
+struct A { void foo() {} };
+template 
+struct B {
+  A a;
+  void bar() {
+this->a.[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  // Similar to above but base expression involves a function call.
+  Code = R"cpp(
+struct A {
+  void foo() {}
+};
+struct B {
+  A getA();
+};
+template 
+struct C {
+  B c;
+  void bar() {
+this->c.getA().[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  // Similar to above but uses a function pointer.
+  Code = R"cpp(
+struct A {
+  void foo() {}
+};
+struct B {
+  using FPtr = A(*)();
+  FPtr fptr;
+};
+template 
+struct C {
+  B c;
+  void bar() {
+this->c.fptr().[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+
+  // Base expression involves a member access into this.
+  Code = R"cpp(
+struct Bar {
+  int ;
+};
+template  struct Foo {
+  Bar func(int);
+  void test() {
+func(1).[[]];
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "int ");
+}
+
 TEST_F(TargetDeclTest, ObjC) {
   Flags = {"-xobjective-c"};
   Code = R"cpp(
@@ -705,36 +773,37 @@
 
 TEST_F(FindExplicitReferencesTest, All) {
   std::pair Cases[] =
-  {// Simple expressions.
-   {R"cpp(
+  {
+  // Simple expressions.
+  {R"cpp(
 int global;
 int func();
 void foo(int param) {
   $0^global = $1^param + $2^func();
 }
 )cpp",
-"0: targets = {global}\n"
-"1: targets = {param}\n"
-"2: targets = {func}\n"},
-   {R"cpp(
+   "0: targets = {global}\n"
+   "1: targets = {param}\n"
+   "2: targets = {func}\n"},
+  {R"cpp(
 struct X { int a; };
 void foo(X x) {
   $0^x.$1^a = 10;
 }
 )cpp",
-"0: targets = {x}\n"
-"1: targets = {X::a}\n"},
-   {R"cpp(
+   "0: targets = {x}\n"
+   "1: targets = {X::a}\n"},
+  {R"cpp(
 // error-ok: testing with broken code
 int bar();
 int foo() {
   return $0^bar() + $1^bar(42);
 }
 )cpp",
-"0: targets = {bar}\n"
-"1: targets = {bar}\n"},
-   // Namespaces and aliases.
-   {R"cpp(
+   "0: targets = {bar}\n"
+   "1: targets = {bar}\n"},
+  // Namespaces and aliases.
+  {R"cpp(
   namespace ns {}
   namespace alias = ns;
   void foo() {
@@ -742,19 +811,19 @@
 using namespace $1^alias;
   }
 )cpp",
-"0: targets = {ns}\n"
-"1: targets = {alias}\n"},
-   // Using declarations.
-   {R"cpp(
+   "0: targets = {ns}\n"
+   "1: targets = {alias}\n"},
+  // Using declarations.
+  {R"cpp(
   namespace ns { int global; }
   void foo() {
 using $0^ns::$1^global;
   }
 )cpp",
-"0: targets = {ns}\n"
-"1: targets = {ns::global}, qualifier = 'ns::'\n"},
-   // Simple types.
-   {R"cpp(
+   "0: targets = {ns}\n"
+   "1: targets = {ns::global}, qualifier = 'ns::'\n"},
+  // Simple types.
+  {R"cpp(
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
@@ -763,13 +832,13 @@
static_cast<$4^Struct*>(0);
  }
)cpp",
-"0: targets = {Struct}\n"
-"1: targets = {x}, decl\n"
-"2: targets = {Typedef}\n"
-"3: targets = {y}, decl\n"
-"4: targets = {Struct}\n"},
-   // Name qualifiers.
-   {R"cpp(
+   "0: targets = {Struct}\n"
+   "1: targets = 

[PATCH] D84122: [clangd] Handle deduction guides in TargetFinder and ExplicitReferenceCollector

2020-07-20 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG100dbd15624c: [clangd] Handle deduction guides in 
TargetFinder and ExplicitReferenceCollector (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84122

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -376,6 +376,8 @@
{"template<> class Foo", Rel::TemplateInstantiation},
{"template  class Foo", Rel::TemplatePattern});
 
+  Flags.push_back("-std=c++17"); // for CTAD tests
+
   Code = R"cpp(
 // Class template argument deduction
 template 
@@ -386,9 +388,20 @@
   [[Test]] a(5);
 }
   )cpp";
-  Flags.push_back("-std=c++17");
   EXPECT_DECLS("DeducedTemplateSpecializationTypeLoc",
{"struct Test", Rel::TemplatePattern});
+
+  Code = R"cpp(
+// Deduction guide
+template 
+struct Test {
+  template 
+  Test(I, I);
+};
+template 
+[[Test]](I, I) -> Test;
+  )cpp";
+  EXPECT_DECLS("CXXDeductionGuideDecl", {"template  struct Test"});
 }
 
 TEST_F(TargetDeclTest, Concept) {
@@ -792,8 +805,8 @@
goto $1^ten;
  }
)cpp",
-   "0: targets = {ten}, decl\n"
-   "1: targets = {ten}\n"},
+"0: targets = {ten}, decl\n"
+"1: targets = {ten}\n"},
// Simple templates.
{R"cpp(
   template  struct vector { using value_type = T; };
@@ -1295,7 +1308,7 @@
 "6: targets = {bar}, decl\n"
 "7: targets = {foo()::Bar::Foo}\n"
 "8: targets = {foo()::Baz::Field}\n"},
-  {R"cpp(
+   {R"cpp(
template
void crash(T);
template
@@ -1305,10 +1318,9 @@
 )cpp",
 "0: targets = {crash}\n"
 "1: targets = {}\n"
-"2: targets = {T}\n"
-  },
-  // unknown template name should not crash.
-  {R"cpp(
+"2: targets = {T}\n"},
+   // unknown template name should not crash.
+   {R"cpp(
 template  typename T>
 struct Base {};
 namespace foo {
@@ -1316,12 +1328,34 @@
 struct $1^Derive : $2^Base<$3^T::template $4^Unknown> {};
 }
   )cpp",
-  "0: targets = {foo::Derive::T}, decl\n"
-  "1: targets = {foo::Derive}, decl\n"
-  "2: targets = {Base}\n"
-  "3: targets = {foo::Derive::T}\n"
-  "4: targets = {}, qualifier = 'T::'\n"},
-};
+"0: targets = {foo::Derive::T}, decl\n"
+"1: targets = {foo::Derive}, decl\n"
+"2: targets = {Base}\n"
+"3: targets = {foo::Derive::T}\n"
+"4: targets = {}, qualifier = 'T::'\n"},
+   // deduction guide
+   {R"cpp(
+  namespace foo {
+template 
+struct $1^Test {
+  template 
+  $3^Test($4^I);
+};
+template 
+$6^Test($7^I) -> $8^Test;
+  }
+)cpp",
+"0: targets = {T}, decl\n"
+"1: targets = {foo::Test}, decl\n"
+"2: targets = {I}, decl\n"
+"3: targets = {foo::Test::Test}, decl\n"
+"4: targets = {I}\n"
+"5: targets = {I}, decl\n"
+"6: targets = {foo::Test}\n"
+"7: targets = {I}\n"
+"8: targets = {foo::Test}\n"
+"9: targets = {I}\n"
+"10: targets = {}, qualifier = 'I::'\n"}};
 
   for (const auto &C : Cases) {
 llvm::StringRef ExpectedCode = C.first;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -302,6 +302,8 @@
   // Record the underlying decl instead, if allowed.
   D = USD->getTargetDecl();
   Flags |= Rel::Underlying; // continue with the underlying decl.
+} else if (const auto *DG = dyn_cast(D)) {
+  D = DG->getDeducedTemplate();
 }
 
 if (const Decl *Pat = getTemplatePattern(D)) {
@@ -659,6 +661,15 @@
   /*IsDecl=*/true,
   {ND}});
 }
+
+void VisitCXXDeductionGuideDecl(const CXXDeductionGuideDecl *DG) {
+  // The class template name in a deduction guide targets the class
+  // template.
+  Refs.push_back(ReferenceLoc{DG->getQualifierLoc(),
+  DG->getNameInfo().getLoc(),
+  /*IsDecl=*/false,
+  {DG->getDeducedTemplate()}});
+}
   };
 
   Visitor V;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/

[clang-tools-extra] 100dbd1 - [clangd] Handle deduction guides in TargetFinder and ExplicitReferenceCollector

2020-07-20 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2020-07-21T01:44:48-04:00
New Revision: 100dbd15624c1ac8d1210e7748462e20fed9a9d9

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

LOG: [clangd] Handle deduction guides in TargetFinder and 
ExplicitReferenceCollector

Summary: Fixes https://github.com/clangd/clangd/issues/463.

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 627f40c85436..c2887f3306fa 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -302,6 +302,8 @@ struct TargetFinder {
   // Record the underlying decl instead, if allowed.
   D = USD->getTargetDecl();
   Flags |= Rel::Underlying; // continue with the underlying decl.
+} else if (const auto *DG = dyn_cast(D)) {
+  D = DG->getDeducedTemplate();
 }
 
 if (const Decl *Pat = getTemplatePattern(D)) {
@@ -659,6 +661,15 @@ llvm::SmallVector refInDecl(const Decl 
*D) {
   /*IsDecl=*/true,
   {ND}});
 }
+
+void VisitCXXDeductionGuideDecl(const CXXDeductionGuideDecl *DG) {
+  // The class template name in a deduction guide targets the class
+  // template.
+  Refs.push_back(ReferenceLoc{DG->getQualifierLoc(),
+  DG->getNameInfo().getLoc(),
+  /*IsDecl=*/false,
+  {DG->getDeducedTemplate()}});
+}
   };
 
   Visitor V;

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index bf5cc62411b7..fa8f4935b1d9 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -376,6 +376,8 @@ TEST_F(TargetDeclTest, ClassTemplate) {
{"template<> class Foo", Rel::TemplateInstantiation},
{"template  class Foo", Rel::TemplatePattern});
 
+  Flags.push_back("-std=c++17"); // for CTAD tests
+
   Code = R"cpp(
 // Class template argument deduction
 template 
@@ -386,9 +388,20 @@ TEST_F(TargetDeclTest, ClassTemplate) {
   [[Test]] a(5);
 }
   )cpp";
-  Flags.push_back("-std=c++17");
   EXPECT_DECLS("DeducedTemplateSpecializationTypeLoc",
{"struct Test", Rel::TemplatePattern});
+
+  Code = R"cpp(
+// Deduction guide
+template 
+struct Test {
+  template 
+  Test(I, I);
+};
+template 
+[[Test]](I, I) -> Test;
+  )cpp";
+  EXPECT_DECLS("CXXDeductionGuideDecl", {"template  struct Test"});
 }
 
 TEST_F(TargetDeclTest, Concept) {
@@ -792,8 +805,8 @@ TEST_F(FindExplicitReferencesTest, All) {
goto $1^ten;
  }
)cpp",
-   "0: targets = {ten}, decl\n"
-   "1: targets = {ten}\n"},
+"0: targets = {ten}, decl\n"
+"1: targets = {ten}\n"},
// Simple templates.
{R"cpp(
   template  struct vector { using value_type = T; };
@@ -1295,7 +1308,7 @@ TEST_F(FindExplicitReferencesTest, All) {
 "6: targets = {bar}, decl\n"
 "7: targets = {foo()::Bar::Foo}\n"
 "8: targets = {foo()::Baz::Field}\n"},
-  {R"cpp(
+   {R"cpp(
template
void crash(T);
template
@@ -1305,10 +1318,9 @@ TEST_F(FindExplicitReferencesTest, All) {
 )cpp",
 "0: targets = {crash}\n"
 "1: targets = {}\n"
-"2: targets = {T}\n"
-  },
-  // unknown template name should not crash.
-  {R"cpp(
+"2: targets = {T}\n"},
+   // unknown template name should not crash.
+   {R"cpp(
 template  typename T>
 struct Base {};
 namespace foo {
@@ -1316,12 +1328,34 @@ TEST_F(FindExplicitReferencesTest, All) {
 struct $1^Derive : $2^Base<$3^T::template $4^Unknown> {};
 }
   )cpp",
-  "0: targets = {foo::Derive::T}, decl\n"
-  "1: targets = {foo::Derive}, decl\n"
-  "2: targets = {Base}\n"
-  "3: targets = {foo::Derive::T}\n"
-  "4: targets = {}, qualifier = 'T::'\n"},
-};
+"0: targets = {foo::Derive::T}, decl\n"
+"1: targets = {foo::Derive}, decl\n"
+"2: targets = {Base}\n"
+"3: targets = {foo::Derive::T}\n"
+"4: targets = {}, qualifier = 'T::'\n"},
+   // deduction guide
+   {R"cpp(
+  namespace foo {
+template 
+struct $1^Test {
+  template 
+

[PATCH] D84122: [clangd] Handle deduction guides in TargetFinder and ExplicitReferenceCollector

2020-07-20 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 279424.
nridge marked an inline comment as done.
nridge added a comment.

Address nit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84122

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -376,6 +376,8 @@
{"template<> class Foo", Rel::TemplateInstantiation},
{"template  class Foo", Rel::TemplatePattern});
 
+  Flags.push_back("-std=c++17"); // for CTAD tests
+
   Code = R"cpp(
 // Class template argument deduction
 template 
@@ -386,9 +388,20 @@
   [[Test]] a(5);
 }
   )cpp";
-  Flags.push_back("-std=c++17");
   EXPECT_DECLS("DeducedTemplateSpecializationTypeLoc",
{"struct Test", Rel::TemplatePattern});
+
+  Code = R"cpp(
+// Deduction guide
+template 
+struct Test {
+  template 
+  Test(I, I);
+};
+template 
+[[Test]](I, I) -> Test;
+  )cpp";
+  EXPECT_DECLS("CXXDeductionGuideDecl", {"template  struct Test"});
 }
 
 TEST_F(TargetDeclTest, Concept) {
@@ -792,8 +805,8 @@
goto $1^ten;
  }
)cpp",
-   "0: targets = {ten}, decl\n"
-   "1: targets = {ten}\n"},
+"0: targets = {ten}, decl\n"
+"1: targets = {ten}\n"},
// Simple templates.
{R"cpp(
   template  struct vector { using value_type = T; };
@@ -1295,7 +1308,7 @@
 "6: targets = {bar}, decl\n"
 "7: targets = {foo()::Bar::Foo}\n"
 "8: targets = {foo()::Baz::Field}\n"},
-  {R"cpp(
+   {R"cpp(
template
void crash(T);
template
@@ -1305,10 +1318,9 @@
 )cpp",
 "0: targets = {crash}\n"
 "1: targets = {}\n"
-"2: targets = {T}\n"
-  },
-  // unknown template name should not crash.
-  {R"cpp(
+"2: targets = {T}\n"},
+   // unknown template name should not crash.
+   {R"cpp(
 template  typename T>
 struct Base {};
 namespace foo {
@@ -1316,12 +1328,34 @@
 struct $1^Derive : $2^Base<$3^T::template $4^Unknown> {};
 }
   )cpp",
-  "0: targets = {foo::Derive::T}, decl\n"
-  "1: targets = {foo::Derive}, decl\n"
-  "2: targets = {Base}\n"
-  "3: targets = {foo::Derive::T}\n"
-  "4: targets = {}, qualifier = 'T::'\n"},
-};
+"0: targets = {foo::Derive::T}, decl\n"
+"1: targets = {foo::Derive}, decl\n"
+"2: targets = {Base}\n"
+"3: targets = {foo::Derive::T}\n"
+"4: targets = {}, qualifier = 'T::'\n"},
+   // deduction guide
+   {R"cpp(
+  namespace foo {
+template 
+struct $1^Test {
+  template 
+  $3^Test($4^I);
+};
+template 
+$6^Test($7^I) -> $8^Test;
+  }
+)cpp",
+"0: targets = {T}, decl\n"
+"1: targets = {foo::Test}, decl\n"
+"2: targets = {I}, decl\n"
+"3: targets = {foo::Test::Test}, decl\n"
+"4: targets = {I}\n"
+"5: targets = {I}, decl\n"
+"6: targets = {foo::Test}\n"
+"7: targets = {I}\n"
+"8: targets = {foo::Test}\n"
+"9: targets = {I}\n"
+"10: targets = {}, qualifier = 'I::'\n"}};
 
   for (const auto &C : Cases) {
 llvm::StringRef ExpectedCode = C.first;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -270,6 +270,8 @@
   // Record the underlying decl instead, if allowed.
   D = USD->getTargetDecl();
   Flags |= Rel::Underlying; // continue with the underlying decl.
+} else if (const auto *DG = dyn_cast(D)) {
+  D = DG->getDeducedTemplate();
 }
 
 if (const Decl *Pat = getTemplatePattern(D)) {
@@ -636,6 +638,15 @@
   /*IsDecl=*/true,
   {ND}});
 }
+
+void VisitCXXDeductionGuideDecl(const CXXDeductionGuideDecl *DG) {
+  // The class template name in a deduction guide targets the class
+  // template.
+  Refs.push_back(ReferenceLoc{DG->getQualifierLoc(),
+  DG->getNameInfo().getLoc(),
+  /*IsDecl=*/false,
+  {DG->getDeducedTemplate()}});
+}
   };
 
   Visitor V;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83492: [OpenMP] Use common interface to access GPU Grid Values

2020-07-20 Thread Saiyedul Islam via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfc7d2908ab38: [OpenMP] Use common interface to access GPU 
Grid Values (authored by saiislam).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83492

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Cuda.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
 
 using namespace clang;
@@ -195,11 +196,9 @@
 /// code.  For all practical purposes this is fine because the configuration
 /// is the same for all known NVPTX architectures.
 enum MachineConfiguration : unsigned {
-  WarpSize = 32,
-  /// Number of bits required to represent a lane identifier, which is
-  /// computed as log_2(WarpSize).
-  LaneIDBits = 5,
-  LaneIDMask = WarpSize - 1,
+  /// See "llvm/Frontend/OpenMP/OMPGridValues.h" for various related target
+  /// specific Grid Values like GV_Warp_Size, GV_Warp_Size_Log2,
+  /// and GV_Warp_Size_Log2_Mask.
 
   /// Global memory alignment for performance.
   GlobalMemoryAlignment = 128,
@@ -431,6 +430,7 @@
 assert(!GlobalizedRD &&
"Record for globalized variables is built already.");
 ArrayRef EscapedDeclsForParallel, EscapedDeclsForTeams;
+unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
 if (IsInTTDRegion)
   EscapedDeclsForTeams = EscapedDecls.getArrayRef();
 else
@@ -634,6 +634,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXWarpID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDBits =
+  CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size_Log2);
   return Bld.CreateAShr(getNVPTXThreadID(CGF), LaneIDBits, "nvptx_warp_id");
 }
 
@@ -642,6 +644,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXLaneID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDMask = CGF.getContext().getTargetInfo().getGridValue(
+  llvm::omp::GV_Warp_Size_Log2_Mask);
   return Bld.CreateAnd(getNVPTXThreadID(CGF), Bld.getInt32(LaneIDMask),
"nvptx_lane_id");
 }
@@ -2058,6 +2062,7 @@
   const RecordDecl *GlobalizedRD = nullptr;
   llvm::SmallVector LastPrivatesReductions;
   llvm::SmallDenseMap MappedDeclsFields;
+  unsigned WarpSize = CGM.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
   // Globalize team reductions variable unconditionally in all modes.
   if (getExecutionMode() != CGOpenMPRuntimeGPU::EM_SPMD)
 getTeamsReductionVars(CGM.getContext(), D, LastPrivatesReductions);
@@ -3233,6 +3238,7 @@
   "__openmp_nvptx_data_transfer_temporary_storage";
   llvm::GlobalVariable *TransferMedium =
   M.getGlobalVariable(TransferMediumName);
+  unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
   if (!TransferMedium) {
 auto *Ty = llvm::ArrayType::get(CGM.Int32Ty, WarpSize);
 unsigned SharedAddressSpace = C.getTargetAddressSpace(LangAS::cuda_shared);


Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Cuda.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
 
 using namespace clang;
@@ -195,11 +196,9 @@
 /// code.  For all practical purposes this is fine because the configuration
 /// is the same for all known NVPTX architectures.
 enum MachineConfiguration : unsigned {
-  WarpSize = 32,
-  /// Number of bits required to represent a lane identifier, which is
-  /// computed as log_2(WarpSize).
-  LaneIDBits = 5,
-  LaneIDMask = WarpSize - 1,
+  /// See "llvm/Frontend/OpenMP/OMPGridValues.h" for various related target
+  /// specific Grid Values like GV_Warp_Size, GV_Warp_Size_Log2,
+  /// and GV_Warp_Size_Log2_Mask.
 
   /// Global memory alignment for performance.
   GlobalMemoryAlignment = 128,
@@ -431,6 +430,7 @@
 assert(!GlobalizedRD &&
"Record for globalized variables is built already.");
 ArrayRef EscapedDeclsForParallel, EscapedDeclsForTeams;
+unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
 if (IsInTTDRegion)
   EscapedDeclsForTeams = EscapedDecls.getArrayRef();
 else
@@ -634,6 +634,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXWarpID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned L

[clang] fc7d290 - [OpenMP] Use common interface to access GPU Grid Values

2020-07-20 Thread Saiyedul Islam via cfe-commits

Author: Saiyedul Islam
Date: 2020-07-21T05:25:46Z
New Revision: fc7d2908ab38e1934b3b6a8ab3ec5c674484434b

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

LOG: [OpenMP] Use common interface to access GPU Grid Values

Use common interface for accessing target specific GPU grid values in NVPTX
OpenMP codegen as proposed in https://reviews.llvm.org/D80917

Originally authored by Greg Rodgers (@gregrodgers).

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 92eca33ee97d..1cd89c540f47 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Cuda.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
 
 using namespace clang;
@@ -195,11 +196,9 @@ class ExecutionRuntimeModesRAII {
 /// code.  For all practical purposes this is fine because the configuration
 /// is the same for all known NVPTX architectures.
 enum MachineConfiguration : unsigned {
-  WarpSize = 32,
-  /// Number of bits required to represent a lane identifier, which is
-  /// computed as log_2(WarpSize).
-  LaneIDBits = 5,
-  LaneIDMask = WarpSize - 1,
+  /// See "llvm/Frontend/OpenMP/OMPGridValues.h" for various related target
+  /// specific Grid Values like GV_Warp_Size, GV_Warp_Size_Log2,
+  /// and GV_Warp_Size_Log2_Mask.
 
   /// Global memory alignment for performance.
   GlobalMemoryAlignment = 128,
@@ -431,6 +430,7 @@ class CheckVarsEscapingDeclContext final
 assert(!GlobalizedRD &&
"Record for globalized variables is built already.");
 ArrayRef EscapedDeclsForParallel, EscapedDeclsForTeams;
+unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
 if (IsInTTDRegion)
   EscapedDeclsForTeams = EscapedDecls.getArrayRef();
 else
@@ -634,6 +634,8 @@ static llvm::Value *getNVPTXThreadID(CodeGenFunction &CGF) {
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXWarpID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDBits =
+  CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size_Log2);
   return Bld.CreateAShr(getNVPTXThreadID(CGF), LaneIDBits, "nvptx_warp_id");
 }
 
@@ -642,6 +644,8 @@ static llvm::Value *getNVPTXWarpID(CodeGenFunction &CGF) {
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXLaneID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDMask = CGF.getContext().getTargetInfo().getGridValue(
+  llvm::omp::GV_Warp_Size_Log2_Mask);
   return Bld.CreateAnd(getNVPTXThreadID(CGF), Bld.getInt32(LaneIDMask),
"nvptx_lane_id");
 }
@@ -2058,6 +2062,7 @@ llvm::Function 
*CGOpenMPRuntimeGPU::emitTeamsOutlinedFunction(
   const RecordDecl *GlobalizedRD = nullptr;
   llvm::SmallVector LastPrivatesReductions;
   llvm::SmallDenseMap MappedDeclsFields;
+  unsigned WarpSize = CGM.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
   // Globalize team reductions variable unconditionally in all modes.
   if (getExecutionMode() != CGOpenMPRuntimeGPU::EM_SPMD)
 getTeamsReductionVars(CGM.getContext(), D, LastPrivatesReductions);
@@ -3233,6 +3238,7 @@ static llvm::Value 
*emitInterWarpCopyFunction(CodeGenModule &CGM,
   "__openmp_nvptx_data_transfer_temporary_storage";
   llvm::GlobalVariable *TransferMedium =
   M.getGlobalVariable(TransferMediumName);
+  unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
   if (!TransferMedium) {
 auto *Ty = llvm::ArrayType::get(CGM.Int32Ty, WarpSize);
 unsigned SharedAddressSpace = C.getTargetAddressSpace(LangAS::cuda_shared);



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


[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-20 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

In D83360#2162898 , @craig.topper 
wrote:

> @aqjune did you put a patch for InstSimplify doing distribution over undef 
> yet?


Sorry, making InstSimplify to safely distribute undef was a nontrivial job - 
other than updating InstSimplify to track uses, it needed rewinding folded 
undef records if simplification failed & update constant folding to track uses 
too. The folded value could be symbolic, making things more complex.
I'm trying an alternative solution for this problem, I will leave a link here 
after submission.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D83820: Change metadata to deferred evalutaion in Clang Transformer.

2020-07-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc0b8954ecba5: [libTooling] In Clang Transformer, change 
`Metadata` field to deferred… (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83820

Files:
  clang/include/clang/Tooling/Transformer/RewriteRule.h
  clang/lib/Tooling/Transformer/RewriteRule.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -440,6 +440,12 @@
 }
 
 TEST_F(TransformerTest, WithMetadata) {
+  auto makeMetadata = [](const MatchFinder::MatchResult &R) -> llvm::Any {
+int N =
+R.Nodes.getNodeAs("int")->getValue().getLimitedValue();
+return N;
+  };
+
   std::string Input = R"cc(
 int f() {
   int x = 5;
@@ -448,8 +454,11 @@
   )cc";
 
   Transformer T(
-  makeRule(declStmt().bind("decl"),
-   withMetadata(remove(statement(std::string("decl"))), 17)),
+  makeRule(
+  declStmt(containsDeclaration(0, varDecl(hasInitializer(
+  integerLiteral().bind("int")
+  .bind("decl"),
+  withMetadata(remove(statement(std::string("decl"))), makeMetadata)),
   consumer());
   T.registerMatchers(&MatchFinder);
   auto Factory = newFrontendActionFactory(&MatchFinder);
@@ -459,7 +468,7 @@
   ASSERT_EQ(Changes.size(), 1u);
   const llvm::Any &Metadata = Changes[0].getMetadata();
   ASSERT_TRUE(llvm::any_isa(Metadata));
-  EXPECT_THAT(llvm::any_cast(Metadata), 17);
+  EXPECT_THAT(llvm::any_cast(Metadata), 5);
 }
 
 TEST_F(TransformerTest, MultiChange) {
Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -44,10 +44,13 @@
 auto Replacement = E.Replacement->eval(Result);
 if (!Replacement)
   return Replacement.takeError();
+auto Metadata = E.Metadata(Result);
+if (!Metadata)
+  return Metadata.takeError();
 transformer::Edit T;
 T.Range = *EditRange;
 T.Replacement = std::move(*Replacement);
-T.Metadata = E.Metadata;
+T.Metadata = std::move(*Metadata);
 Edits.push_back(std::move(T));
   }
   return Edits;
Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -47,6 +47,8 @@
 
 using TextGenerator = std::shared_ptr>;
 
+using AnyGenerator = MatchConsumer;
+
 // Description of a source-code edit, expressed in terms of an AST node.
 // Includes: an ID for the (bound) node, a selector for source related to the
 // node, a replacement and, optionally, an explanation for the edit.
@@ -87,7 +89,11 @@
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
-  llvm::Any Metadata;
+  // Not all transformations will want or need to attach metadata and therefore
+  // should not be required to do so.
+  AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {
+return llvm::Any();
+  };
 };
 
 /// Lifts a list of `ASTEdit`s into an `EditGenerator`.
@@ -261,9 +267,27 @@
 /// Removes the source selected by \p S.
 ASTEdit remove(RangeSelector S);
 
-inline ASTEdit withMetadata(ASTEdit edit, llvm::Any Metadata) {
-  edit.Metadata = std::move(Metadata);
-  return edit;
+// FIXME: If `Metadata` returns an `llvm::Expected` the `AnyGenerator` will
+// construct an `llvm::Expected` where no error is present but the
+// `llvm::Any` holds the error. This is unlikely but potentially surprising.
+// Perhaps the `llvm::Expected` should be unwrapped, or perhaps this should be a
+// compile-time error. No solution here is perfect.
+//
+// Note: This function template accepts any type callable with a MatchResult
+// rather than a `std::function` because the return-type needs to be deduced. If
+// it accepted a `std::function`, lambdas or other callable
+// types would not be able to deduce `R`, and users would be forced to specify
+// explicitly the type they intended to return by wrapping the lambda at the
+// call-site.
+template 
+inline ASTEdit withMetadata(ASTEdit Edit, Callable Metadata) {
+  Edit.Metadata =
+  [Gen = std::move(Metadata)](
+  const ast_matchers::MatchFinder::MatchResult &R) -> llvm::Any {
+return Gen(R);
+  };
+
+  return Edit;
 }
 
 /// The following three functions are a low-level part of the RewriteRule
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-20 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

I've done another pass over the code (but did not get through the tests). I 
have no comments about the code at this time. My understanding is that 
@jasonliu will be doing another pass over this patch, so he can approve while 
I'm away on vacation.


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

https://reviews.llvm.org/D79719



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


[PATCH] D84144: [clangd] Remove TokenBuffer usage in TypeHierarchy

2020-07-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc911803d5df0: [clangd] Remove TokenBuffer usage in 
TypeHierarchy (authored by ArcsinX, committed by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84144

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp

Index: clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -523,6 +523,33 @@
WithKind(SymbolKind::Struct), Children();
 }
 
+TEST(TypeHierarchy, Preamble) {
+  Annotations SourceAnnotations(R"cpp(
+struct Ch^ild : Parent {
+  int b;
+};)cpp");
+
+  Annotations HeaderInPreambleAnnotations(R"cpp(
+struct [[Parent]] {
+  int a;
+};)cpp");
+
+  TestTU TU = TestTU::withCode(SourceAnnotations.code());
+  TU.HeaderCode = HeaderInPreambleAnnotations.code().str();
+  auto AST = TU.build();
+
+  llvm::Optional Result = getTypeHierarchy(
+  AST, SourceAnnotations.point(), 1, TypeHierarchyDirection::Parents);
+
+  ASSERT_TRUE(Result);
+  EXPECT_THAT(
+  *Result,
+  AllOf(WithName("Child"),
+Parents(AllOf(WithName("Parent"),
+  SelectionRangeIs(HeaderInPreambleAnnotations.range()),
+  Parents();
+}
+
 SymbolID findSymbolIDByName(SymbolIndex *Index, llvm::StringRef Name,
 llvm::StringRef TemplateArgs = "") {
   SymbolID Result;
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1183,23 +1183,24 @@
 
 // FIXME(nridge): Reduce duplication between this function and declToSym().
 static llvm::Optional
-declToTypeHierarchyItem(ASTContext &Ctx, const NamedDecl &ND,
-const syntax::TokenBuffer &TB) {
+declToTypeHierarchyItem(ASTContext &Ctx, const NamedDecl &ND) {
   auto &SM = Ctx.getSourceManager();
   SourceLocation NameLoc = nameLocation(ND, Ctx.getSourceManager());
+  SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
+  SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc()));
+  const auto DeclRange =
+  toHalfOpenFileRange(SM, Ctx.getLangOpts(), {BeginLoc, EndLoc});
+  if (!DeclRange)
+return llvm::None;
   auto FilePath =
   getCanonicalPath(SM.getFileEntryForID(SM.getFileID(NameLoc)), SM);
   auto TUPath = getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
   if (!FilePath || !TUPath)
 return llvm::None; // Not useful without a uri.
 
-  auto DeclToks = TB.spelledForExpanded(TB.expandedTokens(ND.getSourceRange()));
-  if (!DeclToks || DeclToks->empty())
-return llvm::None;
-
-  auto NameToks = TB.spelledForExpanded(TB.expandedTokens(NameLoc));
-  if (!NameToks || NameToks->empty())
-return llvm::None;
+  Position NameBegin = sourceLocToPosition(SM, NameLoc);
+  Position NameEnd = sourceLocToPosition(
+  SM, Lexer::getLocForEndOfToken(NameLoc, 0, SM, Ctx.getLangOpts()));
 
   index::SymbolInfo SymInfo = index::getSymbolInfo(&ND);
   // FIXME: this is not classifying constructors, destructors and operators
@@ -1210,12 +1211,9 @@
   THI.name = printName(Ctx, ND);
   THI.kind = SK;
   THI.deprecated = ND.isDeprecated();
-  THI.range = halfOpenToRange(
-  SM, syntax::Token::range(SM, DeclToks->front(), DeclToks->back())
-  .toCharRange(SM));
-  THI.selectionRange = halfOpenToRange(
-  SM, syntax::Token::range(SM, NameToks->front(), NameToks->back())
-  .toCharRange(SM));
+  THI.range = Range{sourceLocToPosition(SM, DeclRange->getBegin()),
+sourceLocToPosition(SM, DeclRange->getEnd())};
+  THI.selectionRange = Range{NameBegin, NameEnd};
   if (!THI.range.contains(THI.selectionRange)) {
 // 'selectionRange' must be contained in 'range', so in cases where clang
 // reports unrelated ranges we need to reconcile somehow.
@@ -1282,8 +1280,7 @@
 
 static void fillSuperTypes(const CXXRecordDecl &CXXRD, ASTContext &ASTCtx,
std::vector &SuperTypes,
-   RecursionProtectionSet &RPSet,
-   const syntax::TokenBuffer &TB) {
+   RecursionProtectionSet &RPSet) {
   // typeParents() will replace dependent template specializations
   // with their class template, so to avoid infinite recursion for
   // certain types of hierarchies, keep the templates encountered
@@ -1298,9 +1295,9 @@
 
   for (const CXXRecordDecl *ParentDecl : typeParents(&CXXRD)) {
 if (Optional ParentSym =
-declToTypeHierarchyItem(ASTCtx, *ParentDecl, TB)) {
+declT

[PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions

2020-07-20 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ff220de9009: [analyzer][StdLibraryFunctionsChecker] Add 
POSIX networking functions (authored by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83407

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c

Index: clang/test/Analysis/std-c-library-functions-POSIX.c
===
--- clang/test/Analysis/std-c-library-functions-POSIX.c
+++ clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -79,6 +79,22 @@
 // CHECK: Loaded summary for: int execv(const char *path, char *const argv[])
 // CHECK: Loaded summary for: int execvp(const char *file, char *const argv[])
 // CHECK: Loaded summary for: int getopt(int argc, char *const argv[], const char *optstring)
+// CHECK: Loaded summary for: int accept(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int bind(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len)
+// CHECK: Loaded summary for: int getpeername(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int getsockname(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int connect(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len)
+// CHECK: Loaded summary for: ssize_t recvfrom(int socket, void *restrict buffer, size_t length, int flags, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: ssize_t sendto(int socket, const void *message, size_t length, int flags, __CONST_SOCKADDR_ARG dest_addr, socklen_t dest_len)
+// CHECK: Loaded summary for: int listen(int sockfd, int backlog)
+// CHECK: Loaded summary for: ssize_t recv(int sockfd, void *buf, size_t len, int flags)
+// CHECK: Loaded summary for: ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags)
+// CHECK: Loaded summary for: ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags)
+// CHECK: Loaded summary for: int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len)
+// CHECK: Loaded summary for: int getsockopt(int socket, int level, int option_name, void *restrict option_value, socklen_t *restrict option_len)
+// CHECK: Loaded summary for: ssize_t send(int sockfd, const void *buf, size_t len, int flags)
+// CHECK: Loaded summary for: int socketpair(int domain, int type, int protocol, int sv[2])
+// CHECK: Loaded summary for: int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, char *restrict node, socklen_t nodelen, char *restrict service, socklen_t servicelen, int flags)
 
 long a64l(const char *str64);
 char *l64a(long value);
@@ -171,6 +187,46 @@
 int execvp(const char *file, char *const argv[]);
 int getopt(int argc, char *const argv[], const char *optstring);
 
+// In some libc implementations, sockaddr parameter is a transparent
+// union of the underlying sockaddr_ pointers instead of being a
+// pointer to struct sockaddr.
+// We match that with the joker Irrelevant type.
+struct sockaddr;
+struct sockaddr_at;
+#define __SOCKADDR_ALLTYPES\
+  __SOCKADDR_ONETYPE(sockaddr) \
+  __SOCKADDR_ONETYPE(sockaddr_at)
+#define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
+typedef union {
+  __SOCKADDR_ALLTYPES
+} __SOCKADDR_ARG __attribute__((__transparent_union__));
+#undef __SOCKADDR_ONETYPE
+#define __SOCKADDR_ONETYPE(type) const struct type *__restrict __##type##__;
+typedef union {
+  __SOCKADDR_ALLTYPES
+} __CONST_SOCKADDR_ARG __attribute__((__transparent_union__));
+#undef __SOCKADDR_ONETYPE
+typedef unsigned socklen_t;
+
+int accept(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int bind(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len);
+int getpeername(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int getsockname(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int connect(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len);
+ssize_t recvfrom(int socket, void *restrict buffer, size_t length, int flags, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+ssize_t sendto(int socket, const void *message, size_t length, int flags, __CONST_SOCKADDR_ARG dest_addr, socklen_t dest_len);
+
+int listen(int sockfd, int backlog);
+ssize_t recv(int sockfd, void *buf, size_t len, int flags);
+struct msghdr;
+ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags);
+ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
+int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len);
+int getsockopt(int socket, int leve

[PATCH] D84090: [clang-format] Add BitFieldColonSpacing option

2020-07-20 Thread Anders Waldenborg via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG52ab7aa0ba5a: [clang-format] Add BitFieldColonSpacing option 
(authored by wanders).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84090

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2165,6 +2165,33 @@
"  uchar : 8;\n"
"  uchar other;\n"
"};");
+  FormatStyle Style = getLLVMStyle();
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  verifyFormat("struct Bitfields {\n"
+   "  unsigned sClass:8;\n"
+   "  unsigned ValueKind:2;\n"
+   "  uchar other;\n"
+   "};",
+   Style);
+  verifyFormat("struct A {\n"
+   "  int a:1,\n"
+   "  b:2;\n"
+   "};",
+   Style);
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_Before;
+  verifyFormat("struct Bitfields {\n"
+   "  unsigned sClass :8;\n"
+   "  unsigned ValueKind :2;\n"
+   "  uchar other;\n"
+   "};",
+   Style);
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_After;
+  verifyFormat("struct Bitfields {\n"
+   "  unsigned sClass: 8;\n"
+   "  unsigned ValueKind: 2;\n"
+   "  uchar other;\n"
+   "};",
+   Style);
 }
 
 TEST_F(FormatTest, FormatsNamespaces) {
@@ -12156,6 +12183,21 @@
"int   oneTwoThree : 23 = 0;",
Alignment);
 
+  Alignment.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  verifyFormat("int const a  :5;\n"
+   "int   oneTwoThree:23;",
+   Alignment);
+
+  Alignment.BitFieldColonSpacing = FormatStyle::BFCS_Before;
+  verifyFormat("int const a   :5;\n"
+   "int   oneTwoThree :23;",
+   Alignment);
+
+  Alignment.BitFieldColonSpacing = FormatStyle::BFCS_After;
+  verifyFormat("int const a  : 5;\n"
+   "int   oneTwoThree: 23;",
+   Alignment);
+
   // Known limitations: ':' is only recognized as a bitfield colon when
   // followed by a number.
   /*
@@ -14004,6 +14046,16 @@
   CHECK_PARSE("IndentExternBlock: false", IndentExternBlock,
   FormatStyle::IEBS_NoIndent);
 
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  CHECK_PARSE("BitFieldColonSpacing: Both", BitFieldColonSpacing,
+  FormatStyle::BFCS_Both);
+  CHECK_PARSE("BitFieldColonSpacing: None", BitFieldColonSpacing,
+  FormatStyle::BFCS_None);
+  CHECK_PARSE("BitFieldColonSpacing: Before", BitFieldColonSpacing,
+  FormatStyle::BFCS_Before);
+  CHECK_PARSE("BitFieldColonSpacing: After", BitFieldColonSpacing,
+  FormatStyle::BFCS_After);
+
   // FIXME: This is required because parsing a configuration simply overwrites
   // the first N elements of the list instead of resetting it.
   Style.ForEachMacros.clear();
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3251,6 +3251,9 @@
   if (Right.is(TT_RangeBasedForLoopColon) &&
   !Style.SpaceBeforeRangeBasedForLoopColon)
 return false;
+  if (Left.is(TT_BitFieldColon))
+return Style.BitFieldColonSpacing == FormatStyle::BFCS_Both ||
+   Style.BitFieldColonSpacing == FormatStyle::BFCS_After;
   if (Right.is(tok::colon)) {
 if (Line.First->isOneOf(tok::kw_case, tok::kw_default) ||
 !Right.getNextNonComment() || Right.getNextNonComment()->is(tok::semi))
@@ -3267,6 +3270,9 @@
   return false;
 if (Right.is(TT_CSharpNamedArgumentColon))
   return false;
+if (Right.is(TT_BitFieldColon))
+  return Style.BitFieldColonSpacing == FormatStyle::BFCS_Both ||
+ Style.BitFieldColonSpacing == FormatStyle::BFCS_Before;
 return true;
   }
   if (Left.is(TT_UnaryOperator)) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -366,6 +366,17 @@
   }
 };
 
+template <>
+struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO,
+  FormatStyle::BitFieldColonSpacingStyle &Value) {
+IO.enumCase(Value, "Both", FormatStyle:

[PATCH] D83592: [Parser] Add comment to skipped regions

2020-07-20 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 279395.
zequanwu added a comment.

Missed something. Updated


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

https://reviews.llvm.org/D83592

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Lex/Preprocessor.cpp
  clang/test/CoverageMapping/break.c
  clang/test/CoverageMapping/builtinmacro.c
  clang/test/CoverageMapping/classtemplate.cpp
  clang/test/CoverageMapping/comment-in-macro.c
  clang/test/CoverageMapping/continue.c
  clang/test/CoverageMapping/coroutine.cpp
  clang/test/CoverageMapping/deferred-region.cpp
  clang/test/CoverageMapping/if.cpp
  clang/test/CoverageMapping/includehell.cpp
  clang/test/CoverageMapping/label.cpp
  clang/test/CoverageMapping/logical.cpp
  clang/test/CoverageMapping/loops.cpp
  clang/test/CoverageMapping/macro-expressions.cpp
  clang/test/CoverageMapping/macroparams2.c
  clang/test/CoverageMapping/macros.c
  clang/test/CoverageMapping/macroscopes.cpp
  clang/test/CoverageMapping/moremacros.c
  clang/test/CoverageMapping/objc.m
  clang/test/CoverageMapping/pr32679.cpp
  clang/test/CoverageMapping/preprocessor.c
  clang/test/CoverageMapping/return.c
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c
  clang/test/CoverageMapping/test.c
  clang/test/CoverageMapping/trycatch.cpp
  clang/test/CoverageMapping/unreachable-macro.c
  clang/test/CoverageMapping/while.c
  clang/test/lit.cfg.py
  compiler-rt/test/profile/Inputs/instrprof-comdat.h
  compiler-rt/test/profile/coverage_comments.cpp

Index: compiler-rt/test/profile/coverage_comments.cpp
===
--- /dev/null
+++ compiler-rt/test/profile/coverage_comments.cpp
@@ -0,0 +1,71 @@
+// RUN: %clangxx_profgen -fcoverage-mapping -Wno-comment -o %t %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-cov show %t -instr-profile %t.profdata -path-equivalence=/tmp,%S 2>&1 | FileCheck %s
+
+int main() {   // CHECK:  [[@LINE]]| 1|int main() {
+/* comment */ int x = 0;   // CHECK:  [[@LINE]]| 1|  /* comment */ int x = 0;
+int y = 0; /* comment */   // CHECK:  [[@LINE]]| 1|  int y = 0; /* comment */
+int z = 0; // comment  // CHECK:  [[@LINE]]| 1|  int z = 0; // comment
+// comment // CHECK:  [[@LINE]]|  |  // comment
+   // CHECK:  [[@LINE]]|  |
+x = 0; /*  // CHECK:  [[@LINE]]| 1|  x = 0; /*
+comment// CHECK:  [[@LINE]]|  |comment
+*/ // CHECK:  [[@LINE]]|  |*/
+   // CHECK:  [[@LINE]]|  |
+/* // CHECK:  [[@LINE]]|  |/*
+comment// CHECK:  [[@LINE]]|  |comment
+*/ x = 0;  // CHECK:  [[@LINE]]| 1|*/ x = 0;
+   // CHECK:  [[@LINE]]|  |
+/* comment */  // CHECK:  [[@LINE]]|  |/* comment */
+// comment // CHECK:  [[@LINE]]|  |// comment
+/* comment */  // CHECK:  [[@LINE]]|  |/* comment */
+z =// CHECK:  [[@LINE]]| 1|z =
+x // comment   // CHECK:  [[@LINE]]| 1|x // comment
+// comment // CHECK:  [[@LINE]]|  |// comment
++ /*   // CHECK:  [[@LINE]]| 1|+ /*
+comment// CHECK:  [[@LINE]]|  |comment
+*/ // CHECK:  [[@LINE]]|  |*/
+/* // CHECK:  [[@LINE]]|  |/*
+comment// CHECK:  [[@LINE]]|  |comment
+*/y;   // CHECK:  [[@LINE]]| 1|*/y;
+   // CHECK:  [[@LINE]]|  |
+// Comments inside directives. // CHECK:  [[@LINE]]|  |// Comments inside directives.
+#if 0 //comment// CHECK:  [[@LINE]]|  |#if 0 //comment
+/* comment */ x = 0;   // CHECK:  [[@LINE]]|  |/* comment */ x = 0;
+y = 0; /* comment */   // CHECK:  [[@LINE]]|  |y = 0; /* comment */
+z = 0; // comment  // CHECK:  [[@LINE]]|  |z = 0; // comment
+// comment // CHECK:  [[@LINE]]|  |// comment
+   // CHECK:  [[@LINE]]|  |
+x = 0; /*  // CHECK:  [[@LINE]]|  |x = 0; /*
+comment// CHECK:  [[@LINE]]|  |comment
+*/ // CHECK:  [[@LINE]]|  | 

[PATCH] D83592: [Parser] Add comment to skipped regions

2020-07-20 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 279394.
zequanwu marked 7 inline comments as done.
zequanwu added a comment.

Address comments.


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

https://reviews.llvm.org/D83592

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Lex/Preprocessor.cpp
  clang/test/CoverageMapping/break.c
  clang/test/CoverageMapping/builtinmacro.c
  clang/test/CoverageMapping/classtemplate.cpp
  clang/test/CoverageMapping/comment-in-macro.c
  clang/test/CoverageMapping/continue.c
  clang/test/CoverageMapping/coroutine.cpp
  clang/test/CoverageMapping/deferred-region.cpp
  clang/test/CoverageMapping/if.cpp
  clang/test/CoverageMapping/includehell.cpp
  clang/test/CoverageMapping/label.cpp
  clang/test/CoverageMapping/logical.cpp
  clang/test/CoverageMapping/loops.cpp
  clang/test/CoverageMapping/macro-expressions.cpp
  clang/test/CoverageMapping/macroparams2.c
  clang/test/CoverageMapping/macros.c
  clang/test/CoverageMapping/macroscopes.cpp
  clang/test/CoverageMapping/moremacros.c
  clang/test/CoverageMapping/objc.m
  clang/test/CoverageMapping/pr32679.cpp
  clang/test/CoverageMapping/preprocessor.c
  clang/test/CoverageMapping/return.c
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c
  clang/test/CoverageMapping/test.c
  clang/test/CoverageMapping/trycatch.cpp
  clang/test/CoverageMapping/unreachable-macro.c
  clang/test/CoverageMapping/while.c
  clang/test/lit.cfg.py
  compiler-rt/test/profile/Inputs/instrprof-comdat.h
  compiler-rt/test/profile/coverage_comments.cpp

Index: compiler-rt/test/profile/coverage_comments.cpp
===
--- /dev/null
+++ compiler-rt/test/profile/coverage_comments.cpp
@@ -0,0 +1,71 @@
+// RUN: %clangxx_profgen -fcoverage-mapping -Wno-comment -o %t %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-cov show %t -instr-profile %t.profdata -path-equivalence=/tmp,%S 2>&1 | FileCheck %s
+
+int main() {   // CHECK:  [[@LINE]]| 1|int main() {
+/* comment */ int x = 0;   // CHECK:  [[@LINE]]| 1|  /* comment */ int x = 0;
+int y = 0; /* comment */   // CHECK:  [[@LINE]]| 1|  int y = 0; /* comment */
+int z = 0; // comment  // CHECK:  [[@LINE]]| 1|  int z = 0; // comment
+// comment // CHECK:  [[@LINE]]|  |  // comment
+   // CHECK:  [[@LINE]]|  |
+x = 0; /*  // CHECK:  [[@LINE]]| 1|  x = 0; /*
+comment// CHECK:  [[@LINE]]|  |comment
+*/ // CHECK:  [[@LINE]]|  |*/
+   // CHECK:  [[@LINE]]|  |
+/* // CHECK:  [[@LINE]]|  |/*
+comment// CHECK:  [[@LINE]]|  |comment
+*/ x = 0;  // CHECK:  [[@LINE]]| 1|*/ x = 0;
+   // CHECK:  [[@LINE]]|  |
+/* comment */  // CHECK:  [[@LINE]]|  |/* comment */
+// comment // CHECK:  [[@LINE]]|  |// comment
+/* comment */  // CHECK:  [[@LINE]]|  |/* comment */
+z =// CHECK:  [[@LINE]]| 1|z =
+x // comment   // CHECK:  [[@LINE]]| 1|x // comment
+// comment // CHECK:  [[@LINE]]|  |// comment
++ /*   // CHECK:  [[@LINE]]| 1|+ /*
+comment// CHECK:  [[@LINE]]|  |comment
+*/ // CHECK:  [[@LINE]]|  |*/
+/* // CHECK:  [[@LINE]]|  |/*
+comment// CHECK:  [[@LINE]]|  |comment
+*/y;   // CHECK:  [[@LINE]]| 1|*/y;
+   // CHECK:  [[@LINE]]|  |
+// Comments inside directives. // CHECK:  [[@LINE]]|  |// Comments inside directives.
+#if 0 //comment// CHECK:  [[@LINE]]|  |#if 0 //comment
+/* comment */ x = 0;   // CHECK:  [[@LINE]]|  |/* comment */ x = 0;
+y = 0; /* comment */   // CHECK:  [[@LINE]]|  |y = 0; /* comment */
+z = 0; // comment  // CHECK:  [[@LINE]]|  |z = 0; // comment
+// comment // CHECK:  [[@LINE]]|  |// comment
+   // CHECK:  [[@LINE]]|  |
+x = 0; /*  // CHECK:  [[@LINE]]|  |x = 0; /*
+comment// CHECK:  [[@LINE]]|  |comment
+*/   

[PATCH] D83519: [NewPM] Support optnone under new pass manager

2020-07-20 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.
This revision is now accepted and ready to land.

LGTM with one nit.




Comment at: llvm/include/llvm/Passes/StandardInstrumentations.h:57
 
+class OptNoneInstrumentation {
+public:

ychen wrote:
> I may probably name this `SkipPassInstrumentation`. But it is up to you.
Errr, let's go with `OptNoneInstrumentation ` if it's your preference. This is 
a bit too verbose IMHO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519



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


[PATCH] D84213: [clang-tools-extra] Disable -Wsuggest-override for unittests/

2020-07-20 Thread Logan Smith via Phabricator via cfe-commits
logan-5 created this revision.
logan-5 added reviewers: aaron.ballman, klimek, alexfh, juliehockett, sammccall.
logan-5 added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

I added `-Wsuggest-override` to the LLVM build earlier today, and have been 
putting out small fires I caused since then. One sticky area here has been 
directories that have files that include googlemock and/or googletest headers, 
which unfortunately do not themselves use `override`, so I've had to add 
`-Wno-suggest-override` to the CMakeLists.txt's in those directories. This 
patch adds this same flag to CMakeLists.txt in clang-tools-extra/unittests. I 
just wanted to get the LGTM from one or more of you fine folks before I 
committed it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84213

Files:
  clang-tools-extra/unittests/CMakeLists.txt


Index: clang-tools-extra/unittests/CMakeLists.txt
===
--- clang-tools-extra/unittests/CMakeLists.txt
+++ clang-tools-extra/unittests/CMakeLists.txt
@@ -5,6 +5,10 @@
   add_unittest(ExtraToolsUnitTests ${test_dirname} ${ARGN})
 endfunction()
 
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+  add_definitions("-Wno-suggest-override")
+endif()
+
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-change-namespace)
 add_subdirectory(clang-doc)


Index: clang-tools-extra/unittests/CMakeLists.txt
===
--- clang-tools-extra/unittests/CMakeLists.txt
+++ clang-tools-extra/unittests/CMakeLists.txt
@@ -5,6 +5,10 @@
   add_unittest(ExtraToolsUnitTests ${test_dirname} ${ARGN})
 endfunction()
 
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+  add_definitions("-Wno-suggest-override")
+endif()
+
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-change-namespace)
 add_subdirectory(clang-doc)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82582: [SVE] Remove calls to VectorType::getNumElements from clang

2020-07-20 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau updated this revision to Diff 279370.
ctetreau added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82582

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/SwiftCallingConv.cpp

Index: clang/lib/CodeGen/SwiftCallingConv.cpp
===
--- clang/lib/CodeGen/SwiftCallingConv.cpp
+++ clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -320,9 +320,12 @@
   // If we have a vector type, split it.
   if (auto vecTy = dyn_cast_or_null(type)) {
 auto eltTy = vecTy->getElementType();
-CharUnits eltSize = (end - begin) / vecTy->getNumElements();
+CharUnits eltSize =
+(end - begin) / cast(vecTy)->getNumElements();
 assert(eltSize == getTypeStoreSize(CGM, eltTy));
-for (unsigned i = 0, e = vecTy->getNumElements(); i != e; ++i) {
+for (unsigned i = 0,
+  e = cast(vecTy)->getNumElements();
+ i != e; ++i) {
   addEntry(eltTy, begin, begin + eltSize);
   begin += eltSize;
 }
@@ -674,8 +677,9 @@
 
 bool swiftcall::isLegalVectorType(CodeGenModule &CGM, CharUnits vectorSize,
   llvm::VectorType *vectorTy) {
-  return isLegalVectorType(CGM, vectorSize, vectorTy->getElementType(),
-   vectorTy->getNumElements());
+  return isLegalVectorType(
+  CGM, vectorSize, vectorTy->getElementType(),
+  cast(vectorTy)->getNumElements());
 }
 
 bool swiftcall::isLegalVectorType(CodeGenModule &CGM, CharUnits vectorSize,
@@ -688,7 +692,7 @@
 std::pair
 swiftcall::splitLegalVectorType(CodeGenModule &CGM, CharUnits vectorSize,
 llvm::VectorType *vectorTy) {
-  auto numElts = vectorTy->getNumElements();
+  auto numElts = cast(vectorTy)->getNumElements();
   auto eltTy = vectorTy->getElementType();
 
   // Try to split the vector type in half.
@@ -710,7 +714,7 @@
   }
 
   // Try to split the vector into legal subvectors.
-  auto numElts = origVectorTy->getNumElements();
+  auto numElts = cast(origVectorTy)->getNumElements();
   auto eltTy = origVectorTy->getElementType();
   assert(numElts != 1);
 
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -1323,7 +1323,7 @@
"Splatted expr doesn't match with vector element type?");
 
 // Splat the element across to all elements
-unsigned NumElements = cast(DstTy)->getNumElements();
+unsigned NumElements = cast(DstTy)->getNumElements();
 return Builder.CreateVectorSplat(NumElements, Src, "splat");
   }
 
@@ -1630,7 +1630,7 @@
 Value *RHS = CGF.EmitScalarExpr(E->getExpr(1));
 Value *Mask;
 
-llvm::VectorType *LTy = cast(LHS->getType());
+auto *LTy = cast(LHS->getType());
 unsigned LHSElts = LTy->getNumElements();
 
 Mask = RHS;
@@ -1648,10 +1648,12 @@
 //   n = extract mask i
 //   x = extract val n
 //   newv = insert newv, x, i
-auto *RTy = llvm::FixedVectorType::get(LTy->getElementType(),
-   MTy->getNumElements());
+auto *RTy = llvm::FixedVectorType::get(
+LTy->getElementType(),
+cast(MTy)->getNumElements());
 Value* NewV = llvm::UndefValue::get(RTy);
-for (unsigned i = 0, e = MTy->getNumElements(); i != e; ++i) {
+for (unsigned i = 0, e = cast(MTy)->getNumElements();
+ i != e; ++i) {
   Value *IIndx = llvm::ConstantInt::get(CGF.SizeTy, i);
   Value *Indx = Builder.CreateExtractElement(Mask, IIndx, "shuf_idx");
 
@@ -1840,7 +1842,7 @@
 return Visit(E->getInit(0));
   }
 
-  unsigned ResElts = VType->getNumElements();
+  unsigned ResElts = cast(VType)->getNumElements();
 
   // Loop over initializers collecting the Value for each, and remembering
   // whether the source was swizzle (ExtVectorElementExpr).  This will allow
@@ -1864,7 +1866,8 @@
   if (isa(IE)) {
 llvm::ExtractElementInst *EI = cast(Init);
 
-if (EI->getVectorOperandType()->getNumElements() == ResElts) {
+if (cast(EI->getVectorOperandType())
+->getNumElements() == ResElts) {
   llvm::ConstantInt *C = cast(EI->getIndexOperand());
   Value *LHS = nullptr, *RHS = nullptr;
   if (CurIdx == 0) {
@@ -1902,7 +1905,7 @@
   continue;
 }
 
-unsigned InitElts = VVT->getNumElements();
+unsigned InitElts = cast(VVT)->getNumElements();
 
 // If the initializer is an ExtVecEltExpr (a swizzle), and the swizzle's
 // input is the same width as the vector being constructed, generate an
@@ -1911,7 +1914,7 @@
 if (isa(IE)) {
   llvm::ShuffleVectorInst *SVI = cast(Init);
   Value *SVOp = SVI->getOperand(0);
-  llvm::VectorType 

[PATCH] D82502: [PowerPC][Power10] Implement Load VSX Vector and Sign Extend and Zero Extend

2020-07-20 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 279362.
Conanap marked 5 inline comments as done.
Conanap added a comment.

Return signature fix, added recognition for ISD:EXTLOAD, some code clean up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82502

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
@@ -1,4 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
 ; RUN:   FileCheck %s
@@ -33,3 +36,61 @@
   %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i1 0)
   ret i32 %0
 }
+
+; These test cases tests that zero extending loads utilize the Load VSX Vector Rightmost
+; (lxvr[b|h|w|d]x) instructions in Power10.
+
+define dso_local <1 x i128> @vec_xl_zext(i64 %__offset, i8* nocapture readonly %__pointer) {
+; CHECK-LABEL: vec_xl_zext:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:lxvrbx v2, r4, r3
+; CHECK-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i8, i8* %__pointer, i64 %__offset
+  %0 = load i8, i8* %add.ptr, align 1
+  %conv = zext i8 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
+
+define dso_local <1 x i128> @vec_xl_zext_short(i64 %__offset, i16* nocapture readonly %__pointer) {
+; CHECK-LABEL: vec_xl_zext_short:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r3, 1
+; CHECK-NEXT:lxvrhx v2, r4, r3
+; CHECK-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i16, i16* %__pointer, i64 %__offset
+  %0 = load i16, i16* %add.ptr, align 2
+  %conv = zext i16 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
+
+define dso_local <1 x i128> @vec_xl_zext_word(i64 %__offset, i32* nocapture readonly %__pointer) {
+; CHECK-LABEL: vec_xl_zext_word:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r3, 2
+; CHECK-NEXT:lxvrwx v2, r4, r3
+; CHECK-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i32, i32* %__pointer, i64 %__offset
+  %0 = load i32, i32* %add.ptr, align 4
+  %conv = zext i32 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
+
+define dso_local <1 x i128> @vec_xl_zext_dw(i64 %__offset, i64* nocapture readonly %__pointer) {
+; CHECK-LABEL: vec_xl_zext_dw:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r3, 3
+; CHECK-NEXT:lxvrdx v2, r4, r3
+; CHECK-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i64, i64* %__pointer, i64 %__offset
+  %0 = load i64, i64* %add.ptr, align 8
+  %conv = zext i64 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -18,6 +18,15 @@
 // address computations).
 class isPCRel { bit PCRel = 1; }
 
+// PowerPC specific type constraints.
+def SDT_PPCLXVRZX : SDTypeProfile<1, 2, [
+  SDTCisVT<0, v1i128>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
+]>;
+
+// PPC Specific DAG Nodes.
+def PPClxvrzx : SDNode<"PPCISD::LXVRZX", SDT_PPCLXVRZX,
+   [SDNPHasChain, SDNPMayLoad]>;
+
 // Top-level class for prefixed instructions.
 class PI pref, bits<6> opcode, dag OOL, dag IOL, string asmstr,
  InstrItinClass itin> : Instruction {
@@ -996,6 +1005,15 @@
 (EXTRACT_SUBREG (XVTLSBB (COPY_TO_REGCLASS $XB, VSRC)), sub_lt)>;
   def : Pat<(i32 (int_ppc_vsx_xvtlsbb v16i8:$XB, 0)),
 (EXTRACT_SUBREG (XVTLSBB (COPY_TO_REGCLASS $XB, VSRC)), sub_eq)>;
+
+  def : Pat <(v1i128 (PPClxvrzx xoaddr:$src, 8)),
+ (v1i128 (COPY_TO_REGCLASS (LXVRBX xoaddr:$src), VRRC))>;
+  def : Pat <(v1i128 (PPClxvrzx xoaddr:$src, 16)),
+ (v1i128 (COPY_TO_REGCLASS (LXVRHX xoaddr:$src), VRRC))>;
+  def : Pat <(v1i128 (PPClxvrzx xoaddr:$src, 32)),
+ (v1i128 (COPY_TO_REGCLASS (LXVRWX xoaddr:$src), VRRC))>;
+  def : Pat <(v1i128 (PPClxvrzx xoaddr:$src, 64)),
+ (v1i128 (COPY_TO_REGCLA

[PATCH] D83812: [clang][RelativeVTablesABI] Do not emit stubs for architectures that support a PLT relocation

2020-07-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 279354.
leonardchan marked an inline comment as done.
leonardchan added a comment.

Add a method to `TargetCodeGenInfo` the returns if the target supports PC 
relative PLT relocations,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83812

Files:
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  
clang/test/CodeGenCXX/RelativeVTablesABI/child-inheritted-from-parent-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-1.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/cross-translation-unit-2.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/diamond-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/diamond-virtual-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inheritted-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inline-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/inlined-key-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/multiple-inheritance.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/no-stub-when-dso-local.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/override-pure-virtual-method.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/overriden-virtual-function.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/parent-and-child-in-comdats.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/pass-byval-attributes.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-flag.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/stub-usage.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp

Index: clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp
@@ -6,8 +6,6 @@
 // CHECK: %class.B = type { %class.A }
 // CHECK: %"class.std::type_info" = type { i32 (...)**, i8* }
 
-// CHECK: $_ZN1A3fooEv.stub = comdat any
-// CHECK: $_ZN1B3fooEv.stub = comdat any
 // CHECK: $_ZTI1A.rtti_proxy = comdat any
 // CHECK: $_ZTI1B.rtti_proxy = comdat any
 
Index: clang/test/CodeGenCXX/RelativeVTablesABI/stub-usage.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/RelativeVTablesABI/stub-usage.cpp
@@ -0,0 +1,31 @@
+// Stubs shouldn't be used on architectures we know support 32-bit PLT relocations.
+
+// RUN: %clang_cc1 %s -triple=aarch64 -fno-rtti -O1 -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s --check-prefixes CHECK,NOSTUB
+// RUN: %clang_cc1 %s -triple=x86_64 -fno-rtti -O1 -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s --check-prefixes CHECK,NOSTUB
+// RUN: %clang_cc1 %s -triple=riscv64 -fno-rtti -O1 -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s --check-prefixes CHECK,STUB
+
+// We should be emitting comdats for each of the virtual function stubs and RTTI proxies
+// NOSTUB-NOT: $_ZN1A3fooEv.stub
+// STUB:  $_ZN1A3fooEv.stub = comdat any
+
+// STUB: @_ZTV1A.local = private unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 0, i32 trunc (i64 sub (i64 ptrtoint (void (%class.A*)* @_ZN1A3fooEv.stub to i64), i64 ptrtoint (i32* getelementptr inbounds ({ [3 x i32] }, { [3 x i32] }* @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, align 4
+// NOSTUB: @_ZTV1A.local = private unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 0, i32 trunc (i64 sub (i64 ptrtoint (void (%class.A*)* @_ZN1A3fooEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ [3 x i32] }, { [3 x i32] }* @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, align 4
+
+// NOSTUB-NOT: @_ZN1A3fooEv.stub
+
+// Stub is in its own comdat group.
+// STUB:  define hidden void @_ZN1A3fooEv.stub(%class.A* nocapture %0) unnamed_addr #{{[0-9]+}} comdat
+// STUB-NEXT: entry:
+// STUB-NEXT:   ret void
+// STUB-NEXT: }
+
+class A {
+public:
+  virtual void foo();
+};
+
+void A::foo() {}
+
+void A_foo(A *a) {
+  a->foo();
+}
Index: clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
===
--- clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
+++ clang/test/CodeGenCXX/RelativeVTablesABI/stub-linkages.cpp
@@ -1,7 +1,7 @@
 // If the linkage of the class is internal, then the stubs and proxies should
 // also be internally linked.
 
-// RUN: %clang_cc1 %s -triple=x86_64-unknown-fuchsia -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s
+// RUN: %clang_cc1 %s -triple=riscv64 -S -o - -emit-llvm -fe

[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-20 Thread Greg Clayton via Phabricator via cfe-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Looks good!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731



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


[PATCH] D83188: [clang-tidy] bugprone-bool-pointer-implicit-conversion doesn't handle members

2020-07-20 Thread Alex Cameron via Phabricator via cfe-commits
tetsuo-cpp added a comment.

Friendly ping. Could I please get this looked at?


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

https://reviews.llvm.org/D83188



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


[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-20 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen updated this revision to Diff 279351.
aelitashen added a comment.

Add a white space in Symbols loaded info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731

Files:
  clang/tools/clang-format/git-clang-format
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/tools/lldb-vscode/JSONUtils.cpp

Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -7,6 +7,8 @@
 //===--===//
 
 #include 
+#include 
+#include 
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FormatAdapters.h"
@@ -327,6 +329,50 @@
   return llvm::json::Value(std::move(object));
 }
 
+static uint64_t GetDebugInfoSizeInSection(lldb::SBSection section) {
+  uint64_t debug_info_size = 0;
+  llvm::StringRef section_name(section.GetName());
+  if (section_name.startswith(".debug") || section_name.startswith("__debug") ||
+  section_name.startswith(".apple") || section_name.startswith("__apple"))
+debug_info_size += section.GetFileByteSize();
+  size_t num_sub_sections = section.GetNumSubSections();
+  for (size_t i = 0; i < num_sub_sections; i++) {
+debug_info_size +=
+GetDebugInfoSizeInSection(section.GetSubSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static uint64_t GetDebugInfoSize(lldb::SBModule module) {
+  uint64_t debug_info_size = 0;
+  size_t num_sections = module.GetNumSections();
+  for (size_t i = 0; i < num_sections; i++) {
+debug_info_size += GetDebugInfoSizeInSection(module.GetSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static std::string ConvertDebugInfoSizeToString(uint64_t debug_info) {
+  std::ostringstream oss;
+  oss << " (";
+  oss << std::fixed << std::setprecision(1);
+
+  if (debug_info < 1024) {
+oss << debug_info << "B";
+  } else if (debug_info < 1024 * 1024) {
+double kb = double(debug_info) / 1024.0;
+oss << kb << "KB";
+  } else if (debug_info < 1024 * 1024 * 1024) {
+double mb = double(debug_info) / (1024.0 * 1024.0);
+oss << mb << "MB";
+  } else {
+double gb = double(debug_info) / (1024.0 * 1024.0 * 1024.0);
+oss << gb << "GB";
+;
+  }
+  oss << ")";
+  return oss.str();
+}
 llvm::json::Value CreateModule(lldb::SBModule &module) {
   llvm::json::Object object;
   if (!module.IsValid())
@@ -339,9 +385,15 @@
   std::string module_path(module_path_arr);
   object.try_emplace("path", module_path);
   if (module.GetNumCompileUnits() > 0) {
-object.try_emplace("symbolStatus", "Symbols loaded.");
+std::string symbol_str = "Symbols loaded.";
+uint64_t debug_info = GetDebugInfoSize(module);
+if (debug_info > 0) {
+  symbol_str += ConvertDebugInfoSizeToString(debug_info);
+}
+object.try_emplace("symbolStatus", symbol_str);
 char symbol_path_arr[PATH_MAX];
-module.GetSymbolFileSpec().GetPath(symbol_path_arr, sizeof(symbol_path_arr));
+module.GetSymbolFileSpec().GetPath(symbol_path_arr,
+   sizeof(symbol_path_arr));
 std::string symbol_path(symbol_path_arr);
 object.try_emplace("symbolFilePath", symbol_path);
   } else {
@@ -352,8 +404,9 @@
   object.try_emplace("addressRange", loaded_addr);
   std::string version_str;
   uint32_t version_nums[3];
-  uint32_t num_versions = module.GetVersion(version_nums, sizeof(version_nums)/sizeof(uint32_t));
-  for (uint32_t i=0; ihttps://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#======#
-
-r"""
-clang-format git integration
-
-
-This file provides a clang-format integration for git. Put it somewhere in your
-path and ensure that it is executable. Then, "git clang-format" will invoke
-clang-format on the changes in current files or a specific commit.
-
-For further details, run:
-git clang-format -h
-
-Requires Python 2.7 or Python 3
-"""
-
-from __future__ import absolute_import, division, print_function
-import argparse
-import collections
-import contextlib
-import errno
-import os
-import re
-import subprocess
-import sys
-
-usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
-
-desc = '''
-If zero or one commits are given, run clang-format on all lines that differ
-between the working directory and , which defaults to HEAD.  Changes are
-only applied to the working directory.
-
-If two commits are given (requires --diff), run clang-format on all lines in the
-second  that differ from the first .
-
-The following git-config settings set the default of the corresponding option:
-  clangFormat.binary
-  clangFormat.commit
-  clangFormat.extensions
- 

[PATCH] D83338: [PowerPC][Power10] Implemented Vector Shift Builtins

2020-07-20 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 279348.
Conanap marked 8 inline comments as done.
Conanap added a comment.

Fixed function names, test case clean up


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83338

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-shift.ll

Index: llvm/test/CodeGen/PowerPC/p10-vector-shift.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-vector-shift.ll
@@ -0,0 +1,50 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; These tests ensure that vector shift quadword builtins are correctly
+; exploited and selected for during codeGen.
+
+define dso_local <1 x i128> @test_vec_vslq(<1 x i128> %a, <1 x i128> %b) {
+; CHECK-LABEL: test_vec_vslq:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vslq v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %slq = call <1 x i128> @llvm.ppc.altivec.vslq(<1 x i128> %a, <1 x i128> %b)
+  ret <1 x i128> %slq
+}
+
+define dso_local <1 x i128> @test_vec_vsrq(<1 x i128> %a, <1 x i128> %b) {
+; CHECK-LABEL: test_vec_vsrq:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsrq v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %slq = call <1 x i128> @llvm.ppc.altivec.vsrq(<1 x i128> %a, <1 x i128> %b)
+  ret <1 x i128> %slq
+}
+
+define dso_local <1 x i128> @test_vec_vsraq(<1 x i128> %a, <1 x i128> %b) {
+; CHECK-LABEL: test_vec_vsraq:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsraq v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %slq = call <1 x i128> @llvm.ppc.altivec.vsraq(<1 x i128> %a, <1 x i128> %b)
+  ret <1 x i128> %slq
+}
+
+; Function Attrs: nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vslq(<1 x i128>, <1 x i128>)
+
+; Function Attrs: nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vsrq(<1 x i128>, <1 x i128>)
+
+; Function Attrs: nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vsraq(<1 x i128>, <1 x i128>)
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1032,9 +1032,9 @@
 (ins vrrc:$vA, vrrc:$vB, vrrc:$vDi),
 "vrlqmi $vD, $vA, $vB", IIC_VecFP, []>,
 RegConstraint<"$vDi = $vD">, NoEncode<"$vDi">;
-  def VSLQ : VX1_VT5_VA5_VB5<261, "vslq", []>;
-  def VSRAQ : VX1_VT5_VA5_VB5<773, "vsraq", []>;
-  def VSRQ : VX1_VT5_VA5_VB5<517, "vsrq", []>;
+  def VSLQ  : VX1_Int_Ty<261, "vslq", int_ppc_altivec_vslq, v1i128>;
+  def VSRAQ : VX1_Int_Ty<773, "vsraq", int_ppc_altivec_vsraq, v1i128>;
+  def VSRQ  : VX1_Int_Ty<517, "vsrq", int_ppc_altivec_vsrq, v1i128>;
   def VRLQ : VX1_VT5_VA5_VB5<5, "vrlq", []>;
   def XSCVQPUQZ : X_VT5_XO5_VB5<63, 0, 836, "xscvqpuqz", []>;
   def XSCVQPSQZ : X_VT5_XO5_VB5<63, 8, 836, "xscvqpsqz", []>;
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -797,6 +797,7 @@
 def int_ppc_altivec_vsrv  : PowerPC_Vec_BBB_Intrinsic<"vsrv">;
 def int_ppc_altivec_vslh  : PowerPC_Vec_HHH_Intrinsic<"vslh">;
 def int_ppc_altivec_vslw  : PowerPC_Vec_WWW_Intrinsic<"vslw">;
+def int_ppc_altivec_vslq  : PowerPC_Vec_QQQ_Intrinsic<"vslq">;
 
 // Right Shifts.
 def int_ppc_altivec_vsr   : PowerPC_Vec_WWW_Intrinsic<"vsr">;
@@ -805,9 +806,11 @@
 def int_ppc_altivec_vsrb  : PowerPC_Vec_BBB_Intrinsic<"vsrb">;
 def int_ppc_altivec_vsrh  : PowerPC_Vec_HHH_Intrinsic<"vsrh">;
 def int_ppc_altivec_vsrw  : PowerPC_Vec_WWW_Intrinsic<"vsrw">;
+def int_ppc_altivec_vsrq  : PowerPC_Vec_QQQ_Intrinsic<"vsrq">;
 def int_ppc_altivec_vsrab : PowerPC_Vec_BBB_Intrinsic<"vsrab">;
 def int_ppc_altivec_vsrah : PowerPC_Vec_HHH_Intrinsic<"vsrah">;
 def int_ppc_altivec_vsraw : PowerPC_Vec_WWW_Intrinsic<"vsraw">;
+def int_ppc_altivec_vsraq : PowerPC_Vec_QQQ_Intrinsic<"vsraq">;
 
 // Rotates.
 def int_ppc_altivec_vrlb  : PowerPC_Vec_BBB_Intrinsic<"vrlb">;
Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -21,6 +21,7 @@
 vector unsigned int vuia, vuib, vuic;
 vector signed lon

[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-20 Thread Greg Clayton via Phabricator via cfe-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Just a space before the '(' of the debug info size.




Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:357
+  std::ostringstream oss;
+  oss << "(";
+  oss << std::fixed << std::setprecision(1);

Need as space before the '(' character as we append this string to the "Symbols 
loaded." string.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731



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


[PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2)

2020-07-20 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked 2 inline comments as done.
jdenny added inline comments.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:3067-3068
+  unsigned Type = getOpenMPSimpleClauseType(OMPC_map, PP.getSpelling(Tok));
+  if (Type < OMPC_MAP_MODIFIER_unknown)
+return OMPC_MAP_MODIFIER_unknown;
+  return static_cast(Type);

ABataev wrote:
> jdenny wrote:
> > ABataev wrote:
> > > Why do we need this?
> > When called with `OMPC_map`, `getOpenMPSimpleClauseType` can return either 
> > an `OpenMPMapModifierKind` or `OpenMPMapClauseKind` depending on `Tok`.  
> > Thus, without this change, both `isMapModifier` and `isMapType` can return 
> > either of those despite the difference in their names and documentation.
> > 
> > I found that, when `Parser::parseMapTypeModifiers` ignores `present` as if 
> > it's not a modifier because OpenMP < 5.1, then `isMapType` later returns 
> > `OMPC_MAP_MODIFIER_present` and causes the following assert to fail in 
> > `Sema::ActOnOpenMPVarListClause`:
> > 
> > ```
> > assert(0 <= ExtraModifier && ExtraModifier <= OMPC_MAP_unknown &&
> >"Unexpected map modifier.");
> > ```
> > 
> > To me, the most obvious solution is to fix `isMapType` and `isMapModifier`. 
> >  Fortunately, looking in `OpenMPKinds.h`, the enumerator values in 
> > `OpenMPMapModifierKind` and `OpenMPMapClauseKind` are disjoint so we can 
> > tell which we have.
> Can we have something like:
> ```
> if (LangOpts.OpenMP <= 50 && Type == OMPC_MAP_MODIFIER_present)
>   return OMPC_MAP_MODIFIER_unknown;
> ```
> or extend `getOpenMPSimpleClauseType` function with the version parameter and 
> check there is modifier is allowed and return `unknown` if it is not 
> compatible with provided version?
As far as I can tell, my changes general fix this bug in `isMapType` and 
`isMapModifier`.  It makes them behave as documented.  The suggestions you're 
making only fix them for the case of `present`.  Why is that better?



Comment at: clang/test/OpenMP/target_data_codegen.cpp:258-260
+// CK1A: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1021]]]
+
+// CK1A: [[MTYPE01:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1425]]]

ABataev wrote:
> Add a comment with interpretaion of the map flags, like `OMP_TO = 0x1 | 
> OMP_FROM=0x2 | OMP_PRESENT = 0x1000 = 0x1003`
Are you asking me to add that comment to every map type encoding appearing in 
this patch?  Or just this one?



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

https://reviews.llvm.org/D83061



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


[PATCH] D83722: [PowerPC] Add options to control paired vector memops support

2020-07-20 Thread Baptiste Saleil via Phabricator via cfe-commits
bsaleil updated this revision to Diff 279341.
bsaleil added a comment.

Add PairedVectorMemops to the list of unsupported features in a comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83722

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-dependent-options.cpp
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/lib/Target/PowerPC/PPCScheduleP9.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/test/CodeGen/PowerPC/future-check-features.ll

Index: llvm/test/CodeGen/PowerPC/future-check-features.ll
===
--- llvm/test/CodeGen/PowerPC/future-check-features.ll
+++ llvm/test/CodeGen/PowerPC/future-check-features.ll
@@ -1,9 +1,9 @@
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs -verify-machineinstrs \
-; RUN:   -mtriple=powerpc64le-unknown-unknown -ppc-asm-full-reg-names \
-; RUN:   %s -o - 2>&1 | FileCheck %s
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs -verify-machineinstrs \
-; RUN:   -mtriple=powerpc64-unknown-unknown -ppc-asm-full-reg-names \
-; RUN:   %s -o - 2>&1 | FileCheck %s
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops \
+; RUN:   -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
+; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops \
+; RUN:   -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
+; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
 
 define dso_local signext i32 @f() {
 entry:
Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -146,6 +146,7 @@
   bool VectorsUseTwoUnits;
   bool UsePPCPreRASchedStrategy;
   bool UsePPCPostRASchedStrategy;
+  bool PairedVectorMemops;
   bool PredictableSelectIsExpensive;
 
   POPCNTDKind HasPOPCNTD;
@@ -266,6 +267,7 @@
   bool hasP10Vector() const { return HasP10Vector; }
   bool hasPrefixInstrs() const { return HasPrefixInstrs; }
   bool hasPCRelativeMemops() const { return HasPCRelativeMemops; }
+  bool pairedVectorMemops() const { return PairedVectorMemops; }
   bool hasMFOCRF() const { return HasMFOCRF; }
   bool hasISEL() const { return HasISEL; }
   bool hasBPERMD() const { return HasBPERMD; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -122,6 +122,7 @@
   VectorsUseTwoUnits = false;
   UsePPCPreRASchedStrategy = false;
   UsePPCPostRASchedStrategy = false;
+  PairedVectorMemops = false;
   PredictableSelectIsExpensive = false;
 
   HasPOPCNTD = POPCNTD_Unavailable;
Index: llvm/lib/Target/PowerPC/PPCScheduleP9.td
===
--- llvm/lib/Target/PowerPC/PPCScheduleP9.td
+++ llvm/lib/Target/PowerPC/PPCScheduleP9.td
@@ -41,10 +41,10 @@
   let CompleteModel = 1;
 
   // Do not support QPX (Quad Processing eXtension), SPE (Signal Processing
-  // Engine), prefixed instructions on Power 9, PC relative mem ops, or
-  // instructions introduced in ISA 3.1.
-  let UnsupportedFeatures = [HasQPX, HasSPE, PrefixInstrs, PCRelativeMemops,
- IsISA3_1];
+  // Engine), prefixed instructions on Power 9, paired vector mem ops,
+  // PC relative mem ops, or instructions introduced in ISA 3.1.
+  let UnsupportedFeatures = [HasQPX, HasSPE, PrefixInstrs, PairedVectorMemops,
+ PCRelativeMemops, IsISA3_1];
 
 }
 
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -454,6 +454,7 @@
 
 def PrefixInstrs : Predicate<"Subtarget->hasPrefixInstrs()">;
 def IsISA3_1 : Predicate<"Subtarget->isISA3_1()">;
+def PairedVectorMemops : Predicate<"PPCSubTarget->pairedVectorMemops()">;
 
 let Predicates = [PrefixInstrs] in {
   let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -237,6 +237,10 @@
   SubtargetFeature<"pcrelative-memops", "HasPCRelativeMemops", "true",
"Enable PC relative Memory Ops",
[FeatureISA3_0]>;
+def FeaturePairedVectorMemops:
+  SubtargetFeature<"paired-vector-memops", "PairedVectorMemops", "true",
+   "32Byte load and store instructions",
+   [FeatureISA3_0]>;
 
 def FeaturePredictableSe

[PATCH] D84202: [clang][noderef] Enable -Wnoderef warning for CXX C-style casts

2020-07-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: aaron.ballman, rsmith.
leonardchan added a project: clang.

We find it more valuable to warn on all instances we're removing the `noderef` 
attribute from a pointer. This patch removes the type holes where we initially 
didn't warn on C-style casts. For instances where removing `noderef` is 
intended, users can still disable the warning on line granularity with pragmas.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84202

Files:
  clang/lib/Sema/SemaCast.cpp
  clang/test/Frontend/noderef.cpp


Index: clang/test/Frontend/noderef.cpp
===
--- clang/test/Frontend/noderef.cpp
+++ clang/test/Frontend/noderef.cpp
@@ -120,20 +120,18 @@
 void cast_from_void_ptr(NODEREF void *x) {
   int *a = static_cast(x);  // expected-warning{{casting to 
dereferenceable pointer removes 'noderef' attribute}}
 
-  // Allow regular C-style casts and C-style through reinterpret_casts to be 
holes
-  int *b = reinterpret_cast(x);
-  int *c = (int *)x;
+  int *b = reinterpret_cast(x); // expected-warning{{casting to 
dereferenceable pointer removes 'noderef' attribute}}
+  int *c = (int *)x; // expected-warning{{casting to dereferenceable pointer 
removes 'noderef' attribute}}
 }
 
 void conversion_sequences() {
   NODEREF int *x;
   int *x2 = x; // expected-warning{{casting to 
dereferenceable pointer removes 'noderef' attribute}}
   int *x3 = static_cast(x); // expected-warning{{casting to 
dereferenceable pointer removes 'noderef' attribute}}
-  int *x4 = reinterpret_cast(x);
 
   // Functional cast - This is exactly equivalent to a C-style cast.
   typedef int *INT_PTR;
-  int *x5 = INT_PTR(x);
+  int *x5 = INT_PTR(x); // expected-warning{{casting to dereferenceable 
pointer removes 'noderef' attribute}}
 
   NODEREF Child *child;
   Child *child2 = dynamic_cast(child); // expected-warning{{casting 
to dereferenceable pointer removes 'noderef' attribute}}
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -164,9 +164,9 @@
 
   void CheckNoDeref(Sema &S, const QualType FromType, const QualType ToType,
 SourceLocation OpLoc) {
-if (const auto *PtrType = dyn_cast(FromType)) {
+if (const auto *PtrType = FromType->getAs()) {
   if (PtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
-if (const auto *DestType = dyn_cast(ToType)) {
+if (const auto *DestType = ToType->getAs()) {
   if (!DestType->getPointeeType()->hasAttr(attr::NoDeref)) {
 S.Diag(OpLoc, diag::warn_noderef_to_dereferenceable_pointer);
   }
@@ -1032,6 +1032,8 @@
 /// like this:
 /// char *bytes = reinterpret_cast\(int_ptr);
 void CastOperation::CheckReinterpretCast() {
+  CheckNoDerefRAII NoderefCheck(*this);
+
   if (ValueKind == VK_RValue && !isPlaceholder(BuiltinType::Overload))
 SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
   else
@@ -2489,6 +2491,7 @@
 void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
bool ListInitialization) {
   assert(Self.getLangOpts().CPlusPlus);
+  CheckNoDerefRAII NoderefCheck(*this);
 
   // Handle placeholders.
   if (isPlaceholder()) {


Index: clang/test/Frontend/noderef.cpp
===
--- clang/test/Frontend/noderef.cpp
+++ clang/test/Frontend/noderef.cpp
@@ -120,20 +120,18 @@
 void cast_from_void_ptr(NODEREF void *x) {
   int *a = static_cast(x);  // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
 
-  // Allow regular C-style casts and C-style through reinterpret_casts to be holes
-  int *b = reinterpret_cast(x);
-  int *c = (int *)x;
+  int *b = reinterpret_cast(x); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+  int *c = (int *)x; // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
 }
 
 void conversion_sequences() {
   NODEREF int *x;
   int *x2 = x; // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
   int *x3 = static_cast(x); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
-  int *x4 = reinterpret_cast(x);
 
   // Functional cast - This is exactly equivalent to a C-style cast.
   typedef int *INT_PTR;
-  int *x5 = INT_PTR(x);
+  int *x5 = INT_PTR(x); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
 
   NODEREF Child *child;
   Child *child2 = dynamic_cast(child); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sem

[PATCH] D83652: Merge some of the PCH object support with modular codegen

2020-07-20 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D83652#2161924 , @hans wrote:

> In D83652#2159585 , @dblaikie wrote:
>
> > @hans - could you perhaps give me a quick summary of commands I could use 
> > to test this feature in Chromium (or anything else you might suggest) on a 
> > Linux box? I don't have a Windows machine, or any projects that use PCH. 
> > (or if you'd be willing to test this, that'd be great - see if the PCH 
> > object file has the same symbols before/after this patch)
>
>
> I tried to do this today, and then realized Chromium's PCH .obj files are 
> basically empty these days. Back when I did D48426 
> , dllexported inline functions were emitted 
> in the pch .obj file, but then Chromium started using /Zc:dllexportInlines- 
> which means we don't dllexport inlines anymore, and even if I remove that 
> flag we've moved to only including libc++ headers in our PCH, and nothing is 
> dllexport there.
>
> After applying and building with your patch, the PCH .obj files look the same.
>
> I also verified that building one of Chromium's test targets succeeds with 
> this patch.


Thanks for checking! So, in summary: This seems to work fine for Chromium, but 
Chromium isn't really exercising this functionality (only insofar as the 
functionality is enabled, but essentially a no-op)?

@llunak Would you be able to test this on anything you've got?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83652



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


[PATCH] D84197: [PowerPC][Power10] 128-bit Vector String Isolate instruction definitions and MC Tests

2020-07-20 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Conanap added reviewers: PowerPC, saghir, nemanjai, hfinkel.
Conanap added projects: LLVM, clang, PowerPC.
Herald added a subscriber: kbarton.

This implements vector string isolate instructions used in vector string 
isolate builtins.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84197

Files:
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s

Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -405,27 +405,24 @@
 # CHECK-BE: vinsdrx 1, 2, 3   # encoding: [0x10,0x22,0x1b,0xcf]
 # CHECK-LE: vinsdrx 1, 2, 3   # encoding: [0xcf,0x1b,0x22,0x10]
 vinsdrx 1, 2, 3
-# CHECK-BE: lxvrbx 32, 1, 2   # encoding: [0x7c,0x01,0x10,0x1b]
-# CHECK-LE: lxvrbx 32, 1, 2   # encoding: [0x1b,0x10,0x01,0x7c]
-lxvrbx 32, 1, 2
-# CHECK-BE: lxvrhx 33, 1, 2   # encoding: [0x7c,0x21,0x10,0x5b]
-# CHECK-LE: lxvrhx 33, 1, 2   # encoding: [0x5b,0x10,0x21,0x7c]
-lxvrhx 33, 1, 2
-# CHECK-BE: lxvrdx 34, 1, 2   # encoding: [0x7c,0x41,0x10,0xdb]
-# CHECK-LE: lxvrdx 34, 1, 2   # encoding: [0xdb,0x10,0x41,0x7c]
-lxvrdx 34, 1, 2
-# CHECK-BE: lxvrwx 35, 1, 2   # encoding: [0x7c,0x61,0x10,0x9b]
-# CHECK-LE: lxvrwx 35, 1, 2   # encoding: [0x9b,0x10,0x61,0x7c]
-lxvrwx 35, 1, 2
-# CHECK-BE: stxvrbx 32, 3, 1  # encoding: [0x7c,0x03,0x09,0x1b]
-# CHECK-LE: stxvrbx 32, 3, 1  # encoding: [0x1b,0x09,0x03,0x7c]
-stxvrbx 32, 3, 1
-# CHECK-BE: stxvrhx 33, 3, 1  # encoding: [0x7c,0x23,0x09,0x5b]
-# CHECK-LE: stxvrhx 33, 3, 1  # encoding: [0x5b,0x09,0x23,0x7c]
-stxvrhx 33, 3, 1
-# CHECK-BE: stxvrwx 34, 3, 1  # encoding: [0x7c,0x43,0x09,0x9b]
-# CHECK-LE: stxvrwx 34, 3, 1  # encoding: [0x9b,0x09,0x43,0x7c]
-stxvrwx 34, 3, 1
-# CHECK-BE: stxvrdx 35, 3, 1  # encoding: [0x7c,0x63,0x09,0xdb]
-# CHECK-LE: stxvrdx 35, 3, 1  # encoding: [0xdb,0x09,0x63,0x7c]
-stxvrdx 35, 3, 1
+# CHECK-BE: vstribr 2, 2  # encoding: [0x10,0x41,0x10,0x0d]
+# CHECK-LE: vstribr 2, 2  # encoding: [0x0d,0x10,0x41,0x10]
+vstribr 2, 2
+# CHECK-BE: vstribl 2, 2  # encoding: [0x10,0x40,0x10,0x0d]
+# CHECK-LE: vstribl 2, 2  # encoding: [0x0d,0x10,0x40,0x10]
+vstribl 2, 2
+# CHECK-BE: vstrihr 2, 2  # encoding: [0x10,0x43,0x10,0x0d]
+# CHECK-LE: vstrihr 2, 2  # encoding: [0x0d,0x10,0x43,0x10]
+vstrihr 2, 2
+# CHECK-BE: vstribr. 2, 2 # encoding: [0x10,0x41,0x14,0x0d]
+# CHECK-LE: vstribr. 2, 2 # encoding: [0x0d,0x14,0x41,0x10]
+vstribr. 2, 2
+# CHECK-BE: vstribl. 2, 2 # encoding: [0x10,0x40,0x14,0x0d]
+# CHECK-LE: vstribl. 2, 2 # encoding: [0x0d,0x14,0x40,0x10]
+vstribl. 2, 2
+# CHECK-BE: vstrihr. 2, 2 # encoding: [0x10,0x43,0x14,0x0d]
+# CHECK-LE: vstrihr. 2, 2 # encoding: [0x0d,0x14,0x43,0x10]
+vstrihr. 2, 2
+# CHECK-BE: vstrihl. 2, 2 # encoding: [0x10,0x42,0x14,0x0d]
+# CHECK-LE: vstrihl. 2, 2 # encoding: [0x0d,0x14,0x42,0x10]
+vstrihl. 2, 2
Index: llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
===
--- llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
+++ llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
@@ -279,26 +279,26 @@
 # CHECK: vinsdrx 1, 2, 3
 0x10 0x22 0x1b 0xcf
 
-# CHECK: lxvrbx 32, 1, 2
-0x7c 0x01 0x10 0x1b
+# CHECK: vstribr 2, 2
+0x10 0x41 0x10 0x0d
 
-# CHECK: lxvrhx 33, 1, 2
-0x7c 0x21 0x10 0x5b
+# CHECK: vstribl 2, 2
+0x10 0x40 0x10 0x0d
 
-# CHECK: lxvrdx 34, 1, 2
-0x7c 0x41 0x10 0xdb
+# CHECK: vstrihr 2, 2
+0x10 0x43 0x10 0x0d
 
-# CHECK: lxvrwx 35, 1, 2
-0x7c 0x61 0x10 0x9b
+# CHECK: vstrihl 2, 2
+0x10 0x42 0x10 0x0d
 
-# CHECK: stxvrbx 32, 3, 1
-0x7c 0x03 0x09 0x1b
+# CHECK: vstribr. 2, 2
+0x10 0x41 0x14 0x0d
 
-# CHECK: stxvrhx 33, 3, 1
-0x7c 0x23 0x09 0x5b
+# CHECK: vstribl. 2, 2
+0x10 0x40 0x14 0x0d
 
-# CHECK: stxvrwx 34, 3, 1
-0x7c 0x43 0x09 0x9b
+# CHECK: vstrihr. 2, 2
+0x10 0x43 0x14 0x0d
 
-# CHECK: stxvrdx 35, 3, 1
-0x7c 0x63 0x09 0xdb
+# CHECK: vstrihl. 2, 2
+0x10 0x42 0x14 0x0d
Index: llv

[PATCH] D83592: [Parser] Add comment to skipped regions

2020-07-20 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

@zequanwu at a high level, I think this is the right approach and it looks nice 
overall. I do have some feedback (inline). Thanks!




Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:310
+  /// Return true if SR should be emitted as SkippedRange.
+  bool updateSkippedRange(SourceManager &SM, SpellingRegion &SR,
+  SourceRange Range) {

Could you restructure this to avoid mutating a SpellingRegion? This can aid 
debugging (the unmodified struct remains available for inspection). One way to 
do this might be to call the function "adjustSkippedRange" and have it return 
an Optional.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:311
+  bool updateSkippedRange(SourceManager &SM, SpellingRegion &SR,
+  SourceRange Range) {
+// If Range begin location is invalid, it's not a comment region.

What exactly is 'Range' in updateSkippedRange? It seems like it's the 
{prev,next}TokLoc pair from SkippedRegion, but it's not obvious based on a 
cursory read. It would help to rename 'Range' to something more specific 
('InnermostNonCommentRange'? 'OverlappingExecutedTokenRange'?).



Comment at: clang/lib/CodeGen/CoverageMappingGen.h:39
+  // A pair of SkippedRanges and PrevTokLoc with NextTokLoc
+  std::vector> SkippedRanges;
+  int LastCommentIndex = -1;

It'd be more self-descriptive to replace the pair with some `struct 
SkippedRange { SourceRange SkippedRange; SourceLocation PrevTokLoc, NextTokLoc; 
}`.



Comment at: clang/lib/CodeGen/CoverageMappingGen.h:40
+  std::vector> SkippedRanges;
+  int LastCommentIndex = -1;
+

`Optional LastCommentIndex` would be slightly more idiomatic.



Comment at: clang/lib/CodeGen/CoverageMappingGen.h:43
 public:
-  ArrayRef getSkippedRanges() const { return SkippedRanges; }
+  SourceLocation PrevTokLoc;
+  SourceLocation BeforeCommentLoc;

Please leave short inline comments explaining the respective roles of 
PrevTokLoc and BeforeCommentLoc.



Comment at: clang/test/lit.cfg.py:96
+config.substitutions.append(
+('%strip_comments', "sed 's/[ \t]*\/\/.*//' %s > %T/%basename_t")
+)

Bit of a nitpick, but I don't think it'll necessarily end up being more 
convenient to have "%T/%basename_t" hardcoded in this substitution (strawman, 
but: you can imagine a test that needs to strip comments from two different 
files). It'd be nice to be more explicit and write the run lines like:

RUN: %strip_comments %s > %t.stripped.c
RUN: clang ... %t.stripped.c



Comment at: compiler-rt/test/profile/Linux/coverage_comments.cpp:1
+// RUN: %clangxx_profgen -std=c++11 -fuse-ld=gold -fcoverage-mapping 
-Wno-comment -o %t %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t

I don't think there's anything Linux or gold-specific about this test. Could 
you move the test up one directory, so we can run it on Darwin/Windows/etc.?


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

https://reviews.llvm.org/D83592



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


[PATCH] D83592: [Parser] Add comment to skipped regions

2020-07-20 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 279331.
zequanwu added a comment.

`arc diff --update` automatically formatted test case. Reverted.


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

https://reviews.llvm.org/D83592

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Lex/Preprocessor.cpp
  clang/test/CoverageMapping/break.c
  clang/test/CoverageMapping/builtinmacro.c
  clang/test/CoverageMapping/classtemplate.cpp
  clang/test/CoverageMapping/comment-in-macro.c
  clang/test/CoverageMapping/continue.c
  clang/test/CoverageMapping/coroutine.cpp
  clang/test/CoverageMapping/deferred-region.cpp
  clang/test/CoverageMapping/if.cpp
  clang/test/CoverageMapping/includehell.cpp
  clang/test/CoverageMapping/label.cpp
  clang/test/CoverageMapping/logical.cpp
  clang/test/CoverageMapping/loops.cpp
  clang/test/CoverageMapping/macro-expressions.cpp
  clang/test/CoverageMapping/macroparams2.c
  clang/test/CoverageMapping/macros.c
  clang/test/CoverageMapping/macroscopes.cpp
  clang/test/CoverageMapping/moremacros.c
  clang/test/CoverageMapping/objc.m
  clang/test/CoverageMapping/pr32679.cpp
  clang/test/CoverageMapping/preprocessor.c
  clang/test/CoverageMapping/return.c
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c
  clang/test/CoverageMapping/test.c
  clang/test/CoverageMapping/trycatch.cpp
  clang/test/CoverageMapping/unreachable-macro.c
  clang/test/CoverageMapping/while.c
  clang/test/lit.cfg.py
  compiler-rt/test/profile/Inputs/instrprof-comdat.h
  compiler-rt/test/profile/Linux/coverage_comments.cpp

Index: compiler-rt/test/profile/Linux/coverage_comments.cpp
===
--- /dev/null
+++ compiler-rt/test/profile/Linux/coverage_comments.cpp
@@ -0,0 +1,71 @@
+// RUN: %clangxx_profgen -std=c++11 -fuse-ld=gold -fcoverage-mapping -Wno-comment -o %t %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-cov show %t -instr-profile %t.profdata -path-equivalence=/tmp,%S 2>&1 | FileCheck %s
+
+int main() {   // CHECK:  [[@LINE]]| 1|int main() {
+/* comment */ int x = 0;   // CHECK:  [[@LINE]]| 1|  /* comment */ int x = 0;
+int y = 0; /* comment */   // CHECK:  [[@LINE]]| 1|  int y = 0; /* comment */
+int z = 0; // comment  // CHECK:  [[@LINE]]| 1|  int z = 0; // comment
+// comment // CHECK:  [[@LINE]]|  |  // comment
+   // CHECK:  [[@LINE]]|  |
+x = 0; /*  // CHECK:  [[@LINE]]| 1|  x = 0; /*
+comment// CHECK:  [[@LINE]]|  |comment
+*/ // CHECK:  [[@LINE]]|  |*/
+   // CHECK:  [[@LINE]]|  |
+/* // CHECK:  [[@LINE]]|  |/*
+comment// CHECK:  [[@LINE]]|  |comment
+*/ x = 0;  // CHECK:  [[@LINE]]| 1|*/ x = 0;
+   // CHECK:  [[@LINE]]|  |
+/* comment */  // CHECK:  [[@LINE]]|  |/* comment */
+// comment // CHECK:  [[@LINE]]|  |// comment
+/* comment */  // CHECK:  [[@LINE]]|  |/* comment */
+z =// CHECK:  [[@LINE]]| 1|z =
+x // comment   // CHECK:  [[@LINE]]| 1|x // comment
+// comment // CHECK:  [[@LINE]]|  |// comment
++ /*   // CHECK:  [[@LINE]]| 1|+ /*
+comment// CHECK:  [[@LINE]]|  |comment
+*/ // CHECK:  [[@LINE]]|  |*/
+/* // CHECK:  [[@LINE]]|  |/*
+comment// CHECK:  [[@LINE]]|  |comment
+*/y;   // CHECK:  [[@LINE]]| 1|*/y;
+   // CHECK:  [[@LINE]]|  |
+// Comments inside directives. // CHECK:  [[@LINE]]|  |// Comments inside directives.
+#if 0 //comment// CHECK:  [[@LINE]]|  |#if 0 //comment
+/* comment */ x = 0;   // CHECK:  [[@LINE]]|  |/* comment */ x = 0;
+y = 0; /* comment */   // CHECK:  [[@LINE]]|  |y = 0; /* comment */
+z = 0; // comment  // CHECK:  [[@LINE]]|  |z = 0; // comment
+// comment // CHECK:  [[@LINE]]|  |// comment
+   // CHECK:  [[@LINE]]|  |
+x = 0; /*  // CHECK:  [[@LINE]]|  |x = 0; /*
+comment// CHECK:  [[@LINE]

[PATCH] D82994: [RFC] Instrumenting Clang/LLVM with Perfetto

2020-07-20 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: llvm/cmake/modules/AddPerfetto.cmake:9
+  ExternalProject_Add(perfetto_git
+  GIT_REPOSITORY https://github.com/google/perfetto.git
+  GIT_TAG releases/v4.x

lebedev.ri wrote:
> nickdesaulniers wrote:
> > lebedev.ri wrote:
> > > I have concerns about this.
> > > It really should use system-provided version via `find_package()`
> > > At worst, the sources should be bundled into the tree like it's already 
> > > done in some rare cases.
> > Not that I'm very good with CMake, but this seems to suggest that 
> > `ExternalProject_Add` may not compose well with `find_package`: 
> > https://stackoverflow.com/questions/6351609/cmake-linking-to-library-downloaded-from-externalproject-add
> What i am saying is that any code that fetches anything from internet during 
> cmake/build time is just plain broken.
> perfetto should be provided by system package and we should link to it just 
> like we link to zlib/etc.
That's how GTest is fetched.  See: llvm/utils/benchmark/cmake/HandleGTest.cmake.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82994



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


[PATCH] D83553: [PATCH 3/4][Sema][AArch64] Add codegen for arm_sve_vector_bits attribute

2020-07-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:152
+  Align, Name,
+  /*ArraySize=*/nullptr, Alloca);
 

Do we need to bitcast the result of CreateTempAlloca to a pointer to the array 
type?  I'm concerned that we might miss a bitcast if the source code uses the 
address of the variable.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:3985
+else
+  Init = EmitNullConstant(D->getType());
   } else {

EmitNullConstant should just do the right thing, I think, now that we've 
changed the default behavior of ConvertTypeForMem.



Comment at: clang/lib/CodeGen/CodeGenTypes.cpp:151
+  return llvm::ArrayType::get(*MemTy, A->getSize().getZExtValue());
+  }
+

I think the default handling for constant arrays should do the right thing, now 
that we've changed the default behavior of ConvertTypeForMem.


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

https://reviews.llvm.org/D83553



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


[PATCH] D83592: [Parser] Add comment to skipped regions

2020-07-20 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 279329.
zequanwu added a comment.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Rebase and address comments.

- Keep track of token locations before and after comment regions by `onToken` 
in `Preprocessor` so when emitting `SkippedRegion` we can determine if the 
region should be emitted or not.
- Add an end-to-end llvm-cov test case.


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

https://reviews.llvm.org/D83592

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Lex/Preprocessor.cpp
  clang/test/CoverageMapping/break.c
  clang/test/CoverageMapping/builtinmacro.c
  clang/test/CoverageMapping/classtemplate.cpp
  clang/test/CoverageMapping/comment-in-macro.c
  clang/test/CoverageMapping/continue.c
  clang/test/CoverageMapping/coroutine.cpp
  clang/test/CoverageMapping/deferred-region.cpp
  clang/test/CoverageMapping/if.cpp
  clang/test/CoverageMapping/includehell.cpp
  clang/test/CoverageMapping/label.cpp
  clang/test/CoverageMapping/logical.cpp
  clang/test/CoverageMapping/loops.cpp
  clang/test/CoverageMapping/macro-expressions.cpp
  clang/test/CoverageMapping/macroparams2.c
  clang/test/CoverageMapping/macros.c
  clang/test/CoverageMapping/macroscopes.cpp
  clang/test/CoverageMapping/moremacros.c
  clang/test/CoverageMapping/objc.m
  clang/test/CoverageMapping/pr32679.cpp
  clang/test/CoverageMapping/preprocessor.c
  clang/test/CoverageMapping/return.c
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c
  clang/test/CoverageMapping/test.c
  clang/test/CoverageMapping/trycatch.cpp
  clang/test/CoverageMapping/unreachable-macro.c
  clang/test/CoverageMapping/while.c
  clang/test/lit.cfg.py
  compiler-rt/test/profile/Inputs/instrprof-comdat.h
  compiler-rt/test/profile/Linux/coverage_comments.cpp

Index: compiler-rt/test/profile/Linux/coverage_comments.cpp
===
--- /dev/null
+++ compiler-rt/test/profile/Linux/coverage_comments.cpp
@@ -0,0 +1,77 @@
+// RUN: %clangxx_profgen -std=c++11 -fuse-ld=gold -fcoverage-mapping -Wno-comment -o %t %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-cov show %t -instr-profile %t.profdata -path-equivalence=/tmp,%S 2>&1 | FileCheck %s
+
+int main() {   // CHECK:  [[@LINE]]| 1|int main() {
+  /* comment */ int x = 0; // CHECK:  [[@LINE]]| 1|  /* comment */ int x = 0;
+  int y = 0; /* comment */ // CHECK:  [[@LINE]]| 1|  int y = 0; /* comment */
+  int z = 0;   // comment  // CHECK:  [[@LINE]]| 1|  int z = 0; // comment
+  // comment // CHECK:  [[@LINE]]|  |  // comment
+  // CHECK:  [[@LINE]]|  |
+  x = 0;/*  // CHECK:  [[@LINE]]| 1|  x = 0; /*
+comment// CHECK:  [[@LINE]]|  |comment
+*/
+// CHECK:  [[@LINE]]|  |*/
+// CHECK:  [[@LINE]]|  |
+/* // CHECK:  [[@LINE]]|  |/*
+comment// CHECK:  [[@LINE]]|  |comment
+*/
+  x = 0;// CHECK:  [[@LINE]]| 1|*/ x = 0;
+// CHECK:  [[@LINE]]|  |
+  /* comment */ // CHECK:  [[@LINE]]|  |/* comment */
+  // comment // CHECK:  [[@LINE]]|  |// comment
+  /* comment */ // CHECK:  [[@LINE]]|  |/* comment */
+  z =   // CHECK:  [[@LINE]]| 1|z =
+  x // comment   // CHECK:  [[@LINE]]| 1|x // comment
+  // comment // CHECK:  [[@LINE]]|  |// comment
+  +  /*   // CHECK:  [[@LINE]]| 1|+ /*
+comment// CHECK:  [[@LINE]]|  |comment
+*/
+ // CHECK:  [[@LINE]]|  |*/
+ /* // CHECK:  [[@LINE]]|  |/*
+comment// CHECK:  [[@LINE]]|  |comment
+*/
+  y; // CHECK:  [[@LINE]]| 1|*/y;
+ // CHECK:  [[@LINE]]|  |
+// Comments inside directives. // CHECK:  [[@LINE]]|  |// Comments inside directives.
+#if 0 //comment// CHECK:  [[@LINE]]|  |#if 0 //comment
+/* comment */ x = 0;   // CHECK:  [[@LINE]]|  |/* comment */ x = 0;
+y = 0; /* comment */   // CHECK:  [[@LINE]]|  |y = 0; /* comment */
+z = 0; // comment  // CHECK:  [[@LINE]]|  |z = 0; // comment
+// comment // CHECK:  [[@LINE]]|  |// comment
+   // CHECK:  [[@LINE]]|  |
+x = 0; /*  // CHECK:  [[@LINE]]|  |x = 0; /*
+comment// CHE

[PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X

2020-07-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

@aqjune did you put a patch for InstSimplify doing distribution over undef yet?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83360



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


[PATCH] D81385: Fix libdl linking for libclang in standalone mode

2020-07-20 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a subscriber: hans.
mstorsjo added a comment.

Ping @beanz

@hans - I think this is something that would be wanted to have fixed in the 
release branch (it's a regression for certain build configurations, afaik) - 
the fix awaits an ack from @beanz.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81385



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-07-20 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen abandoned this revision.
cchen added a comment.

Created a new patch with the support for stride: 
https://reviews.llvm.org/D84192.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972



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


[PATCH] D83261: [OPENMP]Redesign of OMPExecutableDirective representation.

2020-07-20 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D83261#2162561 , @ABataev wrote:

> 1. OMPChildren class uses standard TrailingObjects harness instead of manual 
> calculation.


I was going to argue that OMPExecutableDirective could derive from 
TrailingObjects as well, but it requires a template parameter for its final 
subclass. Good point!

> 2. Child Stmt* based nodes are not related to the AsssociatedStmt* anymore 
> and can exist independently.

It moved into the OMPChildren class. Not sure whether it is better.

>> OMPChildren also handles clauses for OMPExecutableDirectives but not for 
>> declarative directives. Should handling of of clauses also be extracted into 
>> into its own class? That would make (de-)serialization easier for those as 
>> well.
> 
> This class is only for executable directives.

Nearly all directives have clauses. At the moment they all implement their own 
clause list. I don't see why clause management should be centralized for 
executable statements only.

>> There is no effect on D76342  (except a 
>> requiring a rebase), since the OMPTileDirective has children and thus does 
>> not profit from the functionality of `OMPChildren` becoming optional. Since 
>> I don't see a relation to D76342 , more , I 
>> am indifferent to whether this should be merged.
> 
> There should be an additional patch, which, I hope, should simplify things 
> for loop-based directives.

OK. What does this patch do? Are you going to upload it as well?

>> Trailing objects is a technique to ensure that all substmts are consecutive 
>> in memory (so `StmtIterator` can iterator over them). For 
>> OMPExeuctableDirectives, only the associated statement is returned by the 
>> `StmtIterator`, i.e. all the children could be made regular class members 
>> without the complication of computing the offset. I'd prefer that change 
>> over OMPChildren.
> 
> There are also used_children, which are used by the clang analyzer for, at 
> least, use of uninitialized variables diagnostics.

OK, I see.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83261



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


[PATCH] D84192: [OpenMP5.0] map item can be non-contiguous for target update

2020-07-20 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen created this revision.
cchen added a reviewer: ABataev.
Herald added subscribers: cfe-commits, sstefan1, guansong, yaxunl.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

In order not to modify the `tgt_target_data_update` information but still be
able to pass the extra information for non-contiguous map item (offset,
count, and stride for each dimension), this patch overload `arg` when
the maptype is set as `OMP_MAP_DESCRIPTOR`. The origin `arg` is for
passing the pointer information, however, the overloaded `arg` is an
array of descriptor_dim:

struct descriptor_dim {

  int64_t offset;
  int64_t count;
  int64_t stride

};

and the array size is the same as dimension size. In addition, since we
have count and stride information in descriptor_dim, we can replace/overload the
`arg_size` parameter by using dimension size.

For supporting `stride` in array section, we use a dummy dimension in
descriptor to store the unit size. The formula for counting the stride
in dimension D_n: `unit size * (D_0 * D_1 ... * D_n-1) * D_n.stride`.

Demonstrate how it works:

  double arr[3][4][5];
  
  D0: { offset = 0, count = 1, stride = 8 }// 
offset, count, dimension size always be 0, 1, 1 for this extra dimension, 
stride is the unit size
  D1: { offset = 0, count = 2, stride = 8 * 1 * 2 = 16 }   // 
stride = unit size * (product of dimension size of D0) * D1.stride = 4 * 1 * 2 
= 8
  D2: { offset = 2, count = 2, stride = 8 * (1 * 5) * 1 = 40  }// 
stride = unit size * (product of dimension size of D0, D1) * D2.stride = 4 * 5 
* 1 = 20
  D3: { offset = 0, count = 2, stride = 8 * (1 * 5 * 4) * 2 = 320 }// 
stride = unit size * (product of dimension size of D0, D1, D2) * D3.stride = 4 
* 25 * 2 = 200
  
  // X here means we need to offload this data, therefore, runtime will transfer
  // data from offset 80, 96, 120, 136, 400, 416, 440, 456
  // Runtime patch: https://reviews.llvm.org/D82245
  // O O O
  // O O O
  // XOXOO O XOXOO
  // XOXOO O XOXOO


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84192

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp

Index: clang/test/OpenMP/target_update_to_messages.cpp
===
--- clang/test/OpenMP/target_update_to_messages.cpp
+++ clang/test/OpenMP/target_update_to_messages.cpp
@@ -79,6 +79,10 @@
 #pragma omp target update to(*(*(this->ptr)+a+this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(*(this+this)) // expected-error {{invalid operands to binary expression ('S8 *' and 'S8 *')}}
 {}
+
+double marr[10][5][10];
+#pragma omp target update to(marr [0:1][2:4][1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+{}
   }
 };
 
Index: clang/test/OpenMP/target_update_messages.cpp
===
--- clang/test/OpenMP/target_update_messages.cpp
+++ clang/test/OpenMP/target_update_messages.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -39,10 +39,33 @@
 foo();
   }
 
+  double marr[10][5][10];
+#pragma omp target update to(marr[0:2][2:4][1:2]

[PATCH] D84147: Use typedef to represent storage type in FPOption and FPOptionsOverride

2020-07-20 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall 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/D84147/new/

https://reviews.llvm.org/D84147



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


[PATCH] D83909: [OPENMP] Fix PR46730: Fix compiler crash on taskloop over constructible loop counters.

2020-07-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 279308.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83909

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/taskloop_codegen.cpp


Index: clang/test/OpenMP/taskloop_codegen.cpp
===
--- clang/test/OpenMP/taskloop_codegen.cpp
+++ clang/test/OpenMP/taskloop_codegen.cpp
@@ -229,4 +229,20 @@
 // CHECK: br label %
 // CHECK: ret i32 0
 
+class St {
+public:
+  operator int();
+  St &operator+=(int);
+};
+
+// CHECK-LABEL: taskloop_with_class
+void taskloop_with_class() {
+  St s1;
+  // CHECK: [[TD:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* 
@{{.+}}, i32 [[GTID:%.+]], i32 1, i64 88, i64 8, i32 (i32, i8*)* bitcast (i32 
(i32, [[TD_TYPE:%.+]]*)* @{{.+}} to i32 (i32, i8*)*))
+  // CHECK: call void @__kmpc_taskloop(%struct.ident_t* @{{.+}}, i32 [[GTID]], 
i8* [[TD]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 
0, i8* bitcast (void ([[TD_TYPE]]*, [[TD_TYPE]]*, i32)* @{{.+}} to i8*))
+#pragma omp taskloop
+  for (St s = St(); s < s1; s += 1) {
+  }
+}
+
 #endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2244,7 +2244,11 @@
   [](OpenMPDirectiveKind K) { return isOpenMPTaskingDirective(K); },
   Level)) {
 bool IsTriviallyCopyable =
-D->getType().getNonReferenceType().isTriviallyCopyableType(Context);
+D->getType().getNonReferenceType().isTriviallyCopyableType(Context) &&
+!D->getType()
+ .getNonReferenceType()
+ .getCanonicalType()
+ ->getAsCXXRecordDecl();
 OpenMPDirectiveKind DKind = DSAStack->getDirective(Level);
 SmallVector CaptureRegions;
 getOpenMPCaptureRegions(CaptureRegions, DKind);


Index: clang/test/OpenMP/taskloop_codegen.cpp
===
--- clang/test/OpenMP/taskloop_codegen.cpp
+++ clang/test/OpenMP/taskloop_codegen.cpp
@@ -229,4 +229,20 @@
 // CHECK: br label %
 // CHECK: ret i32 0
 
+class St {
+public:
+  operator int();
+  St &operator+=(int);
+};
+
+// CHECK-LABEL: taskloop_with_class
+void taskloop_with_class() {
+  St s1;
+  // CHECK: [[TD:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @{{.+}}, i32 [[GTID:%.+]], i32 1, i64 88, i64 8, i32 (i32, i8*)* bitcast (i32 (i32, [[TD_TYPE:%.+]]*)* @{{.+}} to i32 (i32, i8*)*))
+  // CHECK: call void @__kmpc_taskloop(%struct.ident_t* @{{.+}}, i32 [[GTID]], i8* [[TD]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 1, i32 0, i64 0, i8* bitcast (void ([[TD_TYPE]]*, [[TD_TYPE]]*, i32)* @{{.+}} to i8*))
+#pragma omp taskloop
+  for (St s = St(); s < s1; s += 1) {
+  }
+}
+
 #endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2244,7 +2244,11 @@
   [](OpenMPDirectiveKind K) { return isOpenMPTaskingDirective(K); },
   Level)) {
 bool IsTriviallyCopyable =
-D->getType().getNonReferenceType().isTriviallyCopyableType(Context);
+D->getType().getNonReferenceType().isTriviallyCopyableType(Context) &&
+!D->getType()
+ .getNonReferenceType()
+ .getCanonicalType()
+ ->getAsCXXRecordDecl();
 OpenMPDirectiveKind DKind = DSAStack->getDirective(Level);
 SmallVector CaptureRegions;
 getOpenMPCaptureRegions(CaptureRegions, DKind);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83519: [NewPM] Support optnone under new pass manager

2020-07-20 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 279313.
aeubanks marked 4 inline comments as done.
aeubanks added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Feature/optnone-opt.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -261,7 +261,7 @@
 }
   }
   PassInstrumentationCallbacks PIC;
-  StandardInstrumentations SI;
+  StandardInstrumentations SI(DebugPM);
   SI.registerCallbacks(PIC);
 
   PipelineTuningOptions PTO;
Index: llvm/test/Feature/optnone-opt.ll
===
--- llvm/test/Feature/optnone-opt.ll
+++ llvm/test/Feature/optnone-opt.ll
@@ -1,9 +1,15 @@
-; RUN: opt -S -debug %s 2>&1 | FileCheck %s --check-prefix=OPT-O0
-; RUN: opt -O1 -S -debug %s 2>&1 | FileCheck %s --check-prefix=OPT-O1
-; RUN: opt -O2 -S -debug %s 2>&1 | FileCheck %s --check-prefix=OPT-O1 --check-prefix=OPT-O2O3
-; RUN: opt -O3 -S -debug %s 2>&1 | FileCheck %s --check-prefix=OPT-O1 --check-prefix=OPT-O2O3
-; RUN: opt -dce -die -gvn-hoist -loweratomic -S -debug %s 2>&1 | FileCheck %s --check-prefix=OPT-MORE
-; RUN: opt -indvars -licm -loop-deletion -loop-extract -loop-idiom -loop-instsimplify -loop-reduce -loop-reroll -loop-rotate -loop-unroll -loop-unswitch -S -debug %s 2>&1 | FileCheck %s --check-prefix=OPT-LOOP
+; RUN: opt -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O0
+; RUN: opt -O1 -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O1
+; RUN: opt -O2 -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O1 --check-prefix=O2O3
+; RUN: opt -O3 -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O1 --check-prefix=O2O3
+; RUN: opt -dce -die -gvn-hoist -loweratomic -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=MORE
+; RUN: opt -indvars -licm -loop-deletion -loop-extract -loop-idiom -loop-instsimplify -loop-reduce -loop-reroll -loop-rotate -loop-unroll -loop-unswitch -enable-new-pm=0 -S -debug %s 2>&1 | FileCheck %s --check-prefix=LOOP
+; RUN: opt -enable-npm-optnone -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-O0
+; RUN: opt -enable-npm-optnone -O1 -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-O1
+; RUN: opt -enable-npm-optnone -O2 -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-O1 --check-prefix=NPM-O2O3
+; RUN: opt -enable-npm-optnone -O3 -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-O1 --check-prefix=NPM-O2O3
+; RUN: opt -enable-npm-optnone -dce -gvn-hoist -loweratomic -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-MORE
+; RUN: opt -enable-npm-optnone -indvars -licm -loop-deletion -loop-idiom -loop-instsimplify -loop-reduce -loop-unroll -simple-loop-unswitch -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-LOOP
 
 ; REQUIRES: asserts
 
@@ -34,32 +40,53 @@
 attributes #0 = { optnone noinline }
 
 ; Nothing that runs at -O0 gets skipped.
-; OPT-O0-NOT: Skipping pass
+; O0-NOT: Skipping pass
+; NPM-O0-NOT: Skipping pass
 
 ; IR passes run at -O1 and higher.
-; OPT-O1-DAG: Skipping pass 'Aggressive Dead Code Elimination'
-; OPT-O1-DAG: Skipping pass 'Combine redundant instructions'
-; OPT-O1-DAG: Skipping pass 'Early CSE'
-; OPT-O1-DAG: Skipping pass 'Reassociate expressions'
-; OPT-O1-DAG: Skipping pass 'Simplify the CFG'
-; OPT-O1-DAG: Skipping pass 'Sparse Conditional Constant Propagation'
+; O1-DAG: Skipping pass 'Aggressive Dead Code Elimination'
+; O1-DAG: Skipping pass 'Combine redundant instructions'
+; O1-DAG: Skipping pass 'Early CSE'
+; O1-DAG: Skipping pass 'Reassociate expressions'
+; O1-DAG: Skipping pass 'Simplify the CFG'
+; O1-DAG: Skipping pass 'Sparse Conditional Constant Propagation'
+; NPM-O1-DAG: Skipping pass: SimplifyCFGPass
+; NPM-O1-DAG: Skipping pass: SROA
+; NPM-O1-DAG: Skipping pass: EarlyCSEPass
+; NPM-O1-DAG: Skipping pass: LowerExpectIntrinsicPass
+; NPM-O1-DAG: Skipping pass: PromotePass
+; NPM-O1-DAG: Skipping pass: InstCombinePass
 
 ; Additional IR passes run at -O2 and higher.
-; OPT-O2O3-DAG: Skipping pass 'Global Value Numbering'
-; OPT-O2O3-DAG: Skipping pass 'SLP Vectorizer'
+; O2O3-DAG: Skipping pass 'Global Value Numbering'
+; O2O3-DAG: Skipping pass 'SLP Vectorizer'
+; NPM-O2O3-DAG: Skipping pass: GVN
+; NPM-O2O3-DAG: Skipping pass: SLPVectorizerPass
 
 ; Additional IR passes that opt doesn't turn on by default.
-; OPT-MORE-DAG: Skipping pass 'Dead Code Elimination'
-; OPT-MORE-DAG: Sk

[PATCH] D84172: [clangd] Fix conversion from Windows UNC paths to file URI format.

2020-07-20 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko added a comment.

In D84172#2162736 , @sammccall wrote:

> Thanks! Do you have commit access, or should I land this for you?


No, I don't have commit access. Could you please commit on my behalf?

Ilya Golovenko 

And thanks again for the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84172



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


[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-20 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen updated this revision to Diff 279303.
aelitashen added a comment.

Remove white space for test_module_event


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731

Files:
  clang/tools/clang-format/git-clang-format
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/tools/lldb-vscode/JSONUtils.cpp

Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -7,6 +7,8 @@
 //===--===//
 
 #include 
+#include 
+#include 
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FormatAdapters.h"
@@ -327,6 +329,50 @@
   return llvm::json::Value(std::move(object));
 }
 
+static uint64_t GetDebugInfoSizeInSection(lldb::SBSection section) {
+  uint64_t debug_info_size = 0;
+  llvm::StringRef section_name(section.GetName());
+  if (section_name.startswith(".debug") || section_name.startswith("__debug") ||
+  section_name.startswith(".apple") || section_name.startswith("__apple"))
+debug_info_size += section.GetFileByteSize();
+  size_t num_sub_sections = section.GetNumSubSections();
+  for (size_t i = 0; i < num_sub_sections; i++) {
+debug_info_size +=
+GetDebugInfoSizeInSection(section.GetSubSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static uint64_t GetDebugInfoSize(lldb::SBModule module) {
+  uint64_t debug_info_size = 0;
+  size_t num_sections = module.GetNumSections();
+  for (size_t i = 0; i < num_sections; i++) {
+debug_info_size += GetDebugInfoSizeInSection(module.GetSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static std::string ConvertDebugInfoSizeToString(uint64_t debug_info) {
+  std::ostringstream oss;
+  oss << "(";
+  oss << std::fixed << std::setprecision(1);
+
+  if (debug_info < 1024) {
+oss << debug_info << "B";
+  } else if (debug_info < 1024 * 1024) {
+double kb = double(debug_info) / 1024.0;
+oss << kb << "KB";
+  } else if (debug_info < 1024 * 1024 * 1024) {
+double mb = double(debug_info) / (1024.0 * 1024.0);
+oss << mb << "MB";
+  } else {
+double gb = double(debug_info) / (1024.0 * 1024.0 * 1024.0);
+oss << gb << "GB";
+;
+  }
+  oss << ")";
+  return oss.str();
+}
 llvm::json::Value CreateModule(lldb::SBModule &module) {
   llvm::json::Object object;
   if (!module.IsValid())
@@ -339,9 +385,15 @@
   std::string module_path(module_path_arr);
   object.try_emplace("path", module_path);
   if (module.GetNumCompileUnits() > 0) {
-object.try_emplace("symbolStatus", "Symbols loaded.");
+std::string symbol_str = "Symbols loaded.";
+uint64_t debug_info = GetDebugInfoSize(module);
+if (debug_info > 0) {
+  symbol_str += ConvertDebugInfoSizeToString(debug_info);
+}
+object.try_emplace("symbolStatus", symbol_str);
 char symbol_path_arr[PATH_MAX];
-module.GetSymbolFileSpec().GetPath(symbol_path_arr, sizeof(symbol_path_arr));
+module.GetSymbolFileSpec().GetPath(symbol_path_arr,
+   sizeof(symbol_path_arr));
 std::string symbol_path(symbol_path_arr);
 object.try_emplace("symbolFilePath", symbol_path);
   } else {
@@ -352,8 +404,9 @@
   object.try_emplace("addressRange", loaded_addr);
   std::string version_str;
   uint32_t version_nums[3];
-  uint32_t num_versions = module.GetVersion(version_nums, sizeof(version_nums)/sizeof(uint32_t));
-  for (uint32_t i=0; ihttps://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#======#
-
-r"""
-clang-format git integration
-
-
-This file provides a clang-format integration for git. Put it somewhere in your
-path and ensure that it is executable. Then, "git clang-format" will invoke
-clang-format on the changes in current files or a specific commit.
-
-For further details, run:
-git clang-format -h
-
-Requires Python 2.7 or Python 3
-"""
-
-from __future__ import absolute_import, division, print_function
-import argparse
-import collections
-import contextlib
-import errno
-import os
-import re
-import subprocess
-import sys
-
-usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
-
-desc = '''
-If zero or one commits are given, run clang-format on all lines that differ
-between the working directory and , which defaults to HEAD.  Changes are
-only applied to the working directory.
-
-If two commits are given (requires --diff), run clang-format on all lines in the
-second  that differ from the first .
-
-The following git-config settings set the default of the corresponding option:
-  clangFormat.binary
-  clangFormat.commit
-  clangFormat.extensions
-  c

[clang] 865ee64 - [NFC] Add missing 'override's

2020-07-20 Thread Logan Smith via cfe-commits

Author: Logan Smith
Date: 2020-07-20T19:52:49-07:00
New Revision: 865ee64bf80ca833548582476202ec8b70987341

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

LOG: [NFC] Add missing 'override's

Added: 


Modified: 
clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp
llvm/include/llvm/Support/CrashRecoveryContext.h

Removed: 




diff  --git a/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp 
b/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
index dabcd6aa8f15..b91bf798aa7f 100644
--- a/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
+++ b/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
@@ -104,7 +104,7 @@ void MapExtDefNamesConsumer::addIfInMain(const 
DeclaratorDecl *DD,
 class MapExtDefNamesAction : public ASTFrontendAction {
 protected:
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
- llvm::StringRef) {
+ llvm::StringRef) override {
 return std::make_unique(CI.getASTContext());
   }
 };

diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 91659e76219a..91d2dc23d861 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -179,12 +179,12 @@ class SingleCommandCompilationDatabase : public 
tooling::CompilationDatabase {
   SingleCommandCompilationDatabase(tooling::CompileCommand Cmd)
   : Command(std::move(Cmd)) {}
 
-  virtual std::vector
-  getCompileCommands(StringRef FilePath) const {
+  std::vector
+  getCompileCommands(StringRef FilePath) const override {
 return {Command};
   }
 
-  virtual std::vector getAllCompileCommands() const {
+  std::vector getAllCompileCommands() const override {
 return {Command};
   }
 

diff  --git a/llvm/include/llvm/Support/CrashRecoveryContext.h 
b/llvm/include/llvm/Support/CrashRecoveryContext.h
index 61a1bd405a4d..1529c197a301 100644
--- a/llvm/include/llvm/Support/CrashRecoveryContext.h
+++ b/llvm/include/llvm/Support/CrashRecoveryContext.h
@@ -181,7 +181,7 @@ class CrashRecoveryContextDestructorCleanup : public
   : CrashRecoveryContextCleanupBase<
 CrashRecoveryContextDestructorCleanup, T>(context, resource) {}
 
-  virtual void recoverResources() {
+  void recoverResources() override {
 this->resource->~T();
   }
 };



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


[clang] fc24d1e - [clang][NFC] Add missing 'override's

2020-07-20 Thread Logan Smith via cfe-commits

Author: Logan Smith
Date: 2020-07-20T16:43:24-07:00
New Revision: fc24d1eaddd8c0618e3ef3ab395029a0238d4568

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

LOG: [clang][NFC] Add missing 'override's

Added: 


Modified: 
clang/lib/Tooling/Refactoring/RefactoringActions.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Refactoring/RefactoringActions.cpp 
b/clang/lib/Tooling/Refactoring/RefactoringActions.cpp
index 7ac723f67c04..bf98941f568b 100644
--- a/clang/lib/Tooling/Refactoring/RefactoringActions.cpp
+++ b/clang/lib/Tooling/Refactoring/RefactoringActions.cpp
@@ -18,8 +18,8 @@ namespace {
 
 class DeclNameOption final : public OptionalRefactoringOption {
 public:
-  StringRef getName() const { return "name"; }
-  StringRef getDescription() const {
+  StringRef getName() const override { return "name"; }
+  StringRef getDescription() const override {
 return "Name of the extracted declaration";
   }
 };



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


[clang] a560910 - [Analyzer] Add checkRegionChanges for SmartPtrModeling

2020-07-20 Thread Nithin Vadukkumchery Rajendrakumar via cfe-commits

Author: Nithin Vadukkumchery Rajendrakumar
Date: 2020-07-21T01:13:40+02:00
New Revision: a5609102117d2384fb73a14f37d24a0c844e3864

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

LOG: [Analyzer]   Add checkRegionChanges for SmartPtrModeling

Summary:
Implemented checkRegionChanges for SmartPtrModeling

Reviewers: NoQ, Szelethus, vsavchenko, xazax.hun

Reviewed By: NoQ, vsavchenko, xazax.hun

Subscribers: martong, cfe-commits
Tags: #clang

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
clang/test/Analysis/Inputs/system-header-simulator-cxx.h
clang/test/Analysis/smart-ptr.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
index bcc7d4103c1c..1b2174501d6e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -30,7 +30,8 @@ using namespace clang;
 using namespace ento;
 
 namespace {
-class SmartPtrModeling : public Checker {
+class SmartPtrModeling
+: public Checker {
 
   bool isNullAfterMoveMethod(const CallEvent &Call) const;
 
@@ -40,6 +41,12 @@ class SmartPtrModeling : public Checker {
   bool evalCall(const CallEvent &Call, CheckerContext &C) const;
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
+  ProgramStateRef
+  checkRegionChanges(ProgramStateRef State,
+ const InvalidatedSymbols *Invalidated,
+ ArrayRef ExplicitRegions,
+ ArrayRef Regions,
+ const LocationContext *LCtx, const CallEvent *Call) const;
 
 private:
   ProgramStateRef updateTrackedRegion(const CallEvent &Call, CheckerContext &C,
@@ -87,6 +94,20 @@ bool isNullSmartPtr(const ProgramStateRef State, const 
MemRegion *ThisRegion) {
 } // namespace ento
 } // namespace clang
 
+// If a region is removed all of the subregions need to be removed too.
+static TrackedRegionMapTy
+removeTrackedSubregions(TrackedRegionMapTy RegionMap,
+TrackedRegionMapTy::Factory &RegionMapFactory,
+const MemRegion *Region) {
+  if (!Region)
+return RegionMap;
+  for (const auto &E : RegionMap) {
+if (E.first->isSubRegionOf(Region))
+  RegionMap = RegionMapFactory.remove(RegionMap, E.first);
+  }
+  return RegionMap;
+}
+
 bool SmartPtrModeling::isNullAfterMoveMethod(const CallEvent &Call) const {
   // TODO: Update CallDescription to support anonymous calls?
   // TODO: Handle other methods, such as .get() or .release().
@@ -158,6 +179,20 @@ void SmartPtrModeling::checkDeadSymbols(SymbolReaper 
&SymReaper,
   C.addTransition(State);
 }
 
+ProgramStateRef SmartPtrModeling::checkRegionChanges(
+ProgramStateRef State, const InvalidatedSymbols *Invalidated,
+ArrayRef ExplicitRegions,
+ArrayRef Regions, const LocationContext *LCtx,
+const CallEvent *Call) const {
+  TrackedRegionMapTy RegionMap = State->get();
+  TrackedRegionMapTy::Factory &RegionMapFactory =
+  State->get_context();
+  for (const auto *Region : Regions)
+RegionMap = removeTrackedSubregions(RegionMap, RegionMapFactory,
+Region->getBaseRegion());
+  return State->set(RegionMap);
+}
+
 void SmartPtrModeling::handleReset(const CallEvent &Call,
CheckerContext &C) const {
   const auto *IC = dyn_cast(&Call);

diff  --git a/clang/test/Analysis/Inputs/system-header-simulator-cxx.h 
b/clang/test/Analysis/Inputs/system-header-simulator-cxx.h
index 1dee3294d732..d5e7c4c9218d 100644
--- a/clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ b/clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -953,24 +953,25 @@ next(ForwardIterator it,
 
 #if __cplusplus >= 201103L
 namespace std {
-  template  // TODO: Implement the stub for deleter.
-  class unique_ptr {
-  public:
-unique_ptr() {}
-unique_ptr(T *) {}
-unique_ptr(const unique_ptr &) = delete;
-unique_ptr(unique_ptr &&);
-
-T *get() const;
-T *release() const;
-void reset(T *p = nullptr) const;
-void swap(unique_ptr &p) const;
-
-typename std::add_lvalue_reference::type operator*() const;
-T *operator->() const;
-operator bool() const;
-  };
-}
+template  // TODO: Implement the stub for deleter.
+class unique_ptr {
+public:
+  unique_ptr() noexcept {}
+  unique_ptr(T *) noexcept {}
+  unique_ptr(const unique_ptr &) noexcept = delete;
+  unique_ptr(unique_ptr &&) noexcept;
+
+  T *get() const noexcept;
+  T *release() noexcept;
+  void reset(T

Re: [clang-tools-extra] 9791416 - Silence a "logical operation on address of string constant" via CMake instead.

2020-07-20 Thread David Blaikie via cfe-commits
Should the warning be disabled for LLVM overall, rather than only for
this subproject? (& be good tohave some details in the commit at least
of why this warning is being disabled - how it is noisy/unhelpful/etc)

On Sun, Jul 19, 2020 at 8:20 AM Aaron Ballman via cfe-commits
 wrote:
>
>
> Author: Aaron Ballman
> Date: 2020-07-19T11:19:48-04:00
> New Revision: 97914164f8454e745219566d58479b5762cccd51
>
> URL: 
> https://github.com/llvm/llvm-project/commit/97914164f8454e745219566d58479b5762cccd51
> DIFF: 
> https://github.com/llvm/llvm-project/commit/97914164f8454e745219566d58479b5762cccd51.diff
>
> LOG: Silence a "logical operation on address of string constant" via CMake 
> instead.
>
> Added:
>
>
> Modified:
> clang-tools-extra/clangd/CMakeLists.txt
>
> Removed:
>
>
>
> 
> diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
> b/clang-tools-extra/clangd/CMakeLists.txt
> index b3002b1d5698..8db6656e5291 100644
> --- a/clang-tools-extra/clangd/CMakeLists.txt
> +++ b/clang-tools-extra/clangd/CMakeLists.txt
> @@ -28,6 +28,10 @@ set(LLVM_LINK_COMPONENTS
>Option
>)
>
> +if(MSVC AND NOT CLANG_CL)
> + set_source_files_properties(CompileCommands.cpp PROPERTIES COMPILE_FLAGS 
> -wd4130) # disables C4130: logical operation on address of string constant
> +endif()
> +
>  add_clang_library(clangDaemon
>AST.cpp
>ClangdLSPServer.cpp
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8b6179f - [NFC] Add missing 'override's

2020-07-20 Thread Logan Smith via cfe-commits

Author: Logan Smith
Date: 2020-07-20T14:39:36-07:00
New Revision: 8b6179f48c6c6701447b68615fdd3b0345f241a4

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

LOG: [NFC] Add missing 'override's

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h 
b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
index 40679f9143b9..6dab79e6e20a 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -26,7 +26,7 @@ class CGOpenMPRuntimeNVPTX : public CGOpenMPRuntimeGPU {
 
 public:
   explicit CGOpenMPRuntimeNVPTX(CodeGenModule &CGM);
-  llvm::Value *getGPUWarpSize(CodeGenFunction &CGF);
+  llvm::Value *getGPUWarpSize(CodeGenFunction &CGF) override;
 };
 
 } // CodeGen namespace.

diff  --git 
a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
index 651d5056dd9d..dfa70c8ef6c9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
@@ -89,14 +89,14 @@ class SuspendedThreadsListLinux : public 
SuspendedThreadsList {
  public:
   SuspendedThreadsListLinux() { thread_ids_.reserve(1024); }
 
-  tid_t GetThreadID(uptr index) const;
-  uptr ThreadCount() const;
+  tid_t GetThreadID(uptr index) override const;
+  uptr ThreadCount() const override;
   bool ContainsTid(tid_t thread_id) const;
   void Append(tid_t tid);
 
   PtraceRegistersStatus GetRegistersAndSP(uptr index, uptr *buffer,
-  uptr *sp) const;
-  uptr RegisterCount() const;
+  uptr *sp) const override;
+  uptr RegisterCount() const override;
 
  private:
   InternalMmapVector thread_ids_;



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


[clang] bd994b8 - Revert "[libTooling] In Clang Transformer, change `Metadata` field to deferred evalutaion"

2020-07-20 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-07-20T21:24:58Z
New Revision: bd994b81d376c7132b1155c31e99ce27a08f7ba3

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

LOG: Revert "[libTooling] In Clang Transformer, change `Metadata` field to 
deferred evalutaion"

This reverts commit c0b8954ecba500e3d9609152295b74ccd7d89d62.

The commit has broken various builds. Reverting while I investigate the cause.

Added: 


Modified: 
clang/include/clang/Tooling/Transformer/RewriteRule.h
clang/lib/Tooling/Transformer/RewriteRule.cpp
clang/unittests/Tooling/TransformerTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Transformer/RewriteRule.h 
b/clang/include/clang/Tooling/Transformer/RewriteRule.h
index eb6947b54885..d9e68717d5c8 100644
--- a/clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ b/clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -47,8 +47,6 @@ using EditGenerator = MatchConsumer>;
 
 using TextGenerator = std::shared_ptr>;
 
-using AnyGenerator = MatchConsumer;
-
 // Description of a source-code edit, expressed in terms of an AST node.
 // Includes: an ID for the (bound) node, a selector for source related to the
 // node, a replacement and, optionally, an explanation for the edit.
@@ -89,11 +87,7 @@ struct ASTEdit {
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
-  // Not all transformations will want or need to attach metadata and therefore
-  // should not be required to do so.
-  AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {
-return llvm::Any();
-  };
+  llvm::Any Metadata;
 };
 
 /// Lifts a list of `ASTEdit`s into an `EditGenerator`.
@@ -267,27 +261,9 @@ inline ASTEdit insertAfter(RangeSelector S, TextGenerator 
Replacement) {
 /// Removes the source selected by \p S.
 ASTEdit remove(RangeSelector S);
 
-// FIXME: If `Metadata` returns an `llvm::Expected` the `AnyGenerator` will
-// construct an `llvm::Expected` where no error is present but the
-// `llvm::Any` holds the error. This is unlikely but potentially surprising.
-// Perhaps the `llvm::Expected` should be unwrapped, or perhaps this should be 
a
-// compile-time error. No solution here is perfect.
-//
-// Note: This function template accepts any type callable with a MatchResult
-// rather than a `std::function` because the return-type needs to be deduced. 
If
-// it accepted a `std::function`, lambdas or other callable
-// types would not be able to deduce `R`, and users would be forced to specify
-// explicitly the type they intended to return by wrapping the lambda at the
-// call-site.
-template 
-inline ASTEdit withMetadata(ASTEdit Edit, Callable Metadata) {
-  Edit.Metadata =
-  [Gen = std::move(Metadata)](
-  const ast_matchers::MatchFinder::MatchResult &R) -> llvm::Any {
-return Gen(R);
-  };
-
-  return Edit;
+inline ASTEdit withMetadata(ASTEdit edit, llvm::Any Metadata) {
+  edit.Metadata = std::move(Metadata);
+  return edit;
 }
 
 /// The following three functions are a low-level part of the RewriteRule

diff  --git a/clang/lib/Tooling/Transformer/RewriteRule.cpp 
b/clang/lib/Tooling/Transformer/RewriteRule.cpp
index a212a868c81d..995bec03cd66 100644
--- a/clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ b/clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -44,13 +44,10 @@ translateEdits(const MatchResult &Result, ArrayRef 
ASTEdits) {
 auto Replacement = E.Replacement->eval(Result);
 if (!Replacement)
   return Replacement.takeError();
-auto Metadata = E.Metadata(Result);
-if (!Metadata)
-  return Metadata.takeError();
 transformer::Edit T;
 T.Range = *EditRange;
 T.Replacement = std::move(*Replacement);
-T.Metadata = std::move(*Metadata);
+T.Metadata = E.Metadata;
 Edits.push_back(std::move(T));
   }
   return Edits;

diff  --git a/clang/unittests/Tooling/TransformerTest.cpp 
b/clang/unittests/Tooling/TransformerTest.cpp
index 59b334b0ea5a..7d6b63293748 100644
--- a/clang/unittests/Tooling/TransformerTest.cpp
+++ b/clang/unittests/Tooling/TransformerTest.cpp
@@ -440,12 +440,6 @@ TEST_F(TransformerTest, RemoveEdit) {
 }
 
 TEST_F(TransformerTest, WithMetadata) {
-  auto makeMetadata = [](const MatchFinder::MatchResult &R) -> llvm::Any {
-int N =
-R.Nodes.getNodeAs("int")->getValue().getLimitedValue();
-return N;
-  };
-
   std::string Input = R"cc(
 int f() {
   int x = 5;
@@ -454,11 +448,8 @@ TEST_F(TransformerTest, WithMetadata) {
   )cc";
 
   Transformer T(
-  makeRule(
-  declStmt(containsDeclaration(0, varDecl(hasInitializer(
-  integerLiteral().bind("int")
-  .bind("decl"),
-  withMetadata(remove(statement(std::string("decl")))

[clang] c0b8954 - [libTooling] In Clang Transformer, change `Metadata` field to deferred evalutaion

2020-07-20 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-07-20T21:17:09Z
New Revision: c0b8954ecba500e3d9609152295b74ccd7d89d62

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

LOG: [libTooling] In Clang Transformer, change `Metadata` field to deferred 
evalutaion

`Metadata` is being changed from an `llvm::Any` to a 
`MatchConsumer`, so that it's evaluation can be be dependent on 
`MatchResult`s passed in.

Reviewed By: ymandel, gribozavr2

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

Added: 


Modified: 
clang/include/clang/Tooling/Transformer/RewriteRule.h
clang/lib/Tooling/Transformer/RewriteRule.cpp
clang/unittests/Tooling/TransformerTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Transformer/RewriteRule.h 
b/clang/include/clang/Tooling/Transformer/RewriteRule.h
index d9e68717d5c8..eb6947b54885 100644
--- a/clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ b/clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -47,6 +47,8 @@ using EditGenerator = MatchConsumer>;
 
 using TextGenerator = std::shared_ptr>;
 
+using AnyGenerator = MatchConsumer;
+
 // Description of a source-code edit, expressed in terms of an AST node.
 // Includes: an ID for the (bound) node, a selector for source related to the
 // node, a replacement and, optionally, an explanation for the edit.
@@ -87,7 +89,11 @@ struct ASTEdit {
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
-  llvm::Any Metadata;
+  // Not all transformations will want or need to attach metadata and therefore
+  // should not be required to do so.
+  AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {
+return llvm::Any();
+  };
 };
 
 /// Lifts a list of `ASTEdit`s into an `EditGenerator`.
@@ -261,9 +267,27 @@ inline ASTEdit insertAfter(RangeSelector S, TextGenerator 
Replacement) {
 /// Removes the source selected by \p S.
 ASTEdit remove(RangeSelector S);
 
-inline ASTEdit withMetadata(ASTEdit edit, llvm::Any Metadata) {
-  edit.Metadata = std::move(Metadata);
-  return edit;
+// FIXME: If `Metadata` returns an `llvm::Expected` the `AnyGenerator` will
+// construct an `llvm::Expected` where no error is present but the
+// `llvm::Any` holds the error. This is unlikely but potentially surprising.
+// Perhaps the `llvm::Expected` should be unwrapped, or perhaps this should be 
a
+// compile-time error. No solution here is perfect.
+//
+// Note: This function template accepts any type callable with a MatchResult
+// rather than a `std::function` because the return-type needs to be deduced. 
If
+// it accepted a `std::function`, lambdas or other callable
+// types would not be able to deduce `R`, and users would be forced to specify
+// explicitly the type they intended to return by wrapping the lambda at the
+// call-site.
+template 
+inline ASTEdit withMetadata(ASTEdit Edit, Callable Metadata) {
+  Edit.Metadata =
+  [Gen = std::move(Metadata)](
+  const ast_matchers::MatchFinder::MatchResult &R) -> llvm::Any {
+return Gen(R);
+  };
+
+  return Edit;
 }
 
 /// The following three functions are a low-level part of the RewriteRule

diff  --git a/clang/lib/Tooling/Transformer/RewriteRule.cpp 
b/clang/lib/Tooling/Transformer/RewriteRule.cpp
index 995bec03cd66..a212a868c81d 100644
--- a/clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ b/clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -44,10 +44,13 @@ translateEdits(const MatchResult &Result, ArrayRef 
ASTEdits) {
 auto Replacement = E.Replacement->eval(Result);
 if (!Replacement)
   return Replacement.takeError();
+auto Metadata = E.Metadata(Result);
+if (!Metadata)
+  return Metadata.takeError();
 transformer::Edit T;
 T.Range = *EditRange;
 T.Replacement = std::move(*Replacement);
-T.Metadata = E.Metadata;
+T.Metadata = std::move(*Metadata);
 Edits.push_back(std::move(T));
   }
   return Edits;

diff  --git a/clang/unittests/Tooling/TransformerTest.cpp 
b/clang/unittests/Tooling/TransformerTest.cpp
index 7d6b63293748..59b334b0ea5a 100644
--- a/clang/unittests/Tooling/TransformerTest.cpp
+++ b/clang/unittests/Tooling/TransformerTest.cpp
@@ -440,6 +440,12 @@ TEST_F(TransformerTest, RemoveEdit) {
 }
 
 TEST_F(TransformerTest, WithMetadata) {
+  auto makeMetadata = [](const MatchFinder::MatchResult &R) -> llvm::Any {
+int N =
+R.Nodes.getNodeAs("int")->getValue().getLimitedValue();
+return N;
+  };
+
   std::string Input = R"cc(
 int f() {
   int x = 5;
@@ -448,8 +454,11 @@ TEST_F(TransformerTest, WithMetadata) {
   )cc";
 
   Transformer T(
-  makeRule(declStmt().bind("decl"),
-   withMetadata(remove(statement(std::string("decl"))), 17)),
+  makeRule(
+  declStmt(containsDeclaration

[Differential] D83820: Change metadata to deferred evalutaion in Clang Transformer.

2020-07-20 Thread Yitzhak Mandelbaum 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 rGc0b8954ecba5: [libTooling] In Clang Transformer, change 
`Metadata` field to deferred… (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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


  https://reviews.llvm.org/D83820

Files:
  clang/include/clang/Tooling/Transformer/RewriteRule.h
  clang/lib/Tooling/Transformer/RewriteRule.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -440,6 +440,12 @@
 }
 
 TEST_F(TransformerTest, WithMetadata) {
+  auto makeMetadata = [](const MatchFinder::MatchResult &R) -> llvm::Any {
+int N =
+R.Nodes.getNodeAs("int")->getValue().getLimitedValue();
+return N;
+  };
+
   std::string Input = R"cc(
 int f() {
   int x = 5;
@@ -448,8 +454,11 @@
   )cc";
 
   Transformer T(
-  makeRule(declStmt().bind("decl"),
-   withMetadata(remove(statement(std::string("decl"))), 17)),
+  makeRule(
+  declStmt(containsDeclaration(0, varDecl(hasInitializer(
+  integerLiteral().bind("int")
+  .bind("decl"),
+  withMetadata(remove(statement(std::string("decl"))), makeMetadata)),
   consumer());
   T.registerMatchers(&MatchFinder);
   auto Factory = newFrontendActionFactory(&MatchFinder);
@@ -459,7 +468,7 @@
   ASSERT_EQ(Changes.size(), 1u);
   const llvm::Any &Metadata = Changes[0].getMetadata();
   ASSERT_TRUE(llvm::any_isa(Metadata));
-  EXPECT_THAT(llvm::any_cast(Metadata), 17);
+  EXPECT_THAT(llvm::any_cast(Metadata), 5);
 }
 
 TEST_F(TransformerTest, MultiChange) {
Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -44,10 +44,13 @@
 auto Replacement = E.Replacement->eval(Result);
 if (!Replacement)
   return Replacement.takeError();
+auto Metadata = E.Metadata(Result);
+if (!Metadata)
+  return Metadata.takeError();
 transformer::Edit T;
 T.Range = *EditRange;
 T.Replacement = std::move(*Replacement);
-T.Metadata = E.Metadata;
+T.Metadata = std::move(*Metadata);
 Edits.push_back(std::move(T));
   }
   return Edits;
Index: clang/include/clang/Tooling/Transformer/RewriteRule.h
===
--- clang/include/clang/Tooling/Transformer/RewriteRule.h
+++ clang/include/clang/Tooling/Transformer/RewriteRule.h
@@ -47,6 +47,8 @@
 
 using TextGenerator = std::shared_ptr>;
 
+using AnyGenerator = MatchConsumer;
+
 // Description of a source-code edit, expressed in terms of an AST node.
 // Includes: an ID for the (bound) node, a selector for source related to the
 // node, a replacement and, optionally, an explanation for the edit.
@@ -87,7 +89,11 @@
   RangeSelector TargetRange;
   TextGenerator Replacement;
   TextGenerator Note;
-  llvm::Any Metadata;
+  // Not all transformations will want or need to attach metadata and therefore
+  // should not be required to do so.
+  AnyGenerator Metadata = [](const ast_matchers::MatchFinder::MatchResult &) {
+return llvm::Any();
+  };
 };
 
 /// Lifts a list of `ASTEdit`s into an `EditGenerator`.
@@ -261,9 +267,27 @@
 /// Removes the source selected by \p S.
 ASTEdit remove(RangeSelector S);
 
-inline ASTEdit withMetadata(ASTEdit edit, llvm::Any Metadata) {
-  edit.Metadata = std::move(Metadata);
-  return edit;
+// FIXME: If `Metadata` returns an `llvm::Expected` the `AnyGenerator` will
+// construct an `llvm::Expected` where no error is present but the
+// `llvm::Any` holds the error. This is unlikely but potentially surprising.
+// Perhaps the `llvm::Expected` should be unwrapped, or perhaps this should be a
+// compile-time error. No solution here is perfect.
+//
+// Note: This function template accepts any type callable with a MatchResult
+// rather than a `std::function` because the return-type needs to be deduced. If
+// it accepted a `std::function`, lambdas or other callable
+// types would not be able to deduce `R`, and users would be forced to specify
+// explicitly the type they intended to return by wrapping the lambda at the
+// call-site.
+template 
+inline ASTEdit withMetadata(ASTEdit Edit, Callable Metadata) {
+  Edit.Metadata =
+  [Gen = std::move(Metadata)](
+  const ast_matchers::MatchFinder::MatchResult &R) -> llvm::Any {
+return Gen(R);
+  };
+
+  return Edit;
 }
 
 /// The following three functions are a low-level part of the RewriteRule
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
ht

[Differential] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions

2020-07-20 Thread Gabor Marton via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ff220de9009: [analyzer][StdLibraryFunctionsChecker] Add 
POSIX networking functions (authored by martong).

Repository:
  rG LLVM Github Monorepo

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


  https://reviews.llvm.org/D83407

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c

Index: clang/test/Analysis/std-c-library-functions-POSIX.c
===
--- clang/test/Analysis/std-c-library-functions-POSIX.c
+++ clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -79,6 +79,22 @@
 // CHECK: Loaded summary for: int execv(const char *path, char *const argv[])
 // CHECK: Loaded summary for: int execvp(const char *file, char *const argv[])
 // CHECK: Loaded summary for: int getopt(int argc, char *const argv[], const char *optstring)
+// CHECK: Loaded summary for: int accept(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int bind(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len)
+// CHECK: Loaded summary for: int getpeername(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int getsockname(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int connect(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len)
+// CHECK: Loaded summary for: ssize_t recvfrom(int socket, void *restrict buffer, size_t length, int flags, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: ssize_t sendto(int socket, const void *message, size_t length, int flags, __CONST_SOCKADDR_ARG dest_addr, socklen_t dest_len)
+// CHECK: Loaded summary for: int listen(int sockfd, int backlog)
+// CHECK: Loaded summary for: ssize_t recv(int sockfd, void *buf, size_t len, int flags)
+// CHECK: Loaded summary for: ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags)
+// CHECK: Loaded summary for: ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags)
+// CHECK: Loaded summary for: int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len)
+// CHECK: Loaded summary for: int getsockopt(int socket, int level, int option_name, void *restrict option_value, socklen_t *restrict option_len)
+// CHECK: Loaded summary for: ssize_t send(int sockfd, const void *buf, size_t len, int flags)
+// CHECK: Loaded summary for: int socketpair(int domain, int type, int protocol, int sv[2])
+// CHECK: Loaded summary for: int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, char *restrict node, socklen_t nodelen, char *restrict service, socklen_t servicelen, int flags)
 
 long a64l(const char *str64);
 char *l64a(long value);
@@ -171,6 +187,46 @@
 int execvp(const char *file, char *const argv[]);
 int getopt(int argc, char *const argv[], const char *optstring);
 
+// In some libc implementations, sockaddr parameter is a transparent
+// union of the underlying sockaddr_ pointers instead of being a
+// pointer to struct sockaddr.
+// We match that with the joker Irrelevant type.
+struct sockaddr;
+struct sockaddr_at;
+#define __SOCKADDR_ALLTYPES\
+  __SOCKADDR_ONETYPE(sockaddr) \
+  __SOCKADDR_ONETYPE(sockaddr_at)
+#define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
+typedef union {
+  __SOCKADDR_ALLTYPES
+} __SOCKADDR_ARG __attribute__((__transparent_union__));
+#undef __SOCKADDR_ONETYPE
+#define __SOCKADDR_ONETYPE(type) const struct type *__restrict __##type##__;
+typedef union {
+  __SOCKADDR_ALLTYPES
+} __CONST_SOCKADDR_ARG __attribute__((__transparent_union__));
+#undef __SOCKADDR_ONETYPE
+typedef unsigned socklen_t;
+
+int accept(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int bind(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len);
+int getpeername(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int getsockname(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int connect(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len);
+ssize_t recvfrom(int socket, void *restrict buffer, size_t length, int flags, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+ssize_t sendto(int socket, const void *message, size_t length, int flags, __CONST_SOCKADDR_ARG dest_addr, socklen_t dest_len);
+
+int listen(int sockfd, int backlog);
+ssize_t recv(int sockfd, void *buf, size_t len, int flags);
+struct msghdr;
+ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags);
+ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);

[clang] 3ff220d - [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions

2020-07-20 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-07-20T22:46:24+02:00
New Revision: 3ff220de900970a20c9882b7199c178c6b6428b2

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

LOG: [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions

Summary:
Adding networking functions from the POSIX standard (2017). This includes
functions that deal with sockets from socket.h, netdb.h.

In 'socket.h' of some libc implementations (e.g. glibc) with C99, sockaddr
parameter is a transparent union of the underlying sockaddr_ family of pointers
instead of being a pointer to struct sockaddr. In these cases, the standardized
signature will not match, thus we try to match with another signature that has
the joker Irrelevant type. In the case of transparent unions, we also not add
those constraints which require pointer types for the sockaddr param.

Interestingly, in 'netdb.h' sockaddr is not handled as a transparent union.

Tags: #clang

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

Added: 
clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp

Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/std-c-library-functions-POSIX.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 8b575f4f4759..e437c33bd81a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -302,6 +302,13 @@ class StdLibraryFunctionsChecker
   Tmp.Op = BinaryOperator::negateComparisonOp(Op);
   return std::make_shared(Tmp);
 }
+
+bool checkSpecificValidity(const FunctionDecl *FD) const override {
+  const bool ValidArg = getArgType(FD, ArgN)->isPointerType();
+  assert(ValidArg &&
+ "This constraint should be applied only on a pointer type");
+  return ValidArg;
+}
   };
 
   /// The complete list of constraints that defines a single branch.
@@ -318,8 +325,8 @@ class StdLibraryFunctionsChecker
   // concessive signature, meaning there may be irrelevant types in the
   // signature which we do not check against a function with concrete types.
   struct Signature {
-const ArgTypes ArgTys;
-const QualType RetTy;
+ArgTypes ArgTys;
+QualType RetTy;
 Signature(ArgTypes ArgTys, QualType RetTy) : ArgTys(ArgTys), RetTy(RetTy) {
   assertRetTypeSuitableForSignature(RetTy);
   for (size_t I = 0, E = ArgTys.size(); I != E; ++I) {
@@ -327,6 +334,7 @@ class StdLibraryFunctionsChecker
 assertArgTypeSuitableForSignature(ArgTy);
   }
 }
+
 bool matches(const FunctionDecl *FD) const;
 
   private:
@@ -380,7 +388,7 @@ class StdLibraryFunctionsChecker
   ///   rules for the given parameter's type, those rules are checked once the
   ///   signature is matched.
   class Summary {
-const Signature Sign;
+Optional Sign;
 const InvalidationKind InvalidationKd;
 Cases CaseConstraints;
 ConstraintSet ArgConstraints;
@@ -391,7 +399,14 @@ class StdLibraryFunctionsChecker
 
   public:
 Summary(ArgTypes ArgTys, QualType RetTy, InvalidationKind InvalidationKd)
-: Sign(ArgTys, RetTy), InvalidationKd(InvalidationKd) {}
+: Sign(Signature(ArgTys, RetTy)), InvalidationKd(InvalidationKd) {}
+
+Summary(InvalidationKind InvalidationKd) : InvalidationKd(InvalidationKd) 
{}
+
+Summary &setSignature(const Signature &S) {
+  Sign = S;
+  return *this;
+}
 
 Summary &Case(ConstraintSet&& CS) {
   CaseConstraints.push_back(std::move(CS));
@@ -413,7 +428,9 @@ class StdLibraryFunctionsChecker
 // Returns true if the summary should be applied to the given function.
 // And if yes then store the function declaration.
 bool matchesAndSet(const FunctionDecl *FD) {
-  bool Result = Sign.matches(FD) && validateByConstraints(FD);
+  assert(Sign &&
+ "Signature must be set before comparing to a FunctionDecl");
+  bool Result = Sign->matches(FD) && validateByConstraints(FD);
   if (Result) {
 assert(!this->FD && "FD must not be set more than once");
 this->FD = FD;
@@ -761,6 +778,10 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
   BasicValueFactory &BVF = SVB.getBasicValueFactory();
   const ASTContext &ACtx = BVF.getContext();
 
+  auto getRestrictTy = [&ACtx](QualType Ty) {
+return ACtx.getLangOpts().C99 ? ACtx.getRestrictType(Ty) : Ty;
+  };
+
   // These types are useful for writing specifications quickly,
   // New specifications should probably introduce more types.
   // Some types are hard to obtain from the AST, eg. "ssize_t".
@@ -779,28 +800,18 @@ void StdLibraryFunct

[clang] 52ab7aa - [clang-format] Add BitFieldColonSpacing option

2020-07-20 Thread Anders Waldenborg via cfe-commits

Author: Anders Waldenborg
Date: 2020-07-20T20:55:51+02:00
New Revision: 52ab7aa0ba5a3c7a0b2fe1b48519f1d4dc52cacf

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

LOG: [clang-format] Add BitFieldColonSpacing option

This new option allows controlling if there should be spaces around
the ':' in a bitfield declaration.

BitFieldColonSpacing accepts four different values:

  // "Both" - default
  unsigned bitfield : 5
  unsigned bf2  : 5  // AlignConsecutiveBitFields=true

  // "None"
  unsigned bitfield:5
  unsigned bf2 :5

  // "Before"
  unsigned bitfield :5
  unsigned bf2  :5

  // "After"
  unsigned bitfield: 5
  unsigned bf2 : 5

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 6647b117ac59..c35718b51248 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -794,6 +794,43 @@ the configuration (without a prefix: ``Auto``).
int ,
int aaa) {}
 
+**BitFieldColonSpacing** (``BitFieldColonSpacingStyle``)
+  The BitFieldColonSpacingStyle to use for bitfields.
+
+  Possible values:
+
+  * ``BFCS_Both`` (in configuration: ``Both``)
+Add one space on each side of the ``:``
+
+.. code-block:: c++
+
+  unsigned bf : 2;
+
+  * ``BFCS_None`` (in configuration: ``None``)
+Add no space around the ``:`` (except when needed for
+``AlignConsecutiveBitFields``).
+
+.. code-block:: c++
+
+  unsigned bf:2;
+
+  * ``BFCS_Before`` (in configuration: ``Before``)
+Add space before the ``:`` only
+
+.. code-block:: c++
+
+  unsigned bf :2;
+
+  * ``BFCS_After`` (in configuration: ``After``)
+Add space after the ``:`` only (space may be added before if
+needed for ``AlignConsecutiveBitFields``).
+
+.. code-block:: c++
+
+  unsigned bf: 2;
+
+
+
 **BraceWrapping** (``BraceWrappingFlags``)
   Control of individual brace wrapping cases.
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 10ead604239c..21689c5c5d85 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -149,7 +149,33 @@ AST Matchers
 clang-format
 
 
-- ...
+- Option ``BitFieldColonSpacing`` has been added that decides how
+  space should be added around identifier, colon and bit-width in
+  bitfield definitions.
+
+  .. code-block:: c++
+
+// Both (default)
+struct F {
+  unsigned dscp : 6;
+  unsigned ecn  : 2; // AlignConsecutiveBitFields=true
+};
+// None
+struct F {
+  unsigned dscp:6;
+  unsigned ecn :2;
+};
+// Before
+struct F {
+  unsigned dscp :6;
+  unsigned ecn  :2;
+};
+// After
+struct F {
+  unsigned dscp: 6;
+  unsigned ecn : 2;
+};
+
 
 libclang
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
old mode 100755
new mode 100644
index 7201c11f1158..269eab971a2c
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2233,6 +2233,34 @@ struct FormatStyle {
   /// \endcode
   bool SpaceBeforeSquareBrackets;
 
+  /// Styles for adding spacing around ``:`` in bitfield definitions.
+  enum BitFieldColonSpacingStyle {
+/// Add one space on each side of the ``:``
+/// \code
+///   unsigned bf : 2;
+/// \endcode
+BFCS_Both,
+/// Add no space around the ``:`` (except when needed for
+/// ``AlignConsecutiveBitFields``).
+/// \code
+///   unsigned bf:2;
+/// \endcode
+BFCS_None,
+/// Add space before the ``:`` only
+/// \code
+///   unsigned bf :2;
+/// \endcode
+BFCS_Before,
+/// Add space after the ``:`` only (space may be added before if
+/// needed for ``AlignConsecutiveBitFields``).
+/// \code
+///   unsigned bf: 2;
+/// \endcode
+BFCS_After
+  };
+  /// The BitFieldColonSpacingStyle to use for bitfields.
+  BitFieldColonSpacingStyle BitFieldColonSpacing;
+
   /// Supported language standards for parsing and formatting C++ constructs.
   /// \code
   ///Latest:vector>
@@ -2409,6 +2437,7 @@ struct FormatStyle {
SpacesInParentheses == R.SpacesInParentheses &&
SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
SpaceBeforeSquareBrackets == R.SpaceBeforeSquareBrackets &&
+   BitFieldColo

[clang-tools-extra] c911803 - [clangd] Remove TokenBuffer usage in TypeHierarchy

2020-07-20 Thread Kadir Cetinkaya via cfe-commits

Author: Aleksandr Platonov
Date: 2020-07-20T21:00:49+02:00
New Revision: c911803d5df0f8a781b56849180b4b93a61306a7

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

LOG: [clangd] Remove TokenBuffer usage in TypeHierarchy

Summary:
This patch mostly reverts D74850.
We could not use `AST.getTokens()` here, because it does not have tokens from 
the preamble.

Reviewers: sammccall, kadircet

Reviewed By: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
kbobyrev, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index c208e953f2ab..aeff7ebc32a2 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -1183,23 +1183,24 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, 
const LocatedSymbol &S) {
 
 // FIXME(nridge): Reduce duplication between this function and declToSym().
 static llvm::Optional
-declToTypeHierarchyItem(ASTContext &Ctx, const NamedDecl &ND,
-const syntax::TokenBuffer &TB) {
+declToTypeHierarchyItem(ASTContext &Ctx, const NamedDecl &ND) {
   auto &SM = Ctx.getSourceManager();
   SourceLocation NameLoc = nameLocation(ND, Ctx.getSourceManager());
+  SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
+  SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc()));
+  const auto DeclRange =
+  toHalfOpenFileRange(SM, Ctx.getLangOpts(), {BeginLoc, EndLoc});
+  if (!DeclRange)
+return llvm::None;
   auto FilePath =
   getCanonicalPath(SM.getFileEntryForID(SM.getFileID(NameLoc)), SM);
   auto TUPath = getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
   if (!FilePath || !TUPath)
 return llvm::None; // Not useful without a uri.
 
-  auto DeclToks = 
TB.spelledForExpanded(TB.expandedTokens(ND.getSourceRange()));
-  if (!DeclToks || DeclToks->empty())
-return llvm::None;
-
-  auto NameToks = TB.spelledForExpanded(TB.expandedTokens(NameLoc));
-  if (!NameToks || NameToks->empty())
-return llvm::None;
+  Position NameBegin = sourceLocToPosition(SM, NameLoc);
+  Position NameEnd = sourceLocToPosition(
+  SM, Lexer::getLocForEndOfToken(NameLoc, 0, SM, Ctx.getLangOpts()));
 
   index::SymbolInfo SymInfo = index::getSymbolInfo(&ND);
   // FIXME: this is not classifying constructors, destructors and operators
@@ -1210,12 +1211,9 @@ declToTypeHierarchyItem(ASTContext &Ctx, const NamedDecl 
&ND,
   THI.name = printName(Ctx, ND);
   THI.kind = SK;
   THI.deprecated = ND.isDeprecated();
-  THI.range = halfOpenToRange(
-  SM, syntax::Token::range(SM, DeclToks->front(), DeclToks->back())
-  .toCharRange(SM));
-  THI.selectionRange = halfOpenToRange(
-  SM, syntax::Token::range(SM, NameToks->front(), NameToks->back())
-  .toCharRange(SM));
+  THI.range = Range{sourceLocToPosition(SM, DeclRange->getBegin()),
+sourceLocToPosition(SM, DeclRange->getEnd())};
+  THI.selectionRange = Range{NameBegin, NameEnd};
   if (!THI.range.contains(THI.selectionRange)) {
 // 'selectionRange' must be contained in 'range', so in cases where clang
 // reports unrelated ranges we need to reconcile somehow.
@@ -1282,8 +1280,7 @@ using RecursionProtectionSet = llvm::SmallSet;
 
 static void fillSuperTypes(const CXXRecordDecl &CXXRD, ASTContext &ASTCtx,
std::vector &SuperTypes,
-   RecursionProtectionSet &RPSet,
-   const syntax::TokenBuffer &TB) {
+   RecursionProtectionSet &RPSet) {
   // typeParents() will replace dependent template specializations
   // with their class template, so to avoid infinite recursion for
   // certain types of hierarchies, keep the templates encountered
@@ -1298,9 +1295,9 @@ static void fillSuperTypes(const CXXRecordDecl &CXXRD, 
ASTContext &ASTCtx,
 
   for (const CXXRecordDecl *ParentDecl : typeParents(&CXXRD)) {
 if (Optional ParentSym =
-declToTypeHierarchyItem(ASTCtx, *ParentDecl, TB)) {
+declToTypeHierarchyItem(ASTCtx, *ParentDecl)) {
   ParentSym->parents.emplace();
-  fillSuperTypes(*ParentDecl, ASTCtx, *ParentSym->parents, RPSet, TB);
+  fillSuperTypes(*ParentDecl, ASTCtx, *ParentSym->parents, RPSet);
   SuperTypes.emplace_back(std::move(*ParentSym));
 }
   }
@@ -1404,7 +1401,7 @@ getTypeHierarchy(ParsedAST &AST, Position Pos, int 
ResolveLevels,
 return llvm::None;
 
   Optional Result =
-  declToTypeHierarchyItem(AST.getASTContext(), *

[Differential] D84090: Test revision5 (ignore)

2020-07-20 Thread Anders Waldenborg via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG52ab7aa0ba5a: [clang-format] Add BitFieldColonSpacing option 
(authored by wanders).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D84090?vs=278987&id=279025#toc

Repository:
  rG LLVM Github Monorepo

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


  https://reviews.llvm.org/D84090

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2165,6 +2165,33 @@
"  uchar : 8;\n"
"  uchar other;\n"
"};");
+  FormatStyle Style = getLLVMStyle();
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  verifyFormat("struct Bitfields {\n"
+   "  unsigned sClass:8;\n"
+   "  unsigned ValueKind:2;\n"
+   "  uchar other;\n"
+   "};",
+   Style);
+  verifyFormat("struct A {\n"
+   "  int a:1,\n"
+   "  b:2;\n"
+   "};",
+   Style);
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_Before;
+  verifyFormat("struct Bitfields {\n"
+   "  unsigned sClass :8;\n"
+   "  unsigned ValueKind :2;\n"
+   "  uchar other;\n"
+   "};",
+   Style);
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_After;
+  verifyFormat("struct Bitfields {\n"
+   "  unsigned sClass: 8;\n"
+   "  unsigned ValueKind: 2;\n"
+   "  uchar other;\n"
+   "};",
+   Style);
 }
 
 TEST_F(FormatTest, FormatsNamespaces) {
@@ -12156,6 +12183,21 @@
"int   oneTwoThree : 23 = 0;",
Alignment);
 
+  Alignment.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  verifyFormat("int const a  :5;\n"
+   "int   oneTwoThree:23;",
+   Alignment);
+
+  Alignment.BitFieldColonSpacing = FormatStyle::BFCS_Before;
+  verifyFormat("int const a   :5;\n"
+   "int   oneTwoThree :23;",
+   Alignment);
+
+  Alignment.BitFieldColonSpacing = FormatStyle::BFCS_After;
+  verifyFormat("int const a  : 5;\n"
+   "int   oneTwoThree: 23;",
+   Alignment);
+
   // Known limitations: ':' is only recognized as a bitfield colon when
   // followed by a number.
   /*
@@ -14004,6 +14046,16 @@
   CHECK_PARSE("IndentExternBlock: false", IndentExternBlock,
   FormatStyle::IEBS_NoIndent);
 
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  CHECK_PARSE("BitFieldColonSpacing: Both", BitFieldColonSpacing,
+  FormatStyle::BFCS_Both);
+  CHECK_PARSE("BitFieldColonSpacing: None", BitFieldColonSpacing,
+  FormatStyle::BFCS_None);
+  CHECK_PARSE("BitFieldColonSpacing: Before", BitFieldColonSpacing,
+  FormatStyle::BFCS_Before);
+  CHECK_PARSE("BitFieldColonSpacing: After", BitFieldColonSpacing,
+  FormatStyle::BFCS_After);
+
   // FIXME: This is required because parsing a configuration simply overwrites
   // the first N elements of the list instead of resetting it.
   Style.ForEachMacros.clear();
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3251,6 +3251,9 @@
   if (Right.is(TT_RangeBasedForLoopColon) &&
   !Style.SpaceBeforeRangeBasedForLoopColon)
 return false;
+  if (Left.is(TT_BitFieldColon))
+return Style.BitFieldColonSpacing == FormatStyle::BFCS_Both ||
+   Style.BitFieldColonSpacing == FormatStyle::BFCS_After;
   if (Right.is(tok::colon)) {
 if (Line.First->isOneOf(tok::kw_case, tok::kw_default) ||
 !Right.getNextNonComment() || Right.getNextNonComment()->is(tok::semi))
@@ -3267,6 +3270,9 @@
   return false;
 if (Right.is(TT_CSharpNamedArgumentColon))
   return false;
+if (Right.is(TT_BitFieldColon))
+  return Style.BitFieldColonSpacing == FormatStyle::BFCS_Both ||
+ Style.BitFieldColonSpacing == FormatStyle::BFCS_Before;
 return true;
   }
   if (Left.is(TT_UnaryOperator)) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -366,6 +366,17 @@
   }
 };
 
+template <>
+struct ScalarEnumerationTraits

[PATCH] D83665: [OpenCL] Fixed missing address space for templated copy constructor

2020-07-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:3811
+  if(S.getLangOpts().OpenCL)
+ArgType = S.deduceOpenCLPointeeAddrSpace(ArgType);
   ArgType = S.Context.getLValueReferenceType(ArgType);

olestrohm wrote:
> Anastasia wrote:
> > I feel we can just add an address space explicitly since we are creating 
> > the type here for a known use case. However, does Arg actually have an 
> > address space? I am just unsure whether we should use generic address space 
> > or concrete address space.
> No, there are no known address spaces at this point for the test case I've 
> got. But as far as I understand the function isn't only used for the case we 
> look at here, but there may be case where the argument has an address space.
Ok since there are no known cases for named address spaces now, we could just 
use generic. We can always extend this later if we find that any other address 
space is needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83665



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


[PATCH] D84172: [clangd] Fix conversion from Windows UNC paths to file URI format.

2020-07-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks! Do you have commit access, or should I land this for you?




Comment at: clang-tools-extra/clangd/URI.cpp:29
 
+bool isWindowsPath(llvm::StringRef Path) {
+  return Path.size() > 1 && llvm::isAlpha(Path[0]) && Path[1] == ':';

ilya-golovenko wrote:
> sammccall wrote:
> > the UNC paths are also basically a windows thing, can we have 
> > hasWindowsDriveLetter and isWindowsNetworkPath (or isWindowsUNCPath)?
> This kind of network paths are also supported on Unix/Linux system, e.g. 
> `//hostname/path/file.txt` and `isNetworkPath` will handle those as well.  
> For example, samba and samba client support such paths. RFC 8089 calls them 
> "non-local files" with unspecified type of protocol to access the file, i.e. 
> it is not necessary a UNC path. Does it make sense to continue supporting 
> Linux/Unix version of network path?
Ah, I wasn't aware. This seems fine to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84172



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


[PATCH] D84185: Better defaults for MarshallingInfoString

2020-07-20 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese 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/D84185/new/

https://reviews.llvm.org/D84185



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


[PATCH] D84189: Let denormalizer decide how to render the option based on the option class

2020-07-20 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith.
Herald added projects: clang, LLVM.

Depends on D84188 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84189

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td

Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -198,9 +198,6 @@
   code Normalizer = "normalizeSimpleEnum";
   code Denormalizer = "denormalizeSimpleEnum";
 }
-class AutoNormalizeEnumJoined : AutoNormalizeEnum {
-  code Denormalizer = "denormalizeSimpleEnumJoined";
-}
 class ValueMerger { code ValueMerger = merger; }
 class ValueExtractor { code ValueExtractor = extractor; }
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -143,7 +143,8 @@
 void denormalizeSimpleFlag(SmallVectorImpl &Args,
const char *Spelling,
CompilerInvocation::StringAllocator SA,
-   unsigned TableIndex, T Value) {
+   Option::OptionClass OptClass, unsigned TableIndex,
+   T Value) {
   Args.push_back(Spelling);
 }
 
@@ -177,6 +178,38 @@
 Args.push_back(NegSpelling);
 }
 
+static Optional normalizeString(OptSpecifier Opt, int TableIndex,
+ const ArgList &Args,
+ DiagnosticsEngine &Diags) {
+  auto *Arg = Args.getLastArg(Opt);
+  if (!Arg)
+return None;
+  return std::string(Arg->getValue());
+}
+
+template 
+static void denormalizeString(SmallVectorImpl &Args,
+  const char *Spelling,
+  CompilerInvocation::StringAllocator SA,
+  Option::OptionClass OptClass, unsigned TableIndex,
+  T &&Value) {
+  static_assert(std::is_constructible::value,
+"Cannot convert this value to Twine");
+  switch (OptClass) {
+  case Option::SeparateClass:
+  case Option::JoinedOrSeparateClass:
+Args.push_back(Spelling);
+Args.push_back(SA(Twine(std::forward(Value;
+break;
+  case Option::JoinedClass:
+Args.push_back(SA(Twine(Spelling) + Twine(std::forward(Value;
+break;
+  default:
+llvm_unreachable("Cannot denormalize an option with option class "
+ "incompatible with string denormalization.");
+  }
+}
+
 static Optional
 findValueTableByName(const SimpleEnumValueTable &Table, StringRef Name) {
   for (int I = 0, E = Table.Size; I != E; ++I)
@@ -218,51 +251,19 @@
 static void denormalizeSimpleEnum(SmallVectorImpl &Args,
   const char *Spelling,
   CompilerInvocation::StringAllocator SA,
+  Option::OptionClass OptClass,
   unsigned TableIndex, unsigned Value) {
   assert(TableIndex < SimpleEnumValueTablesSize);
   const SimpleEnumValueTable &Table = SimpleEnumValueTables[TableIndex];
   if (auto MaybeEnumVal = findValueTableByValue(Table, Value)) {
-Args.push_back(Spelling);
-Args.push_back(MaybeEnumVal->Name);
+denormalizeString(Args, Spelling, SA, OptClass, TableIndex,
+  MaybeEnumVal->Name);
   } else {
 llvm_unreachable("The simple enum value was not correctly defined in "
  "the tablegen option description");
   }
 }
 
-static void denormalizeSimpleEnumJoined(SmallVectorImpl &Args,
-const char *Spelling,
-CompilerInvocation::StringAllocator SA,
-unsigned TableIndex, unsigned Value) {
-  assert(TableIndex < SimpleEnumValueTablesSize);
-  const SimpleEnumValueTable &Table = SimpleEnumValueTables[TableIndex];
-  if (auto MaybeEnumVal = findValueTableByValue(Table, Value))
-Args.push_back(SA(Twine(Spelling) + MaybeEnumVal->Name));
-  else
-llvm_unreachable("The simple enum value was not correctly defined in "
- "the tablegen option description");
-}
-
-static Optional normalizeString(OptSpecifier Opt, int TableIndex,
- const ArgList &Args,
- DiagnosticsEngine &Diags) {
-  auto *Arg = Args.getLastArg(Opt);
-  if (!Arg)
-return None;
-  return std::string(Arg->getValue());
-}
-
-template 
-static void denormalizeString(SmallVectorImpl &Args,
-  const char *Spelling,
-  

[PATCH] D84190: Port FrontendOpts simple string based options to new option parsing system

2020-07-20 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: cfe-commits, aaron.ballman, dexonsmith.
Herald added a project: clang.

Depends on D84189 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84190

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1760,15 +1760,11 @@
 << A->getAsString(Args) << A->getValue();
   }
 
-  Opts.OutputFile = std::string(Args.getLastArgValue(OPT_o));
   Opts.Plugins = Args.getAllArgValues(OPT_load);
-  Opts.TimeTraceGranularity = getLastArgIntValue(
-  Args, OPT_ftime_trace_granularity_EQ, Opts.TimeTraceGranularity, Diags);
   Opts.ASTMergeFiles = Args.getAllArgValues(OPT_ast_merge);
   Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);
   Opts.ASTDumpDecls = Args.hasArg(OPT_ast_dump, OPT_ast_dump_EQ);
   Opts.ASTDumpAll = Args.hasArg(OPT_ast_dump_all, OPT_ast_dump_all_EQ);
-  Opts.ASTDumpFilter = std::string(Args.getLastArgValue(OPT_ast_dump_filter));
   Opts.ModuleMapFiles = Args.getAllArgValues(OPT_fmodule_map_file);
   // Only the -fmodule-file= form.
   for (const auto *A : Args.filtered(OPT_fmodule_file)) {
@@ -1782,22 +1778,10 @@
 Diags.Report(diag::err_drv_argument_only_allowed_with) << "-fsystem-module"
<< "-emit-module";
 
-  Opts.OverrideRecordLayoutsFile =
-  std::string(Args.getLastArgValue(OPT_foverride_record_layout_EQ));
-  Opts.AuxTriple = std::string(Args.getLastArgValue(OPT_aux_triple));
   if (Args.hasArg(OPT_aux_target_cpu))
 Opts.AuxTargetCPU = std::string(Args.getLastArgValue(OPT_aux_target_cpu));
   if (Args.hasArg(OPT_aux_target_feature))
 Opts.AuxTargetFeatures = Args.getAllArgValues(OPT_aux_target_feature);
-  Opts.StatsFile = std::string(Args.getLastArgValue(OPT_stats_file));
-
-  Opts.MTMigrateDir =
-  std::string(Args.getLastArgValue(OPT_mt_migrate_directory));
-  Opts.ARCMTMigrateReportOut =
-  std::string(Args.getLastArgValue(OPT_arcmt_migrate_report_output));
-
-  Opts.ObjCMTWhiteListPath =
-  std::string(Args.getLastArgValue(OPT_objcmt_whitelist_dir_path));
 
   if (Opts.ARCMTAction != FrontendOptions::ARCMT_None &&
   Opts.ObjCMTAction != FrontendOptions::ObjCMT_None) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -313,8 +313,6 @@
   HelpText<"Apply modifications to files to conform to ARC">;
 def ccc_arcmt_migrate : Separate<["-"], "ccc-arcmt-migrate">, InternalDriverOpt,
   HelpText<"Apply modifications and produces temporary files that conform to ARC">;
-def arcmt_migrate_report_output : Separate<["-"], "arcmt-migrate-report-output">,
-  HelpText<"Output path for the plist report">,  Flags<[CC1Option]>;
 def gen_reproducer: Flag<["-"], "gen-reproducer">, InternalDebugOpt,
   HelpText<"Auto-generates preprocessed source files and a reproduction script">;
 def gen_cdb_fragment_path: Separate<["-"], "gen-cdb-fragment-path">, InternalDebugOpt,
@@ -327,13 +325,6 @@
   HelpText<"Apply modifications and produces temporary files to migrate to "
"modern ObjC syntax">;
 
-
-def objcmt_whitelist_dir_path: Joined<["-"], "objcmt-whitelist-dir-path=">, Flags<[CC1Option]>,
-  HelpText<"Only modify files with a filename contained in the provided directory path">;
-// The misspelt "white-list" [sic] alias is due for removal.
-def : Joined<["-"], "objcmt-white-list-dir-path=">, Flags<[CC1Option]>,
-Alias;
-
 // Make sure all other -ccc- options are rejected.
 def ccc_ : Joined<["-"], "ccc-">, Group, Flags<[Unsupported]>;
 
@@ -511,6 +502,23 @@
" it will print the supported cpus for the default target)">,
   MarshallingInfoFlag<"FrontendOpts.PrintSupportedCPUs", "false">;
 
+def o : JoinedOrSeparate<["-"], "o">, Flags<[DriverOption, RenderAsInput, CC1Option, CC1AsOption]>,
+  HelpText<"Write output to ">, MetaVarName<"">,
+  MarshallingInfoString<"FrontendOpts.OutputFile">;
+def ftime_trace_granularity_EQ : Joined<["-"], "ftime-trace-granularity=">, Group,
+  HelpText<"Minimum time granularity (in microseconds) traced by time profiler">,
+  Flags<[CC1Option, CoreOption]>,
+  MarshallingInfoStringInt<"FrontendOpts.TimeTraceGranularity", "500u">;
+def arcmt_migrate_report_output : Separate<["-"], "arcmt-migrate-report-output">,
+  HelpText<"Output path for the plist report">,  Flags<[CC1Option]>,
+  MarshallingInfoString<"FrontendOpts.ARCMTMigrateReportOut">;
+def objcmt_whitelist_dir_path: Joined<["-"], "objcmt-whitelist-dir-path=">, Flags<[CC1Option]>,
+  HelpText<"Only modify files with a filename contained in the provided directory path">,
+  Marshal

[PATCH] D84188: Port FileSystem options to new option parsing system

2020-07-20 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Depends on D84187 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84188

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1570,10 +1570,6 @@
   return Success;
 }
 
-static void ParseFileSystemArgs(FileSystemOptions &Opts, ArgList &Args) {
-  Opts.WorkingDir = std::string(Args.getLastArgValue(OPT_working_directory));
-}
-
 /// Parse the argument to the -ftest-module-file-extension
 /// command-line argument.
 ///
@@ -3273,7 +3269,6 @@
   Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
  /*DefaultDiagColor=*/false);
   ParseCommentArgs(LangOpts.CommentOpts, Args);
-  ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
   // FIXME: We shouldn't have to pass the DashX option around here
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
   LangOpts.IsHeaderFile);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -342,6 +342,14 @@
 def fparse_all_comments : Flag<["-"], "fparse-all-comments">, 
Group, Flags<[CC1Option]>,
   MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments", "false">;
 
+// Filesystem Options FileSystemOpts
+
+def working_directory : JoinedOrSeparate<["-"], "working-directory">, 
Flags<[CC1Option]>,
+  HelpText<"Resolve file paths relative to the specified directory">,
+  MarshallingInfoString<"FileSystemOpts.WorkingDir">;
+def working_directory_EQ : Joined<["-"], "working-directory=">, 
Flags<[CC1Option]>,
+  Alias;
+
 // Dependency Output Options
 
 def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>,
@@ -3516,11 +3524,6 @@
 def : Flag<["-"], "no-integrated-as">, Alias,
   Flags<[CC1Option, DriverOption]>;
 
-def working_directory : JoinedOrSeparate<["-"], "working-directory">, 
Flags<[CC1Option]>,
-  HelpText<"Resolve file paths relative to the specified directory">;
-def working_directory_EQ : Joined<["-"], "working-directory=">, 
Flags<[CC1Option]>,
-  Alias;
-
 // Double dash options, which are usually an alias for one of the previous
 // options.
 


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1570,10 +1570,6 @@
   return Success;
 }
 
-static void ParseFileSystemArgs(FileSystemOptions &Opts, ArgList &Args) {
-  Opts.WorkingDir = std::string(Args.getLastArgValue(OPT_working_directory));
-}
-
 /// Parse the argument to the -ftest-module-file-extension
 /// command-line argument.
 ///
@@ -3273,7 +3269,6 @@
   Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
  /*DefaultDiagColor=*/false);
   ParseCommentArgs(LangOpts.CommentOpts, Args);
-  ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
   // FIXME: We shouldn't have to pass the DashX option around here
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
   LangOpts.IsHeaderFile);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -342,6 +342,14 @@
 def fparse_all_comments : Flag<["-"], "fparse-all-comments">, Group, Flags<[CC1Option]>,
   MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments", "false">;
 
+// Filesystem Options FileSystemOpts
+
+def working_directory : JoinedOrSeparate<["-"], "working-directory">, Flags<[CC1Option]>,
+  HelpText<"Resolve file paths relative to the specified directory">,
+  MarshallingInfoString<"FileSystemOpts.WorkingDir">;
+def working_directory_EQ : Joined<["-"], "working-directory=">, Flags<[CC1Option]>,
+  Alias;
+
 // Dependency Output Options
 
 def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>,
@@ -3516,11 +3524,6 @@
 def : Flag<["-"], "no-integrated-as">, Alias,
   Flags<[CC1Option, DriverOption]>;
 
-def working_directory : JoinedOrSeparate<["-"], "working-directory">, Flags<[CC1Option]>,
-  HelpText<"Resolve file paths relative to the specified directory">;
-def working_directory_EQ : Joined<["-"], "working-directory=">, Flags<[CC1Option]>,
-  Alias;
-
 // Double dash options, which are usually an alias for one of the previous
 // options.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.

[PATCH] D84187: Port DependencyOutput string based options to new option parsing system

2020-07-20 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Depends on D84186 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84187

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1347,10 +1347,7 @@
 
 static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
   ArgList &Args) {
-  Opts.OutputFile = std::string(Args.getLastArgValue(OPT_dependency_file));
   Opts.Targets = Args.getAllArgValues(OPT_MT);
-  Opts.HeaderIncludeOutputFile =
-  std::string(Args.getLastArgValue(OPT_header_include_file));
   if (Args.hasArg(OPT_show_includes)) {
 // Writing both /showIncludes and preprocessor output to stdout
 // would produce interleaved output, so use stderr for /showIncludes.
@@ -1362,9 +1359,6 @@
   } else {
 Opts.ShowIncludesDest = ShowIncludesDestination::None;
   }
-  Opts.DOTOutputFile = std::string(Args.getLastArgValue(OPT_dependency_dot));
-  Opts.ModuleDependencyOutputDir =
-  std::string(Args.getLastArgValue(OPT_module_dependency_dir));
   // Add sanitizer blacklists as extra dependencies.
   // They won't be discovered by the regular preprocessor, so
   // we let make / ninja to know about this implicit dependency.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -358,6 +358,16 @@
 HelpText<"Create phony target for each dependency (other than main file)">,
 MarshallingInfoFlag<"DependencyOutputOpts.UsePhonyTargets", "false">;
 
+def dependency_file : Separate<["-"], "dependency-file">, Flags<[CC1Option]>,
+  HelpText<"Filename (or -) to write dependency output to">,
+  MarshallingInfoString<"DependencyOutputOpts.OutputFile">;
+def dependency_dot : Separate<["-"], "dependency-dot">, Flags<[CC1Option]>,
+  HelpText<"Filename to write DOT-formatted header dependencies to">,
+  MarshallingInfoString<"DependencyOutputOpts.DOTOutputFile">;
+def module_dependency_dir : Separate<["-"], "module-dependency-dir">,
+  Flags<[CC1Option]>, HelpText<"Directory to dump module dependencies to">,
+  MarshallingInfoString<"DependencyOutputOpts.ModuleDependencyOutputDir">;
+
 let Flags = [CC1Option, NoDriverOption] in {
 
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
@@ -367,6 +377,10 @@
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag<"DependencyOutputOpts.IncludeModuleFiles", "false">;
 
+def header_include_file : Separate<["-"], "header-include-file">,
+  HelpText<"Filename (or -) to write header include output to">,
+  MarshallingInfoString<"DependencyOutputOpts.HeaderIncludeOutputFile">;
+
 } // Flags = [CC1Option, NoDriverOption]
 
 // Diagnostic Options
@@ -1741,12 +1755,6 @@
 def dM : Flag<["-"], "dM">, Group, Flags<[CC1Option]>,
   HelpText<"Print macro definitions in -E mode instead of normal output">;
 def dead__strip : Flag<["-"], "dead_strip">;
-def dependency_file : Separate<["-"], "dependency-file">, Flags<[CC1Option]>,
-  HelpText<"Filename (or -) to write dependency output to">;
-def dependency_dot : Separate<["-"], "dependency-dot">, Flags<[CC1Option]>,
-  HelpText<"Filename to write DOT-formatted header dependencies to">;
-def module_dependency_dir : Separate<["-"], "module-dependency-dir">,
-  Flags<[CC1Option]>, HelpText<"Directory to dump module dependencies to">;
 def dumpmachine : Flag<["-"], "dumpmachine">;
 def dumpspecs : Flag<["-"], "dumpspecs">, Flags<[Unsupported]>;
 def dumpversion : Flag<["-"], "dumpversion">;
@@ -4322,8 +4330,6 @@
 // Dependency Output Options
 
//===--===//
 
-def header_include_file : Separate<["-"], "header-include-file">,
-  HelpText<"Filename (or -) to write header include output to">;
 def show_includes : Flag<["--"], "show-includes">,
   HelpText<"Print cl.exe style /showIncludes to stdout">;
 


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1347,10 +1347,7 @@
 
 static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
   ArgList &Args) {
-  Opts.OutputFile = std::string(Args.getLastArgValue(OPT_dependency_file));
   Opts.Targets = Args.getAllArgValues(OPT_MT);
-  Opts.HeaderIncludeOutputFile =
-  std::string(Args.getLastArgValue(OPT_header_include_file));
   if (Args.hasArg(OPT_show_includes)) {
 // Writing both /showIncludes an

[PATCH] D84186: Convert Analyzer option string based options to new option parsing system

2020-07-20 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, ASDenysPetrov, dkrupp, 
donat.nagy, Szelethus, dexonsmith, a.sidorin, baloghadamsoftware.
Herald added projects: clang, LLVM.

Depends on D84185 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84186

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td


Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -157,6 +157,12 @@
   code Denormalizer = "denormalizeString";
 }
 
+class MarshallingInfoStringInt
+  : MarshallingInfo {
+  code Normalizer = "normalizeStringIntegral<"#type#">";
+  code Denormalizer = "denormalizeString";
+}
+
 class MarshallingInfoFlag
   : MarshallingInfo {
   code Normalizer = "normalizeSimpleFlag";
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -90,6 +90,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -251,12 +252,30 @@
   return std::string(Arg->getValue());
 }
 
+template 
 static void denormalizeString(SmallVectorImpl &Args,
   const char *Spelling,
   CompilerInvocation::StringAllocator SA,
-  unsigned TableIndex, const std::string &Value) {
+  unsigned TableIndex, T &&Value) {
+  static_assert(std::is_constructible::value,
+"Cannot convert this value to Twine");
   Args.push_back(Spelling);
-  Args.push_back(SA(Value));
+  Args.push_back(SA(Twine(std::forward(Value;
+}
+
+template 
+static Optional normalizeStringIntegral(OptSpecifier Opt, int 
TableIndex,
+   const ArgList &Args,
+   DiagnosticsEngine &Diags) {
+  auto *Arg = Args.getLastArg(Opt);
+  if (!Arg)
+return None;
+  IntTy Res;
+  if (StringRef(Arg->getValue()).getAsInteger(0, Res)) {
+Diags.Report(diag::err_drv_invalid_int_value)
+<< Arg->getAsString(Args) << Arg->getValue();
+  }
+  return Res;
 }
 
 static Optional normalizeTriple(OptSpecifier Opt, int TableIndex,
@@ -487,10 +506,6 @@
   .Case("false", false)
   .Default(false);
 
-  Opts.AnalyzeSpecificFunction =
-  std::string(Args.getLastArgValue(OPT_analyze_function));
-  Opts.maxBlockVisitOnPath =
-  getLastArgIntValue(Args, OPT_analyzer_max_loop, 4, Diags);
   Opts.InlineMaxStackDepth =
   getLastArgIntValue(Args, OPT_analyzer_inline_max_stack_depth,
  Opts.InlineMaxStackDepth, Diags);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4115,7 +4115,8 @@
   HelpText<"Emit verbose output about the analyzer's progress">,
   MarshallingInfoFlag<"AnalyzerOpts->AnalyzerDisplayProgress", "false">;
 def analyze_function : Separate<["-"], "analyze-function">,
-  HelpText<"Run analysis on specific function (for C++ include parameters in 
name)">;
+  HelpText<"Run analysis on specific function (for C++ include parameters in 
name)">,
+  MarshallingInfoString<"AnalyzerOpts->AnalyzeSpecificFunction">;
 def analyze_function_EQ : Joined<["-"], "analyze-function=">, 
Alias;
 def trim_egraph : Flag<["-"], "trim-egraph">,
   HelpText<"Only show error-related paths in the analysis graph">,
@@ -4142,7 +4143,8 @@
   MarshallingInfoFlag<"AnalyzerOpts->NoRetryExhausted", "false">;
 
 def analyzer_max_loop : Separate<["-"], "analyzer-max-loop">,
-  HelpText<"The maximum number of times the analyzer will go through a loop">;
+  HelpText<"The maximum number of times the analyzer will go through a loop">,
+  MarshallingInfoStringInt<"AnalyzerOpts->maxBlockVisitOnPath", "4">;
 def analyzer_stats : Flag<["-"], "analyzer-stats">,
   HelpText<"Print internal analyzer statistics.">,
   MarshallingInfoFlag<"AnalyzerOpts->PrintStats", "false">;


Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -157,6 +157,12 @@
   code Denormalizer = "denormalizeString";
 }
 
+class MarshallingInfoStringInt
+  : MarshallingInfo {
+  code Normalizer = "normalizeStringIntegral<"#type#">";
+  code Denormalizer = "denormalizeString";
+}
+
 class MarshallingInfoFlag
   : MarshallingInfo {
   code Normalizer = "normalizeSimpleFlag";
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/li

[PATCH] D83398: [OPENMP50]Perform data mapping analysis only for explicitly mapped data.

2020-07-20 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2875df0d5657: [OPENMP50]Perform data mapping analysis only 
for explicitly mapped data. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83398

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_map_messages.cpp


Index: clang/test/OpenMP/target_map_messages.cpp
===
--- clang/test/OpenMP/target_map_messages.cpp
+++ clang/test/OpenMP/target_map_messages.cpp
@@ -604,6 +604,7 @@
   const int (&l)[5] = da;
   SC1 s;
   SC1 *p;
+  int Arr[10];
 #pragma omp target data map // expected-error {{expected '(' after 'map'}} 
le45-error {{expected at least one 'map' or 'use_device_ptr' clause for 
'#pragma omp target data'}} le50-error {{expected at least one 'map', 
'use_device_ptr', or 'use_device_addr' clause for '#pragma omp target data'}}
 #pragma omp target data map( // expected-error {{expected ')'}} expected-note 
{{to match this '('}} expected-error {{expected expression}}
 #pragma omp target data map() // expected-error {{expected expression}}
@@ -750,6 +751,12 @@
 #pragma omp target map(iarr[:2:d]) // expected-error {{expected ']'}} 
expected-note {{to match this '['}}
   {}
 
+#pragma omp target data map(Arr[0:4]) // le45-note {{used here}}
+  {
+#pragma omp target
+Arr[0] = 2; // le45-error {{original storage of expression in data 
environment is shared but data environment do not fully contain mapped 
expression storage}}
+  }
+
   return tmain(argc)+tmain(argc); // expected-note {{in 
instantiation of function template specialization 'tmain' requested 
here}} expected-note {{in instantiation of function template specialization 
'tmain' requested here}}
 }
 #endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -17484,6 +17484,7 @@
   /*CurrentRegionOnly=*/true, CurComponents, CKind))
   break;
 if (CKind == OMPC_map &&
+(SemaRef.getLangOpts().OpenMP <= 45 || StartLoc.isValid()) &&
 checkMapConflicts(SemaRef, DSAS, CurDeclaration, SimpleExpr,
   /*CurrentRegionOnly=*/false, CurComponents, CKind))
   break;


Index: clang/test/OpenMP/target_map_messages.cpp
===
--- clang/test/OpenMP/target_map_messages.cpp
+++ clang/test/OpenMP/target_map_messages.cpp
@@ -604,6 +604,7 @@
   const int (&l)[5] = da;
   SC1 s;
   SC1 *p;
+  int Arr[10];
 #pragma omp target data map // expected-error {{expected '(' after 'map'}} le45-error {{expected at least one 'map' or 'use_device_ptr' clause for '#pragma omp target data'}} le50-error {{expected at least one 'map', 'use_device_ptr', or 'use_device_addr' clause for '#pragma omp target data'}}
 #pragma omp target data map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
 #pragma omp target data map() // expected-error {{expected expression}}
@@ -750,6 +751,12 @@
 #pragma omp target map(iarr[:2:d]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
   {}
 
+#pragma omp target data map(Arr[0:4]) // le45-note {{used here}}
+  {
+#pragma omp target
+Arr[0] = 2; // le45-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+  }
+
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
 #endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -17484,6 +17484,7 @@
   /*CurrentRegionOnly=*/true, CurComponents, CKind))
   break;
 if (CKind == OMPC_map &&
+(SemaRef.getLangOpts().OpenMP <= 45 || StartLoc.isValid()) &&
 checkMapConflicts(SemaRef, DSAS, CurDeclaration, SimpleExpr,
   /*CurrentRegionOnly=*/false, CurComponents, CKind))
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2875df0 - [OPENMP50]Perform data mapping analysis only for explicitly mapped data.

2020-07-20 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-07-20T13:01:15-04:00
New Revision: 2875df0d56572168b478f80f59106284ef15d87d

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

LOG: [OPENMP50]Perform data mapping analysis only for explicitly mapped data.

Summary:
According to OpenMP 5.0, the restrictions for mapping of overlapped data
apply only for explicitly mapped data, there is no restriction for
implicitly mapped data just like in OpenMP 4.5.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, cfe-commits, caomhin

Tags: #clang

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/target_map_messages.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 1e7d432217d5..3c9fdbddfa75 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -17484,6 +17484,7 @@ static void checkMappableExpressionList(
   /*CurrentRegionOnly=*/true, CurComponents, CKind))
   break;
 if (CKind == OMPC_map &&
+(SemaRef.getLangOpts().OpenMP <= 45 || StartLoc.isValid()) &&
 checkMapConflicts(SemaRef, DSAS, CurDeclaration, SimpleExpr,
   /*CurrentRegionOnly=*/false, CurComponents, CKind))
   break;

diff  --git a/clang/test/OpenMP/target_map_messages.cpp 
b/clang/test/OpenMP/target_map_messages.cpp
index 833f509cd7f0..df6591d87ea7 100644
--- a/clang/test/OpenMP/target_map_messages.cpp
+++ b/clang/test/OpenMP/target_map_messages.cpp
@@ -604,6 +604,7 @@ int main(int argc, char **argv) {
   const int (&l)[5] = da;
   SC1 s;
   SC1 *p;
+  int Arr[10];
 #pragma omp target data map // expected-error {{expected '(' after 'map'}} 
le45-error {{expected at least one 'map' or 'use_device_ptr' clause for 
'#pragma omp target data'}} le50-error {{expected at least one 'map', 
'use_device_ptr', or 'use_device_addr' clause for '#pragma omp target data'}}
 #pragma omp target data map( // expected-error {{expected ')'}} expected-note 
{{to match this '('}} expected-error {{expected expression}}
 #pragma omp target data map() // expected-error {{expected expression}}
@@ -750,6 +751,12 @@ int main(int argc, char **argv) {
 #pragma omp target map(iarr[:2:d]) // expected-error {{expected ']'}} 
expected-note {{to match this '['}}
   {}
 
+#pragma omp target data map(Arr[0:4]) // le45-note {{used here}}
+  {
+#pragma omp target
+Arr[0] = 2; // le45-error {{original storage of expression in data 
environment is shared but data environment do not fully contain mapped 
expression storage}}
+  }
+
   return tmain(argc)+tmain(argc); // expected-note {{in 
instantiation of function template specialization 'tmain' requested 
here}} expected-note {{in instantiation of function template specialization 
'tmain' requested here}}
 }
 #endif



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


[Differential] D83398: [OPENMP50]Perform data mapping analysis only for explicitly mapped data.

2020-07-20 Thread Alexey Bataev 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 rG2875df0d5657: [OPENMP50]Perform data mapping analysis only 
for explicitly mapped data. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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


  https://reviews.llvm.org/D83398

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_map_messages.cpp



Index: clang/test/OpenMP/target_map_messages.cpp
===
--- clang/test/OpenMP/target_map_messages.cpp
+++ clang/test/OpenMP/target_map_messages.cpp
@@ -604,6 +604,7 @@
   const int (&l)[5] = da;
   SC1 s;
   SC1 *p;
+  int Arr[10];
 #pragma omp target data map // expected-error {{expected '(' after 'map'}} 
le45-error {{expected at least one 'map' or 'use_device_ptr' clause for 
'#pragma omp target data'}} le50-error {{expected at least one 'map', 
'use_device_ptr', or 'use_device_addr' clause for '#pragma omp target data'}}
 #pragma omp target data map( // expected-error {{expected ')'}} expected-note 
{{to match this '('}} expected-error {{expected expression}}
 #pragma omp target data map() // expected-error {{expected expression}}
@@ -750,6 +751,12 @@
 #pragma omp target map(iarr[:2:d]) // expected-error {{expected ']'}} 
expected-note {{to match this '['}}
   {}
 
+#pragma omp target data map(Arr[0:4]) // le45-note {{used here}}
+  {
+#pragma omp target
+Arr[0] = 2; // le45-error {{original storage of expression in data 
environment is shared but data environment do not fully contain mapped 
expression storage}}
+  }
+
   return tmain(argc)+tmain(argc); // expected-note {{in 
instantiation of function template specialization 'tmain' requested 
here}} expected-note {{in instantiation of function template specialization 
'tmain' requested here}}
 }
 #endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -17484,6 +17484,7 @@
   /*CurrentRegionOnly=*/true, CurComponents, CKind))
   break;
 if (CKind == OMPC_map &&
+(SemaRef.getLangOpts().OpenMP <= 45 || StartLoc.isValid()) &&
 checkMapConflicts(SemaRef, DSAS, CurDeclaration, SimpleExpr,
   /*CurrentRegionOnly=*/false, CurComponents, CKind))
   break;


Index: clang/test/OpenMP/target_map_messages.cpp
===
--- clang/test/OpenMP/target_map_messages.cpp
+++ clang/test/OpenMP/target_map_messages.cpp
@@ -604,6 +604,7 @@
   const int (&l)[5] = da;
   SC1 s;
   SC1 *p;
+  int Arr[10];
 #pragma omp target data map // expected-error {{expected '(' after 'map'}} le45-error {{expected at least one 'map' or 'use_device_ptr' clause for '#pragma omp target data'}} le50-error {{expected at least one 'map', 'use_device_ptr', or 'use_device_addr' clause for '#pragma omp target data'}}
 #pragma omp target data map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
 #pragma omp target data map() // expected-error {{expected expression}}
@@ -750,6 +751,12 @@
 #pragma omp target map(iarr[:2:d]) // expected-error {{expected ']'}} expected-note {{to match this '['}}
   {}
 
+#pragma omp target data map(Arr[0:4]) // le45-note {{used here}}
+  {
+#pragma omp target
+Arr[0] = 2; // le45-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+  }
+
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
 #endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -17484,6 +17484,7 @@
   /*CurrentRegionOnly=*/true, CurComponents, CKind))
   break;
 if (CKind == OMPC_map &&
+(SemaRef.getLangOpts().OpenMP <= 45 || StartLoc.isValid()) &&
 checkMapConflicts(SemaRef, DSAS, CurDeclaration, SimpleExpr,
   /*CurrentRegionOnly=*/false, CurComponents, CKind))
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84185: Better defaults for MarshallingInfoString

2020-07-20 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith.
Herald added projects: clang, LLVM.

Depends on D84018 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84185

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td


Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -151,8 +151,11 @@
   code DefaultValue = defaultvalue;
 }
 
-class MarshallingInfoString
-  : MarshallingInfo {}
+class MarshallingInfoString
+  : MarshallingInfo {
+  code Normalizer = "normalizeString";
+  code Denormalizer = "denormalizeString";
+}
 
 class MarshallingInfoFlag
   : MarshallingInfo {
@@ -185,7 +188,6 @@
 class Denormalizer { code Denormalizer = denormalizer; }
 class NormalizedValuesScope { code NormalizedValuesScope = scope; }
 class NormalizedValues definitions> { list NormalizedValues = 
definitions; } 
-class DenormalizeString { code Denormalizer = "denormalizeString"; }
 class AutoNormalizeEnum {
   code Normalizer = "normalizeSimpleEnum";
   code Denormalizer = "denormalizeSimpleEnum";
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -242,6 +242,15 @@
  "the tablegen option description");
 }
 
+static Optional normalizeString(OptSpecifier Opt, int TableIndex,
+ const ArgList &Args,
+ DiagnosticsEngine &Diags) {
+  auto *Arg = Args.getLastArg(Opt);
+  if (!Arg)
+return None;
+  return std::string(Arg->getValue());
+}
+
 static void denormalizeString(SmallVectorImpl &Args,
   const char *Spelling,
   CompilerInvocation::StringAllocator SA,
@@ -478,8 +487,6 @@
   .Case("false", false)
   .Default(false);
 
-  Opts.DumpExplodedGraphTo =
-  std::string(Args.getLastArgValue(OPT_analyzer_dump_egraph));
   Opts.AnalyzeSpecificFunction =
   std::string(Args.getLastArgValue(OPT_analyze_function));
   Opts.maxBlockVisitOnPath =
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -573,7 +573,7 @@
 def triple : Separate<["-"], "triple">,
   HelpText<"Specify target triple (e.g. i686-apple-darwin9)">,
   MarshallingInfoString<"TargetOpts->Triple", 
"llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())">,
-  AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString;
+  AlwaysEmit, Normalizer<"normalizeTriple">;
 
 } // Flags = [CC1Option, CC1AsOption, NoDriverOption]
 
@@ -4124,7 +4124,8 @@
   HelpText<"Display exploded graph using GraphViz">,
   MarshallingInfoFlag<"AnalyzerOpts->visualizeExplodedGraphWithGraphViz", 
"false">;
 def analyzer_dump_egraph : Separate<["-"], "analyzer-dump-egraph">,
-  HelpText<"Dump exploded graph to the specified file">;
+  HelpText<"Dump exploded graph to the specified file">,
+  MarshallingInfoString<"AnalyzerOpts->DumpExplodedGraphTo">;
 def analyzer_dump_egraph_EQ : Joined<["-"], "analyzer-dump-egraph=">, 
Alias;
 
 def analyzer_inline_max_stack_depth : Separate<["-"], 
"analyzer-inline-max-stack-depth">,


Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -151,8 +151,11 @@
   code DefaultValue = defaultvalue;
 }
 
-class MarshallingInfoString
-  : MarshallingInfo {}
+class MarshallingInfoString
+  : MarshallingInfo {
+  code Normalizer = "normalizeString";
+  code Denormalizer = "denormalizeString";
+}
 
 class MarshallingInfoFlag
   : MarshallingInfo {
@@ -185,7 +188,6 @@
 class Denormalizer { code Denormalizer = denormalizer; }
 class NormalizedValuesScope { code NormalizedValuesScope = scope; }
 class NormalizedValues definitions> { list NormalizedValues = definitions; } 
-class DenormalizeString { code Denormalizer = "denormalizeString"; }
 class AutoNormalizeEnum {
   code Normalizer = "normalizeSimpleEnum";
   code Denormalizer = "denormalizeSimpleEnum";
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -242,6 +242,15 @@
  "the tablegen option description");
 }
 
+static Optional normalizeString(OptSpecifier Opt, int TableIndex,
+ const ArgList &Args,
+  

[PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2)

2020-07-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:3067-3068
+  unsigned Type = getOpenMPSimpleClauseType(OMPC_map, PP.getSpelling(Tok));
+  if (Type < OMPC_MAP_MODIFIER_unknown)
+return OMPC_MAP_MODIFIER_unknown;
+  return static_cast(Type);

jdenny wrote:
> ABataev wrote:
> > Why do we need this?
> When called with `OMPC_map`, `getOpenMPSimpleClauseType` can return either an 
> `OpenMPMapModifierKind` or `OpenMPMapClauseKind` depending on `Tok`.  Thus, 
> without this change, both `isMapModifier` and `isMapType` can return either 
> of those despite the difference in their names and documentation.
> 
> I found that, when `Parser::parseMapTypeModifiers` ignores `present` as if 
> it's not a modifier because OpenMP < 5.1, then `isMapType` later returns 
> `OMPC_MAP_MODIFIER_present` and causes the following assert to fail in 
> `Sema::ActOnOpenMPVarListClause`:
> 
> ```
> assert(0 <= ExtraModifier && ExtraModifier <= OMPC_MAP_unknown &&
>"Unexpected map modifier.");
> ```
> 
> To me, the most obvious solution is to fix `isMapType` and `isMapModifier`.  
> Fortunately, looking in `OpenMPKinds.h`, the enumerator values in 
> `OpenMPMapModifierKind` and `OpenMPMapClauseKind` are disjoint so we can tell 
> which we have.
Can we have something like:
```
if (LangOpts.OpenMP <= 50 && Type == OMPC_MAP_MODIFIER_present)
  return OMPC_MAP_MODIFIER_unknown;
```
or extend `getOpenMPSimpleClauseType` function with the version parameter and 
check there is modifier is allowed and return `unknown` if it is not compatible 
with provided version?



Comment at: clang/lib/Parse/ParseOpenMP.cpp:3103
 /// map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list)
 /// where, map-type-modifier ::= always | close | mapper(mapper-identifier)
 bool Parser::parseMapTypeModifiers(OpenMPVarListDataTy &Data) {

Update a comment here



Comment at: clang/test/OpenMP/target_data_codegen.cpp:258-260
+// CK1A: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1021]]]
+
+// CK1A: [[MTYPE01:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1425]]]

Add a comment with interpretaion of the map flags, like `OMP_TO = 0x1 | 
OMP_FROM=0x2 | OMP_PRESENT = 0x1000 = 0x1003`


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

https://reviews.llvm.org/D83061



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


[PATCH] D84082: [tsan] Allow TSan in the Clang driver for Apple Silicon Macs

2020-07-20 Thread Julian Lettner via Phabricator via cfe-commits
yln added inline comments.



Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:2734
 
-  if (isTargetMacOS()) {
-if (IsX86_64)
-  Res |= SanitizerKind::Thread;
+  if ((IsX86_64 || IsAArch64) && isTargetMacOS()) {
+Res |= SanitizerKind::Thread;

This breaks the symmetry with the if below.  Is this intentional?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84082



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


[PATCH] D84082: [tsan] Allow TSan in the Clang driver for Apple Silicon Macs

2020-07-20 Thread Julian Lettner via Phabricator via cfe-commits
yln added a comment.

Simulators on Apple Silicon are not yet supported?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84082



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


[PATCH] D83551: [PATCH 2/4][Sema][AArch64] Add semantics for arm_sve_vector_bits attribute

2020-07-20 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:1887
+
+unsigned getSvePredWidth(const Type *T) { return getSveVectorWidth(T) / 8; }
+

aaron.ballman wrote:
> Should this be dividing by the number of bits in a char for the target as 
> opposed to hard-coding to 8?
> Should this be dividing by the number of bits in a char for the target as 
> opposed to hard-coding to 8?

Predicate registers in SVE hold one bit per byte of a vector register so each 
predicate is 1/8th the size of a vector which are defined in bits, it has to be 
8 and I know `getCharWidth` returns 8 for the target this is implemented for 
but I dont know what it would mean for any other target or if we care about 
that?


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

https://reviews.llvm.org/D83551



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


[PATCH] D83015: [Driver] Add --ld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path

2020-07-20 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1bc5c84710a8: [Driver] Add --ld-path= and deprecate 
-fuse-ld=/abs/path and -fuse-ld=rel/path (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D83015?vs=278555&id=279282#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83015

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/Inputs/basic_freebsd64_tree/usr/bin/ld.bfd
  clang/test/Driver/fuse-ld.c
  clang/test/Driver/ld-path.c
  clang/test/Misc/warning-flags.c

Index: clang/test/Misc/warning-flags.c
===
--- clang/test/Misc/warning-flags.c
+++ clang/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (68):
+CHECK: Warnings without flags (69):
 
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
@@ -47,6 +47,7 @@
 CHECK-NEXT:   warn_drv_assuming_mfloat_abi_is
 CHECK-NEXT:   warn_drv_clang_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
+CHECK-NEXT:   warn_drv_use_ld_non_word
 CHECK-NEXT:   warn_dup_category_def
 CHECK-NEXT:   warn_enum_value_overflow
 CHECK-NEXT:   warn_expected_qualified_after_typename
Index: clang/test/Driver/ld-path.c
===
--- /dev/null
+++ clang/test/Driver/ld-path.c
@@ -0,0 +1,66 @@
+/// This tests uses the PATH environment variable.
+// UNSUPPORTED: system-windows
+
+// RUN: cd %S
+
+/// If --ld-path= specifies a word (without /), -B and COMPILER_PATH are
+/// consulted to locate the linker.
+// RUN: %clang %s -### -B %S/Inputs/basic_freebsd_tree/usr/bin --ld-path=ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+// RUN: env COMPILER_PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+/// Then PATH is consulted.
+// RUN: env PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+
+// BFD: Inputs/basic_freebsd_tree/usr/bin/ld.bfd"
+
+// RUN: env PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=ld.gold \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=GOLD
+
+// GOLD: Inputs/basic_freebsd_tree/usr/bin/ld.gold"
+
+// RUN: env COMPILER_PATH= PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=not_exist \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=NOT_EXIST
+
+// NOT_EXIST: error: invalid linker name in argument '--ld-path=not_exist'
+
+// RUN: %clang %s -### --ld-path= \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=EMPTY
+
+// EMPTY: error: invalid linker name in argument '--ld-path='
+
+/// If --ld-path= contains a slash, PATH is not consulted.
+// RUN: env COMPILER_PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=./ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=NO_BFD
+
+// NO_BFD: error: invalid linker name in argument '--ld-path=./ld.bfd'
+
+/// --ld-path can specify an absolute path.
+// RUN: %clang %s -### --ld-path=%S/Inputs/basic_freebsd_tree/usr/bin/ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+
+// RUN: %clang %s -### --ld-path=Inputs/basic_freebsd_tree/usr/bin/ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+
+/// --ld-path= and -fuse-ld= can be used together. --ld-path= takes precedence.
+/// -fuse-ld= can be used to specify the linker flavor.
+// RUN: %clang %s -### -Werror --ld-path=%S/Inputs/basic_freebsd_tree/usr/bin/ld.bfd -fuse-ld=gold \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD --implicit-check-not=error:
+
+/// --ld-path= respects -working-directory.
+// RUN: %clang %s -### --ld-path=usr/bin/ld.bfd -working-directory=%S/Inputs/basic_freebsd_tree \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %

[Differential] D83015: [Driver] Add --ld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path

2020-07-20 Thread Fangrui Song 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 rG1bc5c84710a8: [Driver] Add --ld-path= and deprecate 
-fuse-ld=/abs/path and -fuse-ld=rel/path (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D83015?vs=278555&id=279015#toc

Repository:
  rG LLVM Github Monorepo

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


  https://reviews.llvm.org/D83015

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/Inputs/basic_freebsd64_tree/usr/bin/ld.bfd
  clang/test/Driver/fuse-ld.c
  clang/test/Driver/ld-path.c
  clang/test/Misc/warning-flags.c

Index: clang/test/Misc/warning-flags.c
===
--- clang/test/Misc/warning-flags.c
+++ clang/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (68):
+CHECK: Warnings without flags (69):
 
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
@@ -47,6 +47,7 @@
 CHECK-NEXT:   warn_drv_assuming_mfloat_abi_is
 CHECK-NEXT:   warn_drv_clang_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
+CHECK-NEXT:   warn_drv_use_ld_non_word
 CHECK-NEXT:   warn_dup_category_def
 CHECK-NEXT:   warn_enum_value_overflow
 CHECK-NEXT:   warn_expected_qualified_after_typename
Index: clang/test/Driver/ld-path.c
===
--- /dev/null
+++ clang/test/Driver/ld-path.c
@@ -0,0 +1,66 @@
+/// This tests uses the PATH environment variable.
+// UNSUPPORTED: system-windows
+
+// RUN: cd %S
+
+/// If --ld-path= specifies a word (without /), -B and COMPILER_PATH are
+/// consulted to locate the linker.
+// RUN: %clang %s -### -B %S/Inputs/basic_freebsd_tree/usr/bin --ld-path=ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+// RUN: env COMPILER_PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+/// Then PATH is consulted.
+// RUN: env PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+
+// BFD: Inputs/basic_freebsd_tree/usr/bin/ld.bfd"
+
+// RUN: env PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=ld.gold \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=GOLD
+
+// GOLD: Inputs/basic_freebsd_tree/usr/bin/ld.gold"
+
+// RUN: env COMPILER_PATH= PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=not_exist \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=NOT_EXIST
+
+// NOT_EXIST: error: invalid linker name in argument '--ld-path=not_exist'
+
+// RUN: %clang %s -### --ld-path= \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=EMPTY
+
+// EMPTY: error: invalid linker name in argument '--ld-path='
+
+/// If --ld-path= contains a slash, PATH is not consulted.
+// RUN: env COMPILER_PATH=%S/Inputs/basic_freebsd_tree/usr/bin %clang %s -### --ld-path=./ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=NO_BFD
+
+// NO_BFD: error: invalid linker name in argument '--ld-path=./ld.bfd'
+
+/// --ld-path can specify an absolute path.
+// RUN: %clang %s -### --ld-path=%S/Inputs/basic_freebsd_tree/usr/bin/ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+
+// RUN: %clang %s -### --ld-path=Inputs/basic_freebsd_tree/usr/bin/ld.bfd \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD
+
+/// --ld-path= and -fuse-ld= can be used together. --ld-path= takes precedence.
+/// -fuse-ld= can be used to specify the linker flavor.
+// RUN: %clang %s -### -Werror --ld-path=%S/Inputs/basic_freebsd_tree/usr/bin/ld.bfd -fuse-ld=gold \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=BFD --implicit-check-not=error:
+
+/// --ld-path= respects -working-directory.
+// RUN: %clang %s -### --ld-path=usr/bin/ld.bfd -working-directory=%S/Inputs/basic_freebsd_tree \
+// RUN:   --target=x86_64-unknown-freebsd --sysroot=%

[clang] 1bc5c84 - [Driver] Add --ld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path

2020-07-20 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-07-20T09:34:39-07:00
New Revision: 1bc5c84710a8c73ef21295e63c19d10a8c71f2f5

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

LOG: [Driver] Add --ld-path= and deprecate -fuse-ld=/abs/path and 
-fuse-ld=rel/path

Supersedes D80225. Add --ld-path= to avoid strange target specific
prefixes and make -fuse-ld= focus on its intended job: "linker flavor".
(-f* affects generated code or language features. --ld-path does not
affect codegen, so it is not named -f*)

The way --ld-path= works is similar to "Command Search and Execution" in 
POSIX.1-2017 2.9.1 Simple Commands.

If --ld-path= specifies

* an absolute path, the value specifies the linker.
* a relative path without a path component separator (/), the value is searched 
using the -B, COMPILER_PATH, then PATH.
* a relative path with a path component separator, the linker is found relative 
to the current working directory.

-fuse-ld= and --ld-path= can be composed, e.g. `-fuse-ld=lld 
--ld-path=/usr/bin/ld.lld`

The driver can base its linker option decision on the flavor -fuse-ld=, but it 
should not do fragile
flavor checking with --ld-path=.

Reviewed By: whitequark, keith

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

Added: 
clang/test/Driver/Inputs/basic_freebsd64_tree/usr/bin/ld.bfd
clang/test/Driver/ld-path.c

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/fuse-ld.c
clang/test/Misc/warning-flags.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3c266846c689..e6b51cfd7a8a 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -458,6 +458,9 @@ def warn_drv_msvc_not_found : Warning<
   "try running Clang from a developer command prompt">,
   InGroup>;
 
+def warn_drv_use_ld_non_word : Warning<
+  "'-fuse-ld=' taking a path is deprecated. Use '--ld-path=' instead">;
+
 def warn_drv_fine_grained_bitfield_accesses_ignored : Warning<
   "option '-ffine-grained-bitfield-accesses' cannot be enabled together with a 
sanitizer; flag ignored">,
   InGroup;

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d549e4b58507..c2d349866814 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3280,6 +3280,7 @@ defm : BooleanFFlag<"keep-inline-functions">, 
Group, 
Group;
 def falign_labels_EQ : Joined<["-"], "falign-labels=">, 
Group;

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index b7256eb08ac6..2984537c23b4 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -547,18 +547,42 @@ std::string ToolChain::GetProgramPath(const char *Name) 
const {
 }
 
 std::string ToolChain::GetLinkerPath() const {
+  // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= 
is
+  // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
   const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
   StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
 
+  // --ld-path= takes precedence over -fuse-ld= and specifies the executable
+  // name. -B, COMPILER_PATH and PATH and consulted if the value does not
+  // contain a path component separator.
+  if (const Arg *A = Args.getLastArg(options::OPT_ld_path_EQ)) {
+std::string Path(A->getValue());
+if (!Path.empty()) {
+  if (llvm::sys::path::parent_path(Path).empty())
+Path = GetProgramPath(A->getValue());
+  if (llvm::sys::fs::can_execute(Path))
+return std::string(Path);
+}
+getDriver().Diag(diag::err_drv_invalid_linker_name) << 
A->getAsString(Args);
+return GetProgramPath(getDefaultLinker());
+  }
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,
+  // then use whatever the default system linker is.
+  if (UseLinker.empty() || UseLinker == "ld")
+return GetProgramPath(getDefaultLinker());
+
+  // Extending -fuse-ld= to an absolute or relative path is unexpected. 
Checking
+  // for the linker flavor is brittle. In addition, prepending "ld." or "ld64."
+  // to a relative path is surprising. This is more complex due to priorities
+  // among -B, COMPILER_PATH and PATH. --ld-path= should be used instead.
+  if (UseLinker.find('/') != StringRef::npos)
+getDriver().Diag(diag::warn_drv_use_ld_non_word);
+
   if (llvm::sys::path::is_absolute(UseLinker)) {
 // If we're passed what looks like an absolute path, don't attempt to
 // second-guess that.
 if (llvm::sys::fs::can_execute(UseLinker))
   return std::stri

[PATCH] D84090: [clang-format] Add BitFieldColonSpacing option

2020-07-20 Thread Anders Waldenborg via Phabricator via cfe-commits
wanders added a comment.

In D84090#2162389 , @MyDeveloperDay 
wrote:

> 2. then I can do `git clang-format`, this will fix up any files in the diff 
> that need formatting (you'll need to git add them again if they have)


(I use https://github.com/kimgr/git-format )  just need to remember to run 
it...  But created a "prepare-patch" script now so as long as I remember to run 
that.

> 
> 
> 3. I then check the documentation builds with `/usr/bin/sphinx-build -n 
> ./docs ./html`  (if the review contains rst files)

Great tip! Thanks

> 
> 
> 4. then I do  `git diff --cached -U99 > patch_to_submitt.diff`
> 5. I check the patch to ensure I'm not changing the mode of the files with 
> `grep -A0 -B2 "new mode" patch_to_submitt.diff`
> 6. and this is the patch_tosubmitt.diff I upload to the review
> 
>   These steps try to reduce the number of review fails I get based on 
> clang-format issues (all of this is scripted so making a patch is repeatable, 
> quick and easy and all based off whats in my staged area)

Thanks for assistance and review. And sorry about the extra noise.


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

https://reviews.llvm.org/D84090



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


[PATCH] D83261: [OPENMP]Redesign of OMPExecutableDirective representation.

2020-07-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D83261#2161217 , @Meinersbur wrote:

> AFAICS this extract out the handling of subnodes of OMPExecutableDirectives 
> into the OMPChildren class which is made optional since `OMPChildren 
> *OMPExecutableDirectives::Data` can be nullptr. However, since it also stores 
> clauses, it seems that about every executable directive will need to have one 
> anyway. Hence I don't see how it makes the representation of some executable 
> directives more correct.




1. OMPChildren class uses standard TrailingObjects harness instead of manual 
calculation.
2. Child Stmt* based nodes are not related to the AsssociatedStmt* anymore and 
can exist independently.

> OMPChildren also handles clauses for OMPExecutableDirectives but not for 
> declarative directives. Should handling of of clauses also be extracted into 
> into its own class? That would make (de-)serialization easier for those as 
> well.

This class is only for executable directives.

> There is no effect on D76342  (except a 
> requiring a rebase), since the OMPTileDirective has children and thus does 
> not profit from the functionality of `OMPChildren` becoming optional. Since I 
> don't see a relation to D76342 , more , I am 
> indifferent to whether this should be merged.

There should be an additional patch, which, I hope, should simplify things for 
loop-based directives.

> Trailing objects is a technique to ensure that all substmts are consecutive 
> in memory (so `StmtIterator` can iterator over them). For 
> OMPExeuctableDirectives, only the associated statement is returned by the 
> `StmtIterator`, i.e. all the children could be made regular class members 
> without the complication of computing the offset. I'd prefer that change over 
> OMPChildren.

There are also used_children, which are used by the clang analyzer for, at 
least, use of uninitialized variables diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83261



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


[PATCH] D84090: [clang-format] Add BitFieldColonSpacing option

2020-07-20 Thread Anders Waldenborg via Phabricator via cfe-commits
wanders updated this revision to Diff 279279.

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

https://reviews.llvm.org/D84090

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2165,6 +2165,33 @@
"  uchar : 8;\n"
"  uchar other;\n"
"};");
+  FormatStyle Style = getLLVMStyle();
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  verifyFormat("struct Bitfields {\n"
+   "  unsigned sClass:8;\n"
+   "  unsigned ValueKind:2;\n"
+   "  uchar other;\n"
+   "};",
+   Style);
+  verifyFormat("struct A {\n"
+   "  int a:1,\n"
+   "  b:2;\n"
+   "};",
+   Style);
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_Before;
+  verifyFormat("struct Bitfields {\n"
+   "  unsigned sClass :8;\n"
+   "  unsigned ValueKind :2;\n"
+   "  uchar other;\n"
+   "};",
+   Style);
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_After;
+  verifyFormat("struct Bitfields {\n"
+   "  unsigned sClass: 8;\n"
+   "  unsigned ValueKind: 2;\n"
+   "  uchar other;\n"
+   "};",
+   Style);
 }
 
 TEST_F(FormatTest, FormatsNamespaces) {
@@ -12156,6 +12183,21 @@
"int   oneTwoThree : 23 = 0;",
Alignment);
 
+  Alignment.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  verifyFormat("int const a  :5;\n"
+   "int   oneTwoThree:23;",
+   Alignment);
+
+  Alignment.BitFieldColonSpacing = FormatStyle::BFCS_Before;
+  verifyFormat("int const a   :5;\n"
+   "int   oneTwoThree :23;",
+   Alignment);
+
+  Alignment.BitFieldColonSpacing = FormatStyle::BFCS_After;
+  verifyFormat("int const a  : 5;\n"
+   "int   oneTwoThree: 23;",
+   Alignment);
+
   // Known limitations: ':' is only recognized as a bitfield colon when
   // followed by a number.
   /*
@@ -14004,6 +14046,16 @@
   CHECK_PARSE("IndentExternBlock: false", IndentExternBlock,
   FormatStyle::IEBS_NoIndent);
 
+  Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
+  CHECK_PARSE("BitFieldColonSpacing: Both", BitFieldColonSpacing,
+  FormatStyle::BFCS_Both);
+  CHECK_PARSE("BitFieldColonSpacing: None", BitFieldColonSpacing,
+  FormatStyle::BFCS_None);
+  CHECK_PARSE("BitFieldColonSpacing: Before", BitFieldColonSpacing,
+  FormatStyle::BFCS_Before);
+  CHECK_PARSE("BitFieldColonSpacing: After", BitFieldColonSpacing,
+  FormatStyle::BFCS_After);
+
   // FIXME: This is required because parsing a configuration simply overwrites
   // the first N elements of the list instead of resetting it.
   Style.ForEachMacros.clear();
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3251,6 +3251,9 @@
   if (Right.is(TT_RangeBasedForLoopColon) &&
   !Style.SpaceBeforeRangeBasedForLoopColon)
 return false;
+  if (Left.is(TT_BitFieldColon))
+return Style.BitFieldColonSpacing == FormatStyle::BFCS_Both ||
+   Style.BitFieldColonSpacing == FormatStyle::BFCS_After;
   if (Right.is(tok::colon)) {
 if (Line.First->isOneOf(tok::kw_case, tok::kw_default) ||
 !Right.getNextNonComment() || Right.getNextNonComment()->is(tok::semi))
@@ -3267,6 +3270,9 @@
   return false;
 if (Right.is(TT_CSharpNamedArgumentColon))
   return false;
+if (Right.is(TT_BitFieldColon))
+  return Style.BitFieldColonSpacing == FormatStyle::BFCS_Both ||
+ Style.BitFieldColonSpacing == FormatStyle::BFCS_Before;
 return true;
   }
   if (Left.is(TT_UnaryOperator)) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -366,6 +366,17 @@
   }
 };
 
+template <>
+struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO,
+  FormatStyle::BitFieldColonSpacingStyle &Value) {
+IO.enumCase(Value, "Both", FormatStyle::BFCS_Both);
+IO.enumCase(Value, "None", FormatStyle::BFCS_None);
+IO.enumCase(Value, "Before", FormatStyle::BFCS_Before);
+IO.enumCase(Value, "After", FormatStyle::BFCS_After);
+  }
+};
+
 template <> struct MappingTraits {
   static void ma

[PATCH] D84182: [OPENMP]Fix PR46012: declare target pointer cannot be accessed in target region.

2020-07-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: jdoerfert, ye-luo.
Herald added subscribers: sstefan1, guansong, yaxunl.
Herald added a project: clang.

Need to avoid an optimization for base pointer mapping for target data
directives.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84182

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  clang/test/OpenMP/target_update_codegen.cpp

Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -310,23 +310,22 @@
 
 #ifdef CK5
 
-// CK5: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// CK5: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 33]
+// CK5: [[SIZE00:@.+]] = {{.+}}constant [2 x i[[sz:64|32]]] [i{{64|32}} {{8|4}}, i{{64|32}} 4]
+// CK5: [[MTYPE00:@.+]] = {{.+}}constant [2 x i64] [i64 33, i64 17]
 
 // CK5-LABEL: lvalue
 void lvalue(int *B, int l, int e) {
 
-  // CK5-DAG: call void @__tgt_target_data_update_mapper(i64 -1, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00]]{{.+}}, i8** null)
+  // CK5-DAG: call void @__tgt_target_data_update_mapper(i64 -1, i32 2, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[2 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[2 x i{{.+}}]* [[MTYPE00]]{{.+}}, i8** null)
   // CK5-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
   // CK5-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
 
-  // CK5-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
-  // CK5-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
-  // CK5-DAG: [[BPC0:%.+]] = bitcast i8** [[BP0]] to i32**
+  // CK5-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 1
+  // CK5-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 1
+  // CK5-DAG: [[BPC0:%.+]] = bitcast i8** [[BP0]] to i32***
   // CK5-DAG: [[PC0:%.+]] = bitcast i8** [[P0]] to i32**
-  // CK5-DAG: store i32* [[B_VAL:%.+]], i32** [[BPC0]]
+  // CK5-DAG: store i32** [[B_ADDR:%.+]], i32*** [[BPC0]]
   // CK5-DAG: store i32* [[B_VAL_2:%.+]], i32** [[PC0]]
-  // CK5-DAG: [[B_VAL]] = load i32*, i32** [[B_ADDR:%.+]]
   // CK5-DAG: [[B_VAL_2]] = load i32*, i32** [[B_ADDR]]
   #pragma omp target update to(*B)
   *B += e;
@@ -352,27 +351,28 @@
 
 #ifdef CK6
 
-// CK6: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// CK6: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 33]
+// CK6: [[SIZE00:@.+]] = {{.+}}constant [2 x i[[sz:64|32]]] [i{{64|32}} {{8|4}}, i{{64|32}} 4]
+// CK6: [[MTYPE00:@.+]] = {{.+}}constant [2 x i64] [i64 33, i64 17]
 
 // CK6-LABEL: lvalue
 void lvalue(int *B, int l, int e) {
 
-  // CK6-DAG: call void @__tgt_target_data_update_mapper(i64 -1, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00]]{{.+}}, i8** null)
+  // CK6-DAG: call void @__tgt_target_data_update_mapper(i64 -1, i32 2, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[2 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[2 x i{{.+}}]* [[MTYPE00]]{{.+}}, i8** null)
   // CK6-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
   // CK6-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
 
-  // CK6-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
-  // CK6-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
-  // CK6-DAG: [[BPC0:%.+]] = bitcast i8** [[BP0]] to i32**
+  // CK6-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 1
+  // CK6-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 1
+  // CK6-DAG: [[BPC0:%.+]] = bitcast i8** [[BP0]] to i32***
   // CK6-DAG: [[PC0:%.+]] = bitcast i8** [[P0]] to i32**
-  // CK6-DAG: store i32* [[ZERO:%.+]], i32** [[BPC0]]
+  // CK6-DAG: store i32** [[B_ADDR:%.+]], i32*** [[BPC0]]
   // CK6-DAG: store i32* [[ADD_PTR:%.+]], i32** [[PC0]]
   // CK6-64-DAG: [[ADD_PTR]] = getelementptr inbounds i32, i32* [[ONE:%.+]], i{{32|64}} [[IDX_EXT:%.+]]
   // CK6-32-DAG: [[ADD_PTR]] = getelementptr inbounds i32, i32* [[ONE:%.+]], i{{32|64}} [[L_VAL:%.+]]
   // CK6-64-DAG: [[IDX_EXT]] = sext i32 [[L_VAL:%.+]] to i64
   // CK6-DAG: [[L_VAL]] = load i32, i32* [[L_ADDR:%.+]]
   // CK6-DAG: store i32 {{.+}}, i32* [[L_ADDR]]
+  // CK6-DAG: [[ONE]] = load i32*, i32** [[B_ADDR]]
   #pragma omp target update to(*(B+l))
   *(B+l) += e;
   #pragma omp target update from(*(B+l))
@@ -397,23 +397,22 @@
 
 #ifdef CK7
 
-// CK7: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// CK7: [[MTYPE00:@.+]] = {{.+}}constant [1 

[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-20 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: compiler-rt/test/fuzzer/custom-allocator.test:2
+UNSUPPORTED: freebsd
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC 
%ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address %S/CustomAllocatorTest.cpp 
%ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorTest

dokyungs wrote:
> morehouse wrote:
> > Why do we need each of these flags?
> With all the flags, I designed this test for the recent failure scenario in 
> which tcmalloc calls strncmp (+memcmp/strstr) when the fuzzer interceptor 
> library is linked into the libFuzzer executable.
> 
> As such, we need to turn off ASan (-fno-sanitize=address) when building the 
> executable to let the fuzzer interceptor library be linked.
> 
> As to the flags used to build the allocator shared library, I wanted to 
> disable ASan and Fuzzer (via `-fno-sanitize=all`) because allocator libraries 
> are typically not instrumented for OOB/UAF errors or coverage. I also wanted 
> to prevent the compiler from optimizing out our calls to 
> strncmp(+memcmp/strstr) by giving `-fno-builtin`; calls to these functions 
> must go to the fuzzer interceptor library to comply with the scenario.
Yes, those flags make sense.  What about `-fPIC %ld_flags_rpath_so1 -O0 
-shared`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494



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


[PATCH] D84172: [clangd] Fix conversion from Windows UNC paths to file URI format.

2020-07-20 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko added a comment.

In D84172#2162284 , @sammccall wrote:

> Thanks for doing this! And sorry about the shaky windows support...
>
> (There are potentially other lurking issues due to filenames being used as 
> keys internally, particularly case-insensitivity issues...)


I'm glad to be useful. And thank you much for the time you spend reviewing the 
code. I really appreciate it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84172



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


[PATCH] D82598: [analyzer][Liveness][NFC] Get rid of statement liveness, because such a thing doesn't exist

2020-07-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In D82598#2162239 , @Szelethus wrote:

> I chased my own tail for weeks before realizing that there is indeed another 
> instance when a live **statement** is stored, other then 
> `ObjCForCollectionStmt`...
>
>   void clang_analyzer_eval(bool);
>  
>   void test_lambda_refcapture() {
> int a = 6;
> [&](int &a) { a = 42; }(a);
> clang_analyzer_eval(a == 42); // expected-warning{{TRUE}}
>   }
>


Hmm, interesting. I don't really understand why do we need to keep that block 
live, as we definitely won't use any of the value it provides (since it does 
not provide a value at all).

I am only doing guessing here, but maybe the side effect of the statement is 
pruned from the store as soon as it is no longer live?

I might be wrong here, but maybe solving this problem would not be the job of 
the liveness analysis but we have a bug elsewhere, as this binding should be 
pruned when `a` is a dead variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82598



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


[PATCH] D84172: [clangd] Fix conversion from Windows UNC paths to file URI format.

2020-07-20 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko marked 2 inline comments as done.
ilya-golovenko added inline comments.



Comment at: clang-tools-extra/clangd/URI.cpp:29
 
+bool isWindowsPath(llvm::StringRef Path) {
+  return Path.size() > 1 && llvm::isAlpha(Path[0]) && Path[1] == ':';

sammccall wrote:
> the UNC paths are also basically a windows thing, can we have 
> hasWindowsDriveLetter and isWindowsNetworkPath (or isWindowsUNCPath)?
This kind of network paths are also supported on Unix/Linux system, e.g. 
`//hostname/path/file.txt` and `isNetworkPath` will handle those as well.  For 
example, samba and samba client support such paths. RFC 8089 calls them 
"non-local files" with unspecified type of protocol to access the file, i.e. it 
is not necessary a UNC path. Does it make sense to continue supporting 
Linux/Unix version of network path?



Comment at: clang-tools-extra/clangd/URI.cpp:34
+bool isNetworkPath(llvm::StringRef Path) {
+  llvm::StringRef Sep = llvm::sys::path::get_separator();
+  return Path.consume_front(Sep) && Path.consume_front(Sep) && !Path.empty();

sammccall wrote:
> conventionally LLVM tools accept both slashes on windows and `/` on other 
> platforms - i.e. we should probably treat `//foo/bar` as a valid network path 
> on windows unless there's a good reason not to.
> 
> So `Path.size() > 2 && llvm::sys::path::is_separator(Path[0]) && 
> llvm::sys::path::is_separator(Path[1])`, I guess
I tried to prevent treating paths like `/\path` or `\/path` as network paths. 
Maybe the following variant will work:

```
bool isNetworkPath(llvm::StringRef Path) {
 return Path.size() > 2 && Path[0] == Path[1] && 
llvm::sys::path::is_separator(Path[0]);
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84172



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


[PATCH] D84172: [clangd] Fix conversion from Windows UNC paths to file URI format.

2020-07-20 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko updated this revision to Diff 279271.
ilya-golovenko marked an inline comment as done.
ilya-golovenko added a comment.

Address code review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84172

Files:
  clang-tools-extra/clangd/URI.cpp
  clang-tools-extra/clangd/unittests/URITests.cpp

Index: clang-tools-extra/clangd/unittests/URITests.cpp
===
--- clang-tools-extra/clangd/unittests/URITests.cpp
+++ clang-tools-extra/clangd/unittests/URITests.cpp
@@ -76,6 +76,16 @@
 #endif
 }
 
+TEST(URITest, CreateUNC) {
+#ifdef _WIN32
+  EXPECT_THAT(createOrDie("test.org\\x\\y\\z"), "file://test.org/x/y/z");
+  EXPECT_THAT(createOrDie("10.0.0.1\\x\\y\\z"), "file://10.0.0.1/x/y/z");
+#else
+  EXPECT_THAT(createOrDie("//test.org/x/y/z"), "file://test.org/x/y/z");
+  EXPECT_THAT(createOrDie("//10.0.0.1/x/y/z"), "file://10.0.0.1/x/y/z");
+#endif
+}
+
 TEST(URITest, FailedCreate) {
   EXPECT_ERROR(URI::create("/x/y/z", "no"));
   // Path has to be absolute.
@@ -127,15 +137,32 @@
   EXPECT_THAT(resolveOrDie(parseOrDie("file:///c:/x/y/z")), "c:\\x\\y\\z");
 #else
   EXPECT_EQ(resolveOrDie(parseOrDie("file:/a/b/c")), "/a/b/c");
-  EXPECT_EQ(resolveOrDie(parseOrDie("file://auth/a/b/c")), "/a/b/c");
+  EXPECT_EQ(resolveOrDie(parseOrDie("file://auth/a/b/c")), "//auth/a/b/c");
   EXPECT_THAT(resolveOrDie(parseOrDie("file://au%3dth/%28x%29/y/%20z")),
-  "/(x)/y/ z");
+  "//au=th/(x)/y/ z");
   EXPECT_THAT(resolveOrDie(parseOrDie("file:///c:/x/y/z")), "c:/x/y/z");
 #endif
   EXPECT_EQ(resolveOrDie(parseOrDie("unittest:///a"), testPath("x")),
 testPath("a"));
 }
 
+TEST(URITest, ResolveUNC) {
+#ifdef _WIN32
+  EXPECT_THAT(resolveOrDie(parseOrDie("file://example.com/x/y/z")),
+  "example.com\\x\\y\\z");
+  EXPECT_THAT(resolveOrDie(parseOrDie("file://127.0.0.1/x/y/z")),
+  "127.0.0.1\\x\\y\\z");
+  // Ensure non-traditional file URI still resolves to correct UNC path.
+  EXPECT_THAT(resolveOrDie(parseOrDie("file:127.0.0.1/x/y/z")),
+  "127.0.0.1\\x\\y\\z");
+#else
+  EXPECT_THAT(resolveOrDie(parseOrDie("file://example.com/x/y/z")),
+  "//example.com/x/y/z");
+  EXPECT_THAT(resolveOrDie(parseOrDie("file://127.0.0.1/x/y/z")),
+  "//127.0.0.1/x/y/z");
+#endif
+}
+
 std::string resolvePathOrDie(llvm::StringRef AbsPath,
  llvm::StringRef HintPath = "") {
   auto Path = URI::resolvePath(AbsPath, HintPath);
Index: clang-tools-extra/clangd/URI.cpp
===
--- clang-tools-extra/clangd/URI.cpp
+++ clang-tools-extra/clangd/URI.cpp
@@ -26,6 +26,15 @@
  llvm::inconvertibleErrorCode());
 }
 
+bool isWindowsPath(llvm::StringRef Path) {
+  return Path.size() > 1 && llvm::isAlpha(Path[0]) && Path[1] == ':';
+}
+
+bool isNetworkPath(llvm::StringRef Path) {
+  return Path.size() > 2 && Path[0] == Path[1] &&
+ llvm::sys::path::is_separator(Path[0]);
+}
+
 /// This manages file paths in the file system. All paths in the scheme
 /// are absolute (with leading '/').
 /// Note that this scheme is hardcoded into the library and not registered in
@@ -33,28 +42,40 @@
 class FileSystemScheme : public URIScheme {
 public:
   llvm::Expected
-  getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
+  getAbsolutePath(llvm::StringRef Authority, llvm::StringRef Body,
   llvm::StringRef /*HintPath*/) const override {
 if (!Body.startswith("/"))
   return make_string_error("File scheme: expect body to be an absolute "
"path starting with '/': " +
Body);
-// For Windows paths e.g. /X:
-if (Body.size() > 2 && Body[0] == '/' && Body[2] == ':')
+llvm::SmallString<128> Path;
+if (!Authority.empty()) {
+  // Windows UNC paths e.g. file://server/share => \\server\share
+  ("//" + Authority).toVector(Path);
+} else if (isWindowsPath(Body.substr(1))) {
+  // Windows paths e.g. file:///X:/path => X:\path
   Body.consume_front("/");
-llvm::SmallVector Path(Body.begin(), Body.end());
+}
+Path.append(Body);
 llvm::sys::path::native(Path);
-return std::string(Path.begin(), Path.end());
+return std::string(Path);
   }
 
   llvm::Expected
   uriFromAbsolutePath(llvm::StringRef AbsolutePath) const override {
 std::string Body;
-// For Windows paths e.g. X:
-if (AbsolutePath.size() > 1 && AbsolutePath[1] == ':')
+llvm::StringRef Authority;
+llvm::StringRef Root = llvm::sys::path::root_name(AbsolutePath);
+if (isNetworkPath(Root)) {
+  // Windows UNC paths e.g. \\server\share => file://server/share
+  Authority = Root.drop_front(2);
+  AbsolutePath.consume_front(Root);
+

[PATCH] D83551: [PATCH 2/4][Sema][AArch64] Add semantics for arm_sve_vector_bits attribute

2020-07-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I like the way the code is shaping up with the slightly altered design, nice!




Comment at: clang/lib/AST/ASTContext.cpp:1872
 
+unsigned getSveVectorWidth(const Type *T) {
+  // Get the vector size from the 'arm_sve_vector_bits' attribute via the

Should declare the method as `static`.



Comment at: clang/lib/AST/ASTContext.cpp:1887
+
+unsigned getSvePredWidth(const Type *T) { return getSveVectorWidth(T) / 8; }
+

Should this be dividing by the number of bits in a char for the target as 
opposed to hard-coding to 8?


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

https://reviews.llvm.org/D83551



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


[PATCH] D83553: [PATCH 3/4][Sema][AArch64] Add codegen for arm_sve_vector_bits attribute

2020-07-20 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes marked an inline comment as done.
c-rhodes added inline comments.



Comment at: clang/lib/CodeGen/CodeGenTypes.h:138
+  llvm::Type *ConvertTypeForMem(QualType T, bool ForBitField = false,
+bool EnforceFixedLengthSVEAttribute = false);
 

efriedma wrote:
> c-rhodes wrote:
> > efriedma wrote:
> > > The default for EnforceFixedLengthSVEAttribute seems backwards; I would 
> > > expect that almost everywhere that calls ConvertTypeForMem actually wants 
> > > the fixed-length type.  The scalable type only exists in registers.
> > > The default for EnforceFixedLengthSVEAttribute seems backwards; I would 
> > > expect that almost everywhere that calls ConvertTypeForMem actually wants 
> > > the fixed-length type. The scalable type only exists in registers.
> > 
> > It has no effect unless `T->isVLST()` so I think it makes sense.
> My question is "why is the current default for EnforceFixedLengthSVEAttribute 
> correct?" You answer for that is "because VLST types are rare"?  I'm not sure 
> how that's related.
> 
> Essentially, the issue is that ConvertTypeForMem means "I'm allocating 
> something in memory; what is its type?".  Except for a few places where we've 
> specifically added handling to make it work, the code assumes scalable types 
> don't exist.  So in most places, we want the fixed version.  With the current 
> default, I'm afraid we're going to end up with weird failures with various 
> constructs you haven't tested.
> 
> I guess if there's some large number of places where the current default is 
> actually beneficial, the current patch wouldn't make it obvious, but my 
> intuition is that are few places like that.
>> My question is "why is the current default for 
>> EnforceFixedLengthSVEAttribute correct?" You answer for that is "because 
>> VLST types are rare"? I'm not sure how that's related.

>Essentially, the issue is that ConvertTypeForMem means "I'm allocating 
>something in memory; what is its type?". Except for a few places where we've 
>specifically added handling to make it work, the code assumes scalable types 
>don't exist. So in most places, we want the fixed version. With the current 
>default, I'm afraid we're going to end up with weird failures with various 
>constructs you haven't tested.

Sorry I misunderstood what you meant. I think you're right that does make 
sense, I guess the benefit of defaulting to false is (hopefully) those failures 
would have come to our attention and we could explicitly add test cases for 
those, although I suspect the same applies with your suggestion with the added 
benefit of us supporting constructs we haven't explicitly tested as you say. 
Anyhow, I've made the change, cheers!


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

https://reviews.llvm.org/D83553



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


[PATCH] D83922: [OpenMP] Fix map clause for unused var: don't ignore it

2020-07-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D83922#2162444 , @jdenny wrote:

> In D83922#2162365 , @ABataev wrote:
>
> > Looks like it breaks unified_shared_memory/close_enter_exit.c test. Could 
> > you check this, please?
>
>
> It doesn't fail for me, and I didn't receive a buildbot notification.  Do you 
> have a link?


I saw it failed it in local build, but probably it was caused by a 
misconfiguration, sorry.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83922



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


[PATCH] D83922: [OpenMP] Fix map clause for unused var: don't ignore it

2020-07-20 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In D83922#2162365 , @ABataev wrote:

> Looks like it breaks unified_shared_memory/close_enter_exit.c test. Could you 
> check this, please?


It doesn't fail for me, and I didn't receive a buildbot notification.  Do you 
have a link?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83922



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


  1   2   3   >