[PATCH] D84837: [clangd] Fix an assertion failure in TargetFinder's heuristic resolution of dependent type.

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



Comment at: clang-tools-extra/clangd/FindTarget.cpp:171
 // or more declarations that it likely references.
-std::vector resolveDependentExprToDecls(const Expr *E) {
-  assert(E->isTypeDependent());
+std::vector resolveExprToDecls(const Expr *E) {
   if (const auto *ME = dyn_cast(E)) {

nridge wrote:
> I do think the "heuristic" nature of this function is an important part of 
> its interface that's currently lost with this rename.
> 
> However, I think that's fine for now. In a future refactor (to get 
> code-completion to use this machinery as well) I plan to move these functions 
> into a `HeuristicResolver` class or a `heuristics` sub-namespace or something 
> like that.
yeah, I agree. It would be clearer if these functions are put into a 
`Heuristic` context.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84837

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


[clang-tools-extra] cd4e8d7 - [clangd] Fix an assertion failure in TargetFinder's heuristic resolution of dependent type.

2020-07-30 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-07-30T08:54:22+02:00
New Revision: cd4e8d7f6f5ef108919f9f53db35ac73d1edea3d

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

LOG: [clangd] Fix an assertion failure in TargetFinder's heuristic resolution 
of dependent type.

The assertion is not true anymore after D82739, this patch just removes
it, and rename related functions.

And also fixes a missing cases.

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

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 c6022b2463e8..a346d6b662e9 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -163,13 +163,12 @@ const Type *getPointeeType(const Type *T) {
 }
 
 // Forward declaration, needed as this function is mutually recursive
-// with resolveDependentExprToDecls.
-const Type *resolveDependentExprToType(const Expr *E);
+// with resolveExprToDecls.
+const Type *resolveExprToType(const Expr *E);
 
-// Try to heuristically resolve a dependent expression `E` to one
+// Try to heuristically resolve a possibly-dependent expression `E` to one
 // or more declarations that it likely references.
-std::vector resolveDependentExprToDecls(const Expr *E) {
-  assert(E->isTypeDependent());
+std::vector resolveExprToDecls(const Expr *E) {
   if (const auto *ME = dyn_cast(E)) {
 const Type *BaseType = ME->getBaseType().getTypePtrOrNull();
 if (ME->isArrow()) {
@@ -183,7 +182,7 @@ std::vector 
resolveDependentExprToDecls(const Expr *E) {
   // can get further by analyzing the depedent expression.
   Expr *Base = ME->isImplicitAccess() ? nullptr : ME->getBase();
   if (Base && BT->getKind() == BuiltinType::Dependent) {
-BaseType = resolveDependentExprToType(Base);
+BaseType = resolveExprToType(Base);
   }
 }
 return getMembersReferencedViaDependentName(
@@ -197,7 +196,7 @@ std::vector 
resolveDependentExprToDecls(const Expr *E) {
 /*IsNonstaticMember=*/false);
   }
   if (const auto *CE = dyn_cast(E)) {
-const auto *CalleeType = resolveDependentExprToType(CE->getCallee());
+const auto *CalleeType = resolveExprToType(CE->getCallee());
 if (!CalleeType)
   return {};
 if (const auto *FnTypePtr = CalleeType->getAs())
@@ -209,15 +208,16 @@ std::vector 
resolveDependentExprToDecls(const Expr *E) {
   }
 }
   }
-  if (const auto *ME = dyn_cast(E)) {
+  if (const auto *ME = dyn_cast(E))
 return {ME->getMemberDecl()};
-  }
+  if (const auto *DRE = dyn_cast(E))
+return {DRE->getFoundDecl()};
   return {};
 }
 
-// Try to heuristically resolve the type of a dependent expression `E`.
-const Type *resolveDependentExprToType(const Expr *E) {
-  std::vector Decls = resolveDependentExprToDecls(E);
+// Try to heuristically resolve the type of a possibly-dependent expression 
`E`.
+const Type *resolveExprToType(const Expr *E) {
+  std::vector Decls = resolveExprToDecls(E);
   if (Decls.size() != 1) // Names an overload set -- just bail.
 return nullptr;
   if (const auto *TD = dyn_cast(Decls[0])) {
@@ -426,12 +426,12 @@ struct TargetFinder {
   }
   void
   VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
-for (const NamedDecl *D : resolveDependentExprToDecls(E)) {
+for (const NamedDecl *D : resolveExprToDecls(E)) {
   Outer.add(D, Flags);
 }
   }
   void VisitDependentScopeDeclRefExpr(const DependentScopeDeclRefExpr *E) {
-for (const NamedDecl *D : resolveDependentExprToDecls(E)) {
+for (const NamedDecl *D : resolveExprToDecls(E)) {
   Outer.add(D, Flags);
 }
   }

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index f7af77e8b57b..92095e871e20 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -627,6 +627,20 @@ TEST_F(TargetDeclTest, DependentExprs) {
 };
   )cpp";
   EXPECT_DECLS("CXXDependentScopeMemberExpr", "int ");
+
+  Code = R"cpp(
+class Foo {
+public:
+  static Foo k(int);
+  template  T convert() const;
+};
+template 
+void test() {
+  Foo::k(T()).template [[convert]]();
+}
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr",
+   "template  T convert() const");
 }
 
 TEST_F(TargetDeclTest, ObjC) {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lis

[PATCH] D84837: [clangd] Fix an assertion failure in TargetFinder's heuristic resolution of dependent type.

2020-07-30 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd4e8d7f6f5e: [clangd] Fix an assertion failure in 
TargetFinder's heuristic resolution of… (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84837

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
@@ -627,6 +627,20 @@
 };
   )cpp";
   EXPECT_DECLS("CXXDependentScopeMemberExpr", "int ");
+
+  Code = R"cpp(
+class Foo {
+public:
+  static Foo k(int);
+  template  T convert() const;
+};
+template 
+void test() {
+  Foo::k(T()).template [[convert]]();
+}
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr",
+   "template  T convert() const");
 }
 
 TEST_F(TargetDeclTest, ObjC) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -163,13 +163,12 @@
 }
 
 // Forward declaration, needed as this function is mutually recursive
-// with resolveDependentExprToDecls.
-const Type *resolveDependentExprToType(const Expr *E);
+// with resolveExprToDecls.
+const Type *resolveExprToType(const Expr *E);
 
-// Try to heuristically resolve a dependent expression `E` to one
+// Try to heuristically resolve a possibly-dependent expression `E` to one
 // or more declarations that it likely references.
-std::vector resolveDependentExprToDecls(const Expr *E) {
-  assert(E->isTypeDependent());
+std::vector resolveExprToDecls(const Expr *E) {
   if (const auto *ME = dyn_cast(E)) {
 const Type *BaseType = ME->getBaseType().getTypePtrOrNull();
 if (ME->isArrow()) {
@@ -183,7 +182,7 @@
   // can get further by analyzing the depedent expression.
   Expr *Base = ME->isImplicitAccess() ? nullptr : ME->getBase();
   if (Base && BT->getKind() == BuiltinType::Dependent) {
-BaseType = resolveDependentExprToType(Base);
+BaseType = resolveExprToType(Base);
   }
 }
 return getMembersReferencedViaDependentName(
@@ -197,7 +196,7 @@
 /*IsNonstaticMember=*/false);
   }
   if (const auto *CE = dyn_cast(E)) {
-const auto *CalleeType = resolveDependentExprToType(CE->getCallee());
+const auto *CalleeType = resolveExprToType(CE->getCallee());
 if (!CalleeType)
   return {};
 if (const auto *FnTypePtr = CalleeType->getAs())
@@ -209,15 +208,16 @@
   }
 }
   }
-  if (const auto *ME = dyn_cast(E)) {
+  if (const auto *ME = dyn_cast(E))
 return {ME->getMemberDecl()};
-  }
+  if (const auto *DRE = dyn_cast(E))
+return {DRE->getFoundDecl()};
   return {};
 }
 
-// Try to heuristically resolve the type of a dependent expression `E`.
-const Type *resolveDependentExprToType(const Expr *E) {
-  std::vector Decls = resolveDependentExprToDecls(E);
+// Try to heuristically resolve the type of a possibly-dependent expression `E`.
+const Type *resolveExprToType(const Expr *E) {
+  std::vector Decls = resolveExprToDecls(E);
   if (Decls.size() != 1) // Names an overload set -- just bail.
 return nullptr;
   if (const auto *TD = dyn_cast(Decls[0])) {
@@ -426,12 +426,12 @@
   }
   void
   VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
-for (const NamedDecl *D : resolveDependentExprToDecls(E)) {
+for (const NamedDecl *D : resolveExprToDecls(E)) {
   Outer.add(D, Flags);
 }
   }
   void VisitDependentScopeDeclRefExpr(const DependentScopeDeclRefExpr *E) {
-for (const NamedDecl *D : resolveDependentExprToDecls(E)) {
+for (const NamedDecl *D : resolveExprToDecls(E)) {
   Outer.add(D, Flags);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84898: [clang-tidy] Add new checker for complex conditions with no meaning

2020-07-30 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I really think this should be in clang proper.
I have seen such patterns written in the wild,
they should be caught by just the compiler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84898

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


[PATCH] D84902: [clang-tidy] Fix ODR violation in unittests.

2020-07-30 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks for all the investigative work!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D84902

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


[clang] 73c12bd - [Concepts] Fix a deserialization crash.

2020-07-30 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-07-30T09:25:15+02:00
New Revision: 73c12bd8ff1a9cd8375a357ea06f171e127ec1b8

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

LOG: [Concepts] Fix a deserialization crash.

`TemplateTypeParmDecl::hasTypeConstraint` is not a safe guard for
checking `TemplateTypeParmDecl::getTypeConstraint()` result is null.

in somecases (e.g. implicit deduction guide templates synthesized from the
constructor, immediately-declared constraint is not formed because of an error),
hasTypeConstraint returns false, and getTypeConstraint returns a nullptr.

Fix https://bugs.llvm.org/show_bug.cgi?id=46790

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

Added: 
clang/test/PCH/cxx2a-constraints-crash.cpp

Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 0b87161ddeea..5413b28ffde2 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2909,9 +2909,11 @@ static bool isSameTemplateParameter(const NamedDecl *X,
   return false;
 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
   return false;
-if (TX->hasTypeConstraint()) {
-  const TypeConstraint *TXTC = TX->getTypeConstraint();
-  const TypeConstraint *TYTC = TY->getTypeConstraint();
+const TypeConstraint *TXTC = TX->getTypeConstraint();
+const TypeConstraint *TYTC = TY->getTypeConstraint();
+if (!TXTC != !TYTC)
+  return false;
+if (TXTC && TYTC) {
   if (TXTC->getNamedConcept() != TYTC->getNamedConcept())
 return false;
   if (TXTC->hasExplicitTemplateArgs() != TYTC->hasExplicitTemplateArgs())

diff  --git a/clang/test/PCH/cxx2a-constraints-crash.cpp 
b/clang/test/PCH/cxx2a-constraints-crash.cpp
new file mode 100644
index ..637c55f0c879
--- /dev/null
+++ b/clang/test/PCH/cxx2a-constraints-crash.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++2a -emit-pch %s -o %t
+// RUN: %clang_cc1 -std=c++2a -include-pch %t -verify %s
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template 
+concept not_same_as = true;
+
+template 
+struct subrange {
+  template  R>
+  subrange(R) requires(Kind == 0);
+
+  template  R>
+  subrange(R) requires(Kind != 0);
+};
+
+template 
+subrange(R) -> subrange<42>;
+
+int main() {
+  int c;
+  subrange s(c);
+}
+
+#endif



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


[PATCH] D84455: [Concepts] Fix a deserialization crash.

2020-07-30 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG73c12bd8ff1a: [Concepts] Fix a deserialization crash. 
(authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D84455?vs=280225&id=281811#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84455

Files:
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/PCH/cxx2a-constraints-crash.cpp


Index: clang/test/PCH/cxx2a-constraints-crash.cpp
===
--- /dev/null
+++ clang/test/PCH/cxx2a-constraints-crash.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++2a -emit-pch %s -o %t
+// RUN: %clang_cc1 -std=c++2a -include-pch %t -verify %s
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template 
+concept not_same_as = true;
+
+template 
+struct subrange {
+  template  R>
+  subrange(R) requires(Kind == 0);
+
+  template  R>
+  subrange(R) requires(Kind != 0);
+};
+
+template 
+subrange(R) -> subrange<42>;
+
+int main() {
+  int c;
+  subrange s(c);
+}
+
+#endif
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2909,9 +2909,11 @@
   return false;
 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
   return false;
-if (TX->hasTypeConstraint()) {
-  const TypeConstraint *TXTC = TX->getTypeConstraint();
-  const TypeConstraint *TYTC = TY->getTypeConstraint();
+const TypeConstraint *TXTC = TX->getTypeConstraint();
+const TypeConstraint *TYTC = TY->getTypeConstraint();
+if (!TXTC != !TYTC)
+  return false;
+if (TXTC && TYTC) {
   if (TXTC->getNamedConcept() != TYTC->getNamedConcept())
 return false;
   if (TXTC->hasExplicitTemplateArgs() != TYTC->hasExplicitTemplateArgs())


Index: clang/test/PCH/cxx2a-constraints-crash.cpp
===
--- /dev/null
+++ clang/test/PCH/cxx2a-constraints-crash.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++2a -emit-pch %s -o %t
+// RUN: %clang_cc1 -std=c++2a -include-pch %t -verify %s
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template 
+concept not_same_as = true;
+
+template 
+struct subrange {
+  template  R>
+  subrange(R) requires(Kind == 0);
+
+  template  R>
+  subrange(R) requires(Kind != 0);
+};
+
+template 
+subrange(R) -> subrange<42>;
+
+int main() {
+  int c;
+  subrange s(c);
+}
+
+#endif
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2909,9 +2909,11 @@
   return false;
 if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
   return false;
-if (TX->hasTypeConstraint()) {
-  const TypeConstraint *TXTC = TX->getTypeConstraint();
-  const TypeConstraint *TYTC = TY->getTypeConstraint();
+const TypeConstraint *TXTC = TX->getTypeConstraint();
+const TypeConstraint *TYTC = TY->getTypeConstraint();
+if (!TXTC != !TYTC)
+  return false;
+if (TXTC && TYTC) {
   if (TXTC->getNamedConcept() != TYTC->getNamedConcept())
 return false;
   if (TXTC->hasExplicitTemplateArgs() != TYTC->hasExplicitTemplateArgs())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84912: [clangd] findNearbyIdentifier(): fix the word search in the token stream.

2020-07-30 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.
ArcsinX requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Without this patch the word occurrence search always returns the first token of 
the file.
Despite of that, `findNeardyIdentifier()` returns the correct result (but 
inefficently) until there are several matched tokens with the same value 
`floor(log2( - ))` (e.g. several matched tokens on the 
same line).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84912

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


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1197,7 +1197,14 @@
 
   // h^i
 )cpp",
-  };
+  R"cpp(
+  // prefer nearest occurrence even if several matched tokens
+  // have the same value of `floor(log2( - ))`.
+  int hello;
+  int x = hello, y = hello;
+  int z = [[hello]];
+  // h^ello
+)cpp"};
   for (const char *Test : Tests) {
 Annotations T(Test);
 auto AST = TestTU::withCode(T.code()).build();
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -518,7 +518,7 @@
   // Find where the word occurred in the token stream, to search forward & 
back.
   auto *I = llvm::partition_point(SpelledTokens, [&](const syntax::Token &T) {
 assert(SM.getFileID(T.location()) == SM.getFileID(Word.Location));
-return T.location() >= Word.Location; // Comparison OK: same file.
+return T.location() < Word.Location; // Comparison OK: same file.
   });
   // Search for matches after the cursor.
   for (const syntax::Token &Tok : llvm::makeArrayRef(I, SpelledTokens.end()))


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1197,7 +1197,14 @@
 
   // h^i
 )cpp",
-  };
+  R"cpp(
+  // prefer nearest occurrence even if several matched tokens
+  // have the same value of `floor(log2( - ))`.
+  int hello;
+  int x = hello, y = hello;
+  int z = [[hello]];
+  // h^ello
+)cpp"};
   for (const char *Test : Tests) {
 Annotations T(Test);
 auto AST = TestTU::withCode(T.code()).build();
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -518,7 +518,7 @@
   // Find where the word occurred in the token stream, to search forward & back.
   auto *I = llvm::partition_point(SpelledTokens, [&](const syntax::Token &T) {
 assert(SM.getFileID(T.location()) == SM.getFileID(Word.Location));
-return T.location() >= Word.Location; // Comparison OK: same file.
+return T.location() < Word.Location; // Comparison OK: same file.
   });
   // Search for matches after the cursor.
   for (const syntax::Token &Tok : llvm::makeArrayRef(I, SpelledTokens.end()))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84843: [Analyzer] Remove inclusion of uniqueing decl from diagnostic profile.

2020-07-30 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1745ba41b196: [Analyzer] Remove inclusion of uniqueing decl 
from diagnostic profile. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84843

Files:
  clang/lib/Analysis/PathDiagnostic.cpp
  clang/test/Analysis/report-uniqueing.cpp


Index: clang/test/Analysis/report-uniqueing.cpp
===
--- /dev/null
+++ clang/test/Analysis/report-uniqueing.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=security
+
+void bzero(void *, unsigned long);
+
+template  void foo(T l) {
+  // The warning comes from multiple instances and with
+  // different declarations that have same source location.
+  // One instance should be shown.
+  bzero(l, 1); // expected-warning{{The bzero() function is obsoleted}}
+}
+
+void p(int *p, unsigned *q) {
+  foo(p);
+  foo(q);
+}
Index: clang/lib/Analysis/PathDiagnostic.cpp
===
--- clang/lib/Analysis/PathDiagnostic.cpp
+++ clang/lib/Analysis/PathDiagnostic.cpp
@@ -1134,7 +1134,6 @@
 void PathDiagnostic::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.Add(getLocation());
   ID.Add(getUniqueingLoc());
-  ID.AddPointer(getUniqueingLoc().isValid() ? getUniqueingDecl() : nullptr);
   ID.AddString(BugType);
   ID.AddString(VerboseDesc);
   ID.AddString(Category);


Index: clang/test/Analysis/report-uniqueing.cpp
===
--- /dev/null
+++ clang/test/Analysis/report-uniqueing.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=security
+
+void bzero(void *, unsigned long);
+
+template  void foo(T l) {
+  // The warning comes from multiple instances and with
+  // different declarations that have same source location.
+  // One instance should be shown.
+  bzero(l, 1); // expected-warning{{The bzero() function is obsoleted}}
+}
+
+void p(int *p, unsigned *q) {
+  foo(p);
+  foo(q);
+}
Index: clang/lib/Analysis/PathDiagnostic.cpp
===
--- clang/lib/Analysis/PathDiagnostic.cpp
+++ clang/lib/Analysis/PathDiagnostic.cpp
@@ -1134,7 +1134,6 @@
 void PathDiagnostic::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.Add(getLocation());
   ID.Add(getUniqueingLoc());
-  ID.AddPointer(getUniqueingLoc().isValid() ? getUniqueingDecl() : nullptr);
   ID.AddString(BugType);
   ID.AddString(VerboseDesc);
   ID.AddString(Category);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1745ba4 - [Analyzer] Remove inclusion of uniqueing decl from diagnostic profile.

2020-07-30 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2020-07-30T09:52:28+02:00
New Revision: 1745ba41b196d80d8a6739dffcbb6f613d371f29

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

LOG: [Analyzer] Remove inclusion of uniqueing decl from diagnostic profile.

The uniqueing decl in PathDiagnostic is the declaration with the
uniqueing loc, as stated by documentation comments.
It is enough to include the uniqueing loc in the profile. It is possible
to have objects with different uniqueing decl but same location, at
least with templates. These belong to the same class and should have
same profile.

Reviewed By: vsavchenko, NoQ

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

Added: 
clang/test/Analysis/report-uniqueing.cpp

Modified: 
clang/lib/Analysis/PathDiagnostic.cpp

Removed: 




diff  --git a/clang/lib/Analysis/PathDiagnostic.cpp 
b/clang/lib/Analysis/PathDiagnostic.cpp
index 9aa3386129d7..f80b99b99806 100644
--- a/clang/lib/Analysis/PathDiagnostic.cpp
+++ b/clang/lib/Analysis/PathDiagnostic.cpp
@@ -1134,7 +1134,6 @@ void 
PathDiagnosticPopUpPiece::Profile(llvm::FoldingSetNodeID &ID) const {
 void PathDiagnostic::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.Add(getLocation());
   ID.Add(getUniqueingLoc());
-  ID.AddPointer(getUniqueingLoc().isValid() ? getUniqueingDecl() : nullptr);
   ID.AddString(BugType);
   ID.AddString(VerboseDesc);
   ID.AddString(Category);

diff  --git a/clang/test/Analysis/report-uniqueing.cpp 
b/clang/test/Analysis/report-uniqueing.cpp
new file mode 100644
index ..0e4d50e13a20
--- /dev/null
+++ b/clang/test/Analysis/report-uniqueing.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=security
+
+void bzero(void *, unsigned long);
+
+template  void foo(T l) {
+  // The warning comes from multiple instances and with
+  // 
diff erent declarations that have same source location.
+  // One instance should be shown.
+  bzero(l, 1); // expected-warning{{The bzero() function is obsoleted}}
+}
+
+void p(int *p, unsigned *q) {
+  foo(p);
+  foo(q);
+}



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


[PATCH] D67421: [analyzer] NFC: Move IssueHash to libAnalysis.

2020-07-30 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Other then the naming issue, I don't see any problems with this change!




Comment at: clang/lib/Analysis/IssueHash.cpp:183
 
-std::string clang::GetIssueString(const SourceManager &SM,
-  FullSourceLoc &IssueLoc,
-  StringRef CheckerName, StringRef BugType,
-  const Decl *D,
-  const LangOptions &LangOpts) {
+std::string clang::getIssueStringV1(const FullSourceLoc &IssueLoc,
+StringRef CheckerName,

I'm not a big fan of things like this in names.  First of all, numbers in names 
look bad.  Second, it is not descriptive at all!  I know, I know, it is hard to 
come up with a name that can capture how this `hash` or `string` algorithm is 
different from the other ones, when there are no other ones yet.  And this 
actually brings up the third concern, why do even need to have this suffix now, 
when we don't have other options?  

Let's maybe postpone it till we have the actual motivation to have another 
method, and give them good distinctive names then.  What do you think?


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

https://reviews.llvm.org/D67421

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


[PATCH] D84898: [clang-tidy] Add new checker for complex conditions with no meaning

2020-07-30 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

For the record `X < Y < Z ` does have a mathematical meaning, Y is constrained 
between X and Z.
However in the context of `C` the expression isnt parsed like that.
If someone writes this they likely wanted `(X < Y) && (Y < Z)`
For this specific check as you pointed out we wouldn't want to make that 
assumption though there is a case for adding notes to silence the warning by 
wrapping one of the comparisons in parenthesis.

It appears that this check fire multiple times for the case of `W < X < Y < Z`
Once for `(W < X < Y) < Z` and another time for `(W < X) < Y`
This again likely wont be visible as the warning currently is emitted at the 
start of the expression




Comment at: clang-tools-extra/clang-tidy/misc/ComplexConditionsCheck.cpp:28-33
+  const auto *If = Result.Nodes.getNodeAs("complex_binop");
+  const auto *Statement = Result.Nodes.getNodeAs("complex_binop");
+  if (If) {
+diag(If->getBeginLoc(),
+ "comparisons like `X<=Y<=Z` have no mathematical meaning");
+  }

The `If` looks suspicious, as you match on a `BinaryOperator`, the `If` will 
always be nullptr and should likely be removed.
Likewise `Statement` will match but should likely be changed to BinOp as that's 
what it is.



Comment at: clang-tools-extra/clang-tidy/misc/ComplexConditionsCheck.cpp:34
+  }
+  if (Statement) {
+diag(Statement->getBeginLoc(),

Elide braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84898

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


[PATCH] D84671: Port LangOpts simple string based options to new option parsing system

2020-07-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 281820.
dang added a comment.

Remove accidental addition


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84671

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -228,7 +228,7 @@
   // Get the option groups and options.
   const std::vector &Groups =
 Records.getAllDerivedDefinitions("OptionGroup");
-  std::vector Opts = Records.getAllDerivedDefinitions("Option");
+  std::vector Opts = Records.getAllDerivedDefinitions("Option");
 
   emitSourceFileHeader("Option Parsing Definitions", OS);
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -327,12 +327,36 @@
   LangOpts.OptimizeSize = CodeGenOpts.OptimizeSize != 0;
   LangOpts.ForceEmitVTables = CodeGenOpts.ForceEmitVTables;
   LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening;
+  LangOpts.CurrentModule = LangOpts.ModuleName;
 
   llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
 
   if (LangOpts.AppleKext && !LangOpts.CPlusPlus)
 Diags.Report(diag::warn_c_kext);
 
+  if (LangOpts.NewAlignOverride &&
+  !llvm::isPowerOf2_32(LangOpts.NewAlignOverride)) {
+Arg *A = Args.getLastArg(OPT_fnew_alignment_EQ);
+Diags.Report(diag::err_fe_invalid_alignment)
+<< A->getAsString(Args) << A->getValue();
+LangOpts.NewAlignOverride = 0;
+  }
+
+  if (auto *Arg = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
+llvm::Triple T(TargetOpts.Triple);
+llvm::Triple::ArchType Arch = T.getArch();
+auto DefaultCC = LangOpts.getDefaultCallingConv();
+bool emitError = (DefaultCC == LangOptions::DCC_FastCall ||
+  DefaultCC == LangOptions::DCC_StdCall) &&
+ Arch != llvm::Triple::x86;
+emitError |= (DefaultCC == LangOptions::DCC_VectorCall ||
+  DefaultCC == LangOptions::DCC_RegCall) &&
+ !T.isX86();
+if (emitError)
+  Diags.Report(diag::err_drv_argument_not_allowed_with)
+  << Arg->getSpelling() << T.getTriple();
+  }
+
   if (CodeGenOpts.ThreadModel != "posix" && CodeGenOpts.ThreadModel != "single")
 Diags.Report(diag::err_drv_invalid_value)
 << Args.getLastArg(OPT_mthread_model)->getAsString(Args)
@@ -2228,24 +2252,6 @@
   Opts.GNUInline = 1;
   }
 
-  if (const auto *A = Args.getLastArg(OPT_fcf_runtime_abi_EQ))
-Opts.CFRuntime =
-llvm::StringSwitch(A->getValue())
-.Cases("unspecified", "standalone", "objc",
-   LangOptions::CoreFoundationABI::ObjectiveC)
-.Cases("swift", "swift-5.0",
-   LangOptions::CoreFoundationABI::Swift5_0)
-.Case("swift-4.2", LangOptions::CoreFoundationABI::Swift4_2)
-.Case("swift-4.1", LangOptions::CoreFoundationABI::Swift4_1)
-.Default(LangOptions::CoreFoundationABI::ObjectiveC);
-
-  // The value-visibility mode defaults to "default".
-  if (Arg *visOpt = Args.getLastArg(OPT_fvisibility)) {
-Opts.setValueVisibilityMode(parseVisibility(visOpt, Args, Diags));
-  } else {
-Opts.setValueVisibilityMode(DefaultVisibility);
-  }
-
   // The type-visibility mode defaults to the value-visibility mode.
   if (Arg *typeVisOpt = Args.getLastArg(OPT_ftype_visibility)) {
 Opts.setTypeVisibilityMode(parseVisibility(typeVisOpt, Args, Diags));
@@ -2285,20 +2291,6 @@
   Opts.DollarIdents = Args.hasFlag(OPT_fdollars_in_identifiers,
OPT_fno_dollars_in_identifiers,
Opts.DollarIdents);
-  Opts.setVtorDispMode(
-  MSVtorDispMode(getLastArgIntValue(Args, OPT_vtordisp_mode_EQ, 1, Diags)));
-  if (Arg *A = Args.getLastArg(OPT_flax_vector_conversions_EQ)) {
-using LaxKind = LangOptions::LaxVectorConversionKind;
-if (auto Kind = llvm::StringSwitch>(A->getValue())
-.Case("none", LaxKind::None)
-.Case("integer", LaxKind::Integer)
-.Case("all", LaxKind::All)
-.Default(llvm::None))
-  Opts.setLaxVectorConversions(*Kind);
-else
-  Diags.Report(diag::err_drv_invalid_value)
-  << A->getAsString(Args) << A->getValue();
-  }
 
   // -ffixed-point
   Opts.FixedPoint =
@@ -2352,15 +2344,6 @@
   Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);
   Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar);
   Opts.Char8 = Args.hasFlag(OPT_fchar8__t, OPT_fno_char8__t, Opts.CPlusPlus20);
-  if (const Arg *

[PATCH] D84919: [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

2020-07-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous.
Herald added a project: clang.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

And also fix a bug where we may return a meaningless location.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84919

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -41,6 +41,7 @@
 using ::testing::Eq;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
+using ::testing::UnorderedElementsAre;
 using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P2(FileRange, File, Range, "") {
@@ -264,18 +265,24 @@
  << llvm::to_string(arg.PreferredDeclaration);
 return false;
   }
+  if (!Def && !arg.Definition)
+return true;
   if (Def && !arg.Definition) {
 *result_listener << "Has no definition";
 return false;
   }
-  if (Def && arg.Definition->range != *Def) {
+  if (!Def && arg.Definition) {
+*result_listener << "Definition is " << llvm::to_string(arg.Definition);
+return false;
+  }
+  if (arg.Definition->range != *Def) {
 *result_listener << "Definition is " << llvm::to_string(arg.Definition);
 return false;
   }
   return true;
 }
 ::testing::Matcher Sym(std::string Name, Range Decl) {
-  return Sym(Name, Decl, llvm::None);
+  return Sym(Name, Decl, Decl);
 }
 MATCHER_P(Sym, Name, "") { return arg.Name == Name; }
 
@@ -891,18 +898,20 @@
   // FIXME: Target the constructor as well.
   EXPECT_THAT(locateSymbolAt(AST, T.point("9")), ElementsAre(Sym("Foo")));
   EXPECT_THAT(locateSymbolAt(AST, T.point("10")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   EXPECT_THAT(locateSymbolAt(AST, T.point("11")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   // These assertions are unordered because the order comes from
   // CXXRecordDecl::lookupDependentName() which doesn't appear to provide
   // an order guarantee.
   EXPECT_THAT(locateSymbolAt(AST, T.point("12")),
-  UnorderedElementsAre(Sym("bar", T.range("NonstaticOverload1")),
-   Sym("bar", T.range("NonstaticOverload2";
-  EXPECT_THAT(locateSymbolAt(AST, T.point("13")),
-  UnorderedElementsAre(Sym("baz", T.range("StaticOverload1")),
-   Sym("baz", T.range("StaticOverload2";
+  UnorderedElementsAre(
+  Sym("bar", T.range("NonstaticOverload1"), llvm::None),
+  Sym("bar", T.range("NonstaticOverload2"), llvm::None)));
+  EXPECT_THAT(
+  locateSymbolAt(AST, T.point("13")),
+  UnorderedElementsAre(Sym("baz", T.range("StaticOverload1"), llvm::None),
+   Sym("baz", T.range("StaticOverload2"), llvm::None)));
 }
 
 TEST(LocateSymbol, TextualDependent) {
@@ -932,9 +941,10 @@
   // interaction between locateASTReferent() and
   // locateSymbolNamedTextuallyAt().
   auto Results = locateSymbolAt(AST, Source.point(), Index.get());
-  EXPECT_THAT(Results, UnorderedElementsAre(
-   Sym("uniqueMethodName", Header.range("FooLoc")),
-   Sym("uniqueMethodName", Header.range("BarLoc";
+  EXPECT_THAT(Results,
+  UnorderedElementsAre(
+  Sym("uniqueMethodName", Header.range("FooLoc"), llvm::None),
+  Sym("uniqueMethodName", Header.range("BarLoc"), llvm::None)));
 }
 
 TEST(LocateSymbol, TemplateTypedefs) {
@@ -1112,7 +1122,7 @@
   // stale one.
   EXPECT_THAT(
   cantFail(runLocateSymbolAt(Server, FooCpp, FooWithoutHeader.point())),
-  ElementsAre(Sym("foo", FooWithoutHeader.range(;
+  ElementsAre(Sym("foo", FooWithoutHeader.range(), llvm::None)));
 
   // Reset test environment.
   runAddDocument(Server, FooCpp, FooWithHeader.code());
@@ -1122,7 +1132,7 @@
   // Use the AST being built in above request.
   EXPECT_THAT(
   cantFail(runLocateSymbolAt(Server, FooCpp, FooWithoutHeader.point())),
-  ElementsAre(Sym("foo", FooWithoutHeader.range(;
+  ElementsAre(Sym("foo", FooWithoutHeader.range(), llvm::None)));
 }
 
 TEST(LocateSymbol, NearbyTokenSmoke) {
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -427,7 +427,8 @@
 LocatedSymbol Located;
 Located.Name = (Sym.Name + Sym.TemplateSpecializationArgs).str();
 Located.PreferredDeclaration = bool(Sym

[PATCH] D84820: [WebAssembly] Implement prototype v128.load{32,64}_zero instructions

2020-07-30 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/include/llvm/IR/IntrinsicsWebAssembly.td:198
+[LLVMPointerType],
+[IntrReadMem, IntrArgMemOnly, IntrSpeculatable],
+ "", [SDNPMemOperand]>;

Can memory accesses be speculatable? The below too


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84820

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


[PATCH] D84902: [clang-tidy] Fix ODR violation in unittests.

2020-07-30 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.

LGTM, Thanks that bug was eating away at me for a good few days.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D84902

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


[PATCH] D84919: [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

2020-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:430
 Located.PreferredDeclaration = bool(Sym.Definition) ? DefLoc : DeclLoc;
-Located.Definition = DefLoc;
+if (Sym.Definition)
+  Located.Definition = DefLoc;

this is the 3rd time we are checking for `Sym.Definition`, what about moving 
the check on line 410 to down here? Then it would look something like this:

```
LocatedSymbol Located;
Located.PreferredDeclaration = DeclLoc;
if (Sym.Definition) {
  auto MaybeDefLoc = indexToLSPLocation(Sym.Definition, MainFilePath);
  if (!MaybeDefLoc) {
log("locateSymbolNamedTextuallyAt: {0}", MaybeDefLoc.takeError());
return;
  }
  Located.PreferredDeclaration = *MaybeDefLoc;
  Located.Definition = *MaybeDefLoc;
}
Located.Name = (Sym.Name + Sym.TemplateSpecializationArgs).str();
```



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:285
 ::testing::Matcher Sym(std::string Name, Range Decl) {
-  return Sym(Name, Decl, llvm::None);
+  return Sym(Name, Decl, Decl);
 }

i am not sure if this change is aligned with the whole idea. we are trying to 
make the matcher more explicit, so if user wants to assert on the definition 
being equal to some range I think they should be explicitly specifying it. so I 
believe this should keep passing `llvm::None` to underlying matcher.

I know it is likely more work than this version, but otherwise we are not 
really making it explicit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84919

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


[PATCH] D72932: [ARM] Follow AACPS standard for volatile bit-fields access width

2020-07-30 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio added a comment.

Ping ... ping...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72932

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


[PATCH] D84811: [clangd] Add an option to exclude symbols outside of project root from index

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



Comment at: clang-tools-extra/clangd/indexer/IndexerMain.cpp:112
+if (!IndexRoot.empty()) {
+  llvm::DenseSet ExcludeIDs;
+  for (const auto &Sym : *Result.Symbols)

I think we could reuse the `FileShardedIndex` to do the filtering job, rather 
than implementing a new one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84811

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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-07-30 Thread Simon Moll via Phabricator via cfe-commits
simoll updated this revision to Diff 281844.
simoll added a comment.

Updated clang test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/constexpr-vectors.cpp
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -331,8 +331,7 @@
 typedef __attribute__((ext_vector_type(4))) int vi4;
 const int &reference_to_vec_element = vi4(1).x;
 
-// PR12649
-typedef bool bad __attribute__((__vector_size__(16)));  // expected-error {{invalid vector element type 'bool'}}
+typedef bool good __attribute__((__vector_size__(16)));
 
 namespace Templates {
 template 
@@ -350,9 +349,7 @@
 void Init() {
   const TemplateVectorType::type Works = {};
   const TemplateVectorType::type Works2 = {};
-  // expected-error@#1 {{invalid vector element type 'bool'}}
-  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoBool = {};
+  const TemplateVectorType::type BoolWorks = {};
   // expected-error@#1 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
   const TemplateVectorType::type NoComplex = {};
Index: clang/test/SemaCXX/constexpr-vectors.cpp
===
--- clang/test/SemaCXX/constexpr-vectors.cpp
+++ clang/test/SemaCXX/constexpr-vectors.cpp
@@ -204,35 +204,35 @@
 
   constexpr auto w = FourCharsVecSize{1, 2, 3, 4} <
  FourCharsVecSize{4, 3, 2, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto x = FourCharsVecSize{1, 2, 3, 4} >
  FourCharsVecSize{4, 3, 2, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto y = FourCharsVecSize{1, 2, 3, 4} <=
  FourCharsVecSize{4, 3, 3, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto z = FourCharsVecSize{1, 2, 3, 4} >=
  FourCharsVecSize{4, 3, 3, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto A = FourCharsVecSize{1, 2, 3, 4} ==
  FourCharsVecSize{4, 3, 3, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto B = FourCharsVecSize{1, 2, 3, 4} !=
  FourCharsVecSize{4, 3, 3, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
 
   constexpr auto C = FourCharsVecSize{1, 2, 3, 4} < 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto D = FourCharsVecSize{1, 2, 3, 4} > 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto E = FourCharsVecSize{1, 2, 3, 4} <= 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto F = FourCharsVecSize{1, 2, 3, 4} >= 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto G = FourCharsVecSize{1, 2, 3, 4} == 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto H = FourCharsVecSize{1, 2, 3, 4} != 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
 
   constexpr auto I = FourCharsVecSize{1, 2, 3, 4} &
  FourCharsVecSize{4, 3, 2, 1};
@@ -252,15 +252,15 @@
 
   constexpr auto O = FourCharsVecSize{5, 0, 6, 0} &&
  FourCharsVecSize{5, 5, 0, 0};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto P = FourCharsVecSize{5, 0, 6, 0} ||
  FourCharsVecSize{5, 5, 0, 0};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
 
   constexpr auto Q = FourCharsVecSize{5, 0, 6, 0} && 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto R = FourCharsVecSize{5, 0, 6, 0} || 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
 
   constexpr auto T = CmpMul(a, b);
   // CHECK: store <4 x i8> 
Index: clang/lib/Sema/SemaType.cpp
==

[PATCH] D84924: [clang-tidy] Added command line option `fix-notes`

2020-07-30 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: alexfh, aaron.ballman, gribozavr2, Eugene.Zelenko, 
hokein.
Herald added subscribers: cfe-commits, arphaman, xazax.hun.
Herald added a project: clang.
njames93 requested review of this revision.

Added an option to control whether to apply the fixes found in notes attached 
to clang tidy errors or not.
Diagnostics may contain multiple notes each offering different ways to fix the 
issue, for that reason the default behaviour should be to not look at fixes 
found in notes.
Instead offer up all the available fix-its in the output but don't try to apply 
the first one unless `-fix-notes` is supplied.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84924

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidy.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/alternative-fixes.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s "llvm-namespace-comment,clang-diagnostic-*" %t
+// RUN: %check_clang_tidy %s "llvm-namespace-comment,clang-diagnostic-*" %t -- -fix-notes
 void foo(int a) {
   if (a = 1) {
   // CHECK-NOTES: [[@LINE-1]]:9: warning: using the result of an assignment as a condition without parentheses [clang-diagnostic-parentheses]
Index: clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
@@ -81,7 +81,6 @@
 // eol-comments aren't removed (yet)
 using n::A; // A
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'A' is unused
-// CHECK-MESSAGES: :[[@LINE-2]]:10: note: remove the using
 // CHECK-FIXES: {{^}}// A
 using n::B;
 using n::C;
Index: clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-definitions-in-headers.hpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t -- -fix-notes
 
 int f() {
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header file; function definitions in header files can lead to ODR violations [misc-definitions-in-headers]
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -170,6 +170,11 @@
  errors were found. If compiler errors have
  attached fix-its, clang-tidy will apply them as
  well.
+--fix-notes- 
+ If a warning has no fix, but has notes attached
+ which contain fixes, apply the first fix found
+ in any notes.
+ Requires -fix to be specified.
 --format-style=-
  Style for formatting code around applied fixes:
- 'none' (default) turns off formatting
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -67,7 +67,8 @@
 Improvements to clang-tidy
 --
 
-The improvements are...
+ - Added command line option `-fix-notes` to apply fixes found in notes
+   attached to warnings.
 
 Improvements to include-fixer
 -
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/

[PATCH] D84924: [clang-tidy][WIP] Added command line option `fix-notes`

2020-07-30 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

This is very much a work in progress


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84924

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


[clang-tools-extra] 45a720a - [clang-tidy] Use StringMap for ClangTidyOptions::OptionsMap

2020-07-30 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-07-30T10:31:13+01:00
New Revision: 45a720a864320bbbeb596abe412786fa91858980

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

LOG: [clang-tidy] Use StringMap for ClangTidyOptions::OptionsMap

Ordering of options isn't important so an `llvm::StringMap` is a much better 
container for this purpose.

Reviewed By: gribozavr2

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index d6913dfd3c07..63c83a0b9954 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -329,12 +329,11 @@ static void setStaticAnalyzerCheckerOpts(const 
ClangTidyOptions &Opts,
  AnalyzerOptionsRef AnalyzerOptions) {
   StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
   for (const auto &Opt : Opts.CheckOptions) {
-StringRef OptName(Opt.first);
-if (!OptName.startswith(AnalyzerPrefix))
+StringRef OptName(Opt.getKey());
+if (!OptName.consume_front(AnalyzerPrefix))
   continue;
 // Analyzer options are always local options so we can ignore priority.
-AnalyzerOptions->Config[OptName.substr(AnalyzerPrefix.size())] =
-Opt.second.Value;
+AnalyzerOptions->Config[OptName] = Opt.getValue().Value;
   }
 }
 

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index ffd5bf974ba2..737d85e092d9 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -72,7 +72,7 @@ llvm::Expected
 ClangTidyCheck::OptionsView::get(StringRef LocalName) const {
   const auto &Iter = CheckOptions.find(NamePrefix + LocalName.str());
   if (Iter != CheckOptions.end())
-return Iter->second.Value;
+return Iter->getValue().Value;
   return llvm::make_error((NamePrefix + LocalName).str());
 }
 
@@ -85,7 +85,7 @@ findPriorityOption(const ClangTidyOptions::OptionMap 
&Options, StringRef NamePre
 return IterGlobal;
   if (IterGlobal == Options.end())
 return IterLocal;
-  if (IterLocal->second.Priority >= IterGlobal->second.Priority)
+  if (IterLocal->getValue().Priority >= IterGlobal->getValue().Priority)
 return IterLocal;
   return IterGlobal;
 }
@@ -94,7 +94,7 @@ llvm::Expected
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
   auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName);
   if (Iter != CheckOptions.end())
-return Iter->second.Value;
+return Iter->getValue().Value;
   return llvm::make_error((NamePrefix + LocalName).str());
 }
 
@@ -135,7 +135,7 @@ llvm::Expected
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const 
{
   auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName);
   if (Iter != CheckOptions.end())
-return getAsBool(Iter->second.Value, Iter->first);
+return getAsBool(Iter->getValue().Value, Iter->getKey());
   return llvm::make_error((NamePrefix + LocalName).str());
 }
 
@@ -177,7 +177,7 @@ llvm::Expected 
ClangTidyCheck::OptionsView::getEnumInt(
   if (Iter == CheckOptions.end())
 return llvm::make_error((NamePrefix + 
LocalName).str());
 
-  StringRef Value = Iter->second.Value;
+  StringRef Value = Iter->getValue().Value;
   StringRef Closest;
   unsigned EditDistance = -1;
   for (const auto &NameAndEnum : Mapping) {
@@ -199,9 +199,9 @@ llvm::Expected 
ClangTidyCheck::OptionsView::getEnumInt(
   }
   if (EditDistance < 3)
 return llvm::make_error(
-Iter->first, Iter->second.Value, std::string(Closest));
-  return llvm::make_error(Iter->first,
-  Iter->second.Value);
+Iter->getKey().str(), Iter->getValue().Value, Closest.str());
+  return llvm::make_error(Iter->getKey().str(),
+  Iter->getValue().Value);
 }
 
 void ClangTidyCheck::OptionsView::logErrToStdErr(llvm::Error &&Err) {

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index bb5a4b513967..19ba47f005dc 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -70,7 +70,7 @@ struct NOptionMap {
   NOptionMap(IO &, const ClangTidyOptions::OptionMa

[PATCH] D84868: [clang-tidy] Use StringMap for ClangTidyOptions::OptionsMap

2020-07-30 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45a720a86432: [clang-tidy] Use StringMap for 
ClangTidyOptions::OptionsMap (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84868

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -17,14 +17,10 @@
 // For this test we have to use names of the real checks because otherwise values are ignored.
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD4
 // CHECK-CHILD4: Checks: {{.*}}modernize-loop-convert,modernize-use-using,llvm-qualified-auto
-// CHECK-CHILD4: - key: llvm-qualified-auto.AddConstToQualified
-// CHECK-CHILD4-NEXT: value: 'true'
-// CHECK-CHILD4: - key: modernize-loop-convert.MaxCopySize
-// CHECK-CHILD4-NEXT: value: '20'
-// CHECK-CHILD4: - key: modernize-loop-convert.MinConfidence
-// CHECK-CHILD4-NEXT: value: reasonable
-// CHECK-CHILD4: - key: modernize-use-using.IgnoreMacros
-// CHECK-CHILD4-NEXT: value: 'false'
+// CHECK-CHILD4-DAG: - key: llvm-qualified-auto.AddConstToQualified{{ *[[:space:]] *}}value: 'true'
+// CHECK-CHILD4-DAG: - key: modernize-loop-convert.MaxCopySize{{ *[[:space:]] *}}value: '20'
+// CHECK-CHILD4-DAG: - key: modernize-loop-convert.MinConfidence{{ *[[:space:]] *}}value: reasonable
+// CHECK-CHILD4-DAG: - key: modernize-use-using.IgnoreMacros{{ *[[:space:]] *}}value: 'false'
 
 // RUN: clang-tidy --explain-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-EXPLAIN
 // CHECK-EXPLAIN: 'llvm-qualified-auto' is enabled in the {{.*}}{{[/\\]}}Inputs{{[/\\]}}config-files{{[/\\]}}4{{[/\\]}}44{{[/\\]}}.clang-tidy.
@@ -37,16 +33,13 @@
 // RUN: CheckOptions: [{key: modernize-loop-convert.MaxCopySize, value: 21}]}' \
 // RUN: %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD5
 // CHECK-CHILD5: Checks: {{.*}}modernize-loop-convert,modernize-use-using,llvm-qualified-auto,-llvm-qualified-auto
-// CHECK-CHILD5: - key: modernize-loop-convert.MaxCopySize
-// CHECK-CHILD5-NEXT: value: '21'
-// CHECK-CHILD5: - key: modernize-loop-convert.MinConfidence
-// CHECK-CHILD5-NEXT: value: reasonable
-// CHECK-CHILD5: - key: modernize-use-using.IgnoreMacros
-// CHECK-CHILD5-NEXT: value: 'false'
+// CHECK-CHILD5-DAG: - key: modernize-loop-convert.MaxCopySize{{ *[[:space:]] *}}value: '21'
+// CHECK-CHILD5-DAG: - key: modernize-loop-convert.MinConfidence{{ *[[:space:]] *}}value: reasonable
+// CHECK-CHILD5-DAG: - key: modernize-use-using.IgnoreMacros{{ *[[:space:]] *}}value: 'false'
 
 // RUN: clang-tidy -dump-config \
 // RUN: --config='{InheritParentConfig: false, \
 // RUN: Checks: -llvm-qualified-auto}' \
 // RUN: %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD6
-// CHECK-CHILD6: Checks: {{.*}}-llvm-qualified-auto
+// CHECK-CHILD6: Checks: {{.*-llvm-qualified-auto'? *$}}
 // CHECK-CHILD6-NOT: - key: modernize-use-using.IgnoreMacros
Index: clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
@@ -1,10 +1,6 @@
 // RUN: clang-tidy -checks='-*,google*' -config='{}' -dump-config - -- | FileCheck %s
 // CHECK: CheckOptions:
-// CHECK: {{- key: *google-readability-braces-around-statements.ShortStatementLines}}
-// CHECK-NEXT: {{value: *'1'}}
-// CHECK: {{- key: *google-readability-function-size.StatementThreshold}}
-// CHECK-NEXT: {{value: *'800'}}
-// CHECK: {{- key: *google-readability-namespace-comments.ShortNamespaceLines}}
-// CHECK-NEXT: {{value: *'10'}}
-// CHECK: {{- key: *google-readability-namespace-comments.SpacesBeforeComments}}
-// CHECK-NEXT: {{value: *'2'}}
+// CHECK-DAG: {{- key: *google-readability-braces-around-statements.ShortStatementLines *[[:space:]] *value: *'1'}}
+// CHECK-DAG: {{- key: *google-readability-function-size.StatementThreshold *[[:space:]] *value: *'800'}}
+// CHECK-DAG: {{- key: *google-readability-namespace-comments.ShortNamespaceLines *[[:space:]] *value: *'10'}}
+// CHECK-DAG: {{- key: *google-readability-namespace-comments.SpacesBeforeComments *[[:space:]] *value: *'2'}}
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
==

[PATCH] D84912: [clangd] findNearbyIdentifier(): fix the word search in the token stream.

2020-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks for catching this, LGTM! This might still end up traversing the whole 
file in non-existent cases, but I suppose that's an adventure for another day.

I think we should also cherry-pick this into release branch. I've filed 
https://bugs.llvm.org/show_bug.cgi?id=46905 for cherry-picking please update 
the bug
with the commit hash once you land the fix (or let me know if you don't have an 
account in bugzilla)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84912

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


[PATCH] D84898: [clang-tidy] Add new checker for complex conditions with no meaning

2020-07-30 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

Thanks all for the prompt and actionable comments. I will address all comments 
directly and 1-1, but would like to bottom out on one point before driving this 
forward. @lebedev.ri commented this should be in the Clang front end rather 
than a tidy check. Can we reach a consensus on that comment before I proceed 
with either a tidy check renamed to bugprone (comment from @Eugene.Zelenko ) or 
implement this check in the front end, enabled only when all warnings are 
enabled? I had considered both approaches when I started this, and thought the 
tidy checker was the best first step.

Also, @njames93, I take your point the expression does have a mathematical 
meaning. I was following the gcc warning message for the same expression, but 
we can cast the warning however we like :) Do you have a suggestion about the 
warning? I like the general idea of a suggestion to use parenthesis to remove 
the ambiguity.

Thanks! - Vince


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84898

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


[PATCH] D84912: [clangd] findNearbyIdentifier(): fix the word search in the token stream.

2020-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

oh and also, how did you notice the discrepancy? was it a random encounter 
while reading the code or did you notice a misbehaviour?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84912

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


[PATCH] D84811: [clangd] Add an option to exclude symbols outside of project root from index

2020-07-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/indexer/IndexerMain.cpp:112
+if (!IndexRoot.empty()) {
+  llvm::DenseSet ExcludeIDs;
+  for (const auto &Sym : *Result.Symbols)

hokein wrote:
> I think we could reuse the `FileShardedIndex` to do the filtering job, rather 
> than implementing a new one.
Ah, this is interesting, I haven't seen `FileShardedIndex` before, let me take 
a look at its API, it looks like a convenient piece of infrastructure for 
implementing this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84811

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


[PATCH] D84919: [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

2020-07-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 281852.
hokein added a comment.

address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84919

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -41,6 +41,7 @@
 using ::testing::Eq;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
+using ::testing::UnorderedElementsAre;
 using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P2(FileRange, File, Range, "") {
@@ -264,18 +265,24 @@
  << llvm::to_string(arg.PreferredDeclaration);
 return false;
   }
+  if (!Def && !arg.Definition)
+return true;
   if (Def && !arg.Definition) {
 *result_listener << "Has no definition";
 return false;
   }
-  if (Def && arg.Definition->range != *Def) {
+  if (!Def && arg.Definition) {
+*result_listener << "Definition is " << llvm::to_string(arg.Definition);
+return false;
+  }
+  if (arg.Definition->range != *Def) {
 *result_listener << "Definition is " << llvm::to_string(arg.Definition);
 return false;
   }
   return true;
 }
 ::testing::Matcher Sym(std::string Name, Range Decl) {
-  return Sym(Name, Decl, llvm::None);
+  return Sym(Name, Decl, Decl);
 }
 MATCHER_P(Sym, Name, "") { return arg.Name == Name; }
 
@@ -891,18 +898,20 @@
   // FIXME: Target the constructor as well.
   EXPECT_THAT(locateSymbolAt(AST, T.point("9")), ElementsAre(Sym("Foo")));
   EXPECT_THAT(locateSymbolAt(AST, T.point("10")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   EXPECT_THAT(locateSymbolAt(AST, T.point("11")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   // These assertions are unordered because the order comes from
   // CXXRecordDecl::lookupDependentName() which doesn't appear to provide
   // an order guarantee.
   EXPECT_THAT(locateSymbolAt(AST, T.point("12")),
-  UnorderedElementsAre(Sym("bar", T.range("NonstaticOverload1")),
-   Sym("bar", T.range("NonstaticOverload2";
-  EXPECT_THAT(locateSymbolAt(AST, T.point("13")),
-  UnorderedElementsAre(Sym("baz", T.range("StaticOverload1")),
-   Sym("baz", T.range("StaticOverload2";
+  UnorderedElementsAre(
+  Sym("bar", T.range("NonstaticOverload1"), llvm::None),
+  Sym("bar", T.range("NonstaticOverload2"), llvm::None)));
+  EXPECT_THAT(
+  locateSymbolAt(AST, T.point("13")),
+  UnorderedElementsAre(Sym("baz", T.range("StaticOverload1"), llvm::None),
+   Sym("baz", T.range("StaticOverload2"), llvm::None)));
 }
 
 TEST(LocateSymbol, TextualDependent) {
@@ -932,9 +941,10 @@
   // interaction between locateASTReferent() and
   // locateSymbolNamedTextuallyAt().
   auto Results = locateSymbolAt(AST, Source.point(), Index.get());
-  EXPECT_THAT(Results, UnorderedElementsAre(
-   Sym("uniqueMethodName", Header.range("FooLoc")),
-   Sym("uniqueMethodName", Header.range("BarLoc";
+  EXPECT_THAT(Results,
+  UnorderedElementsAre(
+  Sym("uniqueMethodName", Header.range("FooLoc"), llvm::None),
+  Sym("uniqueMethodName", Header.range("BarLoc"), llvm::None)));
 }
 
 TEST(LocateSymbol, TemplateTypedefs) {
@@ -1112,7 +1122,7 @@
   // stale one.
   EXPECT_THAT(
   cantFail(runLocateSymbolAt(Server, FooCpp, FooWithoutHeader.point())),
-  ElementsAre(Sym("foo", FooWithoutHeader.range(;
+  ElementsAre(Sym("foo", FooWithoutHeader.range(), llvm::None)));
 
   // Reset test environment.
   runAddDocument(Server, FooCpp, FooWithHeader.code());
@@ -1122,7 +1132,7 @@
   // Use the AST being built in above request.
   EXPECT_THAT(
   cantFail(runLocateSymbolAt(Server, FooCpp, FooWithoutHeader.point())),
-  ElementsAre(Sym("foo", FooWithoutHeader.range(;
+  ElementsAre(Sym("foo", FooWithoutHeader.range(), llvm::None)));
 }
 
 TEST(LocateSymbol, NearbyTokenSmoke) {
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -405,15 +405,17 @@
   log("locateSymbolNamedTextuallyAt: {0}", MaybeDeclLoc.takeError());
   return;
 }
-Location DeclLoc = *MaybeDeclLoc;
-Location DefLoc;
+LocatedSymbol Located;
+Located.PreferredDeclaration = *MaybeDeclLoc;
+Located.Name = (Sym.Name + Sym.TemplateSpecializationA

[PATCH] D84912: [clangd] findNearbyIdentifier(): fix the word search in the token stream.

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

In D84912#2184147 , @kadircet wrote:

> oh and also, how did you notice the discrepancy? was it a random encounter 
> while reading the code or did you notice a misbehaviour?

Case was like this

  void f1(int [[paramValue]]){
  }
  
  void f2(int paramValue){
  }
  
  void f3(int paramValue){
  }
  
  void f4(int paramValue){
  // param^Value
  }

Because of
floor(log2(8)) = floor(log2(8)) ... = floor(log2(15)) = 3


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84912

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


[PATCH] D84919: [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

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



Comment at: clang-tools-extra/clangd/XRefs.cpp:430
 Located.PreferredDeclaration = bool(Sym.Definition) ? DefLoc : DeclLoc;
-Located.Definition = DefLoc;
+if (Sym.Definition)
+  Located.Definition = DefLoc;

kadircet wrote:
> this is the 3rd time we are checking for `Sym.Definition`, what about moving 
> the check on line 410 to down here? Then it would look something like this:
> 
> ```
> LocatedSymbol Located;
> Located.PreferredDeclaration = DeclLoc;
> if (Sym.Definition) {
>   auto MaybeDefLoc = indexToLSPLocation(Sym.Definition, MainFilePath);
>   if (!MaybeDefLoc) {
> log("locateSymbolNamedTextuallyAt: {0}", MaybeDefLoc.takeError());
> return;
>   }
>   Located.PreferredDeclaration = *MaybeDefLoc;
>   Located.Definition = *MaybeDefLoc;
> }
> Located.Name = (Sym.Name + Sym.TemplateSpecializationArgs).str();
> ```
good point.



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:285
 ::testing::Matcher Sym(std::string Name, Range Decl) {
-  return Sym(Name, Decl, llvm::None);
+  return Sym(Name, Decl, Decl);
 }

kadircet wrote:
> i am not sure if this change is aligned with the whole idea. we are trying to 
> make the matcher more explicit, so if user wants to assert on the definition 
> being equal to some range I think they should be explicitly specifying it. so 
> I believe this should keep passing `llvm::None` to underlying matcher.
> 
> I know it is likely more work than this version, but otherwise we are not 
> really making it explicit.
yeah, it seems odd. I think this function is used as a syntax sugar to check 
`LocatedSymbol` has the *same* decl/def range, most callers have this 
assumptions.

options:

1. keeps it as is, and rename it to something like `SymWithSameDeclDefRange` (a 
better name is welcome);
2. remove it, and use the 3-arg matcher above, callers have to be more verbose 
(passing decl/def ranges explicitly, even they are the same), and we have 15 
references;

1 is my preference, what do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84919

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


[PATCH] D84912: [clangd] findNearbyIdentifier(): fix the word search in the token stream.

2020-07-30 Thread Aleksandr Platonov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05b173466142: [clangd] findNearbyIdentifier(): fix the word 
search in the token stream. (authored by ArcsinX).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84912

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


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1197,7 +1197,14 @@
 
   // h^i
 )cpp",
-  };
+  R"cpp(
+  // prefer nearest occurrence even if several matched tokens
+  // have the same value of `floor(log2( - ))`.
+  int hello;
+  int x = hello, y = hello;
+  int z = [[hello]];
+  // h^ello
+)cpp"};
   for (const char *Test : Tests) {
 Annotations T(Test);
 auto AST = TestTU::withCode(T.code()).build();
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -518,7 +518,7 @@
   // Find where the word occurred in the token stream, to search forward & 
back.
   auto *I = llvm::partition_point(SpelledTokens, [&](const syntax::Token &T) {
 assert(SM.getFileID(T.location()) == SM.getFileID(Word.Location));
-return T.location() >= Word.Location; // Comparison OK: same file.
+return T.location() < Word.Location; // Comparison OK: same file.
   });
   // Search for matches after the cursor.
   for (const syntax::Token &Tok : llvm::makeArrayRef(I, SpelledTokens.end()))


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1197,7 +1197,14 @@
 
   // h^i
 )cpp",
-  };
+  R"cpp(
+  // prefer nearest occurrence even if several matched tokens
+  // have the same value of `floor(log2( - ))`.
+  int hello;
+  int x = hello, y = hello;
+  int z = [[hello]];
+  // h^ello
+)cpp"};
   for (const char *Test : Tests) {
 Annotations T(Test);
 auto AST = TestTU::withCode(T.code()).build();
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -518,7 +518,7 @@
   // Find where the word occurred in the token stream, to search forward & back.
   auto *I = llvm::partition_point(SpelledTokens, [&](const syntax::Token &T) {
 assert(SM.getFileID(T.location()) == SM.getFileID(Word.Location));
-return T.location() >= Word.Location; // Comparison OK: same file.
+return T.location() < Word.Location; // Comparison OK: same file.
   });
   // Search for matches after the cursor.
   for (const syntax::Token &Tok : llvm::makeArrayRef(I, SpelledTokens.end()))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 05b1734 - [clangd] findNearbyIdentifier(): fix the word search in the token stream.

2020-07-30 Thread Aleksandr Platonov via cfe-commits

Author: Aleksandr Platonov
Date: 2020-07-30T12:45:58+03:00
New Revision: 05b173466142596b3297ab02e423574cb74b3799

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

LOG: [clangd] findNearbyIdentifier(): fix the word search in the token stream.

Without this patch the word occurrence search always returns the first token of 
the file.
Despite of that, `findNeardyIdentifier()` returns the correct result (but 
inefficently) until there are several matched tokens with the same value 
`floor(log2( - ))` (e.g. several matched tokens on the 
same line).

Reviewed By: kadircet

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index aeff7ebc32a2..cf747b607f4a 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -518,7 +518,7 @@ const syntax::Token *findNearbyIdentifier(const SpelledWord 
&Word,
   // Find where the word occurred in the token stream, to search forward & 
back.
   auto *I = llvm::partition_point(SpelledTokens, [&](const syntax::Token &T) {
 assert(SM.getFileID(T.location()) == SM.getFileID(Word.Location));
-return T.location() >= Word.Location; // Comparison OK: same file.
+return T.location() < Word.Location; // Comparison OK: same file.
   });
   // Search for matches after the cursor.
   for (const syntax::Token &Tok : llvm::makeArrayRef(I, SpelledTokens.end()))

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 0428303f5b0a..0a8f85ed5317 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1197,7 +1197,14 @@ TEST(LocateSymbol, NearbyIdentifier) {
 
   // h^i
 )cpp",
-  };
+  R"cpp(
+  // prefer nearest occurrence even if several matched tokens
+  // have the same value of `floor(log2( - ))`.
+  int hello;
+  int x = hello, y = hello;
+  int z = [[hello]];
+  // h^ello
+)cpp"};
   for (const char *Test : Tests) {
 Annotations T(Test);
 auto AST = TestTU::withCode(T.code()).build();



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


[PATCH] D84912: [clangd] findNearbyIdentifier(): fix the word search in the token stream.

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

In D84912#2184144 , @kadircet wrote:

> I think we should also cherry-pick this into release branch. I've filed 
> https://bugs.llvm.org/show_bug.cgi?id=46905 for cherry-picking please update 
> the bug
> with the commit hash once you land the fix (or let me know if you don't have 
> an account in bugzilla)

I do not have bugzilla account, so could you please do this for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84912

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


[PATCH] D84926: [clang-tidy][NFC] Use StringMap for ClangTidyCheckFactories::FacoryMap

2020-07-30 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84926

Files:
  clang-tools-extra/clang-tidy/ClangTidyModule.cpp
  clang-tools-extra/clang-tidy/ClangTidyModule.h


Index: clang-tools-extra/clang-tidy/ClangTidyModule.h
===
--- clang-tools-extra/clang-tidy/ClangTidyModule.h
+++ clang-tools-extra/clang-tidy/ClangTidyModule.h
@@ -69,7 +69,7 @@
   std::vector>
   createChecks(ClangTidyContext *Context);
 
-  typedef std::map FactoryMap;
+  typedef llvm::StringMap FactoryMap;
   FactoryMap::const_iterator begin() const { return Factories.begin(); }
   FactoryMap::const_iterator end() const { return Factories.end(); }
   bool empty() const { return Factories.empty(); }
Index: clang-tools-extra/clang-tidy/ClangTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyModule.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyModule.cpp
@@ -18,15 +18,15 @@
 
 void ClangTidyCheckFactories::registerCheckFactory(StringRef Name,
CheckFactory Factory) {
-  Factories[std::string(Name)] = std::move(Factory);
+  Factories.insert_or_assign(Name, std::move(Factory));
 }
 
 std::vector>
 ClangTidyCheckFactories::createChecks(ClangTidyContext *Context) {
   std::vector> Checks;
   for (const auto &Factory : Factories) {
-if (Context->isCheckEnabled(Factory.first))
-  Checks.emplace_back(Factory.second(Factory.first, Context));
+if (Context->isCheckEnabled(Factory.getKey()))
+  Checks.emplace_back(Factory.getValue()(Factory.getKey(), Context));
   }
   return Checks;
 }


Index: clang-tools-extra/clang-tidy/ClangTidyModule.h
===
--- clang-tools-extra/clang-tidy/ClangTidyModule.h
+++ clang-tools-extra/clang-tidy/ClangTidyModule.h
@@ -69,7 +69,7 @@
   std::vector>
   createChecks(ClangTidyContext *Context);
 
-  typedef std::map FactoryMap;
+  typedef llvm::StringMap FactoryMap;
   FactoryMap::const_iterator begin() const { return Factories.begin(); }
   FactoryMap::const_iterator end() const { return Factories.end(); }
   bool empty() const { return Factories.empty(); }
Index: clang-tools-extra/clang-tidy/ClangTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyModule.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyModule.cpp
@@ -18,15 +18,15 @@
 
 void ClangTidyCheckFactories::registerCheckFactory(StringRef Name,
CheckFactory Factory) {
-  Factories[std::string(Name)] = std::move(Factory);
+  Factories.insert_or_assign(Name, std::move(Factory));
 }
 
 std::vector>
 ClangTidyCheckFactories::createChecks(ClangTidyContext *Context) {
   std::vector> Checks;
   for (const auto &Factory : Factories) {
-if (Context->isCheckEnabled(Factory.first))
-  Checks.emplace_back(Factory.second(Factory.first, Context));
+if (Context->isCheckEnabled(Factory.getKey()))
+  Checks.emplace_back(Factory.getValue()(Factory.getKey(), Context));
   }
   return Checks;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84894: [clangd] Implement Relations request for remote index

2020-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

thanks mostly nits, only annoying bit is usage of optionals and multi-logging 
but letting them be for now :D.

also looks like there are some irrelevant changes, e.g. auto's in lambdas or 
formatting in protos, feel free to land an NFC change(without review) for those 
before landing this.




Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:382
+
+  auto Serialized = ProtobufMarshaller.toProtobuf(Request);
+  // Not a valid SymbolID.

nit: why not just do:
```
RelationsRequest Serialized;
Serialized.add_subjects("");
// check for failure during deserialization
```



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:391
+TEST(RemoteMarshallingTest, RelationsSerializion) {
+  clangd::Symbol Sym;
+  SymbolID ID = llvm::cantFail(SymbolID::fromStr("0001"));

nit: move it near `Sym.ID` assignemnt.



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:395
+
+  Sym.ID = llvm::cantFail(SymbolID::fromStr("0002"));
+

nit: I would move all of the following population logic into a helper and share 
between here and symbol serialization tests.



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:420
+  ASSERT_TRUE(Deserialized);
+  EXPECT_EQ(ID, Deserialized->first);
+  Sym.CanonicalDeclaration.FileURI = testPathURI(

nit: swap parameters `ID` is expected, `Deserialized->first` is actual.



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:423
+  "local/llvm-project/llvm/clang-tools-extra/clangd/Protocol.h", Strings);
+  EXPECT_EQ(toYAML(Sym), toYAML(Deserialized->second));
+

i think this is already tested in symbol deserialization test above, feel free 
to leave it out.



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:425
+
+  *Serialized->mutable_subject_id() = "Not A Symbol ID";
+  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(*Serialized));

again this should be part of symbol serialization tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84894

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


[PATCH] D84919: [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

2020-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:285
 ::testing::Matcher Sym(std::string Name, Range Decl) {
-  return Sym(Name, Decl, llvm::None);
+  return Sym(Name, Decl, Decl);
 }

hokein wrote:
> kadircet wrote:
> > i am not sure if this change is aligned with the whole idea. we are trying 
> > to make the matcher more explicit, so if user wants to assert on the 
> > definition being equal to some range I think they should be explicitly 
> > specifying it. so I believe this should keep passing `llvm::None` to 
> > underlying matcher.
> > 
> > I know it is likely more work than this version, but otherwise we are not 
> > really making it explicit.
> yeah, it seems odd. I think this function is used as a syntax sugar to check 
> `LocatedSymbol` has the *same* decl/def range, most callers have this 
> assumptions.
> 
> options:
> 
> 1. keeps it as is, and rename it to something like `SymWithSameDeclDefRange` 
> (a better name is welcome);
> 2. remove it, and use the 3-arg matcher above, callers have to be more 
> verbose (passing decl/def ranges explicitly, even they are the same), and we 
> have 15 references;
> 
> 1 is my preference, what do you think?
> yeah, it seems odd. I think this function is used as a syntax sugar to check 
> LocatedSymbol has the *same* decl/def range, most callers have this 
> assumptions.

my reading of the previous state was:

the real matcher treated `llvm::None` on the last parameter as a `Dont care`, 
it was basically ignoring the definition. hence the two parameter version was 
used in places where people didn't care about definition range (or even its 
existence). so this patch is changing the behaviour of this two parameter 
version from `don't care` to `make sure they are equal`, i am not saying that's 
a bad thing but it just feels like more implicit (which is against the idea of 
the patch).

> keeps it as is, and rename it to something like SymWithSameDeclDefRange (a 
> better name is welcome);

renaming would be one way of dealing with implicitness here. i am just not sure 
if it is really worth it though. I don't really think the existing call sites 
had the idea of `make sure def and decl range are identical` in mind. so I 
would opt for 2nd option you proposed if that's ok with you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84919

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


[PATCH] D84926: [clang-tidy][NFC] Use StringMap for ClangTidyCheckFactories::FacoryMap

2020-07-30 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 281862.
njames93 added a comment.

Fix build errors


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84926

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyModule.cpp
  clang-tools-extra/clang-tidy/ClangTidyModule.h


Index: clang-tools-extra/clang-tidy/ClangTidyModule.h
===
--- clang-tools-extra/clang-tidy/ClangTidyModule.h
+++ clang-tools-extra/clang-tidy/ClangTidyModule.h
@@ -69,7 +69,7 @@
   std::vector>
   createChecks(ClangTidyContext *Context);
 
-  typedef std::map FactoryMap;
+  typedef llvm::StringMap FactoryMap;
   FactoryMap::const_iterator begin() const { return Factories.begin(); }
   FactoryMap::const_iterator end() const { return Factories.end(); }
   bool empty() const { return Factories.empty(); }
Index: clang-tools-extra/clang-tidy/ClangTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyModule.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyModule.cpp
@@ -18,15 +18,15 @@
 
 void ClangTidyCheckFactories::registerCheckFactory(StringRef Name,
CheckFactory Factory) {
-  Factories[std::string(Name)] = std::move(Factory);
+  Factories.insert_or_assign(Name, std::move(Factory));
 }
 
 std::vector>
 ClangTidyCheckFactories::createChecks(ClangTidyContext *Context) {
   std::vector> Checks;
   for (const auto &Factory : Factories) {
-if (Context->isCheckEnabled(Factory.first))
-  Checks.emplace_back(Factory.second(Factory.first, Context));
+if (Context->isCheckEnabled(Factory.getKey()))
+  Checks.emplace_back(Factory.getValue()(Factory.getKey(), Context));
   }
   return Checks;
 }
Index: clang-tools-extra/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -450,8 +450,8 @@
 std::vector ClangTidyASTConsumerFactory::getCheckNames() {
   std::vector CheckNames;
   for (const auto &CheckFactory : *CheckFactories) {
-if (Context.isCheckEnabled(CheckFactory.first))
-  CheckNames.push_back(CheckFactory.first);
+if (Context.isCheckEnabled(CheckFactory.getKey()))
+  CheckNames.emplace_back(CheckFactory.getKey());
   }
 
 #if CLANG_ENABLE_STATIC_ANALYZER


Index: clang-tools-extra/clang-tidy/ClangTidyModule.h
===
--- clang-tools-extra/clang-tidy/ClangTidyModule.h
+++ clang-tools-extra/clang-tidy/ClangTidyModule.h
@@ -69,7 +69,7 @@
   std::vector>
   createChecks(ClangTidyContext *Context);
 
-  typedef std::map FactoryMap;
+  typedef llvm::StringMap FactoryMap;
   FactoryMap::const_iterator begin() const { return Factories.begin(); }
   FactoryMap::const_iterator end() const { return Factories.end(); }
   bool empty() const { return Factories.empty(); }
Index: clang-tools-extra/clang-tidy/ClangTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyModule.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyModule.cpp
@@ -18,15 +18,15 @@
 
 void ClangTidyCheckFactories::registerCheckFactory(StringRef Name,
CheckFactory Factory) {
-  Factories[std::string(Name)] = std::move(Factory);
+  Factories.insert_or_assign(Name, std::move(Factory));
 }
 
 std::vector>
 ClangTidyCheckFactories::createChecks(ClangTidyContext *Context) {
   std::vector> Checks;
   for (const auto &Factory : Factories) {
-if (Context->isCheckEnabled(Factory.first))
-  Checks.emplace_back(Factory.second(Factory.first, Context));
+if (Context->isCheckEnabled(Factory.getKey()))
+  Checks.emplace_back(Factory.getValue()(Factory.getKey(), Context));
   }
   return Checks;
 }
Index: clang-tools-extra/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -450,8 +450,8 @@
 std::vector ClangTidyASTConsumerFactory::getCheckNames() {
   std::vector CheckNames;
   for (const auto &CheckFactory : *CheckFactories) {
-if (Context.isCheckEnabled(CheckFactory.first))
-  CheckNames.push_back(CheckFactory.first);
+if (Context.isCheckEnabled(CheckFactory.getKey()))
+  CheckNames.emplace_back(CheckFactory.getKey());
   }
 
 #if CLANG_ENABLE_STATIC_ANALYZER
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84894: [clangd] Implement Relations request for remote index

2020-07-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 281863.
kbobyrev marked 6 inline comments as done.
kbobyrev added a comment.

Address all comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84894

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -10,6 +10,7 @@
 #include "TestFS.h"
 #include "index/Index.h"
 #include "index/Ref.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
 #include "index/SymbolID.h"
@@ -18,6 +19,7 @@
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"
@@ -38,6 +40,51 @@
   return Strings.save(URI.toString()).begin();
 }
 
+clangd::Symbol createSymbol(llvm::StringRef PathPrefix,
+llvm::UniqueStringSaver &Strings) {
+  clangd::Symbol Sym;
+  Sym.ID = llvm::cantFail(SymbolID::fromStr("057557CEBF6E6B2D"));
+
+  index::SymbolInfo Info;
+  Info.Kind = index::SymbolKind::Function;
+  Info.SubKind = index::SymbolSubKind::AccessorGetter;
+  Info.Lang = index::SymbolLanguage::CXX;
+  Info.Properties = static_cast(
+  index::SymbolProperty::TemplateSpecialization);
+  Sym.SymInfo = Info;
+
+  Sym.Name = Strings.save("Foo");
+  Sym.Scope = Strings.save("llvm::foo::bar::");
+
+  clangd::SymbolLocation Location;
+  Location.Start.setLine(1);
+  Location.Start.setColumn(15);
+  Location.End.setLine(3);
+  Location.End.setColumn(121);
+  Location.FileURI = testPathURI(PathPrefix.str() + "Definition.cpp", Strings);
+  Sym.Definition = Location;
+
+  Location.Start.setLine(42);
+  Location.Start.setColumn(31);
+  Location.End.setLine(20);
+  Location.End.setColumn(400);
+  Location.FileURI = testPathURI(PathPrefix.str() + "Declaration.h", Strings);
+  Sym.CanonicalDeclaration = Location;
+
+  Sym.References = 9000;
+  Sym.Origin = clangd::SymbolOrigin::Static;
+  Sym.Signature = Strings.save("(int X, char Y, Type T)");
+  Sym.TemplateSpecializationArgs = Strings.save("");
+  Sym.CompletionSnippetSuffix =
+  Strings.save("({1: int X}, {2: char Y}, {3: Type T})");
+  Sym.Documentation = Strings.save("This is my amazing Foo constructor!");
+  Sym.ReturnType = Strings.save("Foo");
+
+  Sym.Flags = clangd::Symbol::SymbolFlag::IndexedForCodeCompletion;
+
+  return Sym;
+}
+
 TEST(RemoteMarshallingTest, URITranslation) {
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
@@ -86,52 +133,10 @@
 }
 
 TEST(RemoteMarshallingTest, SymbolSerialization) {
-  clangd::Symbol Sym;
-
-  auto ID = SymbolID::fromStr("057557CEBF6E6B2D");
-  ASSERT_TRUE(bool(ID));
-  Sym.ID = *ID;
-
-  index::SymbolInfo Info;
-  Info.Kind = index::SymbolKind::Function;
-  Info.SubKind = index::SymbolSubKind::AccessorGetter;
-  Info.Lang = index::SymbolLanguage::CXX;
-  Info.Properties = static_cast(
-  index::SymbolProperty::TemplateSpecialization);
-  Sym.SymInfo = Info;
-
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
 
-  Sym.Name = Strings.save("Foo");
-  Sym.Scope = Strings.save("llvm::foo::bar::");
-
-  clangd::SymbolLocation Location;
-  Location.Start.setLine(1);
-  Location.Start.setColumn(15);
-  Location.End.setLine(3);
-  Location.End.setColumn(121);
-  Location.FileURI = testPathURI("home/Definition.cpp", Strings);
-  Sym.Definition = Location;
-
-  Location.Start.setLine(42);
-  Location.Start.setColumn(31);
-  Location.End.setLine(20);
-  Location.End.setColumn(400);
-  Location.FileURI = testPathURI("home/Declaration.h", Strings);
-  Sym.CanonicalDeclaration = Location;
-
-  Sym.References = 9000;
-  Sym.Origin = clangd::SymbolOrigin::Static;
-  Sym.Signature = Strings.save("(int X, char Y, Type T)");
-  Sym.TemplateSpecializationArgs = Strings.save("");
-  Sym.CompletionSnippetSuffix =
-  Strings.save("({1: int X}, {2: char Y}, {3: Type T})");
-  Sym.Documentation = Strings.save("This is my amazing Foo constructor!");
-  Sym.ReturnType = Strings.save("Foo");
-
-  Sym.Flags = clangd::Symbol::SymbolFlag::IndexedForCodeCompletion;
-
+  clangd::Symbol Sym = createSymbol("home/", Strings);
   Marshaller ProtobufMarshaller(testPath("home/"), testPath("home/"));
 
   // Check that symbols are exactly the same if the path to indexed project is
@@ -

[PATCH] D84929: [analyzer] Fix out-of-tree only clang build by not relaying on private header

2020-07-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, mgorny, xazax.hun, Szelethus, martong, balazske.
Herald added subscribers: llvm-commits, cfe-commits, ASDenysPetrov, Charusso, 
dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware, whisperity.
Herald added projects: clang, LLVM.
steakhal requested review of this revision.

It turned out that the D78704  included a 
private LLVM header, which is excluded from the LLVM install target.
I'm substituting that `#include` with the public one by moving the necessary 
`#define` into that.
There was a discussion about this at D78704  
and on the cfe-dev 
 mailing list.

I'm also placing a note to remind others of this pitfall.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84929

Files:
  clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
  llvm/include/llvm/Config/config.h.cmake
  llvm/include/llvm/Config/llvm-config.h.cmake


Index: llvm/include/llvm/Config/llvm-config.h.cmake
===
--- llvm/include/llvm/Config/llvm-config.h.cmake
+++ llvm/include/llvm/Config/llvm-config.h.cmake
@@ -79,6 +79,9 @@
  */
 #cmakedefine01 LLVM_FORCE_ENABLE_STATS
 
+/* Define if we have z3 and want to build it */
+#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3}
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic 
library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/include/llvm/Config/config.h.cmake
===
--- llvm/include/llvm/Config/config.h.cmake
+++ llvm/include/llvm/Config/config.h.cmake
@@ -1,6 +1,9 @@
 #ifndef CONFIG_H
 #define CONFIG_H
 
+// Include this header only under the llvm source tree.
+// This is a private header.
+
 /* Exported configuration */
 #include "llvm/Config/llvm-config.h"
 
@@ -335,9 +338,6 @@
 /* Whether GlobalISel rule coverage is being collected */
 #cmakedefine01 LLVM_GISEL_COV_ENABLED
 
-/* Define if we have z3 and want to build it */
-#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3}
-
 /* Define to the default GlobalISel coverage file prefix */
 #cmakedefine LLVM_GISEL_COV_PREFIX "${LLVM_GISEL_COV_PREFIX}"
 
Index: clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
===
--- clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
+++ clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
@@ -16,7 +16,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
 #include "gtest/gtest.h"
 
 // FIXME: Use GTEST_SKIP() instead if GTest is updated to version 1.10.0


Index: llvm/include/llvm/Config/llvm-config.h.cmake
===
--- llvm/include/llvm/Config/llvm-config.h.cmake
+++ llvm/include/llvm/Config/llvm-config.h.cmake
@@ -79,6 +79,9 @@
  */
 #cmakedefine01 LLVM_FORCE_ENABLE_STATS
 
+/* Define if we have z3 and want to build it */
+#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3}
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/include/llvm/Config/config.h.cmake
===
--- llvm/include/llvm/Config/config.h.cmake
+++ llvm/include/llvm/Config/config.h.cmake
@@ -1,6 +1,9 @@
 #ifndef CONFIG_H
 #define CONFIG_H
 
+// Include this header only under the llvm source tree.
+// This is a private header.
+
 /* Exported configuration */
 #include "llvm/Config/llvm-config.h"
 
@@ -335,9 +338,6 @@
 /* Whether GlobalISel rule coverage is being collected */
 #cmakedefine01 LLVM_GISEL_COV_ENABLED
 
-/* Define if we have z3 and want to build it */
-#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3}
-
 /* Define to the default GlobalISel coverage file prefix */
 #cmakedefine LLVM_GISEL_COV_PREFIX "${LLVM_GISEL_COV_PREFIX}"
 
Index: clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
===
--- clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
+++ clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
@@ -16,7 +16,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
-#include "llvm/Config/config.h"
+#include "llvm/Config/llvm-config.h"
 #include "gtest/gtest.h"
 
 // FIXME: Use GTEST_SKIP() instead if GTest is updated to version 1.10.0
_

[PATCH] D78704: [analyzer][NFC] Add unittest for FalsePositiveRefutationBRVisitor

2020-07-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: 
clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp:19
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "llvm/Config/config.h"
+#include "gtest/gtest.h"

steakhal wrote:
> whisperity wrote:
> > steakhal wrote:
> > > mgorny wrote:
> > > > `config.h` is a private LLVM header and must not be used from clang.
> > > I'm not a CMake profession, but shouldn't it be declared private to the 
> > > LLVM target in the corresponding CMakeLists file then?
> > > 
> > > How do you query whether clang has built with Z3 or not @mgorny?
> > > I'm including that header only for that.
> > I've did a quick skim of the code, and it seems there is no way in it 
> > currently to query this.
> > Your best bet would be either adding an extra flag to Clang's CMake 
> > generated Config header that inherits this flag, or checking 
> > `llvm::CreateZ3Solver()` - right now, this method reports a fatal error, 
> > but you could create a bool function in the header which reports constant 
> > true or false, and turn the test's skip into a runtime condition?
> How could I use a //private// header in the first place?
The fix is on the way: D84929


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78704

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


[PATCH] D84894: [clangd] Implement Relations request for remote index

2020-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:391
+  auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
+  ASSERT_TRUE(Deserialized);
+}

i think you should still check for `Deserialized->first == ID` and 
`Deserialized->second->ID == Sym.Id`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84894

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


[PATCH] D84894: [clangd] Implement Relations request for remote index

2020-07-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 281869.
kbobyrev marked an inline comment as done.
kbobyrev added a comment.

Address post-LGTM comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84894

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -10,6 +10,7 @@
 #include "TestFS.h"
 #include "index/Index.h"
 #include "index/Ref.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
 #include "index/SymbolID.h"
@@ -18,6 +19,7 @@
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"
@@ -38,6 +40,51 @@
   return Strings.save(URI.toString()).begin();
 }
 
+clangd::Symbol createSymbol(llvm::StringRef PathPrefix,
+llvm::UniqueStringSaver &Strings) {
+  clangd::Symbol Sym;
+  Sym.ID = llvm::cantFail(SymbolID::fromStr("057557CEBF6E6B2D"));
+
+  index::SymbolInfo Info;
+  Info.Kind = index::SymbolKind::Function;
+  Info.SubKind = index::SymbolSubKind::AccessorGetter;
+  Info.Lang = index::SymbolLanguage::CXX;
+  Info.Properties = static_cast(
+  index::SymbolProperty::TemplateSpecialization);
+  Sym.SymInfo = Info;
+
+  Sym.Name = Strings.save("Foo");
+  Sym.Scope = Strings.save("llvm::foo::bar::");
+
+  clangd::SymbolLocation Location;
+  Location.Start.setLine(1);
+  Location.Start.setColumn(15);
+  Location.End.setLine(3);
+  Location.End.setColumn(121);
+  Location.FileURI = testPathURI(PathPrefix.str() + "Definition.cpp", Strings);
+  Sym.Definition = Location;
+
+  Location.Start.setLine(42);
+  Location.Start.setColumn(31);
+  Location.End.setLine(20);
+  Location.End.setColumn(400);
+  Location.FileURI = testPathURI(PathPrefix.str() + "Declaration.h", Strings);
+  Sym.CanonicalDeclaration = Location;
+
+  Sym.References = 9000;
+  Sym.Origin = clangd::SymbolOrigin::Static;
+  Sym.Signature = Strings.save("(int X, char Y, Type T)");
+  Sym.TemplateSpecializationArgs = Strings.save("");
+  Sym.CompletionSnippetSuffix =
+  Strings.save("({1: int X}, {2: char Y}, {3: Type T})");
+  Sym.Documentation = Strings.save("This is my amazing Foo constructor!");
+  Sym.ReturnType = Strings.save("Foo");
+
+  Sym.Flags = clangd::Symbol::SymbolFlag::IndexedForCodeCompletion;
+
+  return Sym;
+}
+
 TEST(RemoteMarshallingTest, URITranslation) {
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
@@ -86,52 +133,10 @@
 }
 
 TEST(RemoteMarshallingTest, SymbolSerialization) {
-  clangd::Symbol Sym;
-
-  auto ID = SymbolID::fromStr("057557CEBF6E6B2D");
-  ASSERT_TRUE(bool(ID));
-  Sym.ID = *ID;
-
-  index::SymbolInfo Info;
-  Info.Kind = index::SymbolKind::Function;
-  Info.SubKind = index::SymbolSubKind::AccessorGetter;
-  Info.Lang = index::SymbolLanguage::CXX;
-  Info.Properties = static_cast(
-  index::SymbolProperty::TemplateSpecialization);
-  Sym.SymInfo = Info;
-
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
 
-  Sym.Name = Strings.save("Foo");
-  Sym.Scope = Strings.save("llvm::foo::bar::");
-
-  clangd::SymbolLocation Location;
-  Location.Start.setLine(1);
-  Location.Start.setColumn(15);
-  Location.End.setLine(3);
-  Location.End.setColumn(121);
-  Location.FileURI = testPathURI("home/Definition.cpp", Strings);
-  Sym.Definition = Location;
-
-  Location.Start.setLine(42);
-  Location.Start.setColumn(31);
-  Location.End.setLine(20);
-  Location.End.setColumn(400);
-  Location.FileURI = testPathURI("home/Declaration.h", Strings);
-  Sym.CanonicalDeclaration = Location;
-
-  Sym.References = 9000;
-  Sym.Origin = clangd::SymbolOrigin::Static;
-  Sym.Signature = Strings.save("(int X, char Y, Type T)");
-  Sym.TemplateSpecializationArgs = Strings.save("");
-  Sym.CompletionSnippetSuffix =
-  Strings.save("({1: int X}, {2: char Y}, {3: Type T})");
-  Sym.Documentation = Strings.save("This is my amazing Foo constructor!");
-  Sym.ReturnType = Strings.save("Foo");
-
-  Sym.Flags = clangd::Symbol::SymbolFlag::IndexedForCodeCompletion;
-
+  clangd::Symbol Sym = createSymbol("home/", Strings);
   Marshaller ProtobufMarshaller(testPath("home/"), testPath("home/"));
 
   // Check that symbols are exactly the same if the path to indexed project is

[clang-tools-extra] a262f0f - [clangd] Implement Relations request for remote index

2020-07-30 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-07-30T12:57:33+02:00
New Revision: a262f0fea46ce08008f3462c336c3d7107e98b27

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

LOG: [clangd] Implement Relations request for remote index

This is the last missing bit in the core remote index implementation. The only
remaining bits are some API refactorings (replacing Optional with Expected and
being better at reporting errors).

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/Client.cpp
clang-tools-extra/clangd/index/remote/Index.proto
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
clang-tools-extra/clangd/index/remote/server/Server.cpp
clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp 
b/clang-tools-extra/clangd/index/remote/Client.cpp
index 5a33fd2eaf14..af58645d1795 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -91,11 +91,16 @@ class IndexClient : public clangd::SymbolIndex {
 return streamRPC(Request, &remote::SymbolIndex::Stub::Refs, Callback);
   }
 
-  // FIXME(kirillbobyrev): Implement this.
   void
-  relations(const clangd::RelationsRequest &,
-llvm::function_ref)
-  const {}
+  relations(const clangd::RelationsRequest &Request,
+llvm::function_ref
+Callback) const {
+streamRPC(Request, &remote::SymbolIndex::Stub::Relations,
+  // Unpack protobuf Relation.
+  [&](std::pair SubjectAndObject) {
+Callback(SubjectAndObject.first, SubjectAndObject.second);
+  });
+  }
 
   // IndexClient does not take any space since the data is stored on the
   // server.

diff  --git a/clang-tools-extra/clangd/index/remote/Index.proto 
b/clang-tools-extra/clangd/index/remote/Index.proto
index 99c4e3329d67..305164ffef77 100644
--- a/clang-tools-extra/clangd/index/remote/Index.proto
+++ b/clang-tools-extra/clangd/index/remote/Index.proto
@@ -18,6 +18,8 @@ service SymbolIndex {
   rpc FuzzyFind(FuzzyFindRequest) returns (stream FuzzyFindReply) {}
 
   rpc Refs(RefsRequest) returns (stream RefsReply) {}
+
+  rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
 }
 
 message LookupRequest { repeated string ids = 1; }
@@ -114,3 +116,25 @@ message HeaderWithReferences {
   string header = 1;
   uint32 references = 2;
 }
+
+message RelationsRequest {
+  repeated string subjects = 1;
+  uint32 predicate = 2;
+  uint32 limit = 3;
+}
+
+// The response is a stream of reference messages, and one terminating has_more
+// message.
+message RelationsReply {
+  oneof kind {
+Relation stream_result = 1;
+bool final_result = 2; // HasMore
+  }
+}
+
+// This struct does not mirror clangd::Relation but rather the arguments of
+// SymbolIndex::relations callback.
+message Relation {
+  string subject_id = 1;
+  Symbol object = 2;
+}

diff  --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp 
b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index b2085bc21f48..270e15347ee0 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -10,6 +10,7 @@
 #include "Headers.h"
 #include "Index.pb.h"
 #include "Protocol.h"
+#include "index/Index.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
 #include "index/SymbolID.h"
@@ -33,10 +34,10 @@ namespace remote {
 
 namespace {
 
-template 
-llvm::Expected> getIDs(MessageT *Message) {
+template 
+llvm::Expected> getIDs(IDRange IDs) {
   llvm::DenseSet Result;
-  for (const auto &ID : Message->ids()) {
+  for (const auto &ID : IDs) {
 auto SID = SymbolID::fromStr(StringRef(ID));
 if (!SID)
   return SID.takeError();
@@ -69,7 +70,7 @@ Marshaller::Marshaller(llvm::StringRef RemoteIndexRoot,
 llvm::Expected
 Marshaller::fromProtobuf(const LookupRequest *Message) {
   clangd::LookupRequest Req;
-  auto IDs = getIDs(Message);
+  auto IDs = getIDs(Message->ids());
   if (!IDs)
 return IDs.takeError();
   Req.IDs = std::move(*IDs);
@@ -100,7 +101,7 @@ Marshaller::fromProtobuf(const FuzzyFindRequest *Message) {
 llvm::Expected
 Marshaller::fromProtobuf(const RefsRequest *Message) {
   clangd::RefsRequest Req;
-  auto IDs = getIDs(Message);
+  auto IDs = getIDs(Message->ids());
   if (!IDs)
 return IDs.takeError();
   Req.IDs = std::move(*IDs);
@@ -110,6 +111,19 @@ Marshaller::fromProtobuf(const RefsRequest *Message) {
   return Req;
 }
 
+llvm::Expected
+Mar

[PATCH] D84894: [clangd] Implement Relations request for remote index

2020-07-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa262f0fea46c: [clangd] Implement Relations request for 
remote index (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84894

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -10,6 +10,7 @@
 #include "TestFS.h"
 #include "index/Index.h"
 #include "index/Ref.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
 #include "index/SymbolID.h"
@@ -18,6 +19,7 @@
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"
@@ -38,6 +40,51 @@
   return Strings.save(URI.toString()).begin();
 }
 
+clangd::Symbol createSymbol(llvm::StringRef PathPrefix,
+llvm::UniqueStringSaver &Strings) {
+  clangd::Symbol Sym;
+  Sym.ID = llvm::cantFail(SymbolID::fromStr("057557CEBF6E6B2D"));
+
+  index::SymbolInfo Info;
+  Info.Kind = index::SymbolKind::Function;
+  Info.SubKind = index::SymbolSubKind::AccessorGetter;
+  Info.Lang = index::SymbolLanguage::CXX;
+  Info.Properties = static_cast(
+  index::SymbolProperty::TemplateSpecialization);
+  Sym.SymInfo = Info;
+
+  Sym.Name = Strings.save("Foo");
+  Sym.Scope = Strings.save("llvm::foo::bar::");
+
+  clangd::SymbolLocation Location;
+  Location.Start.setLine(1);
+  Location.Start.setColumn(15);
+  Location.End.setLine(3);
+  Location.End.setColumn(121);
+  Location.FileURI = testPathURI(PathPrefix.str() + "Definition.cpp", Strings);
+  Sym.Definition = Location;
+
+  Location.Start.setLine(42);
+  Location.Start.setColumn(31);
+  Location.End.setLine(20);
+  Location.End.setColumn(400);
+  Location.FileURI = testPathURI(PathPrefix.str() + "Declaration.h", Strings);
+  Sym.CanonicalDeclaration = Location;
+
+  Sym.References = 9000;
+  Sym.Origin = clangd::SymbolOrigin::Static;
+  Sym.Signature = Strings.save("(int X, char Y, Type T)");
+  Sym.TemplateSpecializationArgs = Strings.save("");
+  Sym.CompletionSnippetSuffix =
+  Strings.save("({1: int X}, {2: char Y}, {3: Type T})");
+  Sym.Documentation = Strings.save("This is my amazing Foo constructor!");
+  Sym.ReturnType = Strings.save("Foo");
+
+  Sym.Flags = clangd::Symbol::SymbolFlag::IndexedForCodeCompletion;
+
+  return Sym;
+}
+
 TEST(RemoteMarshallingTest, URITranslation) {
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
@@ -86,52 +133,10 @@
 }
 
 TEST(RemoteMarshallingTest, SymbolSerialization) {
-  clangd::Symbol Sym;
-
-  auto ID = SymbolID::fromStr("057557CEBF6E6B2D");
-  ASSERT_TRUE(bool(ID));
-  Sym.ID = *ID;
-
-  index::SymbolInfo Info;
-  Info.Kind = index::SymbolKind::Function;
-  Info.SubKind = index::SymbolSubKind::AccessorGetter;
-  Info.Lang = index::SymbolLanguage::CXX;
-  Info.Properties = static_cast(
-  index::SymbolProperty::TemplateSpecialization);
-  Sym.SymInfo = Info;
-
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
 
-  Sym.Name = Strings.save("Foo");
-  Sym.Scope = Strings.save("llvm::foo::bar::");
-
-  clangd::SymbolLocation Location;
-  Location.Start.setLine(1);
-  Location.Start.setColumn(15);
-  Location.End.setLine(3);
-  Location.End.setColumn(121);
-  Location.FileURI = testPathURI("home/Definition.cpp", Strings);
-  Sym.Definition = Location;
-
-  Location.Start.setLine(42);
-  Location.Start.setColumn(31);
-  Location.End.setLine(20);
-  Location.End.setColumn(400);
-  Location.FileURI = testPathURI("home/Declaration.h", Strings);
-  Sym.CanonicalDeclaration = Location;
-
-  Sym.References = 9000;
-  Sym.Origin = clangd::SymbolOrigin::Static;
-  Sym.Signature = Strings.save("(int X, char Y, Type T)");
-  Sym.TemplateSpecializationArgs = Strings.save("");
-  Sym.CompletionSnippetSuffix =
-  Strings.save("({1: int X}, {2: char Y}, {3: Type T})");
-  Sym.Documentation = Strings.save("This is my amazing Foo constructor!");
-  Sym.ReturnType = Strings.save("Foo");
-
-  Sym.Flags = clangd::Symbol::SymbolFlag::IndexedForCodeCompletion;
-
+  clangd::Symbol Sym = createSymbol("home/", Strings);
   Marshaller ProtobufMarshaller(testPath("home/"), test

[PATCH] D84932: [builtins] Add more test cases for __div[sdt]f3 LibCalls

2020-07-30 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko created this revision.
atrosinenko added reviewers: koviankevin, joerg, efriedma, compnerd, scanon.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.
atrosinenko requested review of this revision.

This patch

- makes the three tests look more uniformly
- adds more test cases (basically, everything that was in some of test files is 
put everythere)
- specifies types of integer and fp literals more stricter
- makes NaN in the second test case of `divtf3` to be `sNaN` instead of testing 
for `qNaN` again

This patch is sent in preparation for unifying the division implementations and 
implementing subnormal result handling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84932

Files:
  compiler-rt/test/builtins/Unit/divdf3_test.c
  compiler-rt/test/builtins/Unit/divsf3_test.c
  compiler-rt/test/builtins/Unit/divtf3_test.c
  compiler-rt/test/builtins/Unit/fp_test.h

Index: compiler-rt/test/builtins/Unit/fp_test.h
===
--- compiler-rt/test/builtins/Unit/fp_test.h
+++ compiler-rt/test/builtins/Unit/fp_test.h
@@ -253,14 +253,29 @@
 return fromRep32(0x7f80U);
 }
 
+static inline float makeNegativeInf32(void)
+{
+return fromRep32(0xff80U);
+}
+
 static inline double makeInf64(void)
 {
 return fromRep64(0x7ff0UL);
 }
 
+static inline double makeNegativeInf64(void)
+{
+return fromRep64(0xfff0UL);
+}
+
 #if __LDBL_MANT_DIG__ == 113
 static inline long double makeInf128(void)
 {
 return fromRep128(0x7fffUL, 0x0UL);
 }
+
+static inline long double makeNegativeInf128(void)
+{
+return fromRep128(0xUL, 0x0UL);
+}
 #endif
Index: compiler-rt/test/builtins/Unit/divtf3_test.c
===
--- compiler-rt/test/builtins/Unit/divtf3_test.c
+++ compiler-rt/test/builtins/Unit/divtf3_test.c
@@ -32,6 +32,8 @@
 int main()
 {
 #if __LDBL_MANT_DIG__ == 113
+// Returned NaNs are assumed to be qNaN by default
+
 // qNaN / any = qNaN
 if (test__divtf3(makeQNaN128(),
  0x1.23456789abcdefp+5L,
@@ -39,17 +41,89 @@
  UINT64_C(0x0)))
 return 1;
 // NaN / any = NaN
-if (test__divtf3(makeNaN128(UINT64_C(0x80003000)),
+if (test__divtf3(makeNaN128(UINT64_C(0x3000)),
  0x1.23456789abcdefp+5L,
  UINT64_C(0x7fff8000),
  UINT64_C(0x0)))
 return 1;
-// inf / any = inf
-if (test__divtf3(makeInf128(),
- 0x1.23456789abcdefp+5L,
+
+// +Inf / positive = +Inf
+if (test__divtf3(makeInf128(), 3.L,
+ UINT64_C(0x7fff),
+ UINT64_C(0x0)))
+return 1;
+// +Inf / negative = -Inf
+if (test__divtf3(makeInf128(), -3.L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// -Inf / positive = -Inf
+if (test__divtf3(makeNegativeInf128(), 3.L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// -Inf / negative = +Inf
+if (test__divtf3(makeNegativeInf128(), -3.L,
+ UINT64_C(0x7fff),
+ UINT64_C(0x0)))
+return 1;
+
+// Inf / Inf = NaN
+if (test__divtf3(makeInf128(), makeInf128(),
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+// 0.0 / 0.0 = NaN
+if (test__divtf3(+0x0.0p+0L, +0x0.0p+0L,
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+
+// positive / +0.0 = +Inf
+if (test__divtf3(+1.0L, +0x0.0p+0L,
+ UINT64_C(0x7fff),
+ UINT64_C(0x0)))
+return 1;
+// positive / -0.0 = -Inf
+if (test__divtf3(+1.0L, -0x0.0p+0L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// negative / +0.0 = -Inf
+if (test__divtf3(-1.0L, +0x0.0p+0L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// negative / -0.0 = +Inf
+if (test__divtf3(-1.0L, -0x0.0p+0L,
  UINT64_C(0x7fff),
  UINT64_C(0x0)))
 return 1;
+
+// 1/3
+if (test__divtf3(1.L, 3.L,
+ UINT64_C(0x3ffd),
+ UINT64_C(0x)))
+return 1;
+// smallest normal result
+if (test__divtf3(0x1.0p-16381L, 2.L,
+ UINT64_C(0x0001),
+ UINT64_C(0x0)))
+return 1;
+
+// divisor is exactly 1.0
+if (test__divtf3(0x1.0p+0L,
+ 0x1.0p+0L,
+ UINT64_C(0x3fff),
+

[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-07-30 Thread Simon Moll via Phabricator via cfe-commits
simoll updated this revision to Diff 281878.
simoll added a comment.

NFC

- Style updates
- Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/constexpr-vectors.cpp
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -331,8 +331,7 @@
 typedef __attribute__((ext_vector_type(4))) int vi4;
 const int &reference_to_vec_element = vi4(1).x;
 
-// PR12649
-typedef bool bad __attribute__((__vector_size__(16)));  // expected-error {{invalid vector element type 'bool'}}
+typedef bool good __attribute__((__vector_size__(16)));
 
 namespace Templates {
 template 
@@ -350,9 +349,7 @@
 void Init() {
   const TemplateVectorType::type Works = {};
   const TemplateVectorType::type Works2 = {};
-  // expected-error@#1 {{invalid vector element type 'bool'}}
-  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoBool = {};
+  const TemplateVectorType::type BoolWorks = {};
   // expected-error@#1 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
   const TemplateVectorType::type NoComplex = {};
Index: clang/test/SemaCXX/constexpr-vectors.cpp
===
--- clang/test/SemaCXX/constexpr-vectors.cpp
+++ clang/test/SemaCXX/constexpr-vectors.cpp
@@ -204,35 +204,35 @@
 
   constexpr auto w = FourCharsVecSize{1, 2, 3, 4} <
  FourCharsVecSize{4, 3, 2, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto x = FourCharsVecSize{1, 2, 3, 4} >
  FourCharsVecSize{4, 3, 2, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto y = FourCharsVecSize{1, 2, 3, 4} <=
  FourCharsVecSize{4, 3, 3, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto z = FourCharsVecSize{1, 2, 3, 4} >=
  FourCharsVecSize{4, 3, 3, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto A = FourCharsVecSize{1, 2, 3, 4} ==
  FourCharsVecSize{4, 3, 3, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto B = FourCharsVecSize{1, 2, 3, 4} !=
  FourCharsVecSize{4, 3, 3, 1};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
 
   constexpr auto C = FourCharsVecSize{1, 2, 3, 4} < 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto D = FourCharsVecSize{1, 2, 3, 4} > 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto E = FourCharsVecSize{1, 2, 3, 4} <= 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto F = FourCharsVecSize{1, 2, 3, 4} >= 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto G = FourCharsVecSize{1, 2, 3, 4} == 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto H = FourCharsVecSize{1, 2, 3, 4} != 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
 
   constexpr auto I = FourCharsVecSize{1, 2, 3, 4} &
  FourCharsVecSize{4, 3, 2, 1};
@@ -252,15 +252,15 @@
 
   constexpr auto O = FourCharsVecSize{5, 0, 6, 0} &&
  FourCharsVecSize{5, 5, 0, 0};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto P = FourCharsVecSize{5, 0, 6, 0} ||
  FourCharsVecSize{5, 5, 0, 0};
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
 
   constexpr auto Q = FourCharsVecSize{5, 0, 6, 0} && 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
   constexpr auto R = FourCharsVecSize{5, 0, 6, 0} || 3;
-  // CHECK: store <4 x i8> 
+  // CHECK: store i8 bitcast (<8 x i1>  to i8)
 
   constexpr auto T = CmpMul(a, b);
   // CHECK: store <4 x i8> 
Index: clang/lib/Sema/SemaType.cpp
==

[PATCH] D84886: Create LoopNestPass

2020-07-30 Thread Ta-Wei Tu via Phabricator via cfe-commits
TaWeiTu updated this revision to Diff 281881.
TaWeiTu added a comment.
Herald added a reviewer: bollu.

Fix several pre-merge checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84886

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Analysis/LoopNestAnalysis.h
  llvm/include/llvm/Analysis/LoopNestAnalysisManager.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Transforms/Scalar/LoopNestPassManager.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/include/llvm/Transforms/Utils/LoopUtils.h
  llvm/lib/Analysis/CMakeLists.txt
  llvm/lib/Analysis/LoopNestAnalysis.cpp
  llvm/lib/Analysis/LoopNestAnalysisManager.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Scalar/CMakeLists.txt
  llvm/lib/Transforms/Scalar/LoopNestPassManager.cpp
  llvm/lib/Transforms/Utils/LoopUtils.cpp
  llvm/test/Transforms/LICM/assume.ll
  llvm/test/Transforms/LoopDeletion/invalidation.ll
  llvm/test/Transforms/LoopDeletion/multiple-exit-conditions.ll
  llvm/test/Transforms/LoopNest/print.ll
  llvm/test/Transforms/LoopRotate/basic.ll
  llvm/test/Transforms/LoopRotate/freeze-crash.ll
  llvm/test/Transforms/LoopRotate/multiple-deopt-exits.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
  llvm/tools/opt/NewPMDriver.cpp
  llvm/unittests/IR/PassBuilderCallbacksTest.cpp
  llvm/unittests/Transforms/Scalar/LICMTest.cpp
  polly/unittests/ScopPassManager/PassManagerTest.cpp

Index: polly/unittests/ScopPassManager/PassManagerTest.cpp
===
--- polly/unittests/ScopPassManager/PassManagerTest.cpp
+++ polly/unittests/ScopPassManager/PassManagerTest.cpp
@@ -16,6 +16,7 @@
 protected:
   ModuleAnalysisManager MAM;
   FunctionAnalysisManager FAM;
+  LoopNestAnalysisManager LNAM;
   LoopAnalysisManager LAM;
   CGSCCAnalysisManager CGAM;
   ScopAnalysisManager SAM;
@@ -26,13 +27,14 @@
   ScopPassRegistry(const ScopPassRegistry &) = delete;
   ScopPassRegistry &operator=(ScopPassRegistry &&) = delete;
   ScopPassRegistry &operator=(const ScopPassRegistry &) = delete;
-  ScopPassRegistry() {
+  ScopPassRegistry() : LNAM(LAM) {
 PassBuilder PB;
 
 AM = PB.buildDefaultAAPipeline();
 PB.registerModuleAnalyses(MAM);
 PB.registerFunctionAnalyses(FAM);
 PB.registerLoopAnalyses(LAM);
+PB.registerLoopNestAnalyses(LNAM);
 PB.registerCGSCCAnalyses(CGAM);
 
 FAM.registerPass([] { return ScopAnalysis(); });
@@ -43,7 +45,7 @@
 // SAM.registerPass([] { return DependenceAnalysis(); });
 SAM.registerPass([this] { return FunctionAnalysisManagerScopProxy(FAM); });
 
-PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
+PB.crossRegisterProxies(LAM, LNAM, FAM, CGAM, MAM);
   }
 };
 
Index: llvm/unittests/Transforms/Scalar/LICMTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LICMTest.cpp
+++ llvm/unittests/Transforms/Scalar/LICMTest.cpp
@@ -22,6 +22,7 @@
   ModulePassManager MPM;
   PassBuilder PB;
   LoopAnalysisManager LAM;
+  LoopNestAnalysisManager LNAM(LAM);
   FunctionAnalysisManager FAM;
   CGSCCAnalysisManager CGAM;
   ModuleAnalysisManager MAM;
@@ -30,7 +31,8 @@
   PB.registerCGSCCAnalyses(CGAM);
   PB.registerFunctionAnalyses(FAM);
   PB.registerLoopAnalyses(LAM);
-  PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
+  PB.registerLoopNestAnalyses(LNAM);
+  PB.crossRegisterProxies(LAM, LNAM, FAM, CGAM, MAM);
 
   StringRef PipelineStr = "require,loop(licm)";
   ASSERT_THAT_ERROR(PB.parsePassPipeline(MPM, PipelineStr), Succeeded());
Index: llvm/unittests/IR/PassBuilderCallbacksTest.cpp
===
--- llvm/unittests/IR/PassBuilderCallbacksTest.cpp
+++ llvm/unittests/IR/PassBuilderCallbacksTest.cpp
@@ -174,6 +174,24 @@
   MockPassHandle() { setDefaults(); }
 };
 
+template <>
+struct MockPassHandle
+: MockPassHandleBase, LoopNest,
+ LoopNestAnalysisManager, LoopStandardAnalysisResults &,
+ LNPMUpdater &> {
+  MOCK_METHOD4(run,
+   PreservedAnalyses(LoopNest &, LoopNestAnalysisManager &,
+ LoopStandardAnalysisResults &, LNPMUpdater &));
+
+  static void invalidateLoopNest(LoopNest &LN, LoopNestAnalysisManager &,
+ LoopStandardAnalysisResults &,
+ LNPMUpdater &Updater) {
+Updater.markLoopNestAsDeleted(LN, LN.getName());
+  }
+
+  MockPassHandle() { setDefaults(); }
+};
+
 template <>
 struct MockPassHandle
 : MockPassHandleBase, Function> {
@@ -226,6 +244,20 @@
   MockAnalysisHandle() { this->setDefaults(); }
 };
 
+template <>
+struct MockAnalysisHandle
+: MockAnalysisHandleBase, Loop,
+ LoopAnalysisManager,

[PATCH] D84939: [clangd] Propagate remote index errors via Expected

2020-07-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous.
Herald added a project: clang.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This is a refactoring: errors should be logged only on the highest level.
Switch from Optional to Expected in the serialization code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84939

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -97,11 +97,11 @@
   "clangd/unittests/remote/MarshallingTests.cpp",
   Strings);
   auto Serialized = ProtobufMarshaller.toProtobuf(Original);
-  ASSERT_TRUE(Serialized);
+  ASSERT_TRUE(bool(Serialized));
   EXPECT_EQ(Serialized->location().file_path(),
 "clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp");
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  ASSERT_TRUE(Deserialized);
+  ASSERT_TRUE(bool(Deserialized));
   EXPECT_STREQ(Deserialized->Location.FileURI,
testPathURI("home/my-projects/llvm-project/clang-tools-extra/"
"clangd/unittests/remote/MarshallingTests.cpp",
@@ -109,12 +109,16 @@
 
   // Can't have empty paths.
   *Serialized->mutable_location()->mutable_file_path() = std::string();
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 
   clangd::Ref WithInvalidURI;
   // Invalid URI results in serialization failure.
   WithInvalidURI.Location.FileURI = "This is not a URI";
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(WithInvalidURI));
+  auto DeserializedRef = ProtobufMarshaller.toProtobuf(WithInvalidURI);
+  EXPECT_FALSE(bool(DeserializedRef));
+  llvm::consumeError(DeserializedRef.takeError());
 
   // Can not use URIs with scheme different from "file".
   auto UnittestURI =
@@ -122,14 +126,18 @@
   ASSERT_TRUE(bool(UnittestURI));
   WithInvalidURI.Location.FileURI =
   Strings.save(UnittestURI->toString()).begin();
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(WithInvalidURI));
+  auto DeserializedSymbol = ProtobufMarshaller.toProtobuf(WithInvalidURI);
+  EXPECT_FALSE(bool(DeserializedSymbol));
+  llvm::consumeError(DeserializedSymbol.takeError());
 
   // Paths transmitted over the wire can not be absolute, they have to be
   // relative.
   Ref WithAbsolutePath;
   *WithAbsolutePath.mutable_location()->mutable_file_path() =
   "/usr/local/user/home/HelloWorld.cpp";
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(WithAbsolutePath));
+  Deserialized = ProtobufMarshaller.fromProtobuf(WithAbsolutePath);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 }
 
 TEST(RemoteMarshallingTest, SymbolSerialization) {
@@ -142,9 +150,9 @@
   // Check that symbols are exactly the same if the path to indexed project is
   // the same on indexing machine and the client.
   auto Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  ASSERT_TRUE(Serialized);
+  ASSERT_TRUE(bool(Serialized));
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  ASSERT_TRUE(Deserialized);
+  ASSERT_TRUE(bool(Deserialized));
   EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
   // Serialized paths are relative and have UNIX slashes.
   EXPECT_EQ(convert_to_slash(Serialized->definition().file_path(),
@@ -156,36 +164,44 @@
   // Missing definition is OK.
   Sym.Definition = clangd::SymbolLocation();
   Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  ASSERT_TRUE(Serialized);
-  EXPECT_TRUE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  ASSERT_TRUE(bool(Serialized));
+  EXPECT_TRUE(bool(ProtobufMarshaller.fromProtobuf(*Serialized)));
 
   // Relative path is absolute.
   *Serialized->mutable_canonical_declaration()->mutable_file_path() =
   convert_to_slash("/path/to/Declaration.h");
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 
   // Fail with an invalid URI.
   Sym.Definition.FileURI = "Not A URI";
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(Sym));
+  Serialized = ProtobufMarshaller.toProtobuf(Sym);
+  EXPECT_FALSE(bool(Serialized));
+  llvm::consumeError(Serialized.t

[PATCH] D84939: [clangd] Propagate remote index errors via Expected

2020-07-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 281897.
kbobyrev added a comment.

Client: print debug string for the stream_result, not the ReplyT.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84939

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -97,11 +97,11 @@
   "clangd/unittests/remote/MarshallingTests.cpp",
   Strings);
   auto Serialized = ProtobufMarshaller.toProtobuf(Original);
-  ASSERT_TRUE(Serialized);
+  ASSERT_TRUE(bool(Serialized));
   EXPECT_EQ(Serialized->location().file_path(),
 "clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp");
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  ASSERT_TRUE(Deserialized);
+  ASSERT_TRUE(bool(Deserialized));
   EXPECT_STREQ(Deserialized->Location.FileURI,
testPathURI("home/my-projects/llvm-project/clang-tools-extra/"
"clangd/unittests/remote/MarshallingTests.cpp",
@@ -109,12 +109,16 @@
 
   // Can't have empty paths.
   *Serialized->mutable_location()->mutable_file_path() = std::string();
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 
   clangd::Ref WithInvalidURI;
   // Invalid URI results in serialization failure.
   WithInvalidURI.Location.FileURI = "This is not a URI";
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(WithInvalidURI));
+  auto DeserializedRef = ProtobufMarshaller.toProtobuf(WithInvalidURI);
+  EXPECT_FALSE(bool(DeserializedRef));
+  llvm::consumeError(DeserializedRef.takeError());
 
   // Can not use URIs with scheme different from "file".
   auto UnittestURI =
@@ -122,14 +126,18 @@
   ASSERT_TRUE(bool(UnittestURI));
   WithInvalidURI.Location.FileURI =
   Strings.save(UnittestURI->toString()).begin();
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(WithInvalidURI));
+  auto DeserializedSymbol = ProtobufMarshaller.toProtobuf(WithInvalidURI);
+  EXPECT_FALSE(bool(DeserializedSymbol));
+  llvm::consumeError(DeserializedSymbol.takeError());
 
   // Paths transmitted over the wire can not be absolute, they have to be
   // relative.
   Ref WithAbsolutePath;
   *WithAbsolutePath.mutable_location()->mutable_file_path() =
   "/usr/local/user/home/HelloWorld.cpp";
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(WithAbsolutePath));
+  Deserialized = ProtobufMarshaller.fromProtobuf(WithAbsolutePath);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 }
 
 TEST(RemoteMarshallingTest, SymbolSerialization) {
@@ -142,9 +150,9 @@
   // Check that symbols are exactly the same if the path to indexed project is
   // the same on indexing machine and the client.
   auto Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  ASSERT_TRUE(Serialized);
+  ASSERT_TRUE(bool(Serialized));
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  ASSERT_TRUE(Deserialized);
+  ASSERT_TRUE(bool(Deserialized));
   EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
   // Serialized paths are relative and have UNIX slashes.
   EXPECT_EQ(convert_to_slash(Serialized->definition().file_path(),
@@ -156,36 +164,44 @@
   // Missing definition is OK.
   Sym.Definition = clangd::SymbolLocation();
   Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  ASSERT_TRUE(Serialized);
-  EXPECT_TRUE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  ASSERT_TRUE(bool(Serialized));
+  EXPECT_TRUE(bool(ProtobufMarshaller.fromProtobuf(*Serialized)));
 
   // Relative path is absolute.
   *Serialized->mutable_canonical_declaration()->mutable_file_path() =
   convert_to_slash("/path/to/Declaration.h");
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 
   // Fail with an invalid URI.
   Sym.Definition.FileURI = "Not A URI";
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(Sym));
+  Serialized = ProtobufMarshaller.toProtobuf(Sym);
+  EXPECT_FALSE(bool(Serialized));
+  llvm::consumeError(Serialized.takeError());
 
   // Schemes other than "file" can not be used.
   auto UnittestURI = URI::create(testPath("home/SomePath.h"), "unittest");
   ASSERT_TRUE(bool(UnittestURI));
   Sym.Definition

[PATCH] D84919: [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

2020-07-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 281904.
hokein added a comment.

remove the 2-arg Sym matcher.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84919

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -41,6 +41,7 @@
 using ::testing::Eq;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
+using ::testing::UnorderedElementsAre;
 using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P2(FileRange, File, Range, "") {
@@ -264,19 +265,23 @@
  << llvm::to_string(arg.PreferredDeclaration);
 return false;
   }
+  if (!Def && !arg.Definition)
+return true;
   if (Def && !arg.Definition) {
 *result_listener << "Has no definition";
 return false;
   }
-  if (Def && arg.Definition->range != *Def) {
+  if (!Def && arg.Definition) {
+*result_listener << "Definition is " << llvm::to_string(arg.Definition);
+return false;
+  }
+  if (arg.Definition->range != *Def) {
 *result_listener << "Definition is " << llvm::to_string(arg.Definition);
 return false;
   }
   return true;
 }
-::testing::Matcher Sym(std::string Name, Range Decl) {
-  return Sym(Name, Decl, llvm::None);
-}
+
 MATCHER_P(Sym, Name, "") { return arg.Name == Name; }
 
 MATCHER_P(RangeIs, R, "") { return arg.range == R; }
@@ -771,7 +776,7 @@
   auto AST = TU.build();
   auto Index = TU.index();
   EXPECT_THAT(locateSymbolAt(AST, T.point(), Index.get()),
-  ElementsAre(Sym("MyClass", T.range(;
+  ElementsAre(Sym("MyClass", T.range(), T.range(;
 }
 
 TEST(LocateSymbol, Textual) {
@@ -891,18 +896,20 @@
   // FIXME: Target the constructor as well.
   EXPECT_THAT(locateSymbolAt(AST, T.point("9")), ElementsAre(Sym("Foo")));
   EXPECT_THAT(locateSymbolAt(AST, T.point("10")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   EXPECT_THAT(locateSymbolAt(AST, T.point("11")),
-  ElementsAre(Sym("Foo", T.range("ConstructorLoc";
+  ElementsAre(Sym("Foo", T.range("ConstructorLoc"), llvm::None)));
   // These assertions are unordered because the order comes from
   // CXXRecordDecl::lookupDependentName() which doesn't appear to provide
   // an order guarantee.
   EXPECT_THAT(locateSymbolAt(AST, T.point("12")),
-  UnorderedElementsAre(Sym("bar", T.range("NonstaticOverload1")),
-   Sym("bar", T.range("NonstaticOverload2";
-  EXPECT_THAT(locateSymbolAt(AST, T.point("13")),
-  UnorderedElementsAre(Sym("baz", T.range("StaticOverload1")),
-   Sym("baz", T.range("StaticOverload2";
+  UnorderedElementsAre(
+  Sym("bar", T.range("NonstaticOverload1"), llvm::None),
+  Sym("bar", T.range("NonstaticOverload2"), llvm::None)));
+  EXPECT_THAT(
+  locateSymbolAt(AST, T.point("13")),
+  UnorderedElementsAre(Sym("baz", T.range("StaticOverload1"), llvm::None),
+   Sym("baz", T.range("StaticOverload2"), llvm::None)));
 }
 
 TEST(LocateSymbol, TextualDependent) {
@@ -932,9 +939,10 @@
   // interaction between locateASTReferent() and
   // locateSymbolNamedTextuallyAt().
   auto Results = locateSymbolAt(AST, Source.point(), Index.get());
-  EXPECT_THAT(Results, UnorderedElementsAre(
-   Sym("uniqueMethodName", Header.range("FooLoc")),
-   Sym("uniqueMethodName", Header.range("BarLoc";
+  EXPECT_THAT(Results,
+  UnorderedElementsAre(
+  Sym("uniqueMethodName", Header.range("FooLoc"), llvm::None),
+  Sym("uniqueMethodName", Header.range("BarLoc"), llvm::None)));
 }
 
 TEST(LocateSymbol, TemplateTypedefs) {
@@ -992,20 +1000,23 @@
   auto Locations =
   runLocateSymbolAt(Server, FooCpp, SourceAnnotations.point("p1"));
   EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
-  EXPECT_THAT(*Locations, ElementsAre(Sym("foo", SourceAnnotations.range(;
+  EXPECT_THAT(*Locations, ElementsAre(Sym("foo", SourceAnnotations.range(),
+  SourceAnnotations.range(;
 
   // Go to a definition in header_in_preamble.h.
   Locations = runLocateSymbolAt(Server, FooCpp, SourceAnnotations.point("p2"));
   EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
   EXPECT_THAT(
   *Locations,
-  ElementsAre(Sym("bar_preamble", HeaderInPreambleAnnotations.range(;
+  ElementsAre(Sym("bar_preamble", HeaderInPreambleAnnotations.range(),
+  HeaderInPreambleAnnotations.rang

[PATCH] D84886: Create LoopNestPass

2020-07-30 Thread Ta-Wei Tu via Phabricator via cfe-commits
TaWeiTu updated this revision to Diff 281907.
TaWeiTu added a comment.

Fix LOOP_NEST_ANALYSIS macro, clang-tidy warnings. Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84886

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Analysis/LoopNestAnalysis.h
  llvm/include/llvm/Analysis/LoopNestAnalysisManager.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Transforms/Scalar/LoopNestPassManager.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/include/llvm/Transforms/Utils/LoopUtils.h
  llvm/lib/Analysis/CMakeLists.txt
  llvm/lib/Analysis/LoopNestAnalysis.cpp
  llvm/lib/Analysis/LoopNestAnalysisManager.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Scalar/CMakeLists.txt
  llvm/lib/Transforms/Scalar/LoopNestPassManager.cpp
  llvm/lib/Transforms/Utils/LoopUtils.cpp
  llvm/test/Transforms/LICM/assume.ll
  llvm/test/Transforms/LoopDeletion/invalidation.ll
  llvm/test/Transforms/LoopDeletion/multiple-exit-conditions.ll
  llvm/test/Transforms/LoopNest/print.ll
  llvm/test/Transforms/LoopRotate/basic.ll
  llvm/test/Transforms/LoopRotate/freeze-crash.ll
  llvm/test/Transforms/LoopRotate/multiple-deopt-exits.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
  llvm/tools/opt/NewPMDriver.cpp
  llvm/unittests/IR/PassBuilderCallbacksTest.cpp
  llvm/unittests/Transforms/Scalar/LICMTest.cpp
  polly/unittests/ScopPassManager/PassManagerTest.cpp

Index: polly/unittests/ScopPassManager/PassManagerTest.cpp
===
--- polly/unittests/ScopPassManager/PassManagerTest.cpp
+++ polly/unittests/ScopPassManager/PassManagerTest.cpp
@@ -16,6 +16,7 @@
 protected:
   ModuleAnalysisManager MAM;
   FunctionAnalysisManager FAM;
+  LoopNestAnalysisManager LNAM;
   LoopAnalysisManager LAM;
   CGSCCAnalysisManager CGAM;
   ScopAnalysisManager SAM;
@@ -26,13 +27,14 @@
   ScopPassRegistry(const ScopPassRegistry &) = delete;
   ScopPassRegistry &operator=(ScopPassRegistry &&) = delete;
   ScopPassRegistry &operator=(const ScopPassRegistry &) = delete;
-  ScopPassRegistry() {
+  ScopPassRegistry() : LNAM(LAM) {
 PassBuilder PB;
 
 AM = PB.buildDefaultAAPipeline();
 PB.registerModuleAnalyses(MAM);
 PB.registerFunctionAnalyses(FAM);
 PB.registerLoopAnalyses(LAM);
+PB.registerLoopNestAnalyses(LNAM);
 PB.registerCGSCCAnalyses(CGAM);
 
 FAM.registerPass([] { return ScopAnalysis(); });
@@ -43,7 +45,7 @@
 // SAM.registerPass([] { return DependenceAnalysis(); });
 SAM.registerPass([this] { return FunctionAnalysisManagerScopProxy(FAM); });
 
-PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
+PB.crossRegisterProxies(LAM, LNAM, FAM, CGAM, MAM);
   }
 };
 
Index: llvm/unittests/Transforms/Scalar/LICMTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LICMTest.cpp
+++ llvm/unittests/Transforms/Scalar/LICMTest.cpp
@@ -22,6 +22,7 @@
   ModulePassManager MPM;
   PassBuilder PB;
   LoopAnalysisManager LAM;
+  LoopNestAnalysisManager LNAM(LAM);
   FunctionAnalysisManager FAM;
   CGSCCAnalysisManager CGAM;
   ModuleAnalysisManager MAM;
@@ -30,7 +31,8 @@
   PB.registerCGSCCAnalyses(CGAM);
   PB.registerFunctionAnalyses(FAM);
   PB.registerLoopAnalyses(LAM);
-  PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
+  PB.registerLoopNestAnalyses(LNAM);
+  PB.crossRegisterProxies(LAM, LNAM, FAM, CGAM, MAM);
 
   StringRef PipelineStr = "require,loop(licm)";
   ASSERT_THAT_ERROR(PB.parsePassPipeline(MPM, PipelineStr), Succeeded());
Index: llvm/unittests/IR/PassBuilderCallbacksTest.cpp
===
--- llvm/unittests/IR/PassBuilderCallbacksTest.cpp
+++ llvm/unittests/IR/PassBuilderCallbacksTest.cpp
@@ -174,6 +174,24 @@
   MockPassHandle() { setDefaults(); }
 };
 
+template <>
+struct MockPassHandle
+: MockPassHandleBase, LoopNest,
+ LoopNestAnalysisManager, LoopStandardAnalysisResults &,
+ LNPMUpdater &> {
+  MOCK_METHOD4(run,
+   PreservedAnalyses(LoopNest &, LoopNestAnalysisManager &,
+ LoopStandardAnalysisResults &, LNPMUpdater &));
+
+  static void invalidateLoopNest(LoopNest &LN, LoopNestAnalysisManager &,
+ LoopStandardAnalysisResults &,
+ LNPMUpdater &Updater) {
+Updater.markLoopNestAsDeleted(LN, LN.getName());
+  }
+
+  MockPassHandle() { setDefaults(); }
+};
+
 template <>
 struct MockPassHandle
 : MockPassHandleBase, Function> {
@@ -226,6 +244,20 @@
   MockAnalysisHandle() { this->setDefaults(); }
 };
 
+template <>
+struct MockAnalysisHandle
+: MockAnalysisHandleBase, Loop,
+ LoopAnalysisManager,
+  

[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM aside from an almost NFC simplification.




Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5350
+
+  D->addAttr(::new (S.Context)
+ NSErrorDomainAttr(S.Context, AL, IdentLoc->Ident));

MForster wrote:
> aaron.ballman wrote:
> > MForster wrote:
> > > aaron.ballman wrote:
> > > > Shouldn't we also be validating that what we found is an NSString that 
> > > > has the correct properties? (That doesn't seem like it should be a 
> > > > change which risks breaking code based on what I understood from Doug's 
> > > > description.)
> > > > Shouldn't we also be validating that what we found is an NSString that 
> > > > has the correct properties?
> > > 
> > > Is your suggestion to string-compare the name of the type?
> > >>Shouldn't we also be validating that what we found is an NSString that 
> > >>has the correct properties?
> > > Is your suggestion to string-compare the name of the type?
> > 
> > You should be able to compare the `QualType` of the resulting `VarDecl` 
> > against `ASTContext::getObjCNSStringType()` (accounting for qualifiers, 
> > pointers, etc).
> Turns out that this didn't work well. `ASTContext::getObjCNSStringType()` is 
> only initialized if ObjC string literals are instantiated without an 
> `NSString` type being defined. In our case there is an `NSString` type, 
> because we need to declare a global variable of that type.
> 
> I've resorted to a string comparison after all.
Well that's really unfortunate to learn, but good news: `isNSStringType()` is 
in SemaDeclAttr.cpp and I hadn't noticed that before, so I think you can use 
that instead, assuming that a mutable string is acceptable for the API. If 
mutable strings are not acceptable, then I think we should add a new parameter 
to `isNSStringType()` to handle it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

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


[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-30 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 updated this revision to Diff 281911.
Jac1494 added a comment.

Hi @aaron.ballman ,
Address your review comments. 
Thank you for accepting this. I don't have commit access please commit this.
Thanks.


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

https://reviews.llvm.org/D84678

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/void-argument.cpp


Index: clang/test/Sema/void-argument.cpp
===
--- /dev/null
+++ clang/test/Sema/void-argument.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void fun(
+void a, // expected-error{{'void' must be the first and only parameter if 
specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if 
specified}}
+{}
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if 
specified}}
+  void); // expected-error{{'void' must be the first and only parameter if 
specified}}
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5109,7 +5109,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {


Index: clang/test/Sema/void-argument.cpp
===
--- /dev/null
+++ clang/test/Sema/void-argument.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void fun(
+void a, // expected-error{{'void' must be the first and only parameter if specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if specified}}
+{}
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if specified}}
+  void); // expected-error{{'void' must be the first and only parameter if specified}}
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5109,7 +5109,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84767: [OPENMP]Fix PR46824: Global declare target pointer cannot be accessed in target region.

2020-07-30 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG142d0d3ed8e0: [OPENMP]Fix PR46824: Global declare target 
pointer cannot be accessed in target… (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84767

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_map_codegen.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  openmp/libomptarget/src/omptarget.cpp
  openmp/libomptarget/test/env/base_ptr_ref_count.c

Index: openmp/libomptarget/test/env/base_ptr_ref_count.c
===
--- /dev/null
+++ openmp/libomptarget/test/env/base_ptr_ref_count.c
@@ -0,0 +1,51 @@
+// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-aarch64-unknown-linux-gnu 2>&1 | %fcheck-aarch64-unknown-linux-gnu
+// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-powerpc64-ibm-linux-gnu 2>&1 | %fcheck-powerpc64-ibm-linux-gnu
+// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-powerpc64le-ibm-linux-gnu 2>&1 | %fcheck-powerpc64le-ibm-linux-gnu
+// RUN: %libomptarget-compile-x86_64-pc-linux-gnu && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-x86_64-pc-linux-gnu 2>&1 | %fcheck-x86_64-pc-linux-gnu
+// RUN: %libomptarget-compile-nvptx64-nvidia-cuda && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-nvptx64-nvidia-cuda 2>&1 | %fcheck-nvptx64-nvidia-cuda
+// REQUIRES: libomptarget-debug
+
+#include 
+
+int *allocate(size_t n) {
+  int *ptr = malloc(sizeof(int) * n);
+#pragma omp target enter data map(to : ptr[:n])
+  return ptr;
+}
+
+void deallocate(int *ptr, size_t n) {
+#pragma omp target exit data map(delete : ptr[:n])
+  free(ptr);
+}
+
+#pragma omp declare target
+int *cnt;
+void foo() {
+  ++(*cnt);
+}
+#pragma omp end declare target
+
+int main(void) {
+  int *A = allocate(10);
+  int *V = allocate(10);
+  deallocate(A, 10);
+  deallocate(V, 10);
+// CHECK-NOT: RefCount=2
+  cnt = malloc(sizeof(int));
+  *cnt = 0;
+#pragma omp target map(cnt[:1])
+  foo();
+  printf("Cnt = %d.\n", *cnt);
+// CHECK: Cnt = 1.
+  *cnt = 0;
+#pragma omp target data map(cnt[:1])
+#pragma omp target
+  foo();
+  printf("Cnt = %d.\n", *cnt);
+// CHECK: Cnt = 1.
+  free(cnt);
+
+  return 0;
+}
+
+
Index: openmp/libomptarget/src/omptarget.cpp
===
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -880,14 +880,9 @@
   return OFFLOAD_FAIL;
 }
   }
-} else if (ArgTypes[I] & OMP_TGT_MAPTYPE_PTR_AND_OBJ) {
-  TgtPtrBegin = Device.getTgtPtrBegin(HstPtrBase, sizeof(void *), IsLast,
-  false, IsHostPtr);
-  TgtBaseOffset = 0; // no offset for ptrs.
-  DP("Obtained target argument " DPxMOD " from host pointer " DPxMOD " to "
- "object " DPxMOD "\n",
- DPxPTR(TgtPtrBegin), DPxPTR(HstPtrBase), DPxPTR(HstPtrBase));
 } else {
+  if (ArgTypes[I] & OMP_TGT_MAPTYPE_PTR_AND_OBJ)
+HstPtrBase = *reinterpret_cast(HstPtrBase);
   TgtPtrBegin = Device.getTgtPtrBegin(HstPtrBegin, ArgSizes[I], IsLast,
   false, IsHostPtr);
   TgtBaseOffset = (intptr_t)HstPtrBase - (intptr_t)HstPtrBegin;
Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -310,22 +310,23 @@
 
 #ifdef CK5
 
-// 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: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
+// CK5: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 33]
 
 // CK5-LABEL: lvalue
 void lvalue(int *B, int l, int e) {
 
-  // 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: 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: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
   // CK5-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
 
-  // CK5-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 1
-  // CK5-DAG: [[P0:%.+]] = getelementptr inbo

[clang] 142d0d3 - [OPENMP]Fix PR46824: Global declare target pointer cannot be accessed in target region.

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

Author: Alexey Bataev
Date: 2020-07-30T09:40:05-04:00
New Revision: 142d0d3ed8e07aca2476bc4ecc1a12d15577a84a

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

LOG: [OPENMP]Fix PR46824: Global declare target pointer cannot be accessed in 
target region.

Need to map the base pointer for all directives, not only target
data-based ones.
The base pointer is mapped for array sections, array subscript, array
shaping and other array-like constructs with the base pointer. Also,
codegen for use_device_ptr clause was modified to correctly handle
mapping combination of array like constructs + use_device_ptr clause.
The data for use_device_ptr clause is emitted as the last records in the
data mapping array.
It applies only for global pointers.

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

Added: 
openmp/libomptarget/test/env/base_ptr_ref_count.c

Modified: 
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_map_codegen.cpp
clang/test/OpenMP/target_update_codegen.cpp
openmp/libomptarget/src/omptarget.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index b8e33948c21c..6c5c54951921 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7392,10 +7392,9 @@ class MappableExprsHandler {
 // &p, &p, sizeof(float*), TARGET_PARAM | TO | FROM
 //
 // map(p[1:24])
+// &p, &p[1], 24*sizeof(float), TARGET_PARAM | TO | FROM | PTR_AND_OBJ
+// in unified shared memory mode or for local pointers
 // p, &p[1], 24*sizeof(float), TARGET_PARAM | TO | FROM
-// for data directives
-// p, p, sizeof(float*), TARGET_PARAM | TO | FROM
-// p, &p[1], 24*sizeof(float), PTR_AND_OBJ | TO | FROM
 //
 // map(s)
 // &s, &s, sizeof(S2), TARGET_PARAM | TO | FROM
@@ -7530,6 +7529,7 @@ class MappableExprsHandler {
 // Track if the map information being generated is the first for a list of
 // components.
 bool IsExpressionFirstInfo = true;
+bool FirstPointerInComplexData = false;
 Address BP = Address::invalid();
 const Expr *AssocExpr = I->getAssociatedExpression();
 const auto *AE = dyn_cast(AssocExpr);
@@ -7572,17 +7572,16 @@ class MappableExprsHandler {
   QualType Ty =
   I->getAssociatedDeclaration()->getType().getNonReferenceType();
   if (Ty->isAnyPointerType() && std::next(I) != CE) {
-BP = CGF.EmitLoadOfPointer(BP, Ty->castAs());
-
-// For non-data directives, we do not need to generate individual map
-// information for the pointer, it can be associated with the combined
-// storage.
+// No need to generate individual map information for the pointer, it
+// can be associated with the combined storage if shared memory mode is
+// active or the base declaration is not global variable.
+const auto *VD = dyn_cast(I->getAssociatedDeclaration());
 if (CGF.CGM.getOpenMPRuntime().hasRequiresUnifiedSharedMemory() ||
-!CurDir.is() ||
-!isOpenMPTargetDataManagementDirective(
-CurDir.get()
-->getDirectiveKind()))
-  ++I;
+!VD || VD->hasLocalStorage())
+  BP = CGF.EmitLoadOfPointer(BP, Ty->castAs());
+else
+  FirstPointerInComplexData = true;
+++I;
   }
 }
 
@@ -7617,8 +7616,19 @@ class MappableExprsHandler {
 EncounteredME = dyn_cast(I->getAssociatedExpression());
 // If we encounter a PTR_AND_OBJ entry from now on it should be marked
 // as MEMBER_OF the parent struct.
-if (EncounteredME)
+if (EncounteredME) {
   ShouldBeMemberOf = true;
+  // Do not emit as complex pointer if this is actually not array-like
+  // expression.
+  if (FirstPointerInComplexData) {
+QualType Ty = std::prev(I)
+  ->getAssociatedDeclaration()
+  ->getType()
+  .getNonReferenceType();
+BP = CGF.EmitLoadOfPointer(BP, Ty->castAs());
+FirstPointerInComplexData = false;
+  }
+}
   }
 
   auto Next = std::next(I);
@@ -7760,7 +7770,8 @@ class MappableExprsHandler {
   // (there is a set of entries for each capture).
   OpenMPOffloadMappingFlags Flags =
   getMapTypeBits(MapType, MapModifiers, MotionModifiers, 
IsImplicit,
- !IsExpressionFirstInfo || RequiresReference,
+ !IsExpressionFirstInfo || RequiresReference ||
+   

[PATCH] D84176: [CMake][CTE] Add "check-clang-extra-..." targets to test only a particular Clang extra tool

2020-07-30 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 281922.
whisperity retitled this revision from "[CMake][CTE] Add 
"check-clang-tools-..." targets to test only a particular Clang extra tool" to 
"[CMake][CTE] Add "check-clang-extra-..." targets to test only a particular 
Clang extra tool".
whisperity added reviewers: chandlerc, alexfh.
whisperity added a comment.

After using this for a while, it feels more natural and more obvious that these 
are the CTE targets, not the "clang/tools" test targets.


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

https://reviews.llvm.org/D84176

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


Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -90,3 +90,7 @@
   )
 
 set_target_properties(check-clang-tools PROPERTIES FOLDER "Clang extra tools' 
tests")
+
+add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS ${CLANG_TOOLS_TEST_DEPS}
+  )


Index: clang-tools-extra/test/CMakeLists.txt
===
--- clang-tools-extra/test/CMakeLists.txt
+++ clang-tools-extra/test/CMakeLists.txt
@@ -90,3 +90,7 @@
   )
 
 set_target_properties(check-clang-tools PROPERTIES FOLDER "Clang extra tools' tests")
+
+add_lit_testsuites(CLANG-EXTRA ${CMAKE_CURRENT_SOURCE_DIR}
+  DEPENDS ${CLANG_TOOLS_TEST_DEPS}
+  )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84939: [clangd] Propagate remote index errors via Expected

2020-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

i think you might want to have an helper for creating stringerrors and use it 
in all places




Comment at: clang-tools-extra/clangd/index/remote/Client.cpp:60
+ Response.takeError());
+llvm::consumeError(Response.takeError());
 ++FailedToParse;

elog already consumes the error



Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:131
+  if (!Message.has_info() || !Message.has_canonical_declaration())
+return make_error("Missing info, definition or declaration.",
+   inconvertibleErrorCode());

error mentions definition too but conditional only looks for info and 
declaration?



Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:162
   Result.IncludeHeaders.push_back(*SerializedHeader);
 else
+  elog("Cannot convert HeaderWithIncludes from protobuf; skipping it: {0}. 
"

nit: swap branches and early exit, i.e.

```
if(!SerializedHeader) {
 elog...
 continue;
}
push_back;
```



Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:163
 else
-  elog("Cannot convert HeaderWithIncludes from protobuf: {0}",
-   Header.DebugString());
+  elog("Cannot convert HeaderWithIncludes from protobuf; skipping it: {0}. 
"
+   "Reason: {1}",

what makes this a non-terminal error?



Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:189
+return SubjectID.takeError();
   if (!Message.has_object()) {
+return make_error("Missing Object.", 
inconvertibleErrorCode());

nit: redundant braces 



Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:273
 auto Serialized = toProtobuf(Header);
 if (!Serialized) {
+  elog("Can not convert IncludeHeaderWithReferences {0} to protobuf; "

again, what makes this non-terminal?



Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:277
+   Header.IncludeHeader, Serialized.takeError());
+  llvm::consumeError(Serialized.takeError());
   continue;

elog already consumes the error



Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:313
  RelativePath, llvm::sys::path::Style::posix));
-  if (RelativePath.empty()) {
-return llvm::None;
-  }
-  if (llvm::sys::path::is_absolute(RelativePath)) {
-return llvm::None;
-  }
+  if (RelativePath.empty())
+return make_error("Empty relative path.",

is `RelativePath` user provided? can't we just assert on non-emptiness and 
non-absoluteness and make this function return a std::string instead?



Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:330
+return ParsedURI.takeError();
+  if (ParsedURI->scheme() != "file")
+return make_error("Can not use URI schemes other than file.",

again why not make this (and the following) an assertion?



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:89
 if (!Req) {
-  elog("Can not parse LookupRequest from protobuf: {0}", Req.takeError());
+  elog("Can not parse {0} from protobuf: {1}",
+   LookupRequest::descriptor()->name(), Req.takeError());

nit: I would keep `LookupRequest` instead of going through 
`descriptor()->name()` (maybe even change the one in tracer), makes it more 
explicit especially for the people not experienced with protos.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:95
 unsigned FailedToSend = 0;
 Index->lookup(*Req, [&](const auto &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);

this still has `auto` in it? (and other callbacks too)



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:100
+ SerializedItem.takeError());
+llvm::consumeError(SerializedItem.takeError());
 ++FailedToSend;

again, elog consumes



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:124
+  elog("Can not parse {0} from protobuf: {1}",
+   LookupRequest::descriptor()->name(), Req.takeError());
   return grpc::Status::CANCELLED;

same for usage of `descriptor()->name()`



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:134
+ SerializedItem.takeError());
+llvm::consumeError(SerializedItem.takeError());
 ++FailedToSend;

again, elog consumes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.or

[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-30 Thread Michael Forster via Phabricator via cfe-commits
MForster updated this revision to Diff 281927.
MForster added a comment.

Simplify code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Analysis/ns_error_enum.m

Index: clang/test/Analysis/ns_error_enum.m
===
--- /dev/null
+++ clang/test/Analysis/ns_error_enum.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -verify %s
+
+#define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_ENUM(_type, _name) CF_ENUM(_type, _name)
+
+#define NS_ERROR_ENUM(_type, _name, _domain)  \
+  enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) _name : _type
+
+typedef NS_ENUM(unsigned, MyEnum) {
+  MyFirst,
+  MySecond,
+};
+
+typedef NS_ENUM(invalidType, MyInvalidEnum) {
+// expected-error@-1{{unknown type name 'invalidType'}}
+// expected-error@-2{{unknown type name 'invalidType'}}
+  MyFirstInvalid,
+  MySecondInvalid,
+};
+
+const char *MyErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnum, MyErrorDomain) {
+	MyErrFirst,
+	MyErrSecond,
+};
+struct __attribute__((ns_error_domain(MyErrorDomain))) MyStructErrorDomain {};
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, InvalidDomain) {
+	// expected-error@-1{{domain argument 'InvalidDomain' does not refer to global constant}}
+	MyErrFirstInvalid,
+	MyErrSecondInvalid,
+};
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, "domain-string");
+  // expected-error@-1{{domain argument must be an identifier}}
+
+int __attribute__((ns_error_domain(MyErrorDomain))) NotTagDecl;
+  // expected-error@-1{{ns_error_domain attribute only valid on enums, structs, and unions}}
+
+void foo() {}
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalidFunction, foo);
+  // expected-error@-1{{domain argument 'foo' does not refer to global constant}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5322,6 +5322,39 @@
   D->addAttr(::new (S.Context) ObjCRequiresSuperAttr(S.Context, Attrs));
 }
 
+static void handleNSErrorDomain(Sema &S, Decl *D, const ParsedAttr &Attr) {
+  if (!isa(D)) {
+S.Diag(D->getBeginLoc(), diag::err_nserrordomain_not_tagdecl)
+<< S.getLangOpts().CPlusPlus;
+return;
+  }
+  IdentifierLoc *identLoc =
+  Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : nullptr;
+  if (!identLoc || !identLoc->Ident) {
+// Try to locate the argument directly
+SourceLocation loc = Attr.getLoc();
+if (Attr.isArgExpr(0) && Attr.getArgAsExpr(0))
+  loc = Attr.getArgAsExpr(0)->getBeginLoc();
+
+S.Diag(loc, diag::err_nserrordomain_requires_identifier);
+return;
+  }
+
+  // Verify that the identifier is a valid decl in the C decl namespace
+  LookupResult lookupResult(S, DeclarationName(identLoc->Ident),
+SourceLocation(),
+Sema::LookupNameKind::LookupOrdinaryName);
+  if (!S.LookupName(lookupResult, S.TUScope) ||
+  !lookupResult.getAsSingle()) {
+S.Diag(identLoc->Loc, diag::err_nserrordomain_invalid_decl)
+<< identLoc->Ident;
+return;
+  }
+
+  D->addAttr(::new (S.Context)
+ NSErrorDomainAttr(S.Context, Attr, identLoc->Ident));
+}
+
 static void handleObjCBridgeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   IdentifierLoc *Parm = AL.isArgIdent(0) ? AL.getArgAsIdent(0) : nullptr;
 
@@ -7093,6 +7126,9 @@
   case ParsedAttr::AT_ObjCBoxable:
 handleObjCBoxable(S, D, AL);
 break;
+  case ParsedAttr::AT_NSErrorDomain:
+handleNSErrorDomain(S, D, AL);
+break;
   case ParsedAttr::AT_CFAuditedTransfer:
 handleSimpleAttributeWithExclusions(S, D, AL);
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9459,6 +9459,14 @@
 def err_nsreturns_retained_attribute_mismatch : Error<
   "overriding method has mismatched ns_returns_%select{not_retained|retained}0"
   " attributes">;
+def err_nserrordomain_not_tagdecl : Error<
+  "ns_error_domain attribute only valid on "
+  "%select{enums, structs, and unions|enums, structs, unions, and classes}0">;
+def err_nserrordomain_invalid_decl : Error<
+  "domain argument %0 does not refer to global constant">;
+def err_nserrordomain_requires_identifier : Error<
+  "domain argument must be an identifier">;
+
 def warn_nsconsumed_attribute_mismatch : Warning<
   err_nsconsumed_attribute_mismatch.Text>, InGroup;
 def warn_nsreturns_retained_attribute_mismatch : Warning<
Index: clang/include/clang/Basic/AttrDocs.td

[PATCH] D84919: [clangd] Be more explicit on testing the optional DefLoc in LocatedSymbol.

2020-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84919

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


[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-30 Thread Michael Forster via Phabricator via cfe-commits
MForster marked an inline comment as done.
MForster added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5350
+
+  D->addAttr(::new (S.Context)
+ NSErrorDomainAttr(S.Context, AL, IdentLoc->Ident));

aaron.ballman wrote:
> MForster wrote:
> > aaron.ballman wrote:
> > > MForster wrote:
> > > > aaron.ballman wrote:
> > > > > Shouldn't we also be validating that what we found is an NSString 
> > > > > that has the correct properties? (That doesn't seem like it should be 
> > > > > a change which risks breaking code based on what I understood from 
> > > > > Doug's description.)
> > > > > Shouldn't we also be validating that what we found is an NSString 
> > > > > that has the correct properties?
> > > > 
> > > > Is your suggestion to string-compare the name of the type?
> > > >>Shouldn't we also be validating that what we found is an NSString that 
> > > >>has the correct properties?
> > > > Is your suggestion to string-compare the name of the type?
> > > 
> > > You should be able to compare the `QualType` of the resulting `VarDecl` 
> > > against `ASTContext::getObjCNSStringType()` (accounting for qualifiers, 
> > > pointers, etc).
> > Turns out that this didn't work well. `ASTContext::getObjCNSStringType()` 
> > is only initialized if ObjC string literals are instantiated without an 
> > `NSString` type being defined. In our case there is an `NSString` type, 
> > because we need to declare a global variable of that type.
> > 
> > I've resorted to a string comparison after all.
> Well that's really unfortunate to learn, but good news: `isNSStringType()` is 
> in SemaDeclAttr.cpp and I hadn't noticed that before, so I think you can use 
> that instead, assuming that a mutable string is acceptable for the API. If 
> mutable strings are not acceptable, then I think we should add a new 
> parameter to `isNSStringType()` to handle it.
Nice find. Should have found this myself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

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


[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-30 Thread Michael Forster via Phabricator via cfe-commits
MForster updated this revision to Diff 281928.
MForster marked 5 inline comments as done.
MForster added a comment.

Fix patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/ns_error_enum.m

Index: clang/test/Sema/ns_error_enum.m
===
--- /dev/null
+++ clang/test/Sema/ns_error_enum.m
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -verify %s -x objective-c
+// RUN: %clang_cc1 -verify %s -x objective-c++
+
+
+#define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_ENUM(_type, _name) CF_ENUM(_type, _name)
+
+#define NS_ERROR_ENUM(_type, _name, _domain)  \
+  enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) _name : _type
+
+typedef NS_ENUM(unsigned, MyEnum) {
+  MyFirst,
+  MySecond,
+};
+
+typedef NS_ENUM(invalidType, MyInvalidEnum) {
+// expected-error@-1{{unknown type name 'invalidType'}}
+// expected-error@-2{{unknown type name 'invalidType'}}
+  MyFirstInvalid,
+  MySecondInvalid,
+};
+
+@interface NSString
+@end
+
+extern NSString *const MyErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnum, MyErrorDomain) {
+	MyErrFirst,
+	MyErrSecond,
+};
+
+typedef NSString *const NsErrorDomain;
+extern NsErrorDomain MyTypedefErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyTypedefErrorEnum, MyTypedefErrorDomain) {
+  MyTypedefErrFirst,
+  MyTypedefErrSecond,
+};
+
+extern char *const WrongErrorDomainType;
+enum __attribute__((ns_error_domain(WrongErrorDomainType))) MyWrongErrorDomainType { MyWrongErrorDomain };
+// expected-error@-1{{domain argument 'WrongErrorDomainType' does not point to an NSString constant}}
+
+struct __attribute__((ns_error_domain(MyErrorDomain))) MyStructWithErrorDomain {};
+// expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+int __attribute__((ns_error_domain(MyErrorDomain))) NotTagDecl;
+  // expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+enum __attribute__((ns_error_domain())) NoArg { NoArgError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+enum __attribute__((ns_error_domain(MyErrorDomain, MyErrorDomain))) TwoArgs { TwoArgsError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, InvalidDomain) {
+	// expected-error@-1{{use of undeclared identifier 'InvalidDomain'}}
+	MyErrFirstInvalid,
+	MyErrSecondInvalid,
+};
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, "domain-string");
+  // expected-error@-1{{domain argument does not refer to global constant}}
+
+void foo() {}
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalidFunction, foo);
+  // expected-error@-1{{domain argument 'foo' does not refer to global constant}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -80,6 +80,7 @@
 // CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
+// CHECK-NEXT: NSErrorDomain (SubjectMatchRule_enum)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
 // CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetBuiltins.h"
@@ -30,12 +31,15 @@
 #include "clang/Sema/DelayedDiagnostic.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/ParsedAttr.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 using namespace sema;
@@ -5322,6 +5326,30 @@
   D->addAttr(::new (S.Context) ObjCRequiresSuperAttr(S.Context, Attrs));
 }
 
+static void handleNSErrorDomain(Sema &S, Decl *D, const ParsedAttr &AL) {
+  auto *E = AL.getArgAsExpr(0);
+  auto Loc = E ? 

[clang] 4e6176f - [AIX] Temporarily disable IncrementalProcessingTest partially

2020-07-30 Thread Xiangling Liao via cfe-commits

Author: Xiangling Liao
Date: 2020-07-30T10:41:52-04:00
New Revision: 4e6176fd912a68de0764fff43a129a73f5cab800

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

LOG: [AIX] Temporarily disable IncrementalProcessingTest partially

Temporarily disable IncrementalProcessingTest partially until the static
initialization implementation on AIX is recovered.

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

Added: 


Modified: 
clang/unittests/CodeGen/IncrementalProcessingTest.cpp

Removed: 




diff  --git a/clang/unittests/CodeGen/IncrementalProcessingTest.cpp 
b/clang/unittests/CodeGen/IncrementalProcessingTest.cpp
index 045ed9bbc760..d1d921bb03c6 100644
--- a/clang/unittests/CodeGen/IncrementalProcessingTest.cpp
+++ b/clang/unittests/CodeGen/IncrementalProcessingTest.cpp
@@ -159,6 +159,11 @@ TEST(IncrementalProcessing, EmitCXXGlobalInitFunc) {
 // First code should not end up in second module:
 ASSERT_FALSE(M[2]->getFunction("funcForProg1"));
 
+// TODO: Remove this after the static initialization frontend 
implementation
+// is recovered on AIX.
+if (compiler.getTarget().getTriple().isOSAIX())
+  return;
+
 // Make sure global inits exist and are unique:
 const Function* GlobalInit1 = getGlobalInit(*M[1]);
 ASSERT_TRUE(GlobalInit1);



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


[PATCH] D84880: [AIX] Temporarily disable IncrementalProcessingTest partially

2020-07-30 Thread Xiangling Liao via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4e6176fd912a: [AIX] Temporarily disable 
IncrementalProcessingTest partially (authored by Xiangling_L).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84880

Files:
  clang/unittests/CodeGen/IncrementalProcessingTest.cpp


Index: clang/unittests/CodeGen/IncrementalProcessingTest.cpp
===
--- clang/unittests/CodeGen/IncrementalProcessingTest.cpp
+++ clang/unittests/CodeGen/IncrementalProcessingTest.cpp
@@ -159,6 +159,11 @@
 // First code should not end up in second module:
 ASSERT_FALSE(M[2]->getFunction("funcForProg1"));
 
+// TODO: Remove this after the static initialization frontend 
implementation
+// is recovered on AIX.
+if (compiler.getTarget().getTriple().isOSAIX())
+  return;
+
 // Make sure global inits exist and are unique:
 const Function* GlobalInit1 = getGlobalInit(*M[1]);
 ASSERT_TRUE(GlobalInit1);


Index: clang/unittests/CodeGen/IncrementalProcessingTest.cpp
===
--- clang/unittests/CodeGen/IncrementalProcessingTest.cpp
+++ clang/unittests/CodeGen/IncrementalProcessingTest.cpp
@@ -159,6 +159,11 @@
 // First code should not end up in second module:
 ASSERT_FALSE(M[2]->getFunction("funcForProg1"));
 
+// TODO: Remove this after the static initialization frontend implementation
+// is recovered on AIX.
+if (compiler.getTarget().getTriple().isOSAIX())
+  return;
+
 // Make sure global inits exist and are unique:
 const Function* GlobalInit1 = getGlobalInit(*M[1]);
 ASSERT_TRUE(GlobalInit1);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b69357c - Revert "[OPENMP]Fix PR46824: Global declare target pointer cannot be accessed in target region."

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

Author: Alexey Bataev
Date: 2020-07-30T10:57:56-04:00
New Revision: b69357c2f4f2aa0c4999d6827a40fe748641fdb1

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

LOG: Revert "[OPENMP]Fix PR46824: Global declare target pointer cannot be 
accessed in target region."

This reverts commit 142d0d3ed8e07aca2476bc4ecc1a12d15577a84a to
investigate undefined behavior revealed by buildbots.

Added: 


Modified: 
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_map_codegen.cpp
clang/test/OpenMP/target_update_codegen.cpp
openmp/libomptarget/src/omptarget.cpp

Removed: 
openmp/libomptarget/test/env/base_ptr_ref_count.c



diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 6c5c54951921..b8e33948c21c 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7392,9 +7392,10 @@ class MappableExprsHandler {
 // &p, &p, sizeof(float*), TARGET_PARAM | TO | FROM
 //
 // map(p[1:24])
-// &p, &p[1], 24*sizeof(float), TARGET_PARAM | TO | FROM | PTR_AND_OBJ
-// in unified shared memory mode or for local pointers
 // p, &p[1], 24*sizeof(float), TARGET_PARAM | TO | FROM
+// for data directives
+// p, p, sizeof(float*), TARGET_PARAM | TO | FROM
+// p, &p[1], 24*sizeof(float), PTR_AND_OBJ | TO | FROM
 //
 // map(s)
 // &s, &s, sizeof(S2), TARGET_PARAM | TO | FROM
@@ -7529,7 +7530,6 @@ class MappableExprsHandler {
 // Track if the map information being generated is the first for a list of
 // components.
 bool IsExpressionFirstInfo = true;
-bool FirstPointerInComplexData = false;
 Address BP = Address::invalid();
 const Expr *AssocExpr = I->getAssociatedExpression();
 const auto *AE = dyn_cast(AssocExpr);
@@ -7572,16 +7572,17 @@ class MappableExprsHandler {
   QualType Ty =
   I->getAssociatedDeclaration()->getType().getNonReferenceType();
   if (Ty->isAnyPointerType() && std::next(I) != CE) {
-// No need to generate individual map information for the pointer, it
-// can be associated with the combined storage if shared memory mode is
-// active or the base declaration is not global variable.
-const auto *VD = dyn_cast(I->getAssociatedDeclaration());
+BP = CGF.EmitLoadOfPointer(BP, Ty->castAs());
+
+// For non-data directives, we do not need to generate individual map
+// information for the pointer, it can be associated with the combined
+// storage.
 if (CGF.CGM.getOpenMPRuntime().hasRequiresUnifiedSharedMemory() ||
-!VD || VD->hasLocalStorage())
-  BP = CGF.EmitLoadOfPointer(BP, Ty->castAs());
-else
-  FirstPointerInComplexData = true;
-++I;
+!CurDir.is() ||
+!isOpenMPTargetDataManagementDirective(
+CurDir.get()
+->getDirectiveKind()))
+  ++I;
   }
 }
 
@@ -7616,19 +7617,8 @@ class MappableExprsHandler {
 EncounteredME = dyn_cast(I->getAssociatedExpression());
 // If we encounter a PTR_AND_OBJ entry from now on it should be marked
 // as MEMBER_OF the parent struct.
-if (EncounteredME) {
+if (EncounteredME)
   ShouldBeMemberOf = true;
-  // Do not emit as complex pointer if this is actually not array-like
-  // expression.
-  if (FirstPointerInComplexData) {
-QualType Ty = std::prev(I)
-  ->getAssociatedDeclaration()
-  ->getType()
-  .getNonReferenceType();
-BP = CGF.EmitLoadOfPointer(BP, Ty->castAs());
-FirstPointerInComplexData = false;
-  }
-}
   }
 
   auto Next = std::next(I);
@@ -7770,8 +7760,7 @@ class MappableExprsHandler {
   // (there is a set of entries for each capture).
   OpenMPOffloadMappingFlags Flags =
   getMapTypeBits(MapType, MapModifiers, MotionModifiers, 
IsImplicit,
- !IsExpressionFirstInfo || RequiresReference ||
- FirstPointerInComplexData,
+ !IsExpressionFirstInfo || RequiresReference,
  IsCaptureFirstInfo && !RequiresReference);
 
   if (!IsExpressionFirstInfo) {
@@ -7830,7 +7819,6 @@ class MappableExprsHandler {
 
 IsExpressionFirstInfo = false;
 IsCaptureFirstInfo = false;
-FirstPointerInComplexData = false;
   }
 }
   }
@@ -8079,7 +8067,6 @@ class MappableExprsHandler {
 // emission o

[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-30 Thread Michael Forster via Phabricator via cfe-commits
MForster added a comment.

For context, this is the backported change, to be applied downstream before 
landing this review: https://github.com/apple/llvm-project/pull/1565


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

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


[clang-tools-extra] c4b7bfd - [clangd] NFC: Spell out types in index callback arguments

2020-07-30 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-07-30T17:12:29+02:00
New Revision: c4b7bfdff65e5883bfe64248ac244b9fadf531ee

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

LOG: [clangd] NFC: Spell out types in index callback arguments

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/server/Server.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index 077d58ea7db0..27e89cbbb48e 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -90,7 +90,7 @@ class RemoteIndexServer final : public SymbolIndex::Service {
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->lookup(*Req, [&](const auto &Item) {
+Index->lookup(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 ++FailedToSend;
@@ -121,7 +121,7 @@ class RemoteIndexServer final : public SymbolIndex::Service 
{
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->fuzzyFind(*Req, [&](const auto &Item) {
+bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 ++FailedToSend;
@@ -150,7 +150,7 @@ class RemoteIndexServer final : public SymbolIndex::Service 
{
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->refs(*Req, [&](const auto &Item) {
+bool HasMore = Index->refs(*Req, [&](const clangd::Ref &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 ++FailedToSend;



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


[PATCH] D84939: [clangd] Propagate remote index errors via Expected

2020-07-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

In D84939#2184836 , @kadircet wrote:

> i think you might want to have an helper for creating stringerrors and use it 
> in all places

Haha, yeah I thought about that but then looked at other examples and saw that 
in some cases there are even more verbose calls :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84939

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


[PATCH] D84260: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 3

2020-07-30 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 281932.
saiislam added a comment.

Moved comments to header files. Used regexps for test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84260

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/OpenMP/amdgcn_target_codegen.cpp
  clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp

Index: clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
===
--- /dev/null
+++ clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
@@ -0,0 +1,25 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+
+#define N 100
+
+int test_amdgcn_target_temp_alloca() {
+  // CHECK-LABEL: test_amdgcn_target_temp_alloca
+  // CHECK-LABEL: entry:
+
+  int arr[N];
+
+  // CHECK:  [[VAR:%.+]].addr = alloca [100 x i32]*, align 8, addrspace(5)
+  // CHECK-NEXT: [[VAR]].addr.ascast = addrspacecast [100 x i32]* addrspace(5)* [[VAR]].addr to [100 x i32]**
+  // CHECK-DAG:  store [100 x i32]* [[VAR]], [100 x i32]** [[VAR]].addr.ascast, align 8
+
+#pragma omp target
+  for (int i = 0; i < N; i++) {
+arr[i] = 1;
+  }
+
+  return arr[0];
+}
Index: clang/test/OpenMP/amdgcn_target_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/amdgcn_target_codegen.cpp
@@ -0,0 +1,43 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+#define N 1000
+
+int test_amdgcn_target_tid_threads() {
+  // CHECK-LABEL: define weak void @{{.*}}test_amdgcn_target_tid_threads
+  
+  int arr[N];
+
+// CHECK: [[NUM_THREADS:%.+]] = call i64 @__ockl_get_local_size(i32 0)
+// CHECK-DAG: [[VAR:%.+]] = trunc i64 [[NUM_THREADS]] to i32
+// CHECK-DAG: sub nuw i32 [[VAR]], 64
+// CHECK-DAG: call i32 @llvm.amdgcn.workitem.id.x()
+#pragma omp target
+  for (int i = 0; i < N; i++) {
+arr[i] = 1;
+  }
+
+  return arr[0];
+}
+
+int test_amdgcn_target_tid_threads_simd() {
+  // CHECK-LABEL: define weak void @{{.*}}test_amdgcn_target_tid_threads_simd
+  
+  int arr[N];
+
+// CHECK: [[NUM_THREADS:%.+]] = call i64 @__ockl_get_local_size(i32 0)
+// CHECK-DAG: [[VAR:%.+]] = trunc i64 [[NUM_THREADS]] to i32
+// CHECK-DAG: call void @__kmpc_spmd_kernel_init(i32 [[VAR]], i16 0, i16 0)
+#pragma omp target simd
+  for (int i = 0; i < N; i++) {
+arr[i] = 1;
+  }
+  return arr[0];
+}
+
+#endif
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -19,6 +19,7 @@
 #include "CGObjCRuntime.h"
 #include "CGOpenCLRuntime.h"
 #include "CGOpenMPRuntime.h"
+#include "CGOpenMPRuntimeAMDGCN.h"
 #include "CGOpenMPRuntimeNVPTX.h"
 #include "CodeGenFunction.h"
 #include "CodeGenPGO.h"
@@ -215,6 +216,11 @@
"OpenMP NVPTX is only prepared to deal with device code.");
 OpenMPRuntime.reset(new CGOpenMPRuntimeNVPTX(*this));
 break;
+  case llvm::Triple::amdgcn:
+assert(getLangOpts().OpenMPIsDevice &&
+   "OpenMP AMDGCN is only prepared to deal with device code.");
+OpenMPRuntime.reset(new CGOpenMPRuntimeAMDGCN(*this));
+break;
   default:
 if (LangOpts.OpenMPSimd)
   OpenMPRuntime.reset(new CGOpenMPSIMDRuntime(*this));
Index: clang/lib/CodeGen/CMakeLists.txt
===
--- clang/lib/CodeGen/CMakeLists.txt
+++ clang/lib/CodeGen/CMakeLists.txt
@@ -62,6 +62,7 @@
   CGObjCRuntime.cpp
   CGOpenCLRuntime.cpp
   CGOpenMPRuntime.cpp
+  CGOpenMPRuntimeAMDGCN.cpp
   CGOpenMPRuntimeGPU.cpp
   CGOpenMPRuntimeNVPTX.cpp
   CGRecordLayoutBuilder.cpp
Index: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ clang/lib/CodeGen/CGOpenM

[PATCH] D83242: [clang][BPF] support type exist/size and enum exist/value relocations

2020-07-30 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 281933.
yonghong-song retitled this revision from "[clang][BPF] support type 
existence/size and enum value relocations" to "[clang][BPF] support type 
exist/size and enum exist/value relocations".
yonghong-song edited the summary of this revision.
yonghong-song added a comment.

use a different __builtin function for new relocations to they are easily 
discoverable in user space and this also make implementation more structured.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83242

Files:
  clang/include/clang/Basic/BuiltinsBPF.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-bpf-preserve-field-info-3.c
  clang/test/CodeGen/builtins-bpf-preserve-field-info-4.c
  clang/test/Sema/builtins-bpf.c
  llvm/include/llvm/IR/IntrinsicsBPF.td

Index: llvm/include/llvm/IR/IntrinsicsBPF.td
===
--- llvm/include/llvm/IR/IntrinsicsBPF.td
+++ llvm/include/llvm/IR/IntrinsicsBPF.td
@@ -26,4 +26,10 @@
   def int_bpf_btf_type_id : GCCBuiltin<"__builtin_bpf_btf_type_id">,
   Intrinsic<[llvm_i32_ty], [llvm_any_ty, llvm_any_ty, llvm_i64_ty],
   [IntrNoMem]>;
+  def int_bpf_preserve_type_info : GCCBuiltin<"__builtin_bpf_preserve_type_info">,
+  Intrinsic<[llvm_i32_ty], [llvm_any_ty, llvm_any_ty, llvm_i64_ty],
+  [IntrNoMem]>;
+  def int_bpf_preserve_enum_value : GCCBuiltin<"__builtin_bpf_preserve_enum_value">,
+  Intrinsic<[llvm_i32_ty], [llvm_any_ty, llvm_any_ty, llvm_i64_ty],
+  [IntrNoMem]>;
 }
Index: clang/test/Sema/builtins-bpf.c
===
--- clang/test/Sema/builtins-bpf.c
+++ clang/test/Sema/builtins-bpf.c
@@ -1,7 +1,29 @@
 // RUN: %clang_cc1 -x c -triple bpf-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
 
-struct s { int a; int b[4]; int c:1; };
-union u { int a; int b[4]; int c:1; };
+struct s {
+  int a;
+  int b[4];
+  int c:1;
+};
+union u {
+  int a;
+  int b[4];
+  int c:1;
+};
+typedef struct {
+  int a;
+  int b;
+} __t;
+typedef int (*__f)(void);
+enum AA {
+  VAL1 = 1,
+  VAL2 = 2,
+  VAL3 = 10,
+};
+typedef enum {
+  VAL10 = 10,
+  VAL11 = 11,
+} __BB;
 
 unsigned invalid1(const int *arg) {
   return __builtin_preserve_field_info(arg, 1); // expected-error {{__builtin_preserve_field_info argument 1 not a field access}}
@@ -46,3 +68,38 @@
 unsigned invalid11(struct s *arg, int info_kind) {
   return __builtin_preserve_field_info(arg->a, info_kind); // expected-error {{__builtin_preserve_field_info argument 2 not a constant}}
 }
+
+unsigned valid12() {
+  const struct s t;
+  return __builtin_preserve_type_info(t, 0) +
+ __builtin_preserve_type_info(*(struct s *)0, 1);
+}
+
+unsigned valid13() {
+  __t t;
+  return __builtin_preserve_type_info(t, 1) +
+ __builtin_preserve_type_info(*(__t *)0, 0);
+}
+
+unsigned valid14() {
+  enum AA t;
+  return __builtin_preserve_type_info(t, 0) +
+ __builtin_preserve_type_info(*(enum AA *)0, 1);
+}
+
+unsigned valid15() {
+  return __builtin_preserve_enum_value(*(enum AA *)VAL2, 1) +
+ __builtin_preserve_enum_value(*(__BB *)10, 0);
+}
+
+unsigned invalid16() {
+  return __builtin_preserve_enum_value(*(enum AA *)0, 1); // expected-error {{__builtin_preserve_enum_value argument 1 invalid}}
+}
+
+unsigned invalid17() {
+  return __builtin_preserve_enum_value(*(enum AA *)VAL10, 1); // expected-error {{__builtin_preserve_enum_value argument 1 invalid}}
+}
+
+unsigned invalid18(struct s *arg) {
+  return __builtin_preserve_type_info(arg->a + 2, 0); // expected-error {{__builtin_preserve_type_info argument 1 invalid}}
+}
Index: clang/test/CodeGen/builtins-bpf-preserve-field-info-4.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-bpf-preserve-field-info-4.c
@@ -0,0 +1,20 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define _(x, y) (__builtin_preserve_enum_value((x), (y)))
+
+enum AA {
+  VAL1 = 1,
+  VAL2 = 2,
+};
+typedef enum AA __AA;
+
+unsigned unit1() {
+  return _(*(enum AA *)VAL2, 0) + _(*(__AA *)2, 1);
+}
+
+// CHECK: call i32 @llvm.bpf.preserve.enum.value.p0i32.i32(i32* inttoptr (i64 2 to i32*), i32 1, i64 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[ENUM_AA:[0-9]+]]
+// CHECK: call i32 @llvm.bpf.preserve.enum.value.p0i32.i32(i32* inttoptr (i64 2 to i32*), i32 1, i64 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[TYPEDEF_ENUM:[0-9]+]]
+
+// CHECK: ![[ENUM_AA]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "AA"
+// CHECK: ![[TYPEDEF_ENUM]] = !DIDerivedType(tag: DW_TAG_typedef, name: "__AA"
Index: clang/test/CodeGen/builtins-bpf-preserve-field-info-3.c
=

[PATCH] D84898: [clang-tidy] Add new checker for complex conditions with no meaning

2020-07-30 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 281937.
vabridgers marked 6 inline comments as done.
vabridgers added a comment.

Address most review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84898

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/ComplexConditionsCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ComplexConditionsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-complex-conditions.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-complex-conditions.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-complex-conditions.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-complex-conditions.c
@@ -0,0 +1,118 @@
+// RUN: %check_clang_tidy %s bugprone-complex-conditions %t
+
+int case1(int p1, int p2, int p3) {
+  if (p1 < p2 < p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case2(int p1, int p2, int p3) {
+  // no warning
+  if ((p1 < p2) && (p2 < p3))
+return 1;
+  return 0;
+}
+
+int case3(int p1, int p2, int p3) {
+  // no warning
+  if ((p1 < p2) && (p2))
+return 1;
+  return 0;
+}
+
+int case4(int p1, int p2, int p3) {
+  // no warning
+  if ((p1) && (p3 < p2))
+return 1;
+  return 0;
+}
+
+int case5(int p1, int p2, int p3) {
+  while (p1 < p3 < p2)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case6(int p1, int p2, int p3) {
+  // should not warn
+  while (p1 && p3 < p2)
+return 1;
+  return 0;
+}
+
+int case7(int p1, int p2, int p3) {
+  // should not warn
+  while ((p1 < p3) < p2)
+return 1;
+  return 0;
+}
+
+int case8(int p1, int p2, int p3) {
+  int ret = p1 < p2 < p3;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+  return ret;
+}
+
+int case9(int p1, int p2, int p3) {
+  int ret = (p1 < p2) < p3 < p1;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+  return ret;
+}
+
+int case10(int p1, int p2, int p3) {
+  if (p1 <= p2 < p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case11(int p1, int p2, int p3) {
+  if (p1 < p2 <= p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case12(int p1, int p2, int p3) {
+  if (p1 <= p2 <= p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case13(int p1, int p2, int p3) {
+  if (p1 > p2 < p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case14(int p1, int p2, int p3) {
+  if (p1 > p2 > p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case15(int p1, int p2, int p3) {
+  if (p1 >= p2 > p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case16(int p1, int p2, int p3) {
+  if (p1 >= p2 >= p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case17(int p1, int p2, int p3) {
+  // should not warn
+  if (p1 >= p2 || p3)
+return 1;
+  return 0;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -51,6 +51,7 @@
`bugprone-bad-signal-to-kill-thread `_,
`bugprone-bool-pointer-implicit-conversion `_, "Yes"
`bugprone-branch-clone `_,
+   `bugprone-complex-conditions `_,
`bugprone-copy-constructor-init `_, "Yes"
`bugprone-dangling-handle `_,
`bugprone-dynamic-static-initializers `_,
@@ -70,7 +71,7 @@
`bugprone-misplaced-widening-cast `_,
`bugprone-move-forwarding-reference `_, "Yes"
`bugprone-multiple-statement-macro `_,
-   `bugprone-no-escape `_, "Yes"
+   `bugprone-no-escape `_,
`bugprone-not-null-terminated-result `_, "Yes"
`bugprone-parent-virtual-call `_, "Yes"
`bugprone-posix-return `_, "Yes"

[clang] 622e461 - [OPENMP]Fix PR46824: Global declare target pointer cannot be accessed in target region.

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

Author: Alexey Bataev
Date: 2020-07-30T11:18:33-04:00
New Revision: 622e46156d9a91206c877a604d069bb3e2dbf294

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

LOG: [OPENMP]Fix PR46824: Global declare target pointer cannot be accessed in 
target region.

Need to map the base pointer for all directives, not only target
data-based ones.
The base pointer is mapped for array sections, array subscript, array
shaping and other array-like constructs with the base pointer. Also,
codegen for use_device_ptr clause was modified to correctly handle
mapping combination of array like constructs + use_device_ptr clause.
The data for use_device_ptr clause is emitted as the last records in the
data mapping array.

Reviewed By: ye-luo

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

Added: 
openmp/libomptarget/test/env/base_ptr_ref_count.c

Modified: 
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_map_codegen.cpp
clang/test/OpenMP/target_update_codegen.cpp
openmp/libomptarget/src/omptarget.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index b8e33948c21c..dc12286c72be 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7392,10 +7392,9 @@ class MappableExprsHandler {
 // &p, &p, sizeof(float*), TARGET_PARAM | TO | FROM
 //
 // map(p[1:24])
+// &p, &p[1], 24*sizeof(float), TARGET_PARAM | TO | FROM | PTR_AND_OBJ
+// in unified shared memory mode or for local pointers
 // p, &p[1], 24*sizeof(float), TARGET_PARAM | TO | FROM
-// for data directives
-// p, p, sizeof(float*), TARGET_PARAM | TO | FROM
-// p, &p[1], 24*sizeof(float), PTR_AND_OBJ | TO | FROM
 //
 // map(s)
 // &s, &s, sizeof(S2), TARGET_PARAM | TO | FROM
@@ -7530,6 +7529,7 @@ class MappableExprsHandler {
 // Track if the map information being generated is the first for a list of
 // components.
 bool IsExpressionFirstInfo = true;
+bool FirstPointerInComplexData = false;
 Address BP = Address::invalid();
 const Expr *AssocExpr = I->getAssociatedExpression();
 const auto *AE = dyn_cast(AssocExpr);
@@ -7572,17 +7572,16 @@ class MappableExprsHandler {
   QualType Ty =
   I->getAssociatedDeclaration()->getType().getNonReferenceType();
   if (Ty->isAnyPointerType() && std::next(I) != CE) {
-BP = CGF.EmitLoadOfPointer(BP, Ty->castAs());
-
-// For non-data directives, we do not need to generate individual map
-// information for the pointer, it can be associated with the combined
-// storage.
+// No need to generate individual map information for the pointer, it
+// can be associated with the combined storage if shared memory mode is
+// active or the base declaration is not global variable.
+const auto *VD = dyn_cast(I->getAssociatedDeclaration());
 if (CGF.CGM.getOpenMPRuntime().hasRequiresUnifiedSharedMemory() ||
-!CurDir.is() ||
-!isOpenMPTargetDataManagementDirective(
-CurDir.get()
-->getDirectiveKind()))
-  ++I;
+!VD || VD->hasLocalStorage())
+  BP = CGF.EmitLoadOfPointer(BP, Ty->castAs());
+else
+  FirstPointerInComplexData = true;
+++I;
   }
 }
 
@@ -7617,8 +7616,19 @@ class MappableExprsHandler {
 EncounteredME = dyn_cast(I->getAssociatedExpression());
 // If we encounter a PTR_AND_OBJ entry from now on it should be marked
 // as MEMBER_OF the parent struct.
-if (EncounteredME)
+if (EncounteredME) {
   ShouldBeMemberOf = true;
+  // Do not emit as complex pointer if this is actually not array-like
+  // expression.
+  if (FirstPointerInComplexData) {
+QualType Ty = std::prev(I)
+  ->getAssociatedDeclaration()
+  ->getType()
+  .getNonReferenceType();
+BP = CGF.EmitLoadOfPointer(BP, Ty->castAs());
+FirstPointerInComplexData = false;
+  }
+}
   }
 
   auto Next = std::next(I);
@@ -7760,7 +7770,8 @@ class MappableExprsHandler {
   // (there is a set of entries for each capture).
   OpenMPOffloadMappingFlags Flags =
   getMapTypeBits(MapType, MapModifiers, MotionModifiers, 
IsImplicit,
- !IsExpressionFirstInfo || RequiresReference,
+ !IsExpressionFirstInfo || RequiresReference ||
+ FirstP

[PATCH] D84898: [clang-tidy] Add new checker for complex conditions with no meaning

2020-07-30 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

I believe all review comments have been address, except for the discussion on 
implementing this in the CFE or as a tidy check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84898

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


[PATCH] D82470: [OpenMP][IRBuilder] Support allocas in nested parallel regions

2020-07-30 Thread Johannes Doerfert via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG19756ef53a49: [OpenMP][IRBuilder] Support allocas in nested 
parallel regions (authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82470

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -6,13 +6,14 @@
 //
 //===--===//
 
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/InstIterator.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "gtest/gtest.h"
@@ -360,9 +361,11 @@
 
   auto FiniCB = [&](InsertPointTy CodeGenIP) { ++NumFinalizationPoints; };
 
+  IRBuilder<>::InsertPoint AllocaIP(&F->getEntryBlock(),
+F->getEntryBlock().getFirstInsertionPt());
   IRBuilder<>::InsertPoint AfterIP =
-  OMPBuilder.CreateParallel(Loc, BodyGenCB, PrivCB, FiniCB, nullptr,
-nullptr, OMP_PROC_BIND_default, false);
+  OMPBuilder.CreateParallel(Loc, AllocaIP, BodyGenCB, PrivCB, FiniCB,
+nullptr, nullptr, OMP_PROC_BIND_default, false);
   EXPECT_EQ(NumBodiesGenerated, 1U);
   EXPECT_EQ(NumPrivatizedVars, 1U);
   EXPECT_EQ(NumFinalizationPoints, 1U);
@@ -400,6 +403,205 @@
   EXPECT_EQ(ForkCI->getArgOperand(3), F->arg_begin());
 }
 
+TEST_F(OpenMPIRBuilderTest, ParallelNested) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  unsigned NumInnerBodiesGenerated = 0;
+  unsigned NumOuterBodiesGenerated = 0;
+  unsigned NumFinalizationPoints = 0;
+
+  auto InnerBodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+BasicBlock &ContinuationIP) {
+++NumInnerBodiesGenerated;
+  };
+
+  auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+// Trivial copy (=firstprivate).
+Builder.restoreIP(AllocaIP);
+Type *VTy = VPtr.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Builder.restoreIP(CodeGenIP);
+Builder.CreateStore(V, ReplacementValue);
+return CodeGenIP;
+  };
+
+  auto FiniCB = [&](InsertPointTy CodeGenIP) { ++NumFinalizationPoints; };
+
+  auto OuterBodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+BasicBlock &ContinuationIP) {
+++NumOuterBodiesGenerated;
+Builder.restoreIP(CodeGenIP);
+BasicBlock *CGBB = CodeGenIP.getBlock();
+BasicBlock *NewBB = SplitBlock(CGBB, &*CodeGenIP.getPoint());
+CGBB->getTerminator()->eraseFromParent();
+;
+
+IRBuilder<>::InsertPoint AfterIP = OMPBuilder.CreateParallel(
+InsertPointTy(CGBB, CGBB->end()), AllocaIP, InnerBodyGenCB, PrivCB,
+FiniCB, nullptr, nullptr, OMP_PROC_BIND_default, false);
+
+Builder.restoreIP(AfterIP);
+Builder.CreateBr(NewBB);
+  };
+
+  IRBuilder<>::InsertPoint AllocaIP(&F->getEntryBlock(),
+F->getEntryBlock().getFirstInsertionPt());
+  IRBuilder<>::InsertPoint AfterIP =
+  OMPBuilder.CreateParallel(Loc, AllocaIP, OuterBodyGenCB, PrivCB, FiniCB,
+nullptr, nullptr, OMP_PROC_BIND_default, false);
+
+  EXPECT_EQ(NumInnerBodiesGenerated, 1U);
+  EXPECT_EQ(NumOuterBodiesGenerated, 1U);
+  EXPECT_EQ(NumFinalizationPoints, 2U);
+
+  Builder.restoreIP(AfterIP);
+  Builder.CreateRetVoid();
+
+  OMPBuilder.finalize();
+
+  EXPECT_EQ(M->size(), 5U);
+  for (Function &OutlinedFn : *M) {
+if (F == &OutlinedFn || OutlinedFn.isDeclaration())
+  continue;
+EXPECT_FALSE(verifyModule(*M, &errs()));
+EXPECT_TRUE(OutlinedFn.hasFnAttribute(Attribute::NoUnwind));
+EXPECT_TRUE(OutlinedFn.hasFnAttribute(Attribute::NoRecurse));
+EXPECT_TRUE(OutlinedFn.hasParamAttribute(0, Attribute::NoAlias));
+EXPECT_TRUE(OutlinedFn.hasParamA

[PATCH] D82822: [OpenMP][FIX] Consistently use OpenMPIRBuilder if requested

2020-07-30 Thread Johannes Doerfert via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGebad64dfe133: [OpenMP][FIX] Consistently use OpenMPIRBuilder 
if requested (authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82822

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/irbuilder_nested_parallel_for.c
  clang/test/OpenMP/task_codegen.cpp

Index: clang/test/OpenMP/task_codegen.cpp
===
--- clang/test/OpenMP/task_codegen.cpp
+++ clang/test/OpenMP/task_codegen.cpp
@@ -33,12 +33,11 @@
   char b;
   S s[2];
   int arr[10][a];
-// CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T]]* @{{.+}})
 // CHECK: [[B_REF:%.+]] = getelementptr inbounds [[STRUCT_SHAREDS]], [[STRUCT_SHAREDS]]* [[CAPTURES:%.+]], i32 0, i32 0
 // CHECK: store i8* [[B]], i8** [[B_REF]]
 // CHECK: [[S_REF:%.+]] = getelementptr inbounds [[STRUCT_SHAREDS]], [[STRUCT_SHAREDS]]* [[CAPTURES]], i32 0, i32 1
 // CHECK: store [2 x [[STRUCT_S]]]* [[S]], [2 x [[STRUCT_S]]]** [[S_REF]]
-// CHECK: [[ORIG_TASK_PTR:%.+]] = call i8* @__kmpc_omp_task_alloc([[IDENT_T]]* @{{.+}}, i32 [[GTID]], i32 33, i64 40, i64 16, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T]]{{.*}}*)* [[TASK_ENTRY1:@.+]] to i32 (i32, i8*)*))
+// CHECK: [[ORIG_TASK_PTR:%.+]] = call i8* @__kmpc_omp_task_alloc([[IDENT_T]]* @{{.+}}, i32 {{%.*}}, i32 33, i64 40, i64 16, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T]]{{.*}}*)* [[TASK_ENTRY1:@.+]] to i32 (i32, i8*)*))
 // CHECK: [[SHAREDS_REF_PTR:%.+]] = getelementptr inbounds [[KMP_TASK_T]], [[KMP_TASK_T]]* [[TASK_PTR:%.+]], i32 0, i32 0
 // CHECK: [[SHAREDS_REF:%.+]] = load i8*, i8** [[SHAREDS_REF_PTR]]
 // CHECK: [[BITCAST:%.+]] = bitcast [[STRUCT_SHAREDS]]* [[CAPTURES]] to i8*
@@ -46,7 +45,7 @@
 // CHECK: [[PRIORITY_REF_PTR:%.+]] = getelementptr inbounds [[KMP_TASK_T]], [[KMP_TASK_T]]* [[TASK_PTR]], i32 0, i32 4
 // CHECK: [[PRIORITY:%.+]] = bitcast %union{{.+}}* [[PRIORITY_REF_PTR]] to i32*
 // CHECK: store i32 {{.+}}, i32* [[PRIORITY]]
-// CHECK: call i32 @__kmpc_omp_task([[IDENT_T]]* @{{.+}}, i32 [[GTID]], i8* [[ORIG_TASK_PTR]])
+// CHECK: call i32 @__kmpc_omp_task([[IDENT_T]]* @{{.+}}, i32 {{%.*}}, i8* [[ORIG_TASK_PTR]])
 #pragma omp task shared(a, b, s) priority(b)
   {
 a = 15;
@@ -55,7 +54,7 @@
   }
 // CHECK: [[S_REF:%.+]] = getelementptr inbounds [[STRUCT_SHAREDS1]], [[STRUCT_SHAREDS1]]* [[CAPTURES:%.+]], i32 0, i32 0
 // CHECK: store [2 x [[STRUCT_S]]]* [[S]], [2 x [[STRUCT_S]]]** [[S_REF]]
-// CHECK: [[ORIG_TASK_PTR:%.+]] = call i8* @__kmpc_omp_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 [[GTID]], i32 1, i64 40, i64 8,
+// CHECK: [[ORIG_TASK_PTR:%.+]] = call i8* @__kmpc_omp_task_alloc([[IDENT_T]]* @{{[^,]+}}, i32 {{%.*}}, i32 1, i64 40, i64 8,
 // CHECK: [[SHAREDS_REF_PTR:%.+]] = getelementptr inbounds [[KMP_TASK_T]], [[KMP_TASK_T]]* [[TASK_PTR:%.+]], i32 0, i32 0
 // CHECK: [[SHAREDS_REF:%.+]] = load i8*, i8** [[SHAREDS_REF_PTR]]
 // CHECK: [[BITCAST:%.+]] = bitcast [[STRUCT_SHAREDS1]]* [[CAPTURES]] to i8*
@@ -101,20 +100,20 @@
 // CHECK: [[T0:%.*]] = getelementptr inbounds [[KMP_DEPEND_INFO]], [[KMP_DEPEND_INFO]]* %{{[^,]+}}, i32 0, i32 2
 // CHECK: store i8 1, i8* [[T0]]
 // CHECK: bitcast [[KMP_DEPEND_INFO]]* [[DEP_BASE]] to i8*
-// CHECK: call i32 @__kmpc_omp_task_with_deps([[IDENT_T]]* @{{.+}}, i32 [[GTID]], i8* [[ORIG_TASK_PTR]], i32 4, i8* %{{[^,]+}}, i32 0, i8* null)
+// CHECK: call i32 @__kmpc_omp_task_with_deps([[IDENT_T]]* @{{.+}}, i32 {{%.*}}, i8* [[ORIG_TASK_PTR]], i32 4, i8* %{{[^,]+}}, i32 0, i8* null)
 #pragma omp task shared(a, s) depend(in : a, b, s, arr[:])
   {
 a = 15;
 s[1].a = 10;
   }
-// CHECK: [[ORIG_TASK_PTR:%.+]] = call i8* @__kmpc_omp_task_alloc([[IDENT_T]]* @{{.+}}, i32 [[GTID]], i32 0, i64 40, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T]]{{.*}}*)* [[TASK_ENTRY2:@.+]] to i32 (i32, i8*)*))
-// CHECK: call i32 @__kmpc_omp_task([[IDENT_T]]* @{{.+}}, i32 [[GTID]], i8* [[ORIG_TASK_PTR]])
+// CHECK: [[ORIG_TASK_PTR:%.+]] = call i8* @__kmpc_omp_task_alloc([[IDENT_T]]* @{{.+}}, i32 {{%.*}}, i32 0, i64 40, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T]]{{.*}}*)* [[TASK_ENTRY2:@.+]] to i32 (i32, i8*)*))
+// CHECK: call i32 @__kmpc_omp_task([[IDENT_T]]* @{{.+}}, i32 {{%.*}}, i8* [[ORIG_TASK_PTR]])
 #pragma omp task untied
   {
 #pragma omp critical
 a = 1;
   }
-// CHECK: [[ORIG_TASK_PTR:%.+]] = call i8* @__kmpc_omp_task_alloc([[IDENT_T]]* @{{.+}}, i32 [[GTID]], i32 0, i64 40, i64 1,
+// CHECK: [[ORIG_TASK_PTR:%.+]] = call i8* @__kmpc_omp_task_alloc([[IDENT_T]]* @{{.+}}, i32 {{%.*}}, i32 0, i64 40, i64 1,
 // CHECK: getelementptr inbounds [2 x [[STRUCT_S]]], [2 x [[STRUCT_S]]]* [[S]], i64 0, i64 0
 // CHECK: getelementptr inbounds [[KMP_DEPEND_INFO]], [[KMP_DEPEND_INFO]]* %{{[^,]+}}

[clang] 19756ef - [OpenMP][IRBuilder] Support allocas in nested parallel regions

2020-07-30 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2020-07-30T10:19:39-05:00
New Revision: 19756ef53a498b7aa1fbac9e3a7cd3aa8e110fad

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

LOG: [OpenMP][IRBuilder] Support allocas in nested parallel regions

We need to keep track of the alloca insertion point (which we already
communicate via the callback to the user) as we place allocas as well.

Reviewed By: fghanim, SouraVX

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 0ee1133ebaa1..df1cc1666de4 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1707,9 +1707,11 @@ void CodeGenFunction::EmitOMPParallelDirective(const 
OMPParallelDirective &S) {
 
 CGCapturedStmtInfo CGSI(*CS, CR_OpenMP);
 CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(*this, &CGSI);
-Builder.restoreIP(OMPBuilder.CreateParallel(Builder, BodyGenCB, PrivCB,
-FiniCB, IfCond, NumThreads,
-ProcBind, S.hasCancel()));
+llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
+AllocaInsertPt->getParent(), AllocaInsertPt->getIterator());
+Builder.restoreIP(
+OMPBuilder.CreateParallel(Builder, AllocaIP, BodyGenCB, PrivCB, FiniCB,
+  IfCond, NumThreads, ProcBind, 
S.hasCancel()));
 return;
   }
 

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h 
b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index 95eed59f1b3d..f813a730342e 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -156,6 +156,7 @@ class OpenMPIRBuilder {
   /// Generator for '#omp parallel'
   ///
   /// \param Loc The insert and source location description.
+  /// \param AllocaIP The insertion points to be used for alloca instructions.
   /// \param BodyGenCB Callback that will generate the region code.
   /// \param PrivCB Callback to copy a given variable (think copy constructor).
   /// \param FiniCB Callback to finalize variable copies.
@@ -166,10 +167,11 @@ class OpenMPIRBuilder {
   ///
   /// \returns The insertion position *after* the parallel.
   IRBuilder<>::InsertPoint
-  CreateParallel(const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB,
- PrivatizeCallbackTy PrivCB, FinalizeCallbackTy FiniCB,
- Value *IfCondition, Value *NumThreads,
- omp::ProcBindKind ProcBind, bool IsCancellable);
+  CreateParallel(const LocationDescription &Loc, InsertPointTy AllocaIP,
+ BodyGenCallbackTy BodyGenCB, PrivatizeCallbackTy PrivCB,
+ FinalizeCallbackTy FiniCB, Value *IfCondition,
+ Value *NumThreads, omp::ProcBindKind ProcBind,
+ bool IsCancellable);
 
   /// Generator for '#omp flush'
   ///

diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 9468a3aa3c8d..a5fe4ec87c46 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -394,9 +394,10 @@ void OpenMPIRBuilder::emitCancelationCheckImpl(
 }
 
 IRBuilder<>::InsertPoint OpenMPIRBuilder::CreateParallel(
-const LocationDescription &Loc, BodyGenCallbackTy BodyGenCB,
-PrivatizeCallbackTy PrivCB, FinalizeCallbackTy FiniCB, Value *IfCondition,
-Value *NumThreads, omp::ProcBindKind ProcBind, bool IsCancellable) {
+const LocationDescription &Loc, InsertPointTy OuterAllocaIP,
+BodyGenCallbackTy BodyGenCB, PrivatizeCallbackTy PrivCB,
+FinalizeCallbackTy FiniCB, Value *IfCondition, Value *NumThreads,
+omp::ProcBindKind ProcBind, bool IsCancellable) {
   if (!updateToLocation(Loc))
 return Loc.IP;
 
@@ -429,7 +430,9 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::CreateParallel(
   // we want to delete at the end.
   SmallVector ToBeDeleted;
 
-  Builder.SetInsertPoint(OuterFn->getEntryBlock().getFirstNonPHI());
+  // Change the location to the outer alloca insertion point to create and
+  // initialize the allocas we pass into the parallel region.
+  Builder.restoreIP(OuterAllocaIP);
   AllocaInst *TIDAddr = Builder.CreateAlloca(Int32, nullptr, "tid.addr");
   AllocaInst *ZeroAddr = Builder.CreateAlloca(Int32, nullptr, "zero.addr");
 
@@ -481,9 +484,9 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::CreateParallel(
 
   // Generate the privatization allocas in the block that will become the entry
   // o

[clang] ebad64d - [OpenMP][FIX] Consistently use OpenMPIRBuilder if requested

2020-07-30 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2020-07-30T10:19:40-05:00
New Revision: ebad64dfe133e64d1df6b82e6ef2fb031d635b08

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

LOG: [OpenMP][FIX] Consistently use OpenMPIRBuilder if requested

When we use the OpenMPIRBuilder for the parallel region we need to also
use it to get the thread ID (among other things) in the body. This is
because CGOpenMPRuntime::getThreadID() and
CGOpenMPRuntime::emitUpdateLocation implicitly assumes that if they are
called from within a parallel region there is a certain structure to the
code and certain members of the OMPRegionInfo are initialized. It might
make sense to initialize them even if we use the OpenMPIRBuilder but we
would preferably get rid of such state instead.

Bug reported by Anchu Rajendran Sudhakumari.

Depends on D82470.

Reviewed By: anchu-rajendran

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

Added: 
clang/test/OpenMP/irbuilder_nested_parallel_for.c

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/cancel_codegen.cpp
clang/test/OpenMP/task_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index dc12286c72be..60c7081b135b 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1455,6 +1455,19 @@ void 
CGOpenMPRuntime::clearLocThreadIdInsertPt(CodeGenFunction &CGF) {
   }
 }
 
+static StringRef getIdentStringFromSourceLocation(CodeGenFunction &CGF,
+  SourceLocation Loc,
+  SmallString<128> &Buffer) {
+  llvm::raw_svector_ostream OS(Buffer);
+  // Build debug location
+  PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
+  OS << ";" << PLoc.getFilename() << ";";
+  if (const auto *FD = dyn_cast_or_null(CGF.CurFuncDecl))
+OS << FD->getQualifiedNameAsString();
+  OS << ";" << PLoc.getLine() << ";" << PLoc.getColumn() << ";;";
+  return OS.str();
+}
+
 llvm::Value *CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,
  SourceLocation Loc,
  unsigned Flags) {
@@ -1464,6 +1477,16 @@ llvm::Value 
*CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,
   Loc.isInvalid())
 return getOrCreateDefaultLocation(Flags).getPointer();
 
+  // If the OpenMPIRBuilder is used we need to use it for all location handling
+  // as the clang invariants used below might be broken.
+  if (CGM.getLangOpts().OpenMPIRBuilder) {
+SmallString<128> Buffer;
+OMPBuilder.updateToLocation(CGF.Builder.saveIP());
+auto *SrcLocStr = OMPBuilder.getOrCreateSrcLocStr(
+getIdentStringFromSourceLocation(CGF, Loc, Buffer));
+return OMPBuilder.getOrCreateIdent(SrcLocStr, IdentFlag(Flags));
+  }
+
   assert(CGF.CurFn && "No function in current CodeGenFunction.");
 
   CharUnits Align = CGM.getContext().getTypeAlignInChars(IdentQTy);
@@ -1497,15 +1520,9 @@ llvm::Value 
*CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,
 
   llvm::Value *OMPDebugLoc = OpenMPDebugLocMap.lookup(Loc.getRawEncoding());
   if (OMPDebugLoc == nullptr) {
-SmallString<128> Buffer2;
-llvm::raw_svector_ostream OS2(Buffer2);
-// Build debug location
-PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
-OS2 << ";" << PLoc.getFilename() << ";";
-if (const auto *FD = dyn_cast_or_null(CGF.CurFuncDecl))
-  OS2 << FD->getQualifiedNameAsString();
-OS2 << ";" << PLoc.getLine() << ";" << PLoc.getColumn() << ";;";
-OMPDebugLoc = CGF.Builder.CreateGlobalStringPtr(OS2.str());
+SmallString<128> Buffer;
+OMPDebugLoc = CGF.Builder.CreateGlobalStringPtr(
+getIdentStringFromSourceLocation(CGF, Loc, Buffer));
 OpenMPDebugLocMap[Loc.getRawEncoding()] = OMPDebugLoc;
   }
   // *psource = ";;";
@@ -1519,6 +1536,16 @@ llvm::Value 
*CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,
 llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF,
   SourceLocation Loc) {
   assert(CGF.CurFn && "No function in current CodeGenFunction.");
+  // If the OpenMPIRBuilder is used we need to use it for all thread id calls 
as
+  // the clang invariants used below might be broken.
+  if (CGM.getLangOpts().OpenMPIRBuilder) {
+SmallString<128> Buffer;
+OMPBuilder.updateToLocation(CGF.Builder.saveIP());
+auto *SrcLocStr = OMPBuilder.getOrCreateSrcLocStr(
+getIdentStringFromSourceLocation(CGF, Loc, Buffer));
+return OMPBuilder.getOrCreateThreadID(
+OMPBuilder.getOrCreateIdent(SrcLocStr));
+  }
 
   llvm::Value *ThreadID = nullptr

[PATCH] D84534: [AIX] Static init frontend recovery and backend support

2020-07-30 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 281938.
Xiangling_L added a comment.

Removed the disablement in IncrementalProcessingTest.cpp cross-target test;


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

https://reviews.llvm.org/D84534

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
  clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp
  clang/unittests/CodeGen/IncrementalProcessingTest.cpp
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-static-init-default-priority.ll
  llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
  llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll

Index: llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll
@@ -0,0 +1,10 @@
+; RUN: not llc -mtriple powerpc-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+; RUN: not llc -mtriple powerpc64-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 655, void ()* @foo, i8* null }]
+
+define void @foo() {
+  ret void
+}
+
+// CHECK: LLVM ERROR: prioritized sinit and sterm functions are not yet supported
Index: llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
@@ -0,0 +1,7 @@
+; RUN: not llc -mtriple powerpc-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+; RUN: not llc -mtriple powerpc64-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }]
+@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @bar, i8* null }]
+
+// CHECK: LLVM ERROR: cannot produce a unique identifier for this module based on strong external symbols
Index: llvm/test/CodeGen/PowerPC/aix-static-init-default-priority.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-static-init-default-priority.ll
@@ -0,0 +1,60 @@
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s
+
+@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @init1, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @init2, i8* null }]
+@llvm.global_dtors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @destruct1, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @destruct2, i8* null }]
+
+define i32 @extFunc() {
+entry:
+  ret i32 3
+}
+
+define internal void @init1() {
+  ret void
+}
+
+define internal void @destruct1() {
+  ret void
+}
+
+define internal void @init2() {
+  ret void
+}
+
+define internal void @destruct2() {
+  ret void
+}
+
+; CHECK:   .lglobl	init1[DS]
+; CHECK:   .lglobl	.init1
+; CHECK:   .csect init1[DS]
+; CHECK: __sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_0: # @init1
+; CHECK: .init1:
+; CHECK: .__sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_0:
+; CHECK:   .lglobl	destruct1[DS]
+; CHECK:   .lglobl	.destruct1
+; CHECK:   .csect destruct1[DS]
+; CHECK: __sterm8000_clang_ac404299654d2af7eae71e75c17f7c9b_0: # @destruct1
+; CHECK: .destruct1:
+; CHECK: .__sterm8000_clang_ac404299654d2af7eae71e75c17f7c9b_0:
+; CHECK:   .lglobl	init2[DS]
+; CHECK:   .lglobl	.init2
+; CHECK:   .csect init2[DS]
+; CHECK: __sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_1: # @init2
+; CHECK: .init2:
+; CHECK: .__sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_1:
+; CHECK:   .lglobl	destruct2[DS]
+; CHECK:   .lglobl	.destruct2
+; CHECK:   .csect destruct2[DS]
+; CHECK: __sterm8000_clang_ac404299654d2af7eae71e75c17f7c9b_1: # @destruct2
+; CHECK: .destruct2:
+; CHECK: .__sterm8000_clang_ac404299654d2af7eae71e75c17f7c9b_1:
+
+; CHECK: 	.globl	__sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_0
+; CHECK: 	.globl	.__sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_0
+; CHECK: 	.globl	__sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_1
+; CHECK: 	.globl	.__sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_1
+; CHECK: 	.globl	__sterm8000_clang_ac404299654d2af7eae71e75c17f7c9b_0
+; CHECK: 	.globl	.__sterm8000_clang_ac404299654d2af7eae

[PATCH] D84898: [clang-tidy] Add new checker for complex conditions with no meaning

2020-07-30 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:75
+
+  Finds complex conditions using `<`, `>`, `<=`, and `>=` that could be
+  interpreted ambiguously.

Double back-ticks, not single ones.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-complex-conditions.rst:6
+
+Finds complex conditions using `<`, `>`, `<=`, and `>=` that could be
+interpreted ambiguously.

Double back-ticks, not single ones.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84898

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


[PATCH] D84260: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 3

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



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h:201-205
   /// Declare generalized virtual functions which need to be defined
-  /// by all specializations of OpenMPGPURuntime Targets.
+  /// by all specializations of OpenMPGPURuntime Targets like AMDGCN
+  /// and NVPTX.
+
+  /// Get the GPU warp size.

Add these notes to the specialized functions too. It is required for better 
doxygen docs



Comment at: clang/test/OpenMP/amdgcn_target_codegen.cpp:17-19
+// CHECK-DAG: [[VAR:%.+]] = trunc i64 [[NUM_THREADS]] to i32
+// CHECK-DAG: sub nuw i32 [[VAR]], 64
+// CHECK-DAG: call i32 @llvm.amdgcn.workitem.id.x()

Same, the order of these checks should be strict



Comment at: clang/test/OpenMP/amdgcn_target_codegen.cpp:34-35
+// CHECK: [[NUM_THREADS:%.+]] = call i64 @__ockl_get_local_size(i32 0)
+// CHECK-DAG: [[VAR:%.+]] = trunc i64 [[NUM_THREADS]] to i32
+// CHECK-DAG: call void @__kmpc_spmd_kernel_init(i32 [[VAR]], i16 0, i16 0)
+#pragma omp target simd

It should not be `CHECK-DAG`, the order of these 2 instructions is defined and 
the second one should definitely follow the first one



Comment at: clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp:11
+  // CHECK-LABEL: test_amdgcn_target_temp_alloca
+  // CHECK-LABEL: entry:
+

`entry:` again



Comment at: clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp:15-17
+  // CHECK:  [[VAR:%.+]].addr = alloca [100 x i32]*, align 8, addrspace(5)
+  // CHECK-NEXT: [[VAR]].addr.ascast = addrspacecast [100 x i32]* 
addrspace(5)* [[VAR]].addr to [100 x i32]**
+  // CHECK-DAG:  store [100 x i32]* [[VAR]], [100 x i32]** 
[[VAR]].addr.ascast, align 8

Do not rely on the names again. Even as part of regexps



Comment at: clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp:17
+  // CHECK-NEXT: [[VAR]].addr.ascast = addrspacecast [100 x i32]* 
addrspace(5)* [[VAR]].addr to [100 x i32]**
+  // CHECK-DAG:  store [100 x i32]* [[VAR]], [100 x i32]** 
[[VAR]].addr.ascast, align 8
+

Just `CHECK`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84260

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


[PATCH] D84422: [OpenMP] Fix `present` for exit from `omp target data`

2020-07-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


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

https://reviews.llvm.org/D84422

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


[PATCH] D84898: [clang-tidy] Add new checker for complex conditions with no meaning

2020-07-30 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 281943.
vabridgers added a comment.

Address backticks in rst files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84898

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/ComplexConditionsCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ComplexConditionsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-complex-conditions.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-complex-conditions.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-complex-conditions.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-complex-conditions.c
@@ -0,0 +1,118 @@
+// RUN: %check_clang_tidy %s bugprone-complex-conditions %t
+
+int case1(int p1, int p2, int p3) {
+  if (p1 < p2 < p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case2(int p1, int p2, int p3) {
+  // no warning
+  if ((p1 < p2) && (p2 < p3))
+return 1;
+  return 0;
+}
+
+int case3(int p1, int p2, int p3) {
+  // no warning
+  if ((p1 < p2) && (p2))
+return 1;
+  return 0;
+}
+
+int case4(int p1, int p2, int p3) {
+  // no warning
+  if ((p1) && (p3 < p2))
+return 1;
+  return 0;
+}
+
+int case5(int p1, int p2, int p3) {
+  while (p1 < p3 < p2)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case6(int p1, int p2, int p3) {
+  // should not warn
+  while (p1 && p3 < p2)
+return 1;
+  return 0;
+}
+
+int case7(int p1, int p2, int p3) {
+  // should not warn
+  while ((p1 < p3) < p2)
+return 1;
+  return 0;
+}
+
+int case8(int p1, int p2, int p3) {
+  int ret = p1 < p2 < p3;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+  return ret;
+}
+
+int case9(int p1, int p2, int p3) {
+  int ret = (p1 < p2) < p3 < p1;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+  return ret;
+}
+
+int case10(int p1, int p2, int p3) {
+  if (p1 <= p2 < p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case11(int p1, int p2, int p3) {
+  if (p1 < p2 <= p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case12(int p1, int p2, int p3) {
+  if (p1 <= p2 <= p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case13(int p1, int p2, int p3) {
+  if (p1 > p2 < p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case14(int p1, int p2, int p3) {
+  if (p1 > p2 > p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case15(int p1, int p2, int p3) {
+  if (p1 >= p2 > p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case16(int p1, int p2, int p3) {
+  if (p1 >= p2 >= p3)
+return 1;
+  return 0;
+  // CHECK-MESSAGES: warning: comparisons like `X<=Y<=Z` have no mathematical meaning [bugprone-complex-conditions]
+}
+
+int case17(int p1, int p2, int p3) {
+  // should not warn
+  if (p1 >= p2 || p3)
+return 1;
+  return 0;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -51,6 +51,7 @@
`bugprone-bad-signal-to-kill-thread `_,
`bugprone-bool-pointer-implicit-conversion `_, "Yes"
`bugprone-branch-clone `_,
+   `bugprone-complex-conditions `_,
`bugprone-copy-constructor-init `_, "Yes"
`bugprone-dangling-handle `_,
`bugprone-dynamic-static-initializers `_,
@@ -70,7 +71,7 @@
`bugprone-misplaced-widening-cast `_,
`bugprone-move-forwarding-reference `_, "Yes"
`bugprone-multiple-statement-macro `_,
-   `bugprone-no-escape `_, "Yes"
+   `bugprone-no-escape `_,
`bugprone-not-null-terminated-result `_, "Yes"
`bugprone-parent-virtual-call `_, "Yes"
`bugprone-posix-return `_, "Yes"
Index: clang-tools-extra/docs/clang-tidy/che

[PATCH] D84898: [clang-tidy] Add new checker for complex conditions with no meaning

2020-07-30 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers marked 2 inline comments as done.
vabridgers added a comment.

Thanks Eugene, I think the backtick issue has been addressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84898

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


[PATCH] D84939: [clangd] Propagate remote index errors via Expected

2020-07-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 281946.
kbobyrev marked 12 inline comments as done.
kbobyrev added a comment.

Resolve most review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84939

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "../TestTU.h"
+#include "Index.pb.h"
 #include "TestFS.h"
 #include "index/Index.h"
 #include "index/Ref.h"
@@ -97,11 +98,11 @@
   "clangd/unittests/remote/MarshallingTests.cpp",
   Strings);
   auto Serialized = ProtobufMarshaller.toProtobuf(Original);
-  ASSERT_TRUE(Serialized);
+  ASSERT_TRUE(bool(Serialized));
   EXPECT_EQ(Serialized->location().file_path(),
 "clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp");
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  ASSERT_TRUE(Deserialized);
+  ASSERT_TRUE(bool(Deserialized));
   EXPECT_STREQ(Deserialized->Location.FileURI,
testPathURI("home/my-projects/llvm-project/clang-tools-extra/"
"clangd/unittests/remote/MarshallingTests.cpp",
@@ -109,12 +110,16 @@
 
   // Can't have empty paths.
   *Serialized->mutable_location()->mutable_file_path() = std::string();
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 
   clangd::Ref WithInvalidURI;
   // Invalid URI results in serialization failure.
   WithInvalidURI.Location.FileURI = "This is not a URI";
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(WithInvalidURI));
+  auto DeserializedRef = ProtobufMarshaller.toProtobuf(WithInvalidURI);
+  EXPECT_FALSE(bool(DeserializedRef));
+  llvm::consumeError(DeserializedRef.takeError());
 
   // Can not use URIs with scheme different from "file".
   auto UnittestURI =
@@ -122,14 +127,18 @@
   ASSERT_TRUE(bool(UnittestURI));
   WithInvalidURI.Location.FileURI =
   Strings.save(UnittestURI->toString()).begin();
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(WithInvalidURI));
+  auto DeserializedSymbol = ProtobufMarshaller.toProtobuf(WithInvalidURI);
+  EXPECT_FALSE(bool(DeserializedSymbol));
+  llvm::consumeError(DeserializedSymbol.takeError());
 
   // Paths transmitted over the wire can not be absolute, they have to be
   // relative.
   Ref WithAbsolutePath;
   *WithAbsolutePath.mutable_location()->mutable_file_path() =
   "/usr/local/user/home/HelloWorld.cpp";
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(WithAbsolutePath));
+  Deserialized = ProtobufMarshaller.fromProtobuf(WithAbsolutePath);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 }
 
 TEST(RemoteMarshallingTest, SymbolSerialization) {
@@ -142,9 +151,9 @@
   // Check that symbols are exactly the same if the path to indexed project is
   // the same on indexing machine and the client.
   auto Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  ASSERT_TRUE(Serialized);
+  ASSERT_TRUE(bool(Serialized));
   auto Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
-  ASSERT_TRUE(Deserialized);
+  ASSERT_TRUE(bool(Deserialized));
   EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
   // Serialized paths are relative and have UNIX slashes.
   EXPECT_EQ(convert_to_slash(Serialized->definition().file_path(),
@@ -156,36 +165,44 @@
   // Missing definition is OK.
   Sym.Definition = clangd::SymbolLocation();
   Serialized = ProtobufMarshaller.toProtobuf(Sym);
-  ASSERT_TRUE(Serialized);
-  EXPECT_TRUE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  ASSERT_TRUE(bool(Serialized));
+  EXPECT_TRUE(bool(ProtobufMarshaller.fromProtobuf(*Serialized)));
 
   // Relative path is absolute.
   *Serialized->mutable_canonical_declaration()->mutable_file_path() =
   convert_to_slash("/path/to/Declaration.h");
-  EXPECT_FALSE(ProtobufMarshaller.fromProtobuf(*Serialized));
+  Deserialized = ProtobufMarshaller.fromProtobuf(*Serialized);
+  EXPECT_FALSE(bool(Deserialized));
+  llvm::consumeError(Deserialized.takeError());
 
   // Fail with an invalid URI.
   Sym.Definition.FileURI = "Not A URI";
-  EXPECT_FALSE(ProtobufMarshaller.toProtobuf(Sym));
+  Serialized = ProtobufMarshaller.toProtobuf(Sym);
+  EXPECT_FALSE(bool(Serialized));

[PATCH] D84939: [clangd] Propagate remote index errors via Expected

2020-07-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:313
  RelativePath, llvm::sys::path::Style::posix));
-  if (RelativePath.empty()) {
-return llvm::None;
-  }
-  if (llvm::sys::path::is_absolute(RelativePath)) {
-return llvm::None;
-  }
+  if (RelativePath.empty())
+return make_error("Empty relative path.",

kadircet wrote:
> is `RelativePath` user provided? can't we just assert on non-emptiness and 
> non-absoluteness and make this function return a std::string instead?
Could you elaborate on what you mean by user provided? Relative path is 
something that comes from the remote index. Ideally, this is non-empty and 
relative but I think the safer option is to maybe check for errors? Actually, 
I'm not sure about this but it's not user provided as in "given as a flag 
passed to CLI invocation by the end user".

I think the point here is making errors recoverable and not shutting down the 
client, otherwise everything could be an assertion? Same in other places.

WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84939

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


[PATCH] D84232: [clangd] Set minimum gRPC version to 1.27

2020-07-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

This patch is not ready for review yet; planned changes: check if the version 
is between 1.25.0 and 1.26.0-4 and bail out in such cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84232

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


[clang-tools-extra] 6a043ec - [clang-tidy] Fix ODR violation in unittests.

2020-07-30 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-07-30T08:52:47-07:00
New Revision: 6a043ecc0cf4d257d06c4fe0c3d5e1d9a8c7ea94

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

LOG: [clang-tidy] Fix ODR violation in unittests.

Both tests define clang::tidy::test::TestCheck::registerMatchers().
This is UB and causes linker to sometimes choose the wrong overload.

Put classes into anonymous namespaces to avoid the problem.

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

Added: 


Modified: 
clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
index a8729660bdce..0894e5fd5eb9 100644
--- a/clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -6,6 +6,7 @@ namespace clang {
 namespace tidy {
 namespace test {
 
+namespace {
 class TestCheck : public ClangTidyCheck {
 public:
   TestCheck(StringRef Name, ClangTidyContext *Context)
@@ -20,17 +21,8 @@ class TestCheck : public ClangTidyCheck {
 diag(Var->getTypeSpecStartLoc(), "type specifier");
   }
 };
+} // namespace
 
-// FIXME: This test seems to cause a strange linking interference
-// with the ValidConfiguration.ValidEnumOptions test on macOS.
-// If both tests are enabled, this test will fail as if
-// runCheckOnCode() is not invoked at all. Looks like a linker bug.
-// For now both tests are disabled on macOS. It is not sufficient
-// to only disable the other test because this test keeps failing
-// under Address Sanitizer, which may be an indication of more
-// such linking interference with other tests and this test
-// seems to be in the center of it.
-#ifndef __APPLE__
 TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
   std::vector Errors;
   runCheckOnCode("int a;", &Errors);
@@ -38,7 +30,6 @@ TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
   EXPECT_EQ("type specifier", Errors[0].Message.Message);
   EXPECT_EQ("variable", Errors[1].Message.Message);
 }
-#endif
 
 } // namespace test
 } // namespace tidy

diff  --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
index c4239af0e767..bfa594098fb7 100644
--- a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -118,6 +118,7 @@ TEST(ParseConfiguration, MergeConfigurations) {
   EXPECT_TRUE(*Options.UseColor);
 }
 
+namespace {
 class TestCheck : public ClangTidyCheck {
 public:
   TestCheck(ClangTidyContext *Context) : ClangTidyCheck("test", Context) {}
@@ -140,6 +141,7 @@ class TestCheck : public ClangTidyCheck {
 return Options.getLocalOrGlobal(std::forward(Arguments)...);
   }
 };
+} // namespace
 
 #define CHECK_VAL(Value, Expected) 
\
   do { 
\
@@ -222,9 +224,6 @@ TEST(CheckOptionsValidation, ValidIntOptions) {
 #undef CHECK_ERROR_INT
 }
 
-// FIXME: Figure out why this test causes crashes on mac os.
-// See also comments around the ClangTidyDiagnosticConsumer.SortsErrors test.
-#ifndef __APPLE__
 TEST(ValidConfiguration, ValidEnumOptions) {
 
   ClangTidyOptions Options;
@@ -276,7 +275,6 @@ TEST(ValidConfiguration, ValidEnumOptions) {
 
 #undef CHECK_ERROR_ENUM
 }
-#endif
 
 #undef CHECK_VAL
 #undef CHECK_ERROR



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


[PATCH] D84902: [clang-tidy] Fix ODR violation in unittests.

2020-07-30 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a043ecc0cf4: [clang-tidy] Fix ODR violation in unittests. 
(authored by dergachev.a).
Herald added a subscriber: steakhal.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84902

Files:
  clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -118,6 +118,7 @@
   EXPECT_TRUE(*Options.UseColor);
 }
 
+namespace {
 class TestCheck : public ClangTidyCheck {
 public:
   TestCheck(ClangTidyContext *Context) : ClangTidyCheck("test", Context) {}
@@ -140,6 +141,7 @@
 return Options.getLocalOrGlobal(std::forward(Arguments)...);
   }
 };
+} // namespace
 
 #define CHECK_VAL(Value, Expected) 
\
   do { 
\
@@ -222,9 +224,6 @@
 #undef CHECK_ERROR_INT
 }
 
-// FIXME: Figure out why this test causes crashes on mac os.
-// See also comments around the ClangTidyDiagnosticConsumer.SortsErrors test.
-#ifndef __APPLE__
 TEST(ValidConfiguration, ValidEnumOptions) {
 
   ClangTidyOptions Options;
@@ -276,7 +275,6 @@
 
 #undef CHECK_ERROR_ENUM
 }
-#endif
 
 #undef CHECK_VAL
 #undef CHECK_ERROR
Index: 
clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -6,6 +6,7 @@
 namespace tidy {
 namespace test {
 
+namespace {
 class TestCheck : public ClangTidyCheck {
 public:
   TestCheck(StringRef Name, ClangTidyContext *Context)
@@ -20,17 +21,8 @@
 diag(Var->getTypeSpecStartLoc(), "type specifier");
   }
 };
+} // namespace
 
-// FIXME: This test seems to cause a strange linking interference
-// with the ValidConfiguration.ValidEnumOptions test on macOS.
-// If both tests are enabled, this test will fail as if
-// runCheckOnCode() is not invoked at all. Looks like a linker bug.
-// For now both tests are disabled on macOS. It is not sufficient
-// to only disable the other test because this test keeps failing
-// under Address Sanitizer, which may be an indication of more
-// such linking interference with other tests and this test
-// seems to be in the center of it.
-#ifndef __APPLE__
 TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
   std::vector Errors;
   runCheckOnCode("int a;", &Errors);
@@ -38,7 +30,6 @@
   EXPECT_EQ("type specifier", Errors[0].Message.Message);
   EXPECT_EQ("variable", Errors[1].Message.Message);
 }
-#endif
 
 } // namespace test
 } // namespace tidy


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -118,6 +118,7 @@
   EXPECT_TRUE(*Options.UseColor);
 }
 
+namespace {
 class TestCheck : public ClangTidyCheck {
 public:
   TestCheck(ClangTidyContext *Context) : ClangTidyCheck("test", Context) {}
@@ -140,6 +141,7 @@
 return Options.getLocalOrGlobal(std::forward(Arguments)...);
   }
 };
+} // namespace
 
 #define CHECK_VAL(Value, Expected) \
   do { \
@@ -222,9 +224,6 @@
 #undef CHECK_ERROR_INT
 }
 
-// FIXME: Figure out why this test causes crashes on mac os.
-// See also comments around the ClangTidyDiagnosticConsumer.SortsErrors test.
-#ifndef __APPLE__
 TEST(ValidConfiguration, ValidEnumOptions) {
 
   ClangTidyOptions Options;
@@ -276,7 +275,6 @@
 
 #undef CHECK_ERROR_ENUM
 }
-#endif
 
 #undef CHECK_VAL
 #undef CHECK_ERROR
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -6,6 +6,7 @@
 namespace tidy {
 namespace test {
 
+namespace {
 class TestCheck : public ClangTidyCheck {
 public:
   TestCheck(StringRef Name, ClangTidyContext *Context)
@@ -20,17 +21,8 @@
 diag(Var->getTypeSpecStartLoc(), "type specifier");
   }
 };
+} // namespace
 
-// FIXME: This test seems to cause a strange linking interference
-// with the ValidConfiguration.ValidEnumOptions test on macOS.
-// If b

[PATCH] D84422: [OpenMP] Fix `present` for exit from `omp target data`

2020-07-30 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked an inline comment as done.
jdenny added a comment.

Thanks for the review.

As discussed during the 7/29 call, I'll wait to push until we're sure about 
what the OpenMP committee intended here.  I'm pursuing this and will report 
back when I have more information.


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

https://reviews.llvm.org/D84422

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


[PATCH] D84924: [clang-tidy][WIP] Added command line option `fix-notes`

2020-07-30 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:109
 SourceMgr(Diags, Files), Context(Context), ApplyFixes(ApplyFixes),
-TotalFixes(0), AppliedFixes(0), WarningsAsErrors(0) {
+ApplyAnyFix(ApplyAnyFix), TotalFixes(0), AppliedFixes(0),
+WarningsAsErrors(0) {

It'll be reasonable to use member initialization for `TotalFixes`, 
`AppliedFixes`, `WarningsAsErrors`.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:252
   RemoveIncompatibleErrors(RemoveIncompatibleErrors),
-  LastErrorRelatesToUserCode(false), LastErrorPassesLineFilter(false),
-  LastErrorWasIgnored(false) {}
+  FindAnyFixIt(FindAnyFixit), LastErrorRelatesToUserCode(false),
+  LastErrorPassesLineFilter(false), LastErrorWasIgnored(false) {}

It'll be reasonable to use member initialization for 
`LastErrorRelatesToUserCode`, `LastErrorPassesLineFilter`, 
`LastErrorWasIgnored`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84924

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


[PATCH] D84886: Create LoopNestPass

2020-07-30 Thread Ta-Wei Tu via Phabricator via cfe-commits
TaWeiTu updated this revision to Diff 281954.
TaWeiTu added a comment.

Fix loop deletion and rotation tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84886

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Analysis/LoopNestAnalysis.h
  llvm/include/llvm/Analysis/LoopNestAnalysisManager.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Transforms/Scalar/LoopNestPassManager.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/include/llvm/Transforms/Utils/LoopUtils.h
  llvm/lib/Analysis/CMakeLists.txt
  llvm/lib/Analysis/LoopNestAnalysis.cpp
  llvm/lib/Analysis/LoopNestAnalysisManager.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Scalar/CMakeLists.txt
  llvm/lib/Transforms/Scalar/LoopNestPassManager.cpp
  llvm/lib/Transforms/Utils/LoopUtils.cpp
  llvm/test/Transforms/LICM/assume.ll
  llvm/test/Transforms/LoopDeletion/invalidation.ll
  llvm/test/Transforms/LoopDeletion/multiple-exit-conditions.ll
  llvm/test/Transforms/LoopNest/print.ll
  llvm/test/Transforms/LoopRotate/basic.ll
  llvm/test/Transforms/LoopRotate/freeze-crash.ll
  llvm/test/Transforms/LoopRotate/multiple-deopt-exits.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
  llvm/tools/opt/NewPMDriver.cpp
  llvm/unittests/IR/PassBuilderCallbacksTest.cpp
  llvm/unittests/Transforms/Scalar/LICMTest.cpp
  polly/unittests/ScopPassManager/PassManagerTest.cpp

Index: polly/unittests/ScopPassManager/PassManagerTest.cpp
===
--- polly/unittests/ScopPassManager/PassManagerTest.cpp
+++ polly/unittests/ScopPassManager/PassManagerTest.cpp
@@ -16,6 +16,7 @@
 protected:
   ModuleAnalysisManager MAM;
   FunctionAnalysisManager FAM;
+  LoopNestAnalysisManager LNAM;
   LoopAnalysisManager LAM;
   CGSCCAnalysisManager CGAM;
   ScopAnalysisManager SAM;
@@ -26,13 +27,14 @@
   ScopPassRegistry(const ScopPassRegistry &) = delete;
   ScopPassRegistry &operator=(ScopPassRegistry &&) = delete;
   ScopPassRegistry &operator=(const ScopPassRegistry &) = delete;
-  ScopPassRegistry() {
+  ScopPassRegistry() : LNAM(LAM) {
 PassBuilder PB;
 
 AM = PB.buildDefaultAAPipeline();
 PB.registerModuleAnalyses(MAM);
 PB.registerFunctionAnalyses(FAM);
 PB.registerLoopAnalyses(LAM);
+PB.registerLoopNestAnalyses(LNAM);
 PB.registerCGSCCAnalyses(CGAM);
 
 FAM.registerPass([] { return ScopAnalysis(); });
@@ -43,7 +45,7 @@
 // SAM.registerPass([] { return DependenceAnalysis(); });
 SAM.registerPass([this] { return FunctionAnalysisManagerScopProxy(FAM); });
 
-PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
+PB.crossRegisterProxies(LAM, LNAM, FAM, CGAM, MAM);
   }
 };
 
Index: llvm/unittests/Transforms/Scalar/LICMTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LICMTest.cpp
+++ llvm/unittests/Transforms/Scalar/LICMTest.cpp
@@ -22,6 +22,7 @@
   ModulePassManager MPM;
   PassBuilder PB;
   LoopAnalysisManager LAM;
+  LoopNestAnalysisManager LNAM(LAM);
   FunctionAnalysisManager FAM;
   CGSCCAnalysisManager CGAM;
   ModuleAnalysisManager MAM;
@@ -30,7 +31,8 @@
   PB.registerCGSCCAnalyses(CGAM);
   PB.registerFunctionAnalyses(FAM);
   PB.registerLoopAnalyses(LAM);
-  PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
+  PB.registerLoopNestAnalyses(LNAM);
+  PB.crossRegisterProxies(LAM, LNAM, FAM, CGAM, MAM);
 
   StringRef PipelineStr = "require,loop(licm)";
   ASSERT_THAT_ERROR(PB.parsePassPipeline(MPM, PipelineStr), Succeeded());
Index: llvm/unittests/IR/PassBuilderCallbacksTest.cpp
===
--- llvm/unittests/IR/PassBuilderCallbacksTest.cpp
+++ llvm/unittests/IR/PassBuilderCallbacksTest.cpp
@@ -174,6 +174,24 @@
   MockPassHandle() { setDefaults(); }
 };
 
+template <>
+struct MockPassHandle
+: MockPassHandleBase, LoopNest,
+ LoopNestAnalysisManager, LoopStandardAnalysisResults &,
+ LNPMUpdater &> {
+  MOCK_METHOD4(run,
+   PreservedAnalyses(LoopNest &, LoopNestAnalysisManager &,
+ LoopStandardAnalysisResults &, LNPMUpdater &));
+
+  static void invalidateLoopNest(LoopNest &LN, LoopNestAnalysisManager &,
+ LoopStandardAnalysisResults &,
+ LNPMUpdater &Updater) {
+Updater.markLoopNestAsDeleted(LN, LN.getName());
+  }
+
+  MockPassHandle() { setDefaults(); }
+};
+
 template <>
 struct MockPassHandle
 : MockPassHandleBase, Function> {
@@ -226,6 +244,20 @@
   MockAnalysisHandle() { this->setDefaults(); }
 };
 
+template <>
+struct MockAnalysisHandle
+: MockAnalysisHandleBase, Loop,
+ LoopAnalysisManager,
+   

[clang] 3d06fc0 - [OpenMP][Docs] Mark `present` motion modifier as done

2020-07-30 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-30T12:21:37-04:00
New Revision: 3d06fc0049c6bb94e6efd77388453206037f43ad

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

LOG: [OpenMP][Docs] Mark `present` motion modifier as done

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index bda52e934c26..28fbd7baebb2 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -270,5 +270,5 @@ want to help with the implementation.
 
+--+--+--+---+
 | device extension | 'present' map type modifier   
   | :part:`mostly done`  | D83061, D83062, D84422  
  |
 
+--+--+--+---+
-| device extension | 'present' motion modifier 
   | :part:`worked on`| D84711, D84712  
  |
+| device extension | 'present' motion modifier 
   | :good:`done` | D84711, D84712  
  |
 
+--+--+--+---+



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


[clang] 3d6f530 - [PGO] Include the mem ops into the function hash.

2020-07-30 Thread Hiroshi Yamauchi via cfe-commits

Author: Hiroshi Yamauchi
Date: 2020-07-30T09:26:20-07:00
New Revision: 3d6f53018f845e893ad34f64ff2851a2e5c3ba1d

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

LOG: [PGO] Include the mem ops into the function hash.

To avoid hash collisions when the only difference is in mem ops.

Added: 


Modified: 
clang/test/CodeGen/Inputs/thinlto_expect1.proftext
clang/test/CodeGen/Inputs/thinlto_expect2.proftext
clang/test/CodeGenCXX/Inputs/profile-remap.proftext
clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
compiler-rt/test/profile/Linux/instrprof-value-merge.c
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext

llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
llvm/test/Transforms/PGOProfile/multiple_hash_profile.ll

Removed: 




diff  --git a/clang/test/CodeGen/Inputs/thinlto_expect1.proftext 
b/clang/test/CodeGen/Inputs/thinlto_expect1.proftext
index e7ce3a4ee237..0c904e2ea1c8 100644
--- a/clang/test/CodeGen/Inputs/thinlto_expect1.proftext
+++ b/clang/test/CodeGen/Inputs/thinlto_expect1.proftext
@@ -2,7 +2,7 @@
 :ir
 foo
 # Func Hash:
-25571299074
+784007059655560962
 # Num Counters:
 2
 # Counter Values:

diff  --git a/clang/test/CodeGen/Inputs/thinlto_expect2.proftext 
b/clang/test/CodeGen/Inputs/thinlto_expect2.proftext
index f9de785587ab..c240a442c465 100644
--- a/clang/test/CodeGen/Inputs/thinlto_expect2.proftext
+++ b/clang/test/CodeGen/Inputs/thinlto_expect2.proftext
@@ -2,7 +2,7 @@
 :csir
 foo
 # Func Hash:
-25571299074
+784007059655560962
 # Num Counters:
 2
 # Counter Values:
@@ -11,7 +11,7 @@ foo
 
 foo
 # Func Hash:
-1152921530178146050
+1936928564262407938
 # Num Counters:
 2
 # Counter Values:

diff  --git a/clang/test/CodeGenCXX/Inputs/profile-remap.proftext 
b/clang/test/CodeGenCXX/Inputs/profile-remap.proftext
index a1f90cfa6e9e..bf57fc696c49 100644
--- a/clang/test/CodeGenCXX/Inputs/profile-remap.proftext
+++ b/clang/test/CodeGenCXX/Inputs/profile-remap.proftext
@

[PATCH] D84924: [clang-tidy][WIP] Added command line option `fix-notes`

2020-07-30 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 2 inline comments as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:109
 SourceMgr(Diags, Files), Context(Context), ApplyFixes(ApplyFixes),
-TotalFixes(0), AppliedFixes(0), WarningsAsErrors(0) {
+ApplyAnyFix(ApplyAnyFix), TotalFixes(0), AppliedFixes(0),
+WarningsAsErrors(0) {

Eugene.Zelenko wrote:
> It'll be reasonable to use member initialization for `TotalFixes`, 
> `AppliedFixes`, `WarningsAsErrors`.
It would be, but that's a refactoring change unrelated to this patch



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:252
   RemoveIncompatibleErrors(RemoveIncompatibleErrors),
-  LastErrorRelatesToUserCode(false), LastErrorPassesLineFilter(false),
-  LastErrorWasIgnored(false) {}
+  FindAnyFixIt(FindAnyFixit), LastErrorRelatesToUserCode(false),
+  LastErrorPassesLineFilter(false), LastErrorWasIgnored(false) {}

Eugene.Zelenko wrote:
> It'll be reasonable to use member initialization for 
> `LastErrorRelatesToUserCode`, `LastErrorPassesLineFilter`, 
> `LastErrorWasIgnored`.
Ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84924

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


[PATCH] D84908: [darwin][compiler-rt] build libclang_rt.sim.a Apple Silicon slice, if SDK supports it

2020-07-30 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 281963.
arphaman added a comment.

don't check if the SDK isn't present.


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

https://reviews.llvm.org/D84908

Files:
  compiler-rt/cmake/builtin-config-ix.cmake


Index: compiler-rt/cmake/builtin-config-ix.cmake
===
--- compiler-rt/cmake/builtin-config-ix.cmake
+++ compiler-rt/cmake/builtin-config-ix.cmake
@@ -93,6 +93,21 @@
 endif()
   endforeach(arch)
 
+  function(set_simulator_arches all_possible_archs os sdkname)
+set(simulator_arches ${X86} ${X86_64})
+# Add additional slices for Apple Silicon simulator targets, if they're
+# supported by the SDK.
+if(NOT "${DARWIN_${os}sim_SYSROOT}" STREQUAL "")
+  foreach(arch ${ARM64})
+sdk_has_arch_support(${DARWIN_${os}sim_SYSROOT} ${sdkname} ${arch} 
SIM_ARM_SUPPORT)
+if (SIM_ARM_SUPPORT)
+  list(APPEND simulator_arches ${arch})
+endif()
+  endforeach()
+endif()
+set("${all_possible_archs}" ${simulator_arches} PARENT_SCOPE)
+  endfunction()
+
   if(COMPILER_RT_ENABLE_IOS)
 list(APPEND DARWIN_EMBEDDED_PLATFORMS ios)
 set(DARWIN_ios_MIN_VER_FLAG -miphoneos-version-min)
@@ -100,7 +115,7 @@
 set(DARWIN_ios_BUILTIN_MIN_VER_FLAG
   ${DARWIN_ios_MIN_VER_FLAG}=${DARWIN_ios_BUILTIN_MIN_VER})
 set(DARWIN_ios_BUILTIN_ALL_POSSIBLE_ARCHS ${ARM64} ${ARM32})
-set(DARWIN_iossim_BUILTIN_ALL_POSSIBLE_ARCHS ${X86} ${X86_64})
+set_simulator_arches(DARWIN_iossim_BUILTIN_ALL_POSSIBLE_ARCHS ios 
iphonesimulator)
   endif()
   if(COMPILER_RT_ENABLE_WATCHOS)
 list(APPEND DARWIN_EMBEDDED_PLATFORMS watchos)
@@ -109,7 +124,7 @@
 set(DARWIN_watchos_BUILTIN_MIN_VER_FLAG
   ${DARWIN_watchos_MIN_VER_FLAG}=${DARWIN_watchos_BUILTIN_MIN_VER})
 set(DARWIN_watchos_BUILTIN_ALL_POSSIBLE_ARCHS armv7 armv7k)
-set(DARWIN_watchossim_BUILTIN_ALL_POSSIBLE_ARCHS ${X86})
+set_simulator_arches(DARWIN_watchossim_BUILTIN_ALL_POSSIBLE_ARCHS watchos 
watchsimulator)
   endif()
   if(COMPILER_RT_ENABLE_TVOS)
 list(APPEND DARWIN_EMBEDDED_PLATFORMS tvos)
@@ -118,7 +133,7 @@
 set(DARWIN_tvos_BUILTIN_MIN_VER_FLAG
   ${DARWIN_tvos_MIN_VER_FLAG}=${DARWIN_tvos_BUILTIN_MIN_VER})
 set(DARWIN_tvos_BUILTIN_ALL_POSSIBLE_ARCHS armv7 arm64)
-set(DARWIN_tvossim_BUILTIN_ALL_POSSIBLE_ARCHS ${X86} ${X86_64})
+set_simulator_arches(DARWIN_tvossim_BUILTIN_ALL_POSSIBLE_ARCHS tvos 
appletvsimulator)
   endif()
 
   set(BUILTIN_SUPPORTED_OS osx)


Index: compiler-rt/cmake/builtin-config-ix.cmake
===
--- compiler-rt/cmake/builtin-config-ix.cmake
+++ compiler-rt/cmake/builtin-config-ix.cmake
@@ -93,6 +93,21 @@
 endif()
   endforeach(arch)
 
+  function(set_simulator_arches all_possible_archs os sdkname)
+set(simulator_arches ${X86} ${X86_64})
+# Add additional slices for Apple Silicon simulator targets, if they're
+# supported by the SDK.
+if(NOT "${DARWIN_${os}sim_SYSROOT}" STREQUAL "")
+  foreach(arch ${ARM64})
+sdk_has_arch_support(${DARWIN_${os}sim_SYSROOT} ${sdkname} ${arch} SIM_ARM_SUPPORT)
+if (SIM_ARM_SUPPORT)
+  list(APPEND simulator_arches ${arch})
+endif()
+  endforeach()
+endif()
+set("${all_possible_archs}" ${simulator_arches} PARENT_SCOPE)
+  endfunction()
+
   if(COMPILER_RT_ENABLE_IOS)
 list(APPEND DARWIN_EMBEDDED_PLATFORMS ios)
 set(DARWIN_ios_MIN_VER_FLAG -miphoneos-version-min)
@@ -100,7 +115,7 @@
 set(DARWIN_ios_BUILTIN_MIN_VER_FLAG
   ${DARWIN_ios_MIN_VER_FLAG}=${DARWIN_ios_BUILTIN_MIN_VER})
 set(DARWIN_ios_BUILTIN_ALL_POSSIBLE_ARCHS ${ARM64} ${ARM32})
-set(DARWIN_iossim_BUILTIN_ALL_POSSIBLE_ARCHS ${X86} ${X86_64})
+set_simulator_arches(DARWIN_iossim_BUILTIN_ALL_POSSIBLE_ARCHS ios iphonesimulator)
   endif()
   if(COMPILER_RT_ENABLE_WATCHOS)
 list(APPEND DARWIN_EMBEDDED_PLATFORMS watchos)
@@ -109,7 +124,7 @@
 set(DARWIN_watchos_BUILTIN_MIN_VER_FLAG
   ${DARWIN_watchos_MIN_VER_FLAG}=${DARWIN_watchos_BUILTIN_MIN_VER})
 set(DARWIN_watchos_BUILTIN_ALL_POSSIBLE_ARCHS armv7 armv7k)
-set(DARWIN_watchossim_BUILTIN_ALL_POSSIBLE_ARCHS ${X86})
+set_simulator_arches(DARWIN_watchossim_BUILTIN_ALL_POSSIBLE_ARCHS watchos watchsimulator)
   endif()
   if(COMPILER_RT_ENABLE_TVOS)
 list(APPEND DARWIN_EMBEDDED_PLATFORMS tvos)
@@ -118,7 +133,7 @@
 set(DARWIN_tvos_BUILTIN_MIN_VER_FLAG
   ${DARWIN_tvos_MIN_VER_FLAG}=${DARWIN_tvos_BUILTIN_MIN_VER})
 set(DARWIN_tvos_BUILTIN_ALL_POSSIBLE_ARCHS armv7 arm64)
-set(DARWIN_tvossim_BUILTIN_ALL_POSSIBLE_ARCHS ${X86} ${X86_64})
+set_simulator_arches(DARWIN_tvossim_BUILTIN_ALL_POSSIBLE_ARCHS tvos appletvsimulator)
   endif()
 
   set(BUILTIN_SUPPORTED_OS osx)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mail

[PATCH] D82317: [Clang/Test]: Update tests where `noundef` attribute is necessary

2020-07-30 Thread Gui Andrade via Phabricator via cfe-commits
guiand added a comment.

@jdoerfert what would the procedure be for reviewing these test changes / 
getting this landed with the noundef patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82317

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


[clang] 555cf42 - [NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

2020-07-30 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2020-07-30T10:07:57-07:00
New Revision: 555cf42f380d86f35e761c3a2179c761356ab152

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

LOG: [NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

Problem:
Right now, our "Running pass" is not accurate when passes are wrapped in 
adaptor because adaptor is never skipped and a pass could be skipped. The other 
problem is that "Running pass" for a adaptor is before any "Running pass" of 
passes/analyses it depends on. (for example, FunctionToLoopPassAdaptor). So the 
order of printing is not the actual order.

Solution:
Doing things like PassManager::Debuglogging is very intrusive because we need 
to specify Debuglogging whenever adaptor is created. (Actually, right now we're 
not specifying Debuglogging for some sub-PassManagers. Check PassBuilder)

This patch move debug logging for pass as a PassInstrument callback. We could 
be sure that all running passes are logged and in the correct order.

This could also be used to implement hierarchy pass logging in legacy PM. We 
could also move logging of pass manager to this if we want.

The test fixes looks messy. It includes changes:
- Remove PassInstrumentationAnalysis
- Remove PassAdaptor
- If a PassAdaptor is for a real pass, the pass is added
- Pass reorder (to the correct order), related to PassAdaptor
- Add missing passes (due to Debuglogging not passed down)

Reviewed By: asbirlea, aeubanks

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

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/include/llvm/IR/PassInstrumentation.h
llvm/include/llvm/IR/PassManager.h
llvm/include/llvm/IR/PassManagerImpl.h
llvm/include/llvm/Passes/StandardInstrumentations.h
llvm/lib/Analysis/CGSCCPassManager.cpp
llvm/lib/IR/PassInstrumentation.cpp
llvm/lib/IR/PassTimingInfo.cpp
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/lib/Transforms/Scalar/LoopPassManager.cpp
llvm/test/Other/loop-pm-invalidation.ll
llvm/test/Other/new-pass-manager.ll
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-lto-defaults.ll
llvm/test/Other/new-pm-pgo.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
llvm/test/Other/pass-pipeline-parsing.ll
llvm/test/Transforms/LoopRotate/pr35210.ll
llvm/test/Transforms/LoopUnroll/revisit.ll
llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 6269fd677ca8..3dcc6a196365 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -1,3 +1,4 @@
+; FIXME: This test should use CHECK-NEXT to keep up-to-date.
 ; REQUIRES: x86-registered-target
 
 ; Validate ThinLTO post link pipeline at O2 and O3
@@ -18,7 +19,6 @@
 ; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
 ; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O3 %s --dump-input=fail
 
-; CHECK-O: Running analysis: PassInstrumentationAnalysis
 ; CHECK-O: Starting {{.*}}Module pass manager run.
 ; CHECK-O: Running pass: WholeProgramDevirtPass
 ; CHECK-O: Running analysis: InnerAnalysisManagerProxy
@@ -26,15 +26,12 @@
 ; CHECK-O: Invalidating all non-preserved analyses for:
 ; CHECK-O: Invalidating analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running pass: ForceFunctionAttrsPass
-; CHECK-O: Running pass: PassManager<{{.*}}Module>
 ; CHECK-O: Starting {{.*}}Module pass manager run.
 ; CHECK-O: Running pass: PGOIndirectCallPromotion
 ; CHECK-O: Running analysis: ProfileSummaryAnalysis
 ; CHECK-O: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
-; CHECK-O: Running analysis: PassInstrumentationAnalysis on main
 ; CHECK-O: Running pass: InferFunctionAttrsPass
-; CHECK-O: Running pass: 
ModuleToFunctionPassAdaptor<{{.*}}PassManager<{{.*}}Function>{{ ?}}>
 ; CHECK-O: Starting {{.*}}Function pass manager run.
 ; CHECK-O: Running pass: SimplifyCFGPass on main
 ; CHECK-O: Running analysis: TargetIRAnalysis on main
@@ -46,18 +43,17 @@
 ; CHECK-O: Running pass: LowerExpectIntrinsicPass on main
 ; CHECK-O3: Running pass: CallSiteSplittingPass on main
 ; CHECK-O: Finished {{.*}}Function pass manager run.
+; CHECK-O: Running pass: LowerTypeTestsPass
 ; CHECK-O: Running pass: IPSCCPPass
 ; CHECK-O: Running pas

[PATCH] D84774: [NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

2020-07-30 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG555cf42f380d: [NewPM][PassInstrument] Add PrintPass callback 
to StandardInstrumentations (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84774

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/IR/PassManagerImpl.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/IR/PassInstrumentation.cpp
  llvm/lib/IR/PassTimingInfo.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/Scalar/LoopPassManager.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-pgo.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Other/pass-pipeline-parsing.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/test/Transforms/LoopUnroll/revisit.ll
  llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
  llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll

Index: llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
===
--- llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
+++ llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
@@ -19,7 +19,6 @@
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for:
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f1
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f2
-; NEW-PM-NEXT: Running pass: ModuleToFunctionPassAdaptor
 ; NEW-PM-NOT: Running analysis:
 
 ; IR-LABEL: @f1
Index: llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
===
--- llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
+++ llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
@@ -6,20 +6,19 @@
 ; RUN: opt -S -passes='loop(require),loop-unroll,loop(print-access-info)' -debug-pass-manager < %s 2>&1 | FileCheck %s
 ;
 ; CHECK: Starting llvm::Function pass manager run.
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Running analysis: LoopAnalysis
 ; CHECK: Running analysis: InnerAnalysisManagerProxy<
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner1.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner2.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner2.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on outer.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %outer.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Running pass: LoopUnrollPass
 ; CHECK: Clearing all analysis results for: inner2.header
@@ -29,16 +28,15 @@
 ; CHECK: Invalidating analysis: LoopAccessAnalysis on inner1.header
 ; CHECK: Invalidating all non-preserved analyses for: inner1.header.1
 ; CHECK-NOT: Invalidating analysis: LoopAccessAnalysis on inner1.header.1
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: LoopAccessInfoPrinterPass
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header
 ; CHECK: Loop access info in function 'test':
 ; CHECK:   inner1.header:
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: LoopAccessInfoPrinterPass
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header.1
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header.1
 ; CHECK: Loop access info in function 'test':
 ; CHECK:   inner1.header.1:
 ; CHECK: Finished Loop pass manager run.
Index: llvm/test/Transforms/LoopUnroll/revisit.ll
===
--- llvm/test/Transforms/LoopUnroll/revisit.ll
+++ llvm/test/Transforms/LoopUnroll/revisit.ll
@@ -15

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay closed this revision.
MaskRay added a comment.

Relanded as 3d6f53018f845e893ad34f64ff2851a2e5c3ba1d 


@yamauchi For a reland, you still need to include `Differential Revision: ` so 
that the differential can be closed automatically when you push the commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

It is also a convention to explain what has changed compared with the initial 
land.

As a hindsight, the option `-pgo-instr-old-cfg-hashing` should probably have 
been mentioned in the description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


  1   2   >