[PATCH] D83914: [clangd] Plan features for FoldingRanges

2020-07-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

just some random comments from my side.

> At least for the AST-based folds, I'd like some formalism like:

+1. I think we need some general rules (mental model) to guide us how the 
folding works.

Some editors (e.g. VSCode) have their builtin folding-range, it is worth to 
investigate how the built folding-range interacts with one provided by the 
language server.

From my experience, VSCode's built folding-range kind of works though this is 
not perfect, would be nice to have some concrete examples see the improvements, 
we may want to prioritize those during the implementation.




Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:261
+
+  if (B && ([["subexpression" != "multi-line" &&
+1 > 0]]))

this example seems vague, it is folded because 

1. it is cross-line
2. it is wrapped by `()`
or both?



Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:284
+  )cpp",
+  // For.
+  R"cpp(

nit: for completeness, add a for-range case.



Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:326
+  int Y = 42;
+  bool B = 15;]]
+  if ([[B]]) {[[ ++X; ]]}

not sure about this case. 

if we decide to support this (btw, the test on L242 should be adjusted too), 
would be nice to support the following usages.

```
// forward decls
[[class A;
class B;
class C;]]

// using decls;
[[using ns::A;
using ns::B;
using ns::C;]]
```



Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:556
+  R"cpp(
+//[[ Some documentation.
+// @param

this `[[` seems mismatched, if I read the code correctly.

btw, this example contains too many brackets, considering split into simpler 
ones.



Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:598
+
+#include [["math.h"]]
+  )cpp",

another option: we could just fold the whole preamble region, it seems easier, 
and provides a visible to see preamble range :), the downside is that any 
comments/macros will be folded together.



Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:601
+  R"cpp(
+#define true [[false]]
+

These macros are quite simple, I'm not sure this is useful to fold them. I'd 
just not fold it, but if the macro body is complicated (multi-lines), it is 
worth folding it.



Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:679
+struct BarStruct {[[]]};
+struct FwdDeclaration;
+  )cpp",

looks like we're missing case of inheritance, e.g. a class inherits multiple 
classes

```
class B : public A,
  private C {};
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83914



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


[clang-tools-extra] 82dbb1b - Fix the clang-tidy build after get/isIntegerConstantExpression

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

Author: Haojian Wu
Date: 2020-07-22T09:38:56+02:00
New Revision: 82dbb1b2b4f1e70ca453cca60a4ba5b856058fc0

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

LOG: Fix the clang-tidy build after get/isIntegerConstantExpression
refactoring.

Added: 


Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
index aa860b30fe75..1837ccb6002f 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
@@ -79,9 +79,8 @@ static QualType getUnqualifiedType(const Expr &E) {
 }
 
 static APValue getConstantExprValue(const ASTContext &Ctx, const Expr &E) {
-  llvm::APSInt IntegerConstant;
-  if (E.isIntegerConstantExpr(IntegerConstant, Ctx))
-return APValue(IntegerConstant);
+  if (auto IntegerConstant = E.getIntegerConstantExpr(Ctx))
+return APValue(*IntegerConstant);
   APValue Constant;
   if (Ctx.getLangOpts().CPlusPlus && E.isCXX11ConstantExpr(Ctx, &Constant))
 return Constant;

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
index dd0bedd742a4..96b0bb0f9b02 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -65,9 +65,9 @@ void ProBoundsConstantArrayIndexCheck::check(
   if (IndexExpr->isValueDependent())
 return; // We check in the specialization.
 
-  llvm::APSInt Index;
-  if (!IndexExpr->isIntegerConstantExpr(Index, *Result.Context, nullptr,
-/*isEvaluated=*/true)) {
+  Optional Index =
+  IndexExpr->getIntegerConstantExpr(*Result.Context);
+  if (!Index) {
 SourceRange BaseRange;
 if (const auto *ArraySubscriptE = dyn_cast(Matched))
   BaseRange = ArraySubscriptE->getBase()->getSourceRange();
@@ -101,9 +101,9 @@ void ProBoundsConstantArrayIndexCheck::check(
   if (!StdArrayDecl)
 return;
 
-  if (Index.isSigned() && Index.isNegative()) {
+  if (Index->isSigned() && Index->isNegative()) {
 diag(Matched->getExprLoc(), "std::array<> index %0 is negative")
-<< Index.toString(10);
+<< Index->toString(10);
 return;
   }
 
@@ -118,11 +118,11 @@ void ProBoundsConstantArrayIndexCheck::check(
 
   // Get uint64_t values, because 
diff erent bitwidths would lead to an assertion
   // in APInt::uge.
-  if (Index.getZExtValue() >= ArraySize.getZExtValue()) {
+  if (Index->getZExtValue() >= ArraySize.getZExtValue()) {
 diag(Matched->getExprLoc(),
  "std::array<> index %0 is past the end of the array "
  "(which contains %1 elements)")
-<< Index.toString(10) << ArraySize.toString(10, false);
+<< Index->toString(10) << ArraySize.toString(10, false);
   }
 }
 

diff  --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
index aef513a527b5..b84e4d525d8c 100644
--- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -500,7 +500,13 @@ static bool retrieveIntegerConstantExpr(const 
MatchFinder::MatchResult &Result,
 const Expr *&ConstExpr) {
   std::string CstId = (Id + "-const").str();
   ConstExpr = Result.Nodes.getNodeAs(CstId);
-  return ConstExpr && ConstExpr->isIntegerConstantExpr(Value, *Result.Context);
+  if (!ConstExpr)
+return false;
+  Optional R = 
ConstExpr->getIntegerConstantExpr(*Result.Context);
+  if (!R)
+return false;
+  Value = *R;
+  return true;
 }
 
 // Overloaded `retrieveIntegerConstantExpr` for compatibility.
@@ -673,7 +679,7 @@ static bool retrieveRelationalIntegerConstantExpr(
 
 if (const auto *Arg = OverloadedOperatorExpr->getArg(1)) {
   if (!Arg->isValueDependent() &&
-  !Arg->isIntegerConstantExpr(Value, *Result.Context))
+  !Arg->isIntegerConstantExpr(*Result.Context))
 return false;
 }
 Symbol = OverloadedOperatorExpr->getArg(0);
@@ -1265,21 +1271,23 @@ void RedundantExpressionCheck::check(const 
MatchFinder::MatchResult &Result) {
   "left-right-shift-conf

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

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

address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84222

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


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


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


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

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



Comment at: clang/lib/AST/Expr.cpp:3747
 case NPC_ValueDependentIsNull:
-  if (isTypeDependent() || getType()->isIntegralType(Ctx))
+  if ((!containsErrors() && isTypeDependent()) ||
+  getType()->isIntegralType(Ctx))

sammccall wrote:
> would it be clearer to say if (containsErrors()) return NPCK_NotNull at the 
> top?
> 
> Only difference in behavior is not hitting llvm_unreachable if we have 
> NPC_NeverValueDependent... do you think we actually want that?
this is good point, I missed that. thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84222



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


[PATCH] D83759: [clangd] Fixes in lit tests

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

In D83759#2165974 , @ArcsinX wrote:

> Seem the problem is in `-i` option.
>  According with OSX man:
>  `sed [-Ealn] command [file ... ]`
>  `sed [-Ealn] [-e command] [-f command_file] [-i extension] [file ...]`.
>
> Seems on macOS `-E` is treated as an argument for `-i` in command like `sed 
> -i -E -e ...` .
>
> Also, seems commands like `sed -i -e ...` are unsafe on macOS. Such commands 
> will create backup with name `-e`, but I do not have macOS to check 
> it.
>  @thakis could you please verify that after tests you have extra  
> `-e` files in 
> `/Users/thakis/src/llvm-project/out/gn/obj/clang-tools-extra/clangd/test/Output/background-index.test.tmp/`
>  ?
>
> I think we could avoid `-i` usage to fix this problem.


your diagnosis seems correct. in addition to avoiding -i altogether, you can 
try passing a value to it. e.g. `sed -i.bak` then both linux and macos should 
hopefully pick it up and the following `-e` should be interpreted correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83759



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


[clang] 706a435 - [AST][RecoveryExpr] Error-dependent expression should not be treat as a nullptr pointer constant.

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

Author: Haojian Wu
Date: 2020-07-22T10:03:51+02:00
New Revision: 706a4353e87b1127446db7daf5e3e95fcb408924

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

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

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

Fix a recovery-ast crash on C.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 399e7e13c445..213a6d1d1caa 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -3740,6 +3740,9 @@ Expr::isNullPointerConstant(ASTContext &Ctx,
 NullPointerConstantValueDependence NPC) const {
   if (isValueDependent() &&
   (!Ctx.getLangOpts().CPlusPlus11 || Ctx.getLangOpts().MSVCCompat)) {
+// Error-dependent expr should never be a null pointer.
+if (containsErrors())
+  return NPCK_NotNull;
 switch (NPC) {
 case NPC_NeverValueDependent:
   llvm_unreachable("Unexpected value dependent expression!");

diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 735349c3de62..9c8f3fdcda4a 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -539,8 +539,10 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
   if (VK == VK_RValue && !E->isRValue()) {
 switch (Kind) {
 default:
-  llvm_unreachable("can't implicitly cast lvalue to rvalue with this cast "
-   "kind");
+  llvm_unreachable(("can't implicitly cast lvalue to rvalue with this cast 
"
+"kind: " +
+std::string(CastExpr::getCastKindName(Kind)))
+   .c_str());
 case CK_Dependent:
 case CK_LValueToRValue:
 case CK_ArrayToPointerDecay:

diff  --git a/clang/test/AST/ast-dump-recovery.c 
b/clang/test/AST/ast-dump-recovery.c
index b49c0103dbaf..f3a33fdac49b 100644
--- a/clang/test/AST/ast-dump-recovery.c
+++ b/clang/test/AST/ast-dump-recovery.c
@@ -39,3 +39,14 @@ void test1() {
   // CHECK-NEXT:  `-DeclRefExpr {{.*}} 'a' 'const int'
   static int foo = a++; // verify no crash on local static var decl.
 }
+
+void test2() {
+  int* ptr;
+  // FIXME: the top-level expr should be a binary operator.
+  // CHECK:  ImplicitCastExpr {{.*}} contains-errors 
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors lvalue
+  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'ptr' 'int *'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}}
+  // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
+  ptr = some_func(); // should not crash
+}



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


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

2020-07-22 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG706a4353e87b: [AST][RecoveryExpr] Error-dependent expression 
should not be treat as a nullptr… (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84222

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


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


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


[PATCH] D82948: [Driver][ARM] Disable unsupported features when nofp arch extension is used

2020-07-22 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:476
+// -mfpu=none, -march=armvX+nofp or -mcpu=X+nofp is *very* similar to
+// -mfloat-abi=soft, only that it should not disable MVE-I.
 Features.insert(Features.end(),

chill wrote:
> DavidSpickett wrote:
> > Why not disable MVE-I? I assume because it's integer only but then why does 
> > -mfloat-abi=soft disable it?
> > 
> > If possible add a regression test for this. In general a test like the bf16 
> > test below, but for all the listed extensions would help. Perhaps it makes 
> > more sense to add a driver test that looks for the "-" bits in the 
> > -### output instead of doing each extension on its own.
> > Why not disable MVE-I?
> 
> After MVE, "FPU" registers are a separate entity from the FPU.
> 
> `-mfpu=none`/`+nofp` disable the FPU. MVE-I does not require an FPU.
> `-mfloat-abi=soft` disables both the FPU instructions and the FPU registers.
> MVE-I requires "FPU" registers.
> 
> It's possible to define different semantics, but this is the one we agreed 
> with GCC.
Got it. @vhscampos  can you add that to the comment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82948



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


[PATCH] D84291: [PowerPC][Power10] Fix the Test LSB by Byte (xvtlsbb) Builtins Implementation

2020-07-22 Thread Rafik Zurob via Phabricator via cfe-commits
rzurob accepted this revision.
rzurob added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84291



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


[clang] 3895466 - accept 'clang++ -c a.pch -o a.o' to create PCH's object file

2020-07-22 Thread Luboš Luňák via cfe-commits

Author: Luboš Luňák
Date: 2020-07-22T10:21:23+02:00
New Revision: 3895466e2c336c0797710ae35150ba1ce6bc0b96

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

LOG: accept 'clang++ -c a.pch -o a.o' to create PCH's object file

This way should be the same like with a.pcm for modules.
An alternative way is 'clang++ -c empty.cpp -include-pch a.pch -o a.o
-Xclang -building-pch-with-obj', which is what clang-cl's /Yc does
internally.

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

Added: 
clang/test/Driver/pch-codegen.cpp

Modified: 
clang/lib/Driver/Types.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/PCH/codegen.cpp

Removed: 




diff  --git a/clang/lib/Driver/Types.cpp b/clang/lib/Driver/Types.cpp
index 399e26d8d64a..2050dffa6fa0 100644
--- a/clang/lib/Driver/Types.cpp
+++ b/clang/lib/Driver/Types.cpp
@@ -141,7 +141,7 @@ bool types::isAcceptedByClang(ID Id) {
   case TY_CXXHeader: case TY_PP_CXXHeader:
   case TY_ObjCXXHeader: case TY_PP_ObjCXXHeader:
   case TY_CXXModule: case TY_PP_CXXModule:
-  case TY_AST: case TY_ModuleFile:
+  case TY_AST: case TY_ModuleFile: case TY_PCH:
   case TY_LLVM_IR: case TY_LLVM_BC:
 return true;
   }

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index c34c2a18b048..0b5f33541060 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2022,8 +2022,9 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, 
ArgList &Args,
 // FIXME: Supporting '-header-cpp-output' would be useful.
 bool Preprocessed = XValue.consume_back("-cpp-output");
 bool ModuleMap = XValue.consume_back("-module-map");
-IsHeaderFile =
-!Preprocessed && !ModuleMap && XValue.consume_back("-header");
+IsHeaderFile = !Preprocessed && !ModuleMap &&
+   XValue != "precompiled-header" &&
+   XValue.consume_back("-header");
 
 // Principal languages.
 DashX = llvm::StringSwitch(XValue)
@@ -2050,7 +2051,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, 
ArgList &Args,
   DashX = llvm::StringSwitch(XValue)
   .Case("cpp-output", InputKind(Language::C).getPreprocessed())
   .Case("assembler-with-cpp", Language::Asm)
-  .Cases("ast", "pcm",
+  .Cases("ast", "pcm", "precompiled-header",
  InputKind(Language::Unknown, InputKind::Precompiled))
   .Case("ir", Language::LLVM_IR)
   .Default(Language::Unknown);

diff  --git a/clang/test/Driver/pch-codegen.cpp 
b/clang/test/Driver/pch-codegen.cpp
new file mode 100644
index ..1b125107fb28
--- /dev/null
+++ b/clang/test/Driver/pch-codegen.cpp
@@ -0,0 +1,38 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+
+// Create PCH without codegen.
+// RUN: %clang -x c++-header %S/../Modules/Inputs/codegen-flags/foo.h -o 
%t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CREATE
+// CHECK-PCH-CREATE: -emit-pch
+// CHECK-PCH-CREATE-NOT: -fmodules-codegen
+// CHECK-PCH-CREATE-NOT: -fmodules-debuginfo
+
+// Create PCH with -fmodules-codegen.
+// RUN: %clang -x c++-header -Xclang -fmodules-codegen 
%S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck 
%s -check-prefix=CHECK-PCH-CODEGEN-CREATE
+// CHECK-PCH-CODEGEN-CREATE: -emit-pch
+// CHECK-PCH-CODEGEN-CREATE: -fmodules-codegen
+// CHECK-PCH-CODEGEN-CREATE: "-x" "c++-header"
+// CHECK-PCH-CODEGEN-CREATE-NOT: -fmodules-debuginfo
+
+// Create PCH with -fmodules-debuginfo.
+// RUN: %clang -x c++-header -Xclang -fmodules-debuginfo 
%S/../Modules/Inputs/codegen-flags/foo.h -g -o %t/foo-di.pch -### 2>&1 | 
FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-CREATE
+// CHECK-PCH-DEBUGINFO-CREATE: -emit-pch
+// CHECK-PCH-DEBUGINFO-CREATE: -fmodules-debuginfo
+// CHECK-PCH-DEBUGINFO-CREATE: "-x" "c++-header"
+// CHECK-PCH-DEBUGINFO-CREATE-NOT: -fmodules-codegen
+
+// Create PCH's object file for -fmodules-codegen.
+// RUN: touch %t/foo-cg.pch
+// RUN: %clang -c %t/foo-cg.pch -o %t/foo-cg.o -### 2>&1 | FileCheck %s 
-check-prefix=CHECK-PCH-CODEGEN-OBJ
+// CHECK-PCH-CODEGEN-OBJ: -emit-obj
+// CHECK-PCH-CODEGEN-OBJ: "-main-file-name" "foo-cg.pch"
+// CHECK-PCH-CODEGEN-OBJ: "-o" "{{.*}}foo-cg.o"
+// CHECK-PCH-CODEGEN-OBJ: "-x" "precompiled-header"
+
+// Create PCH's object file for -fmodules-debuginfo.
+// RUN: touch %t/foo-di.pch
+// RUN: %clang -c %t/foo-di.pch -g -o %t/foo-di.o -### 2>&1 | FileCheck %s 
-check-prefix=CHECK-PCH-DEBUGINFO-OBJ
+// CHECK-PCH-DEBUGINFO-OBJ: -emit-obj
+// CHECK-PCH-DEBUGINFO-OBJ: "-main-file-name" "foo-di.pch"
+// CHECK-PCH-DEBUGINFO-OBJ: "-o" "{{.*}}foo-di.o"
+// CHECK-PCH-DEBUGINFO-OBJ: "-x" "precompiled-header"

dif

[PATCH] D83623: add -fpch-codegen/debuginfo options mapping to -fmodules-codegen/debuginfo

2020-07-22 Thread Luboš Luňák via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG54eea6127c4d: add -fpch-codegen/debuginfo mapping to 
-fmodules-codegen/debuginfo (authored by llunak).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D83623?vs=278998&id=279720#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83623

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/pch-codegen.cpp

Index: clang/test/Driver/pch-codegen.cpp
===
--- clang/test/Driver/pch-codegen.cpp
+++ clang/test/Driver/pch-codegen.cpp
@@ -7,21 +7,21 @@
 // CHECK-PCH-CREATE-NOT: -fmodules-codegen
 // CHECK-PCH-CREATE-NOT: -fmodules-debuginfo
 
-// Create PCH with -fmodules-codegen.
-// RUN: %clang -x c++-header -Xclang -fmodules-codegen %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-CREATE
+// Create PCH with -fpch-codegen.
+// RUN: %clang -x c++-header -fpch-codegen %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-CREATE
 // CHECK-PCH-CODEGEN-CREATE: -emit-pch
 // CHECK-PCH-CODEGEN-CREATE: -fmodules-codegen
 // CHECK-PCH-CODEGEN-CREATE: "-x" "c++-header"
 // CHECK-PCH-CODEGEN-CREATE-NOT: -fmodules-debuginfo
 
-// Create PCH with -fmodules-debuginfo.
-// RUN: %clang -x c++-header -Xclang -fmodules-debuginfo %S/../Modules/Inputs/codegen-flags/foo.h -g -o %t/foo-di.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-CREATE
+// Create PCH with -fpch-debuginfo.
+// RUN: %clang -x c++-header -fpch-debuginfo %S/../Modules/Inputs/codegen-flags/foo.h -g -o %t/foo-di.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-CREATE
 // CHECK-PCH-DEBUGINFO-CREATE: -emit-pch
 // CHECK-PCH-DEBUGINFO-CREATE: -fmodules-debuginfo
 // CHECK-PCH-DEBUGINFO-CREATE: "-x" "c++-header"
 // CHECK-PCH-DEBUGINFO-CREATE-NOT: -fmodules-codegen
 
-// Create PCH's object file for -fmodules-codegen.
+// Create PCH's object file for -fpch-codegen.
 // RUN: touch %t/foo-cg.pch
 // RUN: %clang -c %t/foo-cg.pch -o %t/foo-cg.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-OBJ
 // CHECK-PCH-CODEGEN-OBJ: -emit-obj
@@ -29,7 +29,7 @@
 // CHECK-PCH-CODEGEN-OBJ: "-o" "{{.*}}foo-cg.o"
 // CHECK-PCH-CODEGEN-OBJ: "-x" "precompiled-header"
 
-// Create PCH's object file for -fmodules-debuginfo.
+// Create PCH's object file for -fpch-debuginfo.
 // RUN: touch %t/foo-di.pch
 // RUN: %clang -c %t/foo-di.pch -g -o %t/foo-di.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-OBJ
 // CHECK-PCH-DEBUGINFO-OBJ: -emit-obj
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5642,6 +5642,12 @@
   if (Args.hasFlag(options::OPT_fpch_instantiate_templates,
options::OPT_fno_pch_instantiate_templates, false))
 CmdArgs.push_back("-fpch-instantiate-templates");
+  if (Args.hasFlag(options::OPT_fpch_codegen, options::OPT_fno_pch_codegen,
+   false))
+CmdArgs.push_back("-fmodules-codegen");
+  if (Args.hasFlag(options::OPT_fpch_debuginfo, options::OPT_fno_pch_debuginfo,
+   false))
+CmdArgs.push_back("-fmodules-debuginfo");
 
   Args.AddLastArg(CmdArgs, options::OPT_fexperimental_new_pass_manager,
   options::OPT_fno_experimental_new_pass_manager);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1440,6 +1440,10 @@
 def fno_pch_instantiate_templates:
   Flag <["-"], "fno-pch-instantiate-templates">,
   Group, Flags<[CC1Option]>;
+defm pch_codegen: OptInFFlag<"pch-codegen", "Generate ", "Do not generate ",
+  "code for uses of this PCH that assumes an explicit object file will be built for the PCH">;
+defm pch_debuginfo: OptInFFlag<"pch-debuginfo", "Generate ", "Do not generate ",
+  "debug info for types in an object file built from this PCH and do not generate them elsewhere">;
 
 def fmodules : Flag <["-"], "fmodules">, Group,
   Flags<[DriverOption, CC1Option]>,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -63,6 +63,32 @@
 
 - ...
 
+- -fpch-codegen and -fpch-debuginfo generate shared code and/or debuginfo
+  for contents of a precompiled header in a separate object file. This object
+  file needs to be linked in, but its contents do not need to be generated
+  for other objects using the precompiled header. This should us

[clang] 54eea61 - add -fpch-codegen/debuginfo mapping to -fmodules-codegen/debuginfo

2020-07-22 Thread Luboš Luňák via cfe-commits

Author: Luboš Luňák
Date: 2020-07-22T10:21:53+02:00
New Revision: 54eea6127c4d77db03787b7c55765632fb9a6f1c

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

LOG: add -fpch-codegen/debuginfo mapping to -fmodules-codegen/debuginfo

Using -fmodules-* options for PCHs is a bit confusing, so add -fpch-*
variants. Having extra options also makes it simple to do a configure
check for the feature.
Also document the options in the release notes.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/pch-codegen.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 21689c5c5d85..9274081c4d62 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -63,6 +63,32 @@ New Compiler Flags
 
 - ...
 
+- -fpch-codegen and -fpch-debuginfo generate shared code and/or debuginfo
+  for contents of a precompiled header in a separate object file. This object
+  file needs to be linked in, but its contents do not need to be generated
+  for other objects using the precompiled header. This should usually save
+  compile time. If not using clang-cl, the separate object file needs to
+  be created explicitly from the precompiled header.
+  Example of use:
+
+  .. code-block:: console
+
+$ clang++ -x c++-header header.h -o header.pch -fpch-codegen 
-fpch-debuginfo
+$ clang++ -c header.pch -o shared.o
+$ clang++ -c source.cpp -o source.o -include-pch header.pch
+$ clang++ -o binary source.o shared.o
+
+  - Using -fpch-instantiate-templates when generating the precompiled header
+usually increases the amount of code/debuginfo that can be shared.
+  - In some cases, especially when building with optimizations enabled, using
+-fpch-codegen may generate so much code in the shared object that compiling
+it may be a net loss in build time.
+  - Since headers may bring in private symbols of other libraries, it may be
+sometimes necessary to discard unused symbols (such as by adding
+-Wl,--gc-sections on ELF platforms to the linking command, and possibly
+adding -fdata-sections -ffunction-sections to the command generating
+the shared object).
+
 Deprecated Compiler Flags
 -
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c2d349866814..700a5c4578f6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1440,6 +1440,10 @@ def fpch_instantiate_templates:
 def fno_pch_instantiate_templates:
   Flag <["-"], "fno-pch-instantiate-templates">,
   Group, Flags<[CC1Option]>;
+defm pch_codegen: OptInFFlag<"pch-codegen", "Generate ", "Do not generate ",
+  "code for uses of this PCH that assumes an explicit object file will be 
built for the PCH">;
+defm pch_debuginfo: OptInFFlag<"pch-debuginfo", "Generate ", "Do not generate 
",
+  "debug info for types in an object file built from this PCH and do not 
generate them elsewhere">;
 
 def fmodules : Flag <["-"], "fmodules">, Group,
   Flags<[DriverOption, CC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 8ce7e20408ab..7a73eea013bd 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5642,6 +5642,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   if (Args.hasFlag(options::OPT_fpch_instantiate_templates,
options::OPT_fno_pch_instantiate_templates, false))
 CmdArgs.push_back("-fpch-instantiate-templates");
+  if (Args.hasFlag(options::OPT_fpch_codegen, options::OPT_fno_pch_codegen,
+   false))
+CmdArgs.push_back("-fmodules-codegen");
+  if (Args.hasFlag(options::OPT_fpch_debuginfo, options::OPT_fno_pch_debuginfo,
+   false))
+CmdArgs.push_back("-fmodules-debuginfo");
 
   Args.AddLastArg(CmdArgs, options::OPT_fexperimental_new_pass_manager,
   options::OPT_fno_experimental_new_pass_manager);

diff  --git a/clang/test/Driver/pch-codegen.cpp 
b/clang/test/Driver/pch-codegen.cpp
index 1b125107fb28..c6b6d9217e42 100644
--- a/clang/test/Driver/pch-codegen.cpp
+++ b/clang/test/Driver/pch-codegen.cpp
@@ -7,21 +7,21 @@
 // CHECK-PCH-CREATE-NOT: -fmodules-codegen
 // CHECK-PCH-CREATE-NOT: -fmodules-debuginfo
 
-// Create PCH with -fmodules-codegen.
-// RUN: %clang -x c++-header -Xclang -fmodules-codegen 
%S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck 
%s -check-prefix=CHECK-PCH-CODEGEN-CREATE
+// Create PCH with -fpch-codegen.
+// RUN: %clang -x c++-header -fpch-codegen 
%

[Differential] D83623: add -fpch-codegen/debuginfo options mapping to -fmodules-codegen/debuginfo

2020-07-22 Thread Luboš Luňák via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG54eea6127c4d: add -fpch-codegen/debuginfo mapping to 
-fmodules-codegen/debuginfo (authored by llunak).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D83623?vs=277671&id=279074#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83623

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/pch-codegen.cpp

Index: clang/test/Driver/pch-codegen.cpp
===
--- clang/test/Driver/pch-codegen.cpp
+++ clang/test/Driver/pch-codegen.cpp
@@ -7,21 +7,21 @@
 // CHECK-PCH-CREATE-NOT: -fmodules-codegen
 // CHECK-PCH-CREATE-NOT: -fmodules-debuginfo
 
-// Create PCH with -fmodules-codegen.
-// RUN: %clang -x c++-header -Xclang -fmodules-codegen %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-CREATE
+// Create PCH with -fpch-codegen.
+// RUN: %clang -x c++-header -fpch-codegen %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-CREATE
 // CHECK-PCH-CODEGEN-CREATE: -emit-pch
 // CHECK-PCH-CODEGEN-CREATE: -fmodules-codegen
 // CHECK-PCH-CODEGEN-CREATE: "-x" "c++-header"
 // CHECK-PCH-CODEGEN-CREATE-NOT: -fmodules-debuginfo
 
-// Create PCH with -fmodules-debuginfo.
-// RUN: %clang -x c++-header -Xclang -fmodules-debuginfo %S/../Modules/Inputs/codegen-flags/foo.h -g -o %t/foo-di.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-CREATE
+// Create PCH with -fpch-debuginfo.
+// RUN: %clang -x c++-header -fpch-debuginfo %S/../Modules/Inputs/codegen-flags/foo.h -g -o %t/foo-di.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-CREATE
 // CHECK-PCH-DEBUGINFO-CREATE: -emit-pch
 // CHECK-PCH-DEBUGINFO-CREATE: -fmodules-debuginfo
 // CHECK-PCH-DEBUGINFO-CREATE: "-x" "c++-header"
 // CHECK-PCH-DEBUGINFO-CREATE-NOT: -fmodules-codegen
 
-// Create PCH's object file for -fmodules-codegen.
+// Create PCH's object file for -fpch-codegen.
 // RUN: touch %t/foo-cg.pch
 // RUN: %clang -c %t/foo-cg.pch -o %t/foo-cg.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-OBJ
 // CHECK-PCH-CODEGEN-OBJ: -emit-obj
@@ -29,7 +29,7 @@
 // CHECK-PCH-CODEGEN-OBJ: "-o" "{{.*}}foo-cg.o"
 // CHECK-PCH-CODEGEN-OBJ: "-x" "precompiled-header"
 
-// Create PCH's object file for -fmodules-debuginfo.
+// Create PCH's object file for -fpch-debuginfo.
 // RUN: touch %t/foo-di.pch
 // RUN: %clang -c %t/foo-di.pch -g -o %t/foo-di.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-OBJ
 // CHECK-PCH-DEBUGINFO-OBJ: -emit-obj
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5642,6 +5642,12 @@
   if (Args.hasFlag(options::OPT_fpch_instantiate_templates,
options::OPT_fno_pch_instantiate_templates, false))
 CmdArgs.push_back("-fpch-instantiate-templates");
+  if (Args.hasFlag(options::OPT_fpch_codegen, options::OPT_fno_pch_codegen,
+   false))
+CmdArgs.push_back("-fmodules-codegen");
+  if (Args.hasFlag(options::OPT_fpch_debuginfo, options::OPT_fno_pch_debuginfo,
+   false))
+CmdArgs.push_back("-fmodules-debuginfo");
 
   Args.AddLastArg(CmdArgs, options::OPT_fexperimental_new_pass_manager,
   options::OPT_fno_experimental_new_pass_manager);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1440,6 +1440,10 @@
 def fno_pch_instantiate_templates:
   Flag <["-"], "fno-pch-instantiate-templates">,
   Group, Flags<[CC1Option]>;
+defm pch_codegen: OptInFFlag<"pch-codegen", "Generate ", "Do not generate ",
+  "code for uses of this PCH that assumes an explicit object file will be built for the PCH">;
+defm pch_debuginfo: OptInFFlag<"pch-debuginfo", "Generate ", "Do not generate ",
+  "debug info for types in an object file built from this PCH and do not generate them elsewhere">;
 
 def fmodules : Flag <["-"], "fmodules">, Group,
   Flags<[DriverOption, CC1Option]>,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -63,6 +63,32 @@
 
 - ...
 
+- -fpch-codegen and -fpch-debuginfo generate shared code and/or debuginfo
+  for contents of a precompiled header in a separate object file. This object
+  file needs to be linked in, but its contents do not need to be generated
+  for other objects using the precompiled header. This should us

[PATCH] D83716: Accept 'clang++ -c a.pch -o a.o' to create PCH's object file

2020-07-22 Thread Luboš Luňák via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3895466e2c33: accept 'clang++ -c a.pch -o a.o' to 
create PCH's object file (authored by llunak).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83716

Files:
  clang/lib/Driver/Types.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/pch-codegen.cpp
  clang/test/PCH/codegen.cpp

Index: clang/test/PCH/codegen.cpp
===
--- clang/test/PCH/codegen.cpp
+++ clang/test/PCH/codegen.cpp
@@ -9,8 +9,8 @@
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++-header -building-pch-with-obj -emit-pch %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-debuginfo -x c++-header -building-pch-with-obj -emit-pch %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-di.pch
 
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-cg.pch -building-pch-with-obj -fmodules-codegen | FileCheck --check-prefix=CG %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-di.pch -building-pch-with-obj -fmodules-debuginfo | FileCheck --check-prefix=DI %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -x precompiled-header %t/foo-cg.pch | FileCheck --check-prefix=CG %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -x precompiled-header %t/foo-di.pch | FileCheck --check-prefix=DI %s
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-cg.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=CG-USE %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-di.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=DI-USE %s
@@ -20,8 +20,8 @@
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++-header -building-pch-with-obj -emit-pch -fpch-instantiate-templates %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-debuginfo -x c++-header -building-pch-with-obj -emit-pch -fpch-instantiate-templates %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-di.pch
 
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-cg.pch -building-pch-with-obj -fmodules-codegen | FileCheck --check-prefix=CG %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-di.pch -building-pch-with-obj -fmodules-debuginfo | FileCheck --check-prefix=DI %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -x precompiled-header %t/foo-cg.pch | FileCheck --check-prefix=CG %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -x precompiled-header %t/foo-di.pch | FileCheck --check-prefix=DI %s
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-cg.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=CG-USE %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-di.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=DI-USE %s
Index: clang/test/Driver/pch-codegen.cpp
===
--- /dev/null
+++ clang/test/Driver/pch-codegen.cpp
@@ -0,0 +1,38 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+
+// Create PCH without codegen.
+// RUN: %clang -x c++-header %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CREATE
+// CHECK-PCH-CREATE: -emit-pch
+// CHECK-PCH-CREATE-NOT: -fmodules-codegen
+// CHECK-PCH-CREATE-NOT: -fmodules-debuginfo
+
+// Create PCH with -fmodules-codegen.
+// RUN: %clang -x c++-header -Xclang -fmodules-codegen %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-CREATE
+// CHECK-PCH-CODEGEN-CREATE: -emit-pch
+// CHECK-PCH-CODEGEN-CREATE: -fmodules-codegen
+// CHECK-PCH-CODEGEN-CREATE: "-x" "c++-header"
+// CHECK-PCH-CODEGEN-CREATE-NOT: -fmodules-debuginfo
+
+// Create PCH with -fmodules-debuginfo.
+// RUN: %clang -x c++-header -Xclang -fmodules-debuginfo %S/../Modules/Inputs/codegen-flags/foo.h -g -o %t/foo-di.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-CREATE
+// CHECK-PCH-DEBUGINFO-CREATE: -emit-pch
+// CHECK-PCH-DEBUGINFO-CREATE: -fmodules-debuginfo
+// CHECK-PCH-DEBUGINFO-CREATE: "-x" "c++-header"
+// CHECK-PCH-DEBUGINFO-CREATE-NOT: -fmodules-codegen
+
+//

[Differential] D83716: Accept 'clang++ -c a.pch -o a.o' to create PCH's object file

2020-07-22 Thread Luboš Luňák via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3895466e2c33: accept 'clang++ -c a.pch -o a.o' to 
create PCH's object file (authored by llunak).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D83716?vs=277670&id=279073#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83716

Files:
  clang/lib/Driver/Types.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/pch-codegen.cpp
  clang/test/PCH/codegen.cpp

Index: clang/test/PCH/codegen.cpp
===
--- clang/test/PCH/codegen.cpp
+++ clang/test/PCH/codegen.cpp
@@ -9,8 +9,8 @@
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++-header -building-pch-with-obj -emit-pch %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-debuginfo -x c++-header -building-pch-with-obj -emit-pch %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-di.pch
 
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-cg.pch -building-pch-with-obj -fmodules-codegen | FileCheck --check-prefix=CG %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-di.pch -building-pch-with-obj -fmodules-debuginfo | FileCheck --check-prefix=DI %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -x precompiled-header %t/foo-cg.pch | FileCheck --check-prefix=CG %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -x precompiled-header %t/foo-di.pch | FileCheck --check-prefix=DI %s
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-cg.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=CG-USE %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-di.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=DI-USE %s
@@ -20,8 +20,8 @@
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++-header -building-pch-with-obj -emit-pch -fpch-instantiate-templates %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-debuginfo -x c++-header -building-pch-with-obj -emit-pch -fpch-instantiate-templates %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-di.pch
 
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-cg.pch -building-pch-with-obj -fmodules-codegen | FileCheck --check-prefix=CG %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-di.pch -building-pch-with-obj -fmodules-debuginfo | FileCheck --check-prefix=DI %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -x precompiled-header %t/foo-cg.pch | FileCheck --check-prefix=CG %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -x precompiled-header %t/foo-di.pch | FileCheck --check-prefix=DI %s
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-cg.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=CG-USE %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-di.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=DI-USE %s
Index: clang/test/Driver/pch-codegen.cpp
===
--- /dev/null
+++ clang/test/Driver/pch-codegen.cpp
@@ -0,0 +1,38 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+
+// Create PCH without codegen.
+// RUN: %clang -x c++-header %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CREATE
+// CHECK-PCH-CREATE: -emit-pch
+// CHECK-PCH-CREATE-NOT: -fmodules-codegen
+// CHECK-PCH-CREATE-NOT: -fmodules-debuginfo
+
+// Create PCH with -fmodules-codegen.
+// RUN: %clang -x c++-header -Xclang -fmodules-codegen %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-CODEGEN-CREATE
+// CHECK-PCH-CODEGEN-CREATE: -emit-pch
+// CHECK-PCH-CODEGEN-CREATE: -fmodules-codegen
+// CHECK-PCH-CODEGEN-CREATE: "-x" "c++-header"
+// CHECK-PCH-CODEGEN-CREATE-NOT: -fmodules-debuginfo
+
+// Create PCH with -fmodules-debuginfo.
+// RUN: %clang -x c++-header -Xclang -fmodules-debuginfo %S/../Modules/Inputs/codegen-flags/foo.h -g -o %t/foo-di.pch -### 2>&1 | FileCheck %s -check-prefix=CHECK-PCH-DEBUGINFO-CREATE
+// CHECK-PCH-DEBUGINFO-CREATE: -emit-pch
+// CHECK-PCH-DEBUGINFO-CREATE: -fmodules-debuginfo
+// CHECK-PCH-DEBUGINFO-C

[PATCH] D75044: [AArch64] __builtin_return_address for PAuth.

2020-07-22 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

In D75044#2165496 , @chill wrote:

> The issue is that the definition of the instructions `XPAC{D,I}` is 
> incorrect: it does not mention at all the operand to those insns.


Err, they do mention the operand, but only as an input one, it should be 
input/output.


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

https://reviews.llvm.org/D75044



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


[PATCH] D84297: [clangd] Fix Origin and MainFileOnly-ness for macros

2020-07-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

This was resulting in macros coming from preambles vanishing when user
have opened the source header. For example:

  // test.h:

and

  // test.cc
  ^

If user only opens test.cc, we'll get `X` as a completion candidate,
since it is indexed as part of the preamble. But if the user opens
test.h afterwards we would index it as part of the main file and lose
the symbol (as new index shard for test.h will override the existing one
in dynamic index).

Also we were not setting origins for macros correctly, this patch also
fixes it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84297

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1402,6 +1402,9 @@
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(
Field(&Symbol::Origin, SymbolOrigin::Static)));
+  runSymbolCollector("#define FOO", /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   Field(&Symbol::Origin, SymbolOrigin::Static)));
 }
 
 TEST_F(SymbolCollectorTest, CollectMacros) {
@@ -1504,6 +1507,13 @@
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "PUNCT").ID, _)));
 }
 
+TEST_F(SymbolCollectorTest, MacrosInHeaders) {
+  CollectorOpts.CollectMacro = true;
+  TestFileName = testPath("test.h");
+  runSymbolCollector("", "#define X");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(AllOf(QName("X"), 
ForCodeCompletion(true;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -377,7 +377,10 @@
   const auto &SM = PP->getSourceManager();
   auto DefLoc = MI->getDefinitionLoc();
   auto SpellingLoc = SM.getSpellingLoc(Loc);
-  bool IsMainFileSymbol = SM.isInMainFile(SM.getExpansionLoc(DefLoc));
+  bool IsMainFileOnly =
+  SM.isInMainFile(SM.getExpansionLoc(DefLoc)) &&
+  !isHeaderFile(SM.getFileEntryForID(SM.getMainFileID())->getName(),
+ASTCtx->getLangOpts());
 
   // Builtin macros don't have useful locations and aren't needed in 
completion.
   if (MI->isBuiltinMacro())
@@ -392,7 +395,7 @@
 return true;
 
   // Do not store references to main-file macros.
-  if ((static_cast(Opts.RefFilter) & Roles) && !IsMainFileSymbol &&
+  if ((static_cast(Opts.RefFilter) & Roles) && !IsMainFileOnly &&
   (Opts.RefsInHeaders || SM.getFileID(SpellingLoc) == SM.getMainFileID()))
 MacroRefs[*ID].push_back({Loc, Roles});
 
@@ -401,7 +404,7 @@
 return true;
 
   // Skip main-file macros if we are not collecting them.
-  if (IsMainFileSymbol && !Opts.CollectMainFileSymbols)
+  if (IsMainFileOnly && !Opts.CollectMainFileSymbols)
 return false;
 
   // Mark the macro as referenced if this is a reference coming from the main
@@ -425,11 +428,12 @@
   Symbol S;
   S.ID = std::move(*ID);
   S.Name = Name->getName();
-  if (!IsMainFileSymbol) {
+  if (!IsMainFileOnly) {
 S.Flags |= Symbol::IndexedForCodeCompletion;
 S.Flags |= Symbol::VisibleOutsideFile;
   }
   S.SymInfo = index::getSymbolInfoForMacro(*MI);
+  S.Origin = Opts.Origin;
   std::string FileURI;
   // FIXME: use the result to filter out symbols.
   shouldIndexFile(SM.getFileID(Loc));


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1402,6 +1402,9 @@
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(
Field(&Symbol::Origin, SymbolOrigin::Static)));
+  runSymbolCollector("#define FOO", /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   Field(&Symbol::Origin, SymbolOrigin::Static)));
 }
 
 TEST_F(SymbolCollectorTest, CollectMacros) {
@@ -1504,6 +1507,13 @@
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "PUNCT").ID, _)));
 }
 
+TEST_F(SymbolCollectorTest, MacrosInHeaders) {
+  CollectorOpts.CollectMacro = true;
+  TestFileName = testPath("test.h");
+  runSymbolCollector("", "#define X");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(AllOf(QName("X"), ForCodeCompletion(true;
+}
 } // namespace
 } // 

[clang] 5567c62 - [Matrix] Add LowerMatrixIntrinsics to the NPM

2020-07-22 Thread Sjoerd Meijer via cfe-commits

Author: Sjoerd Meijer
Date: 2020-07-22T09:47:53+01:00
New Revision: 5567c62afa559dc2f2604601ec9269f1e3fbfdab

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

LOG: [Matrix] Add LowerMatrixIntrinsics to the NPM

Pass LowerMatrixIntrinsics wasn't running yet running under the new pass
manager, and this adds LowerMatrixIntrinsics to the pipeline (to the
same place as where it is running in the old PM).

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

Added: 
clang/test/CodeGen/matrix-lowering-opt-levels.c

Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 3405c48bc389..111ca1981fe3 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -74,6 +74,7 @@
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
+#include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
@@ -1372,6 +1373,13 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 }
 
 if (CodeGenOpts.OptimizationLevel == 0) {
+  // FIXME: the backends do not handle matrix intrinsics currently. Make
+  // sure they are also lowered in O0. A lightweight version of the pass
+  // should run in the backend pipeline on demand.
+  if (LangOpts.MatrixTypes)
+MPM.addPass(
+createModuleToFunctionPassAdaptor(LowerMatrixIntrinsicsPass()));
+
   addCoroutinePassesAtO0(MPM, LangOpts, CodeGenOpts);
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
 }

diff  --git a/clang/test/CodeGen/matrix-lowering-opt-levels.c 
b/clang/test/CodeGen/matrix-lowering-opt-levels.c
new file mode 100644
index ..73a9458b8bf5
--- /dev/null
+++ b/clang/test/CodeGen/matrix-lowering-opt-levels.c
@@ -0,0 +1,28 @@
+// RUN: %clang -O0 -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -O1 -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -O2 -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -O3 -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -Ofast -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -Os -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -Oz -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+
+// RUN: %clang -O0 -fenable-matrix -fexperimental-new-pass-manager -S 
-emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -O1 -fenable-matrix -fexperimental-new-pass-manager -S 
-emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -O2 -fenable-matrix -fexperimental-new-pass-manager -S 
-emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -O3 -fenable-matrix -fexperimental-new-pass-manager -S 
-emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -Ofast -fenable-matrix -fexperimental-new-pass-manager -S 
-emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -Os -fenable-matrix -fexperimental-new-pass-manager -S 
-emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -Oz -fenable-matrix -fexperimental-new-pass-manager -S 
-emit-llvm %s -o - | FileCheck  %s
+
+// Smoke test that the matrix intrinsics are lowered at any optimisation level.
+
+typedef float m4x4_t __attribute__((matrix_type(4, 4)));
+
+m4x4_t f(m4x4_t a, m4x4_t b, m4x4_t c) {
+  //
+  // CHECK-LABEL: f(
+  // CHECK-NOT: @llvm.matrix
+  // CHECK:   }
+  //
+  return a + b * c;
+}

diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 76c3c8a90f2d..b534853a1213 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -275,6 +275,8 @@ extern cl::opt FlattenedProfileUsed;
 extern cl::opt AttributorRun;
 extern cl::opt EnableKnowledgeRetention;
 
+extern cl::opt EnableMatrix;
+
 const PassBuilder::OptimizationLevel PassBuilder::OptimizationLevel::O0 = {
 /*SpeedLevel*/ 0,
 /*SizeLevel*/ 0};
@@ -1093,6 +1095,11 @@ ModulePassManager 
PassBuilder::buildModuleOptimizationPipeline(
   OptimizePM.addPass(Float2IntPass());
   OptimizePM.addPass(LowerConstantIntrinsicsPass());
 
+  if (EnableMatrix) {
+OptimizePM.addPass(LowerMatrixIntrinsicsPass());
+OptimizePM.addPass(EarlyCSEPass());
+  }
+
   // FIXME: We need to run some loop optimizations to re-rotate loops after
   // simplify-cfg and others undo their rotation.
 

diff  --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp 
b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index 5a3be7580c6e..c045c277706b 100644
--- a/llvm/lib/Transforms/IPO/Pass

[PATCH] D84180: [Matrix] Add LowerMatrixIntrinsics to the NPM

2020-07-22 Thread Sjoerd Meijer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5567c62afa55: [Matrix] Add LowerMatrixIntrinsics to the NPM 
(authored by SjoerdMeijer).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D84180?vs=279559&id=279727#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84180

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/matrix-lowering-opt-levels.c
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
===
--- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -149,9 +149,9 @@
 "enable-order-file-instrumentation", cl::init(false), cl::Hidden,
 cl::desc("Enable order file instrumentation (default = off)"));
 
-static cl::opt
-EnableMatrix("enable-matrix", cl::init(false), cl::Hidden,
- cl::desc("Enable lowering of the matrix intrinsics"));
+cl::opt EnableMatrix(
+"enable-matrix", cl::init(false), cl::Hidden,
+cl::desc("Enable lowering of the matrix intrinsics"));
 
 cl::opt AttributorRun(
 "attributor-enable", cl::Hidden, cl::init(AttributorRunOption::NONE),
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -275,6 +275,8 @@
 extern cl::opt AttributorRun;
 extern cl::opt EnableKnowledgeRetention;
 
+extern cl::opt EnableMatrix;
+
 const PassBuilder::OptimizationLevel PassBuilder::OptimizationLevel::O0 = {
 /*SpeedLevel*/ 0,
 /*SizeLevel*/ 0};
@@ -1093,6 +1095,11 @@
   OptimizePM.addPass(Float2IntPass());
   OptimizePM.addPass(LowerConstantIntrinsicsPass());
 
+  if (EnableMatrix) {
+OptimizePM.addPass(LowerMatrixIntrinsicsPass());
+OptimizePM.addPass(EarlyCSEPass());
+  }
+
   // FIXME: We need to run some loop optimizations to re-rotate loops after
   // simplify-cfg and others undo their rotation.
 
Index: clang/test/CodeGen/matrix-lowering-opt-levels.c
===
--- /dev/null
+++ clang/test/CodeGen/matrix-lowering-opt-levels.c
@@ -0,0 +1,28 @@
+// RUN: %clang -O0 -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -O1 -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -O2 -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -O3 -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -Ofast -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -Os -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -Oz -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
+
+// RUN: %clang -O0 -fenable-matrix -fexperimental-new-pass-manager -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -O1 -fenable-matrix -fexperimental-new-pass-manager -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -O2 -fenable-matrix -fexperimental-new-pass-manager -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -O3 -fenable-matrix -fexperimental-new-pass-manager -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -Ofast -fenable-matrix -fexperimental-new-pass-manager -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -Os -fenable-matrix -fexperimental-new-pass-manager -S -emit-llvm %s -o - | FileCheck  %s
+// RUN: %clang -Oz -fenable-matrix -fexperimental-new-pass-manager -S -emit-llvm %s -o - | FileCheck  %s
+
+// Smoke test that the matrix intrinsics are lowered at any optimisation level.
+
+typedef float m4x4_t __attribute__((matrix_type(4, 4)));
+
+m4x4_t f(m4x4_t a, m4x4_t b, m4x4_t c) {
+  //
+  // CHECK-LABEL: f(
+  // CHECK-NOT: @llvm.matrix
+  // CHECK:   }
+  //
+  return a + b * c;
+}
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -74,6 +74,7 @@
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
+#include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
@@ -1372,6 +1373,13 @@
 }
 
 if (CodeGenOpts.OptimizationLevel == 0) {
+  // FIXME: the backends do not handle matrix intrinsics currently. Make
+  // sure they are also lowered in O0. A lightweight version of the pass
+  // should run in the backend pipeline on demand.
+  if (LangOpts.MatrixTypes)
+MPM.addPass(
+createModuleToFunctionPassAdaptor(LowerMatrixIntrinsicsPass()));
+
   addCoroutinePassesAtO0(MPM, LangOp

[PATCH] D83296: [clang-format] Add a MacroExpander.

2020-07-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Sorry for the long delay, I've made up for it with extra comments :-\

This looks really well-thought-out and I'm rationalizing my pickiness as:

- this is conceptually complicated
- I expect this code to live a long time and be read and "modified around" by 
lots of people

Some of the comments/requests for doc might strictly be more in scope for in 
later patches (documenting functionality that doesn't exist yet). Those docs 
would help *me* now but happy if you'd rather briefly explain and add them 
later.




Comment at: clang/lib/Format/FormatToken.h:166
+  ///   \- P0  \- P1
+  /// ExpandedFrom stacks for each generated token will be:
+  /// ( -> P0

this is a great example, it might be a little more clear with more distinct 
chars and some vertical alignment:
```
Given X(A)=[A], Y(A)=,
  X({ Y(0)  } ) expands as
  [ { < 0 > } ]
StartOfExpansion  1   1
ExpandedFrom[0]   X X X X X X X
ExpandedFrom[1]   Y Y Y
```

You could extend this to cover all the fields and hoist it to be a comment on 
MacroContext if you like, I think the concreteness helps.



Comment at: clang/lib/Format/FormatToken.h:176
+
+  /// Whether this token is the first token in a macro expansion.
+  bool StartOfExpansion = false;

why the asymmetry between start/end?

given `ID(x)=X`, `ID(ID(0))` yields `0` which starts and ends two expansions, 
right?
Consider making them both integer, even if you don't need it at this point.

(also 64 bits, really?)



Comment at: clang/lib/Format/FormatToken.h:183
+
+  /// When macro expansion introduces parents, those are marked as
+  /// \c MacroParent, so formatting knows their children need to be formatted.

this isn't used in this patch - can we leave it out until used?



Comment at: clang/lib/Format/FormatToken.h:389
+  // in a configured macro expansion.
+  MacroContext MacroCtx;
+

if you're not extremely concerned about memory layout, I'd consider making this 
an `Optional` with nullopt replacing the current MR_None. 

This reduces the number of implicit invariants (AIUI MR_None can't be combined 
with any other fields being set) and means the name MacroContext more closely 
fits the thing it's modeling.



Comment at: clang/lib/Format/FormatToken.h:632
 
+  void copyInto(FormatToken &Tok) { Tok = *this; }
+

const.

I guess it doesn't matter, but copyFrom would seem a little less weird to me in 
an OOP/encapsulation sense.
I do like this explicit form rather than clone() + move constructor though, as 
pointer identity is pretty important for tokens.



Comment at: clang/lib/Format/MacroExpander.cpp:35
+  SmallVector Params;
+  SmallVector Tokens;
+};

Tokens -> Expansion? (semantics rather than type)



Comment at: clang/lib/Format/MacroExpander.cpp:38
+
+// A simple macro parser.
+class MacroExpander::DefinitionParser {

Dmitri gave a tech talk on dropping comments like these :-)



Comment at: clang/lib/Format/MacroExpander.cpp:42
+  DefinitionParser(ArrayRef Tokens) : Tokens(Tokens) {
+assert(!Tokens.empty());
+Current = Tokens[0];

who's responsible for establishing this?

AIUI this will fail if e.g. `Macros` contains a string that contains only 
whitespace, which is a slightly weird precondition.



Comment at: clang/lib/Format/MacroExpander.cpp:63
+  bool parseParams() {
+if (Current->isNot(tok::l_paren))
+  return false;

assert instead? Caller checks this



Comment at: clang/lib/Format/MacroExpander.cpp:81
+do {
+  Def.Tokens.push_back(Current);
+  nextToken();

this assumes the expansion is nonempty, which the grammar doesn't. while{} 
instead?



Comment at: clang/lib/Format/MacroExpander.cpp:113
+void MacroExpander::parseDefinitions(
+const std::vector &MacroExpander) {
+  for (const std::string &Macro : MacroExpander) {

weird param name!



Comment at: clang/lib/Format/MacroExpander.cpp:116
+Buffers.push_back(
+llvm::MemoryBuffer::getMemBufferCopy(Macro, ""));
+clang::FileID FID =

This is a slightly spooky buffer name - it's the magic name the PP uses for 
pasted tokens.
A closer fit for config is maybe "" (like macro definitions 
passed with `-D`).
Is it necessary to use one of clang's magic buffer names at all? If so, 
comment! Else maybe "" or something?



Comment at: clang/lib/Format/MacroExpander.cpp:133
+  ArgsList Args) {
+  assert(defined(ID->TokenText));
+  SmallVector Result;

is the caller responsible for checking the #args matches #params?
If so, document and assert here?

L

Re: [clang-tools-extra] 82dbb1b - Fix the clang-tidy build after get/isIntegerConstantExpression

2020-07-22 Thread David Blaikie via cfe-commits
Thanks for that! Sorry I was a bit slow to get that cleaned up.

On Wed, Jul 22, 2020 at 12:41 AM Haojian Wu via cfe-commits
 wrote:
>
>
> Author: Haojian Wu
> Date: 2020-07-22T09:38:56+02:00
> New Revision: 82dbb1b2b4f1e70ca453cca60a4ba5b856058fc0
>
> URL: 
> https://github.com/llvm/llvm-project/commit/82dbb1b2b4f1e70ca453cca60a4ba5b856058fc0
> DIFF: 
> https://github.com/llvm/llvm-project/commit/82dbb1b2b4f1e70ca453cca60a4ba5b856058fc0.diff
>
> LOG: Fix the clang-tidy build after get/isIntegerConstantExpression
> refactoring.
>
> Added:
>
>
> Modified:
> 
> clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
> 
> clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
> clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
> clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
>
> Removed:
>
>
>
> 
> diff  --git 
> a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
>  
> b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
> index aa860b30fe75..1837ccb6002f 100644
> --- 
> a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
> +++ 
> b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
> @@ -79,9 +79,8 @@ static QualType getUnqualifiedType(const Expr &E) {
>  }
>
>  static APValue getConstantExprValue(const ASTContext &Ctx, const Expr &E) {
> -  llvm::APSInt IntegerConstant;
> -  if (E.isIntegerConstantExpr(IntegerConstant, Ctx))
> -return APValue(IntegerConstant);
> +  if (auto IntegerConstant = E.getIntegerConstantExpr(Ctx))
> +return APValue(*IntegerConstant);
>APValue Constant;
>if (Ctx.getLangOpts().CPlusPlus && E.isCXX11ConstantExpr(Ctx, &Constant))
>  return Constant;
>
> diff  --git 
> a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
>  
> b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
> index dd0bedd742a4..96b0bb0f9b02 100644
> --- 
> a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
> +++ 
> b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
> @@ -65,9 +65,9 @@ void ProBoundsConstantArrayIndexCheck::check(
>if (IndexExpr->isValueDependent())
>  return; // We check in the specialization.
>
> -  llvm::APSInt Index;
> -  if (!IndexExpr->isIntegerConstantExpr(Index, *Result.Context, nullptr,
> -/*isEvaluated=*/true)) {
> +  Optional Index =
> +  IndexExpr->getIntegerConstantExpr(*Result.Context);
> +  if (!Index) {
>  SourceRange BaseRange;
>  if (const auto *ArraySubscriptE = dyn_cast(Matched))
>BaseRange = ArraySubscriptE->getBase()->getSourceRange();
> @@ -101,9 +101,9 @@ void ProBoundsConstantArrayIndexCheck::check(
>if (!StdArrayDecl)
>  return;
>
> -  if (Index.isSigned() && Index.isNegative()) {
> +  if (Index->isSigned() && Index->isNegative()) {
>  diag(Matched->getExprLoc(), "std::array<> index %0 is negative")
> -<< Index.toString(10);
> +<< Index->toString(10);
>  return;
>}
>
> @@ -118,11 +118,11 @@ void ProBoundsConstantArrayIndexCheck::check(
>
>// Get uint64_t values, because
> diff erent bitwidths would lead to an assertion
>// in APInt::uge.
> -  if (Index.getZExtValue() >= ArraySize.getZExtValue()) {
> +  if (Index->getZExtValue() >= ArraySize.getZExtValue()) {
>  diag(Matched->getExprLoc(),
>   "std::array<> index %0 is past the end of the array "
>   "(which contains %1 elements)")
> -<< Index.toString(10) << ArraySize.toString(10, false);
> +<< Index->toString(10) << ArraySize.toString(10, false);
>}
>  }
>
>
> diff  --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp 
> b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
> index aef513a527b5..b84e4d525d8c 100644
> --- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
> +++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
> @@ -500,7 +500,13 @@ static bool retrieveIntegerConstantExpr(const 
> MatchFinder::MatchResult &Result,
>  const Expr *&ConstExpr) {
>std::string CstId = (Id + "-const").str();
>ConstExpr = Result.Nodes.getNodeAs(CstId);
> -  return ConstExpr && ConstExpr->isIntegerConstantExpr(Value, 
> *Result.Context);
> +  if (!ConstExpr)
> +return false;
> +  Optional R = 
> ConstExpr->getIntegerConstantExpr(*Result.Context);
> +  if (!R)
> +return false;
> +  Value = *R;
> +  return true;
>  }
>
>  // Overloaded `retrieveIntegerConstantExpr` for compatibility.
> @@ -673,7 +679,7 @@ static bool retrieveRelationalIntegerConstantExpr(
>
>  if (const auto *Arg = OverloadedOperatorExpr->getArg(1)) {
>if (!Arg->isVal

[PATCH] D84277: [PowerPC][Power10] Fix vins*vlx instructions to have i32 arguments.

2020-07-22 Thread Rafik Zurob via Phabricator via cfe-commits
rzurob accepted this revision.
rzurob added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84277



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


[PATCH] D84291: [PowerPC][Power10] Fix the Test LSB by Byte (xvtlsbb) Builtins Implementation

2020-07-22 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.

LGTM. The test case addition can be done on the commit.




Comment at: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll:2
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \

Since the issue was discovered when compiling with `-O0`, can you please add a 
`RUN` line with `-O0` to this test case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84291



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


[PATCH] D84297: [clangd] Fix Origin and MainFileOnly-ness for macros

2020-07-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

thanks!

the test.h in the patch description is missing a `#define X`.




Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:383
+  !isHeaderFile(SM.getFileEntryForID(SM.getMainFileID())->getName(),
+ASTCtx->getLangOpts());
 

nit: move this var to Line 398, in some cases (builtin macros), it is not used, 
so would save some cost.

this is duplicated with the one in `handleDeclOccurrence`, creating a new 
function seems not worthy...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84297



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


[PATCH] D84297: [clangd] Fix Origin and MainFileOnly-ness for macros

2020-07-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 279731.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Move declarations closer to use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84297

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1402,6 +1402,9 @@
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(
Field(&Symbol::Origin, SymbolOrigin::Static)));
+  runSymbolCollector("#define FOO", /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   Field(&Symbol::Origin, SymbolOrigin::Static)));
 }
 
 TEST_F(SymbolCollectorTest, CollectMacros) {
@@ -1504,6 +1507,13 @@
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "PUNCT").ID, _)));
 }
 
+TEST_F(SymbolCollectorTest, MacrosInHeaders) {
+  CollectorOpts.CollectMacro = true;
+  TestFileName = testPath("test.h");
+  runSymbolCollector("", "#define X");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(AllOf(QName("X"), 
ForCodeCompletion(true;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -373,16 +373,12 @@
 index::SymbolRoleSet Roles,
 SourceLocation Loc) {
   assert(PP.get());
-
-  const auto &SM = PP->getSourceManager();
-  auto DefLoc = MI->getDefinitionLoc();
-  auto SpellingLoc = SM.getSpellingLoc(Loc);
-  bool IsMainFileSymbol = SM.isInMainFile(SM.getExpansionLoc(DefLoc));
-
   // Builtin macros don't have useful locations and aren't needed in 
completion.
   if (MI->isBuiltinMacro())
 return true;
 
+  const auto &SM = PP->getSourceManager();
+  auto DefLoc = MI->getDefinitionLoc();
   // Also avoid storing predefined macros like __DBL_MIN__.
   if (SM.isWrittenInBuiltinFile(DefLoc))
 return true;
@@ -391,8 +387,13 @@
   if (!ID)
 return true;
 
+  auto SpellingLoc = SM.getSpellingLoc(Loc);
+  bool IsMainFileOnly =
+  SM.isInMainFile(SM.getExpansionLoc(DefLoc)) &&
+  !isHeaderFile(SM.getFileEntryForID(SM.getMainFileID())->getName(),
+ASTCtx->getLangOpts());
   // Do not store references to main-file macros.
-  if ((static_cast(Opts.RefFilter) & Roles) && !IsMainFileSymbol &&
+  if ((static_cast(Opts.RefFilter) & Roles) && !IsMainFileOnly &&
   (Opts.RefsInHeaders || SM.getFileID(SpellingLoc) == SM.getMainFileID()))
 MacroRefs[*ID].push_back({Loc, Roles});
 
@@ -401,7 +402,7 @@
 return true;
 
   // Skip main-file macros if we are not collecting them.
-  if (IsMainFileSymbol && !Opts.CollectMainFileSymbols)
+  if (IsMainFileOnly && !Opts.CollectMainFileSymbols)
 return false;
 
   // Mark the macro as referenced if this is a reference coming from the main
@@ -425,11 +426,12 @@
   Symbol S;
   S.ID = std::move(*ID);
   S.Name = Name->getName();
-  if (!IsMainFileSymbol) {
+  if (!IsMainFileOnly) {
 S.Flags |= Symbol::IndexedForCodeCompletion;
 S.Flags |= Symbol::VisibleOutsideFile;
   }
   S.SymInfo = index::getSymbolInfoForMacro(*MI);
+  S.Origin = Opts.Origin;
   std::string FileURI;
   // FIXME: use the result to filter out symbols.
   shouldIndexFile(SM.getFileID(Loc));


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1402,6 +1402,9 @@
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(
Field(&Symbol::Origin, SymbolOrigin::Static)));
+  runSymbolCollector("#define FOO", /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   Field(&Symbol::Origin, SymbolOrigin::Static)));
 }
 
 TEST_F(SymbolCollectorTest, CollectMacros) {
@@ -1504,6 +1507,13 @@
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "PUNCT").ID, _)));
 }
 
+TEST_F(SymbolCollectorTest, MacrosInHeaders) {
+  CollectorOpts.CollectMacro = true;
+  TestFileName = testPath("test.h");
+  runSymbolCollector("", "#define X");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(AllOf(QName("X"), ForCodeCompletion(true;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-e

[clang-tools-extra] a69f9a8 - [clangd] Fix Origin and MainFileOnly-ness for macros

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

Author: Kadir Cetinkaya
Date: 2020-07-22T11:24:31+02:00
New Revision: a69f9a8584f2a090b5fe6235a112f9b68c324863

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

LOG: [clangd] Fix Origin and MainFileOnly-ness for macros

Summary:
This was resulting in macros coming from preambles vanishing when user
have opened the source header. For example:

```
// test.h:
 #define X
```

and

```
// test.cc
 #include "test.h
^
```

If user only opens test.cc, we'll get `X` as a completion candidate,
since it is indexed as part of the preamble. But if the user opens
test.h afterwards we would index it as part of the main file and lose
the symbol (as new index shard for test.h will override the existing one
in dynamic index).

Also we were not setting origins for macros correctly, this patch also
fixes it.

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

Reviewers: hokein

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index b502dfb03aec..6c11399c87b6 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -373,16 +373,12 @@ bool SymbolCollector::handleMacroOccurrence(const 
IdentifierInfo *Name,
 index::SymbolRoleSet Roles,
 SourceLocation Loc) {
   assert(PP.get());
-
-  const auto &SM = PP->getSourceManager();
-  auto DefLoc = MI->getDefinitionLoc();
-  auto SpellingLoc = SM.getSpellingLoc(Loc);
-  bool IsMainFileSymbol = SM.isInMainFile(SM.getExpansionLoc(DefLoc));
-
   // Builtin macros don't have useful locations and aren't needed in 
completion.
   if (MI->isBuiltinMacro())
 return true;
 
+  const auto &SM = PP->getSourceManager();
+  auto DefLoc = MI->getDefinitionLoc();
   // Also avoid storing predefined macros like __DBL_MIN__.
   if (SM.isWrittenInBuiltinFile(DefLoc))
 return true;
@@ -391,8 +387,13 @@ bool SymbolCollector::handleMacroOccurrence(const 
IdentifierInfo *Name,
   if (!ID)
 return true;
 
+  auto SpellingLoc = SM.getSpellingLoc(Loc);
+  bool IsMainFileOnly =
+  SM.isInMainFile(SM.getExpansionLoc(DefLoc)) &&
+  !isHeaderFile(SM.getFileEntryForID(SM.getMainFileID())->getName(),
+ASTCtx->getLangOpts());
   // Do not store references to main-file macros.
-  if ((static_cast(Opts.RefFilter) & Roles) && !IsMainFileSymbol &&
+  if ((static_cast(Opts.RefFilter) & Roles) && !IsMainFileOnly &&
   (Opts.RefsInHeaders || SM.getFileID(SpellingLoc) == SM.getMainFileID()))
 MacroRefs[*ID].push_back({Loc, Roles});
 
@@ -401,7 +402,7 @@ bool SymbolCollector::handleMacroOccurrence(const 
IdentifierInfo *Name,
 return true;
 
   // Skip main-file macros if we are not collecting them.
-  if (IsMainFileSymbol && !Opts.CollectMainFileSymbols)
+  if (IsMainFileOnly && !Opts.CollectMainFileSymbols)
 return false;
 
   // Mark the macro as referenced if this is a reference coming from the main
@@ -425,11 +426,12 @@ bool SymbolCollector::handleMacroOccurrence(const 
IdentifierInfo *Name,
   Symbol S;
   S.ID = std::move(*ID);
   S.Name = Name->getName();
-  if (!IsMainFileSymbol) {
+  if (!IsMainFileOnly) {
 S.Flags |= Symbol::IndexedForCodeCompletion;
 S.Flags |= Symbol::VisibleOutsideFile;
   }
   S.SymInfo = index::getSymbolInfoForMacro(*MI);
+  S.Origin = Opts.Origin;
   std::string FileURI;
   // FIXME: use the result to filter out symbols.
   shouldIndexFile(SM.getFileID(Loc));

diff  --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp 
b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
index d90f99ff9f8c..9e4f75b5cca3 100644
--- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1402,6 +1402,9 @@ TEST_F(SymbolCollectorTest, Origin) {
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(
Field(&Symbol::Origin, SymbolOrigin::Static)));
+  runSymbolCollector("#define FOO", /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   Field(&Symbol::Origin, SymbolOrigin::Static)));
 }
 
 TEST_F(SymbolCollectorTest, CollectMacros) {
@@ -1504,6 +1507,13 @@ TEST_F(SymbolCollectorTest, BadUTF8) {
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "PUNCT").ID, _)));
 }
 
+TEST_F(SymbolCollectorTest, Macro

[PATCH] D84297: [clangd] Fix Origin and MainFileOnly-ness for macros

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

> the test.h in the patch description is missing a #define X.

ah right, git descriptions omitting lines starting with `#` fixed it for 
include, but missed the define :face_palm:




Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:383
+  !isHeaderFile(SM.getFileEntryForID(SM.getMainFileID())->getName(),
+ASTCtx->getLangOpts());
 

hokein wrote:
> nit: move this var to Line 398, in some cases (builtin macros), it is not 
> used, so would save some cost.
> 
> this is duplicated with the one in `handleDeclOccurrence`, creating a new 
> function seems not worthy...
yeah and these are slightly different, the one in declOccurence makes sure the 
decl is written inside the main file, whereas this one also accepts remappings 
through `#line` directives.

not sure if it is necessary, but it was the old behavior, so I am just keeping 
it, no tests seem to break and we already do not index builtin macros or the 
ones spelled in a builtin-file. I don't think line directives are widely used 
within the rest, but again such a change would deserve a separate patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84297



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


[PATCH] D84297: [clangd] Fix Origin and MainFileOnly-ness for macros

2020-07-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa69f9a8584f2: [clangd] Fix Origin and MainFileOnly-ness for 
macros (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84297

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1402,6 +1402,9 @@
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(
Field(&Symbol::Origin, SymbolOrigin::Static)));
+  runSymbolCollector("#define FOO", /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   Field(&Symbol::Origin, SymbolOrigin::Static)));
 }
 
 TEST_F(SymbolCollectorTest, CollectMacros) {
@@ -1504,6 +1507,13 @@
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "PUNCT").ID, _)));
 }
 
+TEST_F(SymbolCollectorTest, MacrosInHeaders) {
+  CollectorOpts.CollectMacro = true;
+  TestFileName = testPath("test.h");
+  runSymbolCollector("", "#define X");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(AllOf(QName("X"), 
ForCodeCompletion(true;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -373,16 +373,12 @@
 index::SymbolRoleSet Roles,
 SourceLocation Loc) {
   assert(PP.get());
-
-  const auto &SM = PP->getSourceManager();
-  auto DefLoc = MI->getDefinitionLoc();
-  auto SpellingLoc = SM.getSpellingLoc(Loc);
-  bool IsMainFileSymbol = SM.isInMainFile(SM.getExpansionLoc(DefLoc));
-
   // Builtin macros don't have useful locations and aren't needed in 
completion.
   if (MI->isBuiltinMacro())
 return true;
 
+  const auto &SM = PP->getSourceManager();
+  auto DefLoc = MI->getDefinitionLoc();
   // Also avoid storing predefined macros like __DBL_MIN__.
   if (SM.isWrittenInBuiltinFile(DefLoc))
 return true;
@@ -391,8 +387,13 @@
   if (!ID)
 return true;
 
+  auto SpellingLoc = SM.getSpellingLoc(Loc);
+  bool IsMainFileOnly =
+  SM.isInMainFile(SM.getExpansionLoc(DefLoc)) &&
+  !isHeaderFile(SM.getFileEntryForID(SM.getMainFileID())->getName(),
+ASTCtx->getLangOpts());
   // Do not store references to main-file macros.
-  if ((static_cast(Opts.RefFilter) & Roles) && !IsMainFileSymbol &&
+  if ((static_cast(Opts.RefFilter) & Roles) && !IsMainFileOnly &&
   (Opts.RefsInHeaders || SM.getFileID(SpellingLoc) == SM.getMainFileID()))
 MacroRefs[*ID].push_back({Loc, Roles});
 
@@ -401,7 +402,7 @@
 return true;
 
   // Skip main-file macros if we are not collecting them.
-  if (IsMainFileSymbol && !Opts.CollectMainFileSymbols)
+  if (IsMainFileOnly && !Opts.CollectMainFileSymbols)
 return false;
 
   // Mark the macro as referenced if this is a reference coming from the main
@@ -425,11 +426,12 @@
   Symbol S;
   S.ID = std::move(*ID);
   S.Name = Name->getName();
-  if (!IsMainFileSymbol) {
+  if (!IsMainFileOnly) {
 S.Flags |= Symbol::IndexedForCodeCompletion;
 S.Flags |= Symbol::VisibleOutsideFile;
   }
   S.SymInfo = index::getSymbolInfoForMacro(*MI);
+  S.Origin = Opts.Origin;
   std::string FileURI;
   // FIXME: use the result to filter out symbols.
   shouldIndexFile(SM.getFileID(Loc));


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1402,6 +1402,9 @@
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(
Field(&Symbol::Origin, SymbolOrigin::Static)));
+  runSymbolCollector("#define FOO", /*Main=*/"");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   Field(&Symbol::Origin, SymbolOrigin::Static)));
 }
 
 TEST_F(SymbolCollectorTest, CollectMacros) {
@@ -1504,6 +1507,13 @@
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "PUNCT").ID, _)));
 }
 
+TEST_F(SymbolCollectorTest, MacrosInHeaders) {
+  CollectorOpts.CollectMacro = true;
+  TestFileName = testPath("test.h");
+  runSymbolCollector("", "#define X");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(AllOf(QName("X"), ForCodeCompletion(true;
+}
 } // namespace
 } // namespace clangd
 } // name

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

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

@sammccall sorry for bothering you, could you please land this for me?

Ilya Golovenko 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84172



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


[PATCH] D83942: [analyzer][tests] Add a notion of project sizes

2020-07-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 279738.
vsavchenko added a comment.

Make --projects and --max-size compatible


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83942

Files:
  clang/utils/analyzer/ProjectMap.py
  clang/utils/analyzer/SATest.py
  clang/utils/analyzer/projects/projects.json

Index: clang/utils/analyzer/projects/projects.json
===
--- clang/utils/analyzer/projects/projects.json
+++ clang/utils/analyzer/projects/projects.json
@@ -4,139 +4,159 @@
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/jarro2783/cxxopts.git";,
-"commit": "794c975"
+"commit": "794c975",
+"size": "tiny"
   },
   {
 "name": "box2d",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/erincatto/box2d.git";,
-"commit": "1025f9a"
+"commit": "1025f9a",
+"size": "small"
   },
   {
 "name": "tinyexpr",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/codeplea/tinyexpr.git";,
-"commit": "ffb0d41"
+"commit": "ffb0d41",
+"size": "tiny"
   },
   {
 "name": "symengine",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/symengine/symengine.git";,
-"commit": "4f669d59"
+"commit": "4f669d59",
+"size": "small"
   },
   {
 "name": "termbox",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/nsf/termbox.git";,
-"commit": "0df1355"
+"commit": "0df1355",
+"size": "tiny"
   },
   {
 "name": "tinyvm",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/jakogut/tinyvm.git";,
-"commit": "10c25d8"
+"commit": "10c25d8",
+"size": "tiny"
   },
   {
 "name": "tinyspline",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/msteinbeck/tinyspline.git";,
-"commit": "f8b1ab7"
+"commit": "f8b1ab7",
+"size": "tiny"
   },
   {
 "name": "oatpp",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/oatpp/oatpp.git";,
-"commit": "d3e60fb"
+"commit": "d3e60fb",
+"size": "small"
   },
   {
 "name": "libsoundio",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/andrewrk/libsoundio.git";,
-"commit": "b810bf2"
+"commit": "b810bf2",
+"size": "tiny"
   },
   {
 "name": "zstd",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/facebook/zstd.git";,
-"commit": "2af4e073"
+"commit": "2af4e073",
+"size": "small"
   },
   {
 "name": "simbody",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/simbody/simbody.git";,
-"commit": "5cf513d"
+"commit": "5cf513d",
+"size": "big"
   },
   {
 "name": "duckdb",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/cwida/duckdb.git";,
-"commit": "d098c9f"
+"commit": "d098c9f",
+"size": "big"
   },
   {
 "name": "drogon",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/an-tao/drogon.git";,
-"commit": "fd2a612"
+"commit": "fd2a612",
+"size": "small"
   },
   {
 "name": "fmt",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/fmtlib/fmt.git";,
-"commit": "5e7c70e"
+"commit": "5e7c70e",
+"size": "small"
   },
   {
 "name": "re2",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/google/re2.git";,
-"commit": "2b25567"
+"commit": "2b25567",
+"size": "small"
   },
   {
 "name": "cppcheck",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/danmar/cppcheck.git";,
-"commit": "5fa3d53"
+"commit": "5fa3d53",
+"size": "small"
   },
   {
 "name": "harfbuzz",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/harfbuzz/harfbuzz.git";,
-"commit": "f8d345e"
+"commit": "f8d345e",
+"size": "small"
   },
   {
 "name": "capnproto",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/capnproto/capnproto.git";,
-"commit": "8be1c9f"
+"commit": "8be1c9f",
+"size": "small"
   },
   {
 "name": "tmux",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/tmux/tmux.git";,
-"commit": "a5f99e1"
+"commit": "a5f99e1",
+"size": "big"
   },
   {
 "name": "faiss",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/facebookresearch/faiss.git";,
-"commit": "9e5d5b7"
+"commit": "9e5d5b7",
+"size": "small"
   }
 ]
Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -37,7 +37,7 @@
 
 SATestBuild.VERBOSE = args.verbose
 
-projects = get_projects(parser, args.projects)
+projects = get_projects(parser, args)
 tester = SATestBuild.Regress

[clang] e63b488 - [analyzer][solver] Track symbol disequalities

2020-07-22 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-07-22T13:02:39+03:00
New Revision: e63b488f2755f91e8147fd678ed525cf6ba007cc

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

LOG: [analyzer][solver] Track symbol disequalities

Summary:
This commmit adds another relation that we can track separately from
range constraints.  Symbol disequality can help us understand that
two equivalence classes are not equal to each other.  We can generalize
this knowledge to classes because for every a,b,c, and d that
a == b, c == d, and b != c it is true that a != d.

As a result, we can reason about other equalities/disequalities of symbols
that we know nothing else about, i.e. no constraint ranges associated
with them.  However, we also benefit from the knowledge of disequal
symbols by following the rule:
  if a != b and b == C where C is a constant, a != C
This information can refine associated ranges for different classes
and reduce the number of false positives and paths to explore.

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

Added: 
clang/test/Analysis/mutually_exclusive_null_fp.cpp

Modified: 
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/test/Analysis/equality_tracking.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 4c134b63efb0..32766d796add 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -401,6 +401,9 @@ REGISTER_MAP_WITH_PROGRAMSTATE(ClassMap, SymbolRef, 
EquivalenceClass)
 REGISTER_MAP_WITH_PROGRAMSTATE(ClassMembers, EquivalenceClass, SymbolSet)
 REGISTER_MAP_WITH_PROGRAMSTATE(ConstraintRange, EquivalenceClass, RangeSet)
 
+REGISTER_SET_FACTORY_WITH_PROGRAMSTATE(ClassSet, EquivalenceClass)
+REGISTER_MAP_WITH_PROGRAMSTATE(DisequalityMap, EquivalenceClass, ClassSet)
+
 namespace {
 /// This class encapsulates a set of symbols equal to each other.
 ///
@@ -450,6 +453,26 @@ class EquivalenceClass : public llvm::FoldingSetNode {
   LLVM_NODISCARD inline bool isTriviallyDead(ProgramStateRef State,
  SymbolReaper &Reaper);
 
+  LLVM_NODISCARD static inline ProgramStateRef
+  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
+   ProgramStateRef State, SymbolRef First, SymbolRef Second);
+  LLVM_NODISCARD static inline ProgramStateRef
+  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
+   ProgramStateRef State, EquivalenceClass First,
+   EquivalenceClass Second);
+  LLVM_NODISCARD inline ProgramStateRef
+  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
+   ProgramStateRef State, EquivalenceClass Other) const;
+  LLVM_NODISCARD static inline ClassSet
+  getDisequalClasses(ProgramStateRef State, SymbolRef Sym);
+  LLVM_NODISCARD inline ClassSet
+  getDisequalClasses(ProgramStateRef State) const;
+  LLVM_NODISCARD inline ClassSet
+  getDisequalClasses(DisequalityMapTy Map, ClassSet::Factory &Factory) const;
+
+  LLVM_NODISCARD static inline Optional
+  areEqual(ProgramStateRef State, SymbolRef First, SymbolRef Second);
+
   /// Check equivalence data for consistency.
   LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
   isClassDataConsistent(ProgramStateRef State);
@@ -496,6 +519,11 @@ class EquivalenceClass : public llvm::FoldingSetNode {
ProgramStateRef State, SymbolSet Members,
EquivalenceClass Other,
SymbolSet OtherMembers);
+  static inline void
+  addToDisequalityInfo(DisequalityMapTy &Info, ConstraintRangeTy &Constraints,
+   BasicValueFactory &BV, RangeSet::Factory &F,
+   ProgramStateRef State, EquivalenceClass First,
+   EquivalenceClass Second);
 
   /// This is a unique identifier of the class.
   uintptr_t ID;
@@ -505,17 +533,6 @@ class EquivalenceClass : public llvm::FoldingSetNode {
 // Constraint functions
 
//===--===//
 
-LLVM_NODISCARD inline ProgramStateRef setConstraint(ProgramStateRef State,
-EquivalenceClass Class,
-RangeSet Constraint) {
-  return State->set(Class, Constraint);
-}
-
-LLVM_NODISCARD inline ProgramStateRef
-setConstraint(ProgramStateRef State, SymbolRef Sym, RangeSet Constraint) {
-  return setConstraint(State, EquivalenceClass::find(State, Sym), Constraint);
-}
-
 LLVM_NODISCARD inline const RangeSet *getConstraint(ProgramStateRef State,

[Differential] D82381: [analyzer] Introduce small improvements to the solver infra

2020-07-22 Thread Valeriy Savchenko 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 rGf531c1c7c0d5: [analyzer] Introduce small improvements to the 
solver infra (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82381

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -89,7 +89,7 @@
   }
 
   TriStateKind getCmpOpState(BinaryOperatorKind CurrentOP,
- BinaryOperatorKind QueriedOP) const {
+ BinaryOperatorKind QueriedOP) const {
 return CmpOpTable[getIndexFromOp(CurrentOP)][getIndexFromOp(QueriedOP)];
   }
 
@@ -364,6 +364,18 @@
   return newRanges;
 }
 
+RangeSet RangeSet::Delete(BasicValueFactory &BV, Factory &F,
+  const llvm::APSInt &Point) const {
+  llvm::APSInt Upper = Point;
+  llvm::APSInt Lower = Point;
+
+  ++Upper;
+  --Lower;
+
+  // Notice that the lower bound is greater than the upper bound.
+  return Intersect(BV, F, Upper, Lower);
+}
+
 void RangeSet::print(raw_ostream &os) const {
   bool isFirst = true;
   os << "{ ";
@@ -381,6 +393,107 @@
 
 namespace {
 
+//===--===//
+//Intersection functions
+//===--===//
+
+template 
+LLVM_NODISCARD inline RangeSet intersect(BasicValueFactory &BV,
+ RangeSet::Factory &F, RangeSet Head,
+ SecondTy Second, RestTy... Tail);
+
+template  struct IntersectionTraits;
+
+template  struct IntersectionTraits {
+  // Found RangeSet, no need to check any further
+  using Type = RangeSet;
+};
+
+template <> struct IntersectionTraits<> {
+  // We ran out of types, and we didn't find any RangeSet, so the result should
+  // be optional.
+  using Type = Optional;
+};
+
+template 
+struct IntersectionTraits {
+  // If current type is Optional or a raw pointer, we should keep looking.
+  using Type = typename IntersectionTraits::Type;
+};
+
+template 
+LLVM_NODISCARD inline EndTy intersect(BasicValueFactory &BV,
+  RangeSet::Factory &F, EndTy End) {
+  // If the list contains only RangeSet or Optional, simply return
+  // that range set.
+  return End;
+}
+
+LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED inline Optional
+intersect(BasicValueFactory &BV, RangeSet::Factory &F, const RangeSet *End) {
+  // This is an extraneous conversion from a raw pointer into Optional
+  if (End) {
+return *End;
+  }
+  return llvm::None;
+}
+
+template 
+LLVM_NODISCARD inline RangeSet intersect(BasicValueFactory &BV,
+ RangeSet::Factory &F, RangeSet Head,
+ RangeSet Second, RestTy... Tail) {
+  // Here we call either the  or  version
+  // of the function and can be sure that the result is RangeSet.
+  return intersect(BV, F, Head.Intersect(BV, F, Second), Tail...);
+}
+
+template 
+LLVM_NODISCARD inline RangeSet intersect(BasicValueFactory &BV,
+ RangeSet::Factory &F, RangeSet Head,
+ SecondTy Second, RestTy... Tail) {
+  if (Second) {
+// Here we call the  version of the function...
+return intersect(BV, F, Head, *Second, Tail...);
+  }
+  // ...and here it is either  or , which
+  // means that the result is definitely RangeSet.
+  return intersect(BV, F, Head, Tail...);
+}
+
+/// Main generic intersect function.
+/// It intersects all of the given range sets.  If some of the given arguments
+/// don't hold a range set (nullptr or llvm::None), the function will skip them.
+///
+/// Available representations for the arguments are:
+///   * RangeSet
+///   * Optional
+///   * RangeSet *
+/// Pointer to a RangeSet is automatically assumed to be nullable and will get
+/// checked as well as the optional version.  If this behaviour is undesired,
+/// please dereference the pointer in the call.
+///
+/// Return type depends on the arguments' types.  If we can be sure in compile
+/// time that there will be a range set as a result, the returning type is
+/// simply RangeSet, in other cases we have to back off to Optional.
+///
+/// Please, prefer optional range sets to raw pointers.  If the last argument is
+/// a raw pointer and all previous arguments are None, it will cost one
+/// additional check to convert RangeSet * into Optional.
+template 
+LLVM_NODISC

[clang] b13d987 - [analyzer][solver] Track symbol equivalence

2020-07-22 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-07-22T13:02:39+03:00
New Revision: b13d9878b8dcef4354ddfc86f382ca9b537e65aa

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

LOG: [analyzer][solver] Track symbol equivalence

Summary:
For the most cases, we try to reason about symbol either based on the
information we know about that symbol in particular or about its
composite parts.  This is faster and eliminates costly brute force
searches through existing constraints.

However, we do want to support some cases that are widespread enough
and involve reasoning about different existing constraints at once.
These include:
  * resoning about 'a - b' based on what we know about 'b - a'
  * reasoning about 'a <= b' based on what we know about 'a > b' or 'a < b'

This commit expands on that part by tracking symbols known to be equal
while still avoiding brute force searches.  It changes the way we track
constraints for individual symbols.  If we know for a fact that 'a == b'
then there is no need in tracking constraints for both 'a' and 'b' especially
if these constraints are different.  This additional relationship makes
dead/live logic for constraints harder as we want to maintain as much
information on the equivalence class as possible, but we still won't
carry the information that we don't need anymore.

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

Added: 
clang/test/Analysis/equality_tracking.c

Modified: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h

clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
index 365b1ff1bfe3..1aff2ca34a70 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -373,7 +373,7 @@ class SuppressInlineDefensiveChecksVisitor final : public 
BugReporterVisitor {
 class FalsePositiveRefutationBRVisitor final : public BugReporterVisitor {
 private:
   /// Holds the constraints in a given path
-  ConstraintRangeTy Constraints;
+  ConstraintMap Constraints;
 
 public:
   FalsePositiveRefutationBRVisitor();
@@ -390,7 +390,6 @@ class FalsePositiveRefutationBRVisitor final : public 
BugReporterVisitor {
   bool OverwriteConstraintsOnExistingSyms);
 };
 
-
 /// The visitor detects NoteTags and displays the event notes they contain.
 class TagVisitor : public BugReporterVisitor {
 public:

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
index 2f71f6fa..bc5d5f57cd68 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -136,14 +136,8 @@ class RangeSet {
   }
 };
 
-class ConstraintRange {};
-using ConstraintRangeTy = llvm::ImmutableMap;
-
-template <>
-struct ProgramStateTrait
-: public ProgramStatePartialTrait {
-  static void *GDMIndex();
-};
+using ConstraintMap = llvm::ImmutableMap;
+ConstraintMap getConstraintMap(ProgramStateRef State);
 
 class RangedConstraintManager : public SimpleConstraintManager {
 public:
@@ -222,4 +216,6 @@ class RangedConstraintManager : public 
SimpleConstraintManager {
 } // namespace ento
 } // namespace clang
 
+REGISTER_FACTORY_WITH_PROGRAMSTATE(ConstraintMap)
+
 #endif

diff  --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index ef4d38ff498f..bc72f4f8c1e3 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2813,7 +2813,7 @@ UndefOrNullArgVisitor::VisitNode(const ExplodedNode *N, 
BugReporterContext &BRC,
 
//===--===//
 
 FalsePositiveRefutationBRVisitor::FalsePositiveRefutationBRVisitor()
-: Constraints(ConstraintRangeTy::Factory().getEmptyMap()) {}
+: Constraints(ConstraintMap::Factory().getEmptyMap()) {}
 
 void FalsePositiveRefutationBRVisitor::finalizeVisitor(
 BugReporterContext &BRC, const ExplodedNode *EndPathNode,
@@ -2855,9 +2855,8 @@ void FalsePositiveRefutationBRVisitor::finalizeVisitor(
 void FalsePositiveRefutationBRVisitor::addConstraints(
 const ExplodedNode *N, bool Overwrit

[clang] f531c1c - [analyzer] Introduce small improvements to the solver infra

2020-07-22 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-07-22T13:02:39+03:00
New Revision: f531c1c7c0d5850c824333518ff32708730d775b

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

LOG: [analyzer] Introduce small improvements to the solver infra

Summary:
* Add a new function to delete points from range sets.
* Introduce an internal generic interface for range set intersections.
* Remove unnecessary bits from a couple of solver functions.
* Add in-code sections.

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

Added: 


Modified: 

clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
index a42eebd7d4e8..2f71f6fa 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -126,6 +126,8 @@ class RangeSet {
   RangeSet Intersect(BasicValueFactory &BV, Factory &F,
  const RangeSet &Other) const;
   RangeSet Negate(BasicValueFactory &BV, Factory &F) const;
+  RangeSet Delete(BasicValueFactory &BV, Factory &F,
+  const llvm::APSInt &Point) const;
 
   void print(raw_ostream &os) const;
 
@@ -139,11 +141,10 @@ using ConstraintRangeTy = llvm::ImmutableMap;
 
 template <>
 struct ProgramStateTrait
-  : public ProgramStatePartialTrait {
+: public ProgramStatePartialTrait {
   static void *GDMIndex();
 };
 
-
 class RangedConstraintManager : public SimpleConstraintManager {
 public:
   RangedConstraintManager(ExprEngine *EE, SValBuilder &SB)
@@ -169,8 +170,8 @@ class RangedConstraintManager : public 
SimpleConstraintManager {
 protected:
   /// Assume a constraint between a symbolic expression and a concrete integer.
   virtual ProgramStateRef assumeSymRel(ProgramStateRef State, SymbolRef Sym,
-   BinaryOperator::Opcode op,
-   const llvm::APSInt &Int);
+   BinaryOperator::Opcode op,
+   const llvm::APSInt &Int);
 
   //===--===//
   // Interface that subclasses must implement.
@@ -218,8 +219,7 @@ class RangedConstraintManager : public 
SimpleConstraintManager {
   static void computeAdjustment(SymbolRef &Sym, llvm::APSInt &Adjustment);
 };
 
-} // end GR namespace
-
-} // end clang namespace
+} // namespace ento
+} // namespace clang
 
 #endif

diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index cb6f61e86ae3..a5bb36e2026e 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -89,7 +89,7 @@ class OperatorRelationsTable {
   }
 
   TriStateKind getCmpOpState(BinaryOperatorKind CurrentOP,
- BinaryOperatorKind QueriedOP) const {
+ BinaryOperatorKind QueriedOP) const {
 return CmpOpTable[getIndexFromOp(CurrentOP)][getIndexFromOp(QueriedOP)];
   }
 
@@ -364,6 +364,18 @@ RangeSet RangeSet::Negate(BasicValueFactory &BV, Factory 
&F) const {
   return newRanges;
 }
 
+RangeSet RangeSet::Delete(BasicValueFactory &BV, Factory &F,
+  const llvm::APSInt &Point) const {
+  llvm::APSInt Upper = Point;
+  llvm::APSInt Lower = Point;
+
+  ++Upper;
+  --Lower;
+
+  // Notice that the lower bound is greater than the upper bound.
+  return Intersect(BV, F, Upper, Lower);
+}
+
 void RangeSet::print(raw_ostream &os) const {
   bool isFirst = true;
   os << "{ ";
@@ -381,6 +393,107 @@ void RangeSet::print(raw_ostream &os) const {
 
 namespace {
 
+//===--===//
+//Intersection functions
+//===--===//
+
+template 
+LLVM_NODISCARD inline RangeSet intersect(BasicValueFactory &BV,
+ RangeSet::Factory &F, RangeSet Head,
+ SecondTy Second, RestTy... Tail);
+
+template  struct IntersectionTraits;
+
+template  struct IntersectionTraits {
+  // Found RangeSet, no need to check any further
+  using Type = RangeSet;
+};
+
+template <> struct IntersectionTraits<> {
+  // We ran out of types, and we didn't find any RangeSet, so the result should
+  // be optional.
+  using Type = Optional;
+};
+
+template 
+struct Intersec

[PATCH] D82381: [analyzer] Introduce small improvements to the solver infra

2020-07-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf531c1c7c0d5: [analyzer] Introduce small improvements to the 
solver infra (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82381

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -89,7 +89,7 @@
   }
 
   TriStateKind getCmpOpState(BinaryOperatorKind CurrentOP,
- BinaryOperatorKind QueriedOP) const {
+ BinaryOperatorKind QueriedOP) const {
 return CmpOpTable[getIndexFromOp(CurrentOP)][getIndexFromOp(QueriedOP)];
   }
 
@@ -364,6 +364,18 @@
   return newRanges;
 }
 
+RangeSet RangeSet::Delete(BasicValueFactory &BV, Factory &F,
+  const llvm::APSInt &Point) const {
+  llvm::APSInt Upper = Point;
+  llvm::APSInt Lower = Point;
+
+  ++Upper;
+  --Lower;
+
+  // Notice that the lower bound is greater than the upper bound.
+  return Intersect(BV, F, Upper, Lower);
+}
+
 void RangeSet::print(raw_ostream &os) const {
   bool isFirst = true;
   os << "{ ";
@@ -381,6 +393,107 @@
 
 namespace {
 
+//===--===//
+//Intersection functions
+//===--===//
+
+template 
+LLVM_NODISCARD inline RangeSet intersect(BasicValueFactory &BV,
+ RangeSet::Factory &F, RangeSet Head,
+ SecondTy Second, RestTy... Tail);
+
+template  struct IntersectionTraits;
+
+template  struct IntersectionTraits {
+  // Found RangeSet, no need to check any further
+  using Type = RangeSet;
+};
+
+template <> struct IntersectionTraits<> {
+  // We ran out of types, and we didn't find any RangeSet, so the result should
+  // be optional.
+  using Type = Optional;
+};
+
+template 
+struct IntersectionTraits {
+  // If current type is Optional or a raw pointer, we should keep looking.
+  using Type = typename IntersectionTraits::Type;
+};
+
+template 
+LLVM_NODISCARD inline EndTy intersect(BasicValueFactory &BV,
+  RangeSet::Factory &F, EndTy End) {
+  // If the list contains only RangeSet or Optional, simply return
+  // that range set.
+  return End;
+}
+
+LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED inline Optional
+intersect(BasicValueFactory &BV, RangeSet::Factory &F, const RangeSet *End) {
+  // This is an extraneous conversion from a raw pointer into Optional
+  if (End) {
+return *End;
+  }
+  return llvm::None;
+}
+
+template 
+LLVM_NODISCARD inline RangeSet intersect(BasicValueFactory &BV,
+ RangeSet::Factory &F, RangeSet Head,
+ RangeSet Second, RestTy... Tail) {
+  // Here we call either the  or  version
+  // of the function and can be sure that the result is RangeSet.
+  return intersect(BV, F, Head.Intersect(BV, F, Second), Tail...);
+}
+
+template 
+LLVM_NODISCARD inline RangeSet intersect(BasicValueFactory &BV,
+ RangeSet::Factory &F, RangeSet Head,
+ SecondTy Second, RestTy... Tail) {
+  if (Second) {
+// Here we call the  version of the function...
+return intersect(BV, F, Head, *Second, Tail...);
+  }
+  // ...and here it is either  or , which
+  // means that the result is definitely RangeSet.
+  return intersect(BV, F, Head, Tail...);
+}
+
+/// Main generic intersect function.
+/// It intersects all of the given range sets.  If some of the given arguments
+/// don't hold a range set (nullptr or llvm::None), the function will skip them.
+///
+/// Available representations for the arguments are:
+///   * RangeSet
+///   * Optional
+///   * RangeSet *
+/// Pointer to a RangeSet is automatically assumed to be nullable and will get
+/// checked as well as the optional version.  If this behaviour is undesired,
+/// please dereference the pointer in the call.
+///
+/// Return type depends on the arguments' types.  If we can be sure in compile
+/// time that there will be a range set as a result, the returning type is
+/// simply RangeSet, in other cases we have to back off to Optional.
+///
+/// Please, prefer optional range sets to raw pointers.  If the last argument is
+/// a raw pointer and all previous arguments are None, it will cost one
+/// additional check to convert RangeSet * into Optional.
+template 
+LLVM_NODISCARD inline
+typename IntersectionTraits::Type
+i

[PATCH] D82445: [analyzer][solver] Track symbol equivalence

2020-07-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb13d9878b8dc: [analyzer][solver] Track symbol equivalence 
(authored by vsavchenko).

Changed prior to commit:
  https://reviews.llvm.org/D82445?vs=275981&id=279746#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82445

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/test/Analysis/equality_tracking.c

Index: clang/test/Analysis/equality_tracking.c
===
--- /dev/null
+++ clang/test/Analysis/equality_tracking.c
@@ -0,0 +1,167 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+
+#define NULL (void *)0
+
+#define UCHAR_MAX (unsigned char)(~0U)
+#define CHAR_MAX (char)(UCHAR_MAX & (UCHAR_MAX >> 1))
+#define CHAR_MIN (char)(UCHAR_MAX & ~(UCHAR_MAX >> 1))
+
+void clang_analyzer_eval(int);
+void clang_analyzer_warnIfReached();
+
+int getInt();
+
+void zeroImpliesEquality(int a, int b) {
+  clang_analyzer_eval((a - b) == 0); // expected-warning{{UNKNOWN}}
+  if ((a - b) == 0) {
+clang_analyzer_eval(b != a);// expected-warning{{FALSE}}
+clang_analyzer_eval(b == a);// expected-warning{{TRUE}}
+clang_analyzer_eval(!(a != b)); // expected-warning{{TRUE}}
+clang_analyzer_eval(!(b == a)); // expected-warning{{FALSE}}
+return;
+  }
+  clang_analyzer_eval((a - b) == 0); // expected-warning{{FALSE}}
+  // FIXME: we should track disequality information as well
+  clang_analyzer_eval(b == a); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b != a); // expected-warning{{UNKNOWN}}
+}
+
+void zeroImpliesReversedEqual(int a, int b) {
+  clang_analyzer_eval((b - a) == 0); // expected-warning{{UNKNOWN}}
+  if ((b - a) == 0) {
+clang_analyzer_eval(b != a); // expected-warning{{FALSE}}
+clang_analyzer_eval(b == a); // expected-warning{{TRUE}}
+return;
+  }
+  clang_analyzer_eval((b - a) == 0); // expected-warning{{FALSE}}
+  // FIXME: we should track disequality information as well
+  clang_analyzer_eval(b == a); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b != a); // expected-warning{{UNKNOWN}}
+}
+
+void canonicalEqual(int a, int b) {
+  clang_analyzer_eval(a == b); // expected-warning{{UNKNOWN}}
+  if (a == b) {
+clang_analyzer_eval(b == a); // expected-warning{{TRUE}}
+return;
+  }
+  clang_analyzer_eval(a == b); // expected-warning{{FALSE}}
+  clang_analyzer_eval(b == a); // expected-warning{{FALSE}}
+}
+
+void test(int a, int b, int c, int d) {
+  if (a == b && c == d) {
+if (a == 0 && b == d) {
+  clang_analyzer_eval(c == 0); // expected-warning{{TRUE}}
+}
+c = 10;
+if (b == d) {
+  clang_analyzer_eval(c == 10); // expected-warning{{TRUE}}
+  clang_analyzer_eval(d == 10); // expected-warning{{UNKNOWN}}
+// expected-warning@-1{{FALSE}}
+  clang_analyzer_eval(b == a);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a == d);  // expected-warning{{TRUE}}
+
+  b = getInt();
+  clang_analyzer_eval(a == d); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a == b); // expected-warning{{UNKNOWN}}
+}
+  }
+
+  if (a != b && b == c) {
+if (c == 42) {
+  clang_analyzer_eval(b == 42); // expected-warning{{TRUE}}
+  // FIXME: we should track disequality information as well
+  clang_analyzer_eval(a != 42); // expected-warning{{UNKNOWN}}
+}
+  }
+}
+
+void testIntersection(int a, int b, int c) {
+  if (a < 42 && b > 15 && c >= 25 && c <= 30) {
+if (a != b)
+  return;
+
+clang_analyzer_eval(a > 15);  // expected-warning{{TRUE}}
+clang_analyzer_eval(b < 42);  // expected-warning{{TRUE}}
+clang_analyzer_eval(a <= 30); // expected-warning{{UNKNOWN}}
+
+if (c == b) {
+  // For all equal symbols, we should track the minimal common range.
+  //
+  // Also, it should be noted that c is dead at this point, but the
+  // constraint initially associated with c is still around.
+  clang_analyzer_eval(a >= 25 && a <= 30); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b >= 25 && b <= 30); // expected-warning{{TRUE}}
+}
+  }
+}
+
+void testPromotion(int a, char b) {
+  if (b > 10) {
+if (a == b) {
+  // FIXME: support transferring char ranges onto equal int symbols
+  //when char is promoted to int
+  clang_analyzer_eval(a > 10);// expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a <= CHAR_MAX); // expected-warning{{UNKNOWN}}
+}
+  }
+}
+
+void testProm

[Differential] D83286: [analyzer][solver] Track symbol disequalities

2020-07-22 Thread Valeriy Savchenko 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 rGe63b488f2755: [analyzer][solver] Track symbol disequalities 
(authored by vsavchenko).

Changed prior to commit:
  https://reviews.llvm.org/D83286?vs=276729&id=279082#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83286

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/equality_tracking.c
  clang/test/Analysis/mutually_exclusive_null_fp.cpp

Index: clang/test/Analysis/mutually_exclusive_null_fp.cpp
===
--- /dev/null
+++ clang/test/Analysis/mutually_exclusive_null_fp.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// rdar://problem/56586853
+// expected-no-diagnostics
+
+struct Data {
+  int x;
+  Data *data;
+};
+
+int compare(Data &a, Data &b) {
+  Data *aData = a.data;
+  Data *bData = b.data;
+
+  // Covers the cases where both pointers are null as well as both pointing to the same buffer.
+  if (aData == bData)
+return 0;
+
+  if (aData && !bData)
+return 1;
+
+  if (!aData && bData)
+return -1;
+
+  return compare(*aData, *bData); // no-warning
+}
Index: clang/test/Analysis/equality_tracking.c
===
--- clang/test/Analysis/equality_tracking.c
+++ clang/test/Analysis/equality_tracking.c
@@ -23,9 +23,8 @@
 return;
   }
   clang_analyzer_eval((a - b) == 0); // expected-warning{{FALSE}}
-  // FIXME: we should track disequality information as well
-  clang_analyzer_eval(b == a); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(b != a); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b == a);   // expected-warning{{FALSE}}
+  clang_analyzer_eval(b != a);   // expected-warning{{TRUE}}
 }
 
 void zeroImpliesReversedEqual(int a, int b) {
@@ -36,9 +35,8 @@
 return;
   }
   clang_analyzer_eval((b - a) == 0); // expected-warning{{FALSE}}
-  // FIXME: we should track disequality information as well
-  clang_analyzer_eval(b == a); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(b != a); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b == a);   // expected-warning{{FALSE}}
+  clang_analyzer_eval(b != a);   // expected-warning{{TRUE}}
 }
 
 void canonicalEqual(int a, int b) {
@@ -73,8 +71,7 @@
   if (a != b && b == c) {
 if (c == 42) {
   clang_analyzer_eval(b == 42); // expected-warning{{TRUE}}
-  // FIXME: we should track disequality information as well
-  clang_analyzer_eval(a != 42); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a != 42); // expected-warning{{TRUE}}
 }
   }
 }
@@ -144,8 +141,31 @@
 
   if (a != b && b == c) {
 if (c == NULL) {
-  // FIXME: we should track disequality information as well
-  clang_analyzer_eval(a != NULL); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a != NULL); // expected-warning{{TRUE}}
+}
+  }
+}
+
+void testDisequalitiesAfter(int a, int b, int c) {
+  if (a >= 10 && b <= 42) {
+if (a == b && c == 15 && c != a) {
+  clang_analyzer_eval(b != c);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a != 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b != 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b >= 10); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a <= 42); // expected-warning{{TRUE}}
+}
+  }
+}
+
+void testDisequalitiesBefore(int a, int b, int c) {
+  if (a >= 10 && b <= 42 && c == 15) {
+if (a == b && c != a) {
+  clang_analyzer_eval(b != c);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a != 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b != 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b >= 10); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a <= 42); // expected-warning{{TRUE}}
 }
   }
 }
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -401,6 +401,9 @@
 REGISTER_MAP_WITH_PROGRAMSTATE(ClassMembers, EquivalenceClass, SymbolSet)
 REGISTER_MAP_WITH_PROGRAMSTATE(ConstraintRange, EquivalenceClass, RangeSet)
 
+REGISTER_SET_FACTORY_WITH_PROGRAMSTATE(ClassSet, EquivalenceClass)
+REGISTER_MAP_WITH_PROGRAMSTATE(DisequalityMap, EquivalenceClass, ClassSet)
+
 namespace {
 /// This class encapsulates a set of symbols equal to each other.
 ///
@@ -450,6 +453,26 @@
   LLVM_NODISCARD inline bool isTriviallyDead(ProgramStateRef State,
  SymbolReaper &Reaper);
 
+  LLVM_NODISCARD static inline ProgramStateRef
+  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
+ 

[Differential] D82445: [analyzer][solver] Track symbol equivalence

2020-07-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb13d9878b8dc: [analyzer][solver] Track symbol equivalence 
(authored by vsavchenko).

Changed prior to commit:
  https://reviews.llvm.org/D82445?vs=275981&id=279081#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82445

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/test/Analysis/equality_tracking.c

Index: clang/test/Analysis/equality_tracking.c
===
--- /dev/null
+++ clang/test/Analysis/equality_tracking.c
@@ -0,0 +1,167 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+
+#define NULL (void *)0
+
+#define UCHAR_MAX (unsigned char)(~0U)
+#define CHAR_MAX (char)(UCHAR_MAX & (UCHAR_MAX >> 1))
+#define CHAR_MIN (char)(UCHAR_MAX & ~(UCHAR_MAX >> 1))
+
+void clang_analyzer_eval(int);
+void clang_analyzer_warnIfReached();
+
+int getInt();
+
+void zeroImpliesEquality(int a, int b) {
+  clang_analyzer_eval((a - b) == 0); // expected-warning{{UNKNOWN}}
+  if ((a - b) == 0) {
+clang_analyzer_eval(b != a);// expected-warning{{FALSE}}
+clang_analyzer_eval(b == a);// expected-warning{{TRUE}}
+clang_analyzer_eval(!(a != b)); // expected-warning{{TRUE}}
+clang_analyzer_eval(!(b == a)); // expected-warning{{FALSE}}
+return;
+  }
+  clang_analyzer_eval((a - b) == 0); // expected-warning{{FALSE}}
+  // FIXME: we should track disequality information as well
+  clang_analyzer_eval(b == a); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b != a); // expected-warning{{UNKNOWN}}
+}
+
+void zeroImpliesReversedEqual(int a, int b) {
+  clang_analyzer_eval((b - a) == 0); // expected-warning{{UNKNOWN}}
+  if ((b - a) == 0) {
+clang_analyzer_eval(b != a); // expected-warning{{FALSE}}
+clang_analyzer_eval(b == a); // expected-warning{{TRUE}}
+return;
+  }
+  clang_analyzer_eval((b - a) == 0); // expected-warning{{FALSE}}
+  // FIXME: we should track disequality information as well
+  clang_analyzer_eval(b == a); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b != a); // expected-warning{{UNKNOWN}}
+}
+
+void canonicalEqual(int a, int b) {
+  clang_analyzer_eval(a == b); // expected-warning{{UNKNOWN}}
+  if (a == b) {
+clang_analyzer_eval(b == a); // expected-warning{{TRUE}}
+return;
+  }
+  clang_analyzer_eval(a == b); // expected-warning{{FALSE}}
+  clang_analyzer_eval(b == a); // expected-warning{{FALSE}}
+}
+
+void test(int a, int b, int c, int d) {
+  if (a == b && c == d) {
+if (a == 0 && b == d) {
+  clang_analyzer_eval(c == 0); // expected-warning{{TRUE}}
+}
+c = 10;
+if (b == d) {
+  clang_analyzer_eval(c == 10); // expected-warning{{TRUE}}
+  clang_analyzer_eval(d == 10); // expected-warning{{UNKNOWN}}
+// expected-warning@-1{{FALSE}}
+  clang_analyzer_eval(b == a);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a == d);  // expected-warning{{TRUE}}
+
+  b = getInt();
+  clang_analyzer_eval(a == d); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a == b); // expected-warning{{UNKNOWN}}
+}
+  }
+
+  if (a != b && b == c) {
+if (c == 42) {
+  clang_analyzer_eval(b == 42); // expected-warning{{TRUE}}
+  // FIXME: we should track disequality information as well
+  clang_analyzer_eval(a != 42); // expected-warning{{UNKNOWN}}
+}
+  }
+}
+
+void testIntersection(int a, int b, int c) {
+  if (a < 42 && b > 15 && c >= 25 && c <= 30) {
+if (a != b)
+  return;
+
+clang_analyzer_eval(a > 15);  // expected-warning{{TRUE}}
+clang_analyzer_eval(b < 42);  // expected-warning{{TRUE}}
+clang_analyzer_eval(a <= 30); // expected-warning{{UNKNOWN}}
+
+if (c == b) {
+  // For all equal symbols, we should track the minimal common range.
+  //
+  // Also, it should be noted that c is dead at this point, but the
+  // constraint initially associated with c is still around.
+  clang_analyzer_eval(a >= 25 && a <= 30); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b >= 25 && b <= 30); // expected-warning{{TRUE}}
+}
+  }
+}
+
+void testPromotion(int a, char b) {
+  if (b > 10) {
+if (a == b) {
+  // FIXME: support transferring char ranges onto equal int symbols
+  //when char is promoted to int
+  clang_analyzer_eval(a > 10);// expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a <= CHAR_MAX); // expected-warning{{UNKNOWN}}
+}
+  }
+}
+
+void testProm

[PATCH] D83286: [analyzer][solver] Track symbol disequalities

2020-07-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe63b488f2755: [analyzer][solver] Track symbol disequalities 
(authored by vsavchenko).

Changed prior to commit:
  https://reviews.llvm.org/D83286?vs=276729&id=279747#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83286

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/equality_tracking.c
  clang/test/Analysis/mutually_exclusive_null_fp.cpp

Index: clang/test/Analysis/mutually_exclusive_null_fp.cpp
===
--- /dev/null
+++ clang/test/Analysis/mutually_exclusive_null_fp.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// rdar://problem/56586853
+// expected-no-diagnostics
+
+struct Data {
+  int x;
+  Data *data;
+};
+
+int compare(Data &a, Data &b) {
+  Data *aData = a.data;
+  Data *bData = b.data;
+
+  // Covers the cases where both pointers are null as well as both pointing to the same buffer.
+  if (aData == bData)
+return 0;
+
+  if (aData && !bData)
+return 1;
+
+  if (!aData && bData)
+return -1;
+
+  return compare(*aData, *bData); // no-warning
+}
Index: clang/test/Analysis/equality_tracking.c
===
--- clang/test/Analysis/equality_tracking.c
+++ clang/test/Analysis/equality_tracking.c
@@ -23,9 +23,8 @@
 return;
   }
   clang_analyzer_eval((a - b) == 0); // expected-warning{{FALSE}}
-  // FIXME: we should track disequality information as well
-  clang_analyzer_eval(b == a); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(b != a); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b == a);   // expected-warning{{FALSE}}
+  clang_analyzer_eval(b != a);   // expected-warning{{TRUE}}
 }
 
 void zeroImpliesReversedEqual(int a, int b) {
@@ -36,9 +35,8 @@
 return;
   }
   clang_analyzer_eval((b - a) == 0); // expected-warning{{FALSE}}
-  // FIXME: we should track disequality information as well
-  clang_analyzer_eval(b == a); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(b != a); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b == a);   // expected-warning{{FALSE}}
+  clang_analyzer_eval(b != a);   // expected-warning{{TRUE}}
 }
 
 void canonicalEqual(int a, int b) {
@@ -73,8 +71,7 @@
   if (a != b && b == c) {
 if (c == 42) {
   clang_analyzer_eval(b == 42); // expected-warning{{TRUE}}
-  // FIXME: we should track disequality information as well
-  clang_analyzer_eval(a != 42); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a != 42); // expected-warning{{TRUE}}
 }
   }
 }
@@ -144,8 +141,31 @@
 
   if (a != b && b == c) {
 if (c == NULL) {
-  // FIXME: we should track disequality information as well
-  clang_analyzer_eval(a != NULL); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a != NULL); // expected-warning{{TRUE}}
+}
+  }
+}
+
+void testDisequalitiesAfter(int a, int b, int c) {
+  if (a >= 10 && b <= 42) {
+if (a == b && c == 15 && c != a) {
+  clang_analyzer_eval(b != c);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a != 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b != 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b >= 10); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a <= 42); // expected-warning{{TRUE}}
+}
+  }
+}
+
+void testDisequalitiesBefore(int a, int b, int c) {
+  if (a >= 10 && b <= 42 && c == 15) {
+if (a == b && c != a) {
+  clang_analyzer_eval(b != c);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a != 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b != 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b >= 10); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a <= 42); // expected-warning{{TRUE}}
 }
   }
 }
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -401,6 +401,9 @@
 REGISTER_MAP_WITH_PROGRAMSTATE(ClassMembers, EquivalenceClass, SymbolSet)
 REGISTER_MAP_WITH_PROGRAMSTATE(ConstraintRange, EquivalenceClass, RangeSet)
 
+REGISTER_SET_FACTORY_WITH_PROGRAMSTATE(ClassSet, EquivalenceClass)
+REGISTER_MAP_WITH_PROGRAMSTATE(DisequalityMap, EquivalenceClass, ClassSet)
+
 namespace {
 /// This class encapsulates a set of symbols equal to each other.
 ///
@@ -450,6 +453,26 @@
   LLVM_NODISCARD inline bool isTriviallyDead(ProgramStateRef State,
  SymbolReaper &Reaper);
 
+  LLVM_NODISCARD static inline ProgramStateRef
+  markDisequal(BasicValueFactory &BV, RangeSet::Factory &F,
+   ProgramStateRef State, SymbolRef First, SymbolRef 

[PATCH] D83814: [clangd] Add Random Forest runtime for code completion.

2020-07-22 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 added a comment.

The features refers to the code completion signals in 
https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clangd/Quality.h
These signals are currently used to map the code completion candidates to a 
relevance score using hand-coded heuristics. 
We intend to replace the heuristics with a Decision forest model. This patch 
introduces a dummy model and corresponding runtime that will be used to 
inference this model.

This is still WIP and I will provide more details in the description once this 
is finalized.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83814



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


[clang-tools-extra] 3975c3b - [clangd] Fix conversion from Windows UNC paths to file URI format.

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

Author: Ilya Golovenko
Date: 2020-07-22T12:13:09+02:00
New Revision: 3975c3be80412bb6b1376bcef53ebce53984ddd7

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

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

Summary:
The fix improves handling of Windows UNC paths to align with Appendix E. 
Nonstandard Syntax Variations of RFC 8089.

Before this fix it was difficult to use Windows UNC paths in 
compile_commands.json database as such paths were converted to file URIs using 
'file:auth/share/file.cpp' notation instead of recommended 
'file://auth/share/file.cpp'.

As an example, VS.Code cannot understand file URIs with 4 starting slashes, 
thus such features as go-to-definition, jump-to-file, hover tooltip, etc. stop 
working. This also applicable to files which reside on Windows network-mapped 
drives because clangd internally resolves file paths to real paths in some 
cases and such paths get resolved to UNC paths.

Reviewers: sammccall, kadircet

Reviewed By: sammccall

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

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/URI.cpp 
b/clang-tools-extra/clangd/URI.cpp
index 2061a5601c58..fad93143a30d 100644
--- a/clang-tools-extra/clangd/URI.cpp
+++ b/clang-tools-extra/clangd/URI.cpp
@@ -26,6 +26,15 @@ inline llvm::Error make_string_error(const llvm::Twine 
&Message) {
  llvm::inconvertibleErrorCode());
 }
 
+bool isWindowsPath(llvm::StringRef Path) {
+  return Path.size() > 1 && llvm::isAlpha(Path[0]) && Path[1] == ':';
+}
+
+bool isNetworkPath(llvm::StringRef Path) {
+  return Path.size() > 2 && Path[0] == Path[1] &&
+ llvm::sys::path::is_separator(Path[0]);
+}
+
 /// This manages file paths in the file system. All paths in the scheme
 /// are absolute (with leading '/').
 /// Note that this scheme is hardcoded into the library and not registered in
@@ -33,28 +42,40 @@ inline llvm::Error make_string_error(const llvm::Twine 
&Message) {
 class FileSystemScheme : public URIScheme {
 public:
   llvm::Expected
-  getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
+  getAbsolutePath(llvm::StringRef Authority, llvm::StringRef Body,
   llvm::StringRef /*HintPath*/) const override {
 if (!Body.startswith("/"))
   return make_string_error("File scheme: expect body to be an absolute "
"path starting with '/': " +
Body);
-// For Windows paths e.g. /X:
-if (Body.size() > 2 && Body[0] == '/' && Body[2] == ':')
+llvm::SmallString<128> Path;
+if (!Authority.empty()) {
+  // Windows UNC paths e.g. file://server/share => \\server\share
+  ("//" + Authority).toVector(Path);
+} else if (isWindowsPath(Body.substr(1))) {
+  // Windows paths e.g. file:///X:/path => X:\path
   Body.consume_front("/");
-llvm::SmallVector Path(Body.begin(), Body.end());
+}
+Path.append(Body);
 llvm::sys::path::native(Path);
-return std::string(Path.begin(), Path.end());
+return std::string(Path);
   }
 
   llvm::Expected
   uriFromAbsolutePath(llvm::StringRef AbsolutePath) const override {
 std::string Body;
-// For Windows paths e.g. X:
-if (AbsolutePath.size() > 1 && AbsolutePath[1] == ':')
+llvm::StringRef Authority;
+llvm::StringRef Root = llvm::sys::path::root_name(AbsolutePath);
+if (isNetworkPath(Root)) {
+  // Windows UNC paths e.g. \\server\share => file://server/share
+  Authority = Root.drop_front(2);
+  AbsolutePath.consume_front(Root);
+} else if (isWindowsPath(Root)) {
+  // Windows paths e.g. X:\path => file:///X:/path
   Body = "/";
+}
 Body += llvm::sys::path::convert_to_slash(AbsolutePath);
-return URI("file", /*Authority=*/"", Body);
+return URI("file", Authority, Body);
   }
 };
 
@@ -96,13 +117,13 @@ bool shouldEscape(unsigned char C) {
 void percentEncode(llvm::StringRef Content, std::string &Out) {
   std::string Result;
   for (unsigned char C : Content)
-if (shouldEscape(C))
-{
+if (shouldEscape(C)) {
   Out.push_back('%');
   Out.push_back(llvm::hexdigit(C / 16));
   Out.push_back(llvm::hexdigit(C % 16));
-} else
-{ Out.push_back(C); }
+} else {
+  Out.push_back(C);
+}
 }
 
 /// Decodes a string according to percent-encoding.

diff  --git a/clang-tools-extra/clangd/unittests/URITests.cpp 
b/clang-tools-extra/clangd/unittests/URITests.cpp
index 52ca7b4447cd..cd734cfe

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

2020-07-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3975c3be8041: [clangd] Fix conversion from Windows UNC paths 
to file URI format. (authored by walrus, committed by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84172

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

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

[PATCH] D84226: [AST][RecoveryExpr] Support dependent binary operator in C for error recovery.

2020-07-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 279751.
hokein added a comment.
Herald added a subscriber: dang.

Add a cc1 flag to enable building dependent nodes in C.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84226

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-recovery.c
  clang/test/Sema/error-dependence.c

Index: clang/test/Sema/error-dependence.c
===
--- /dev/null
+++ clang/test/Sema/error-dependence.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -frecovery-ast -fno-recovery-ast-type -fc-dependence %s
+
+int call(int); // expected-note {{'call' declared here}}
+
+void test1(int s) {
+  // verify "assigning to 'int' from incompatible type ''" is
+  // not emitted.
+  s = call(); // expected-error {{too few arguments to function call}}
+}
Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -frecovery-ast -fno-recovery-ast-type -ast-dump %s | FileCheck -strict-whitespace %s
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -frecovery-ast -fno-recovery-ast-type -fc-dependence -ast-dump %s | FileCheck -strict-whitespace %s
 
 int some_func(int);
 
@@ -42,11 +42,16 @@
 
 void test2() {
   int* ptr;
-  // FIXME: the top-level expr should be a binary operator.
-  // CHECK:  ImplicitCastExpr {{.*}} contains-errors 
-  // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors lvalue
-  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'ptr' 'int *'
-  // CHECK-NEXT:   `-RecoveryExpr {{.*}}
-  // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
+  // CHECK: BinaryOperator {{.*}} contains-errors '='
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ptr' 'int *'
+  // CHECK-NEXT: `-RecoveryExpr {{.*}}
+  // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'some_func'
   ptr = some_func(); // should not crash
+
+  int compoundOp;
+  // CHECK: CompoundAssignOperator {{.*}} '+='
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'compoundOp'
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
+  // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'some_func'
+  compoundOp += some_func();
 }
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -13290,18 +13290,8 @@
   // If either side is type-dependent, create an appropriate dependent
   // expression.
   if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
-if (Fns.empty()) {
-  // If there are no functions to store, just build a dependent
-  // BinaryOperator or CompoundAssignment.
-  if (Opc <= BO_Assign || Opc > BO_OrAssign)
-return BinaryOperator::Create(
-Context, Args[0], Args[1], Opc, Context.DependentTy, VK_RValue,
-OK_Ordinary, OpLoc, CurFPFeatureOverrides());
-  return CompoundAssignOperator::Create(
-  Context, Args[0], Args[1], Opc, Context.DependentTy, VK_LValue,
-  OK_Ordinary, OpLoc, CurFPFeatureOverrides(), Context.DependentTy,
-  Context.DependentTy);
-}
+if (Fns.empty())
+  return CreateDependentBinOp(OpLoc, Opc, Args[0], Args[1]);
 
 // FIXME: save results of ADL from here?
 CXXRecordDecl *NamingClass = nullptr; // lookup ignores member operators
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13641,7 +13641,7 @@
 CorrectDelayedTyposInBinOp(Sema &S, BinaryOperatorKind Opc, Expr *LHSExpr,
Expr *RHSExpr) {
   ExprResult LHS = LHSExpr, RHS = RHSExpr;
-  if (!S.getLangOpts().CPlusPlus) {
+  if (!S.getLangOpts().CPlusPlus && !S.getLangOpts().CDependence) {
 // C cannot handle TypoExpr nodes on either side of a binop because it
 // doesn't handle dependent types properly, so make sure any TypoExprs have
 // been dealt with before checking the operands.
@@ -14220,6 +14220,21 @@
   return S.CreateOverloadedBinOp(OpLoc, Opc, Functions, LHS, RHS);
 }
 
+ExprResult Sema::CreateDependentBinOp(SourceLocation OpLoc,
+  BinaryOperatorKind Opc, Expr *LHS,
+  Expr *RHS) {
+  assert(LHS->isTypeDependent() || RHS->isTypeDependent());
+  // If there are no functions to store, just build a dependent
+  // BinaryOperator or CompoundAssignment.
+  if (Opc <= BO_Assign || Opc > BO_OrAssign)
+return BinaryOperator::Create(Context, LHS, RHS, Opc, Context.DependentTy,
+

[PATCH] D84180: [Matrix] Add LowerMatrixIntrinsics to the NPM

2020-07-22 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Awesome, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84180



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


[PATCH] D83759: [clangd] Fixes in lit tests

2020-07-22 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 279754.
ArcsinX added a comment.

[macOS] Fix `background-index.test` failure, don't create `*-e` files during 
`background-index.test`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83759

Files:
  clang-tools-extra/clangd/test/background-index.test
  clang-tools-extra/clangd/test/did-change-configuration-params.test
  clang-tools-extra/clangd/test/test-uri-windows.test


Index: clang-tools-extra/clangd/test/test-uri-windows.test
===
--- clang-tools-extra/clangd/test/test-uri-windows.test
+++ clang-tools-extra/clangd/test/test-uri-windows.test
@@ -1,5 +1,5 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
-# REQUIRES: windows-gnu || windows-msvc
+# UNSUPPORTED: !(windows-gnu || windows-msvc)
 # Test authority-less URI
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
Index: clang-tools-extra/clangd/test/did-change-configuration-params.test
===
--- clang-tools-extra/clangd/test/did-change-configuration-params.test
+++ clang-tools-extra/clangd/test/did-change-configuration-params.test
@@ -1,5 +1,5 @@
 # RUN: clangd -compile_args_from=lsp -lit-test < %s 2> %t | FileCheck 
-strict-whitespace %s
-# RUN: cat %t | FileCheck --check-prefix=ERR %s
+# RUN: FileCheck --check-prefix=ERR --input-file=%t %s
 # UNSUPPORTED: windows-gnu,windows-msvc
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
Index: clang-tools-extra/clangd/test/background-index.test
===
--- clang-tools-extra/clangd/test/background-index.test
+++ clang-tools-extra/clangd/test/background-index.test
@@ -1,23 +1,23 @@
-# We need to splice paths into file:// URIs for this test.
-# UNSUPPORTED: windows-msvc
-
 # Use a copy of inputs, as we'll mutate it (as will the background index).
-# RUN: rm -rf %t
-# RUN: cp -r %S/Inputs/background-index %t
+# RUN: rm -rf %/t
+# RUN: cp -r %/S/Inputs/background-index %/t
 # Need to embed the correct temp path in the actual JSON-RPC requests.
-# RUN: sed -i -e "s|DIRECTORY|%t|" %t/definition.jsonrpc
-# RUN: sed -i -e "s|DIRECTORY|%t|" %t/compile_commands.json
+# RUN: sed -e "s|DIRECTORY|%/t|" %/t/definition.jsonrpc > 
%/t/definition.jsonrpc.1
+# RUN: sed -i.bak -e "s|DIRECTORY|%/t|" %/t/compile_commands.json
+# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
+# (with the extra slash in the front), so we add it here.
+# RUN: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' 
%/t/definition.jsonrpc.1 > %/t/definition.jsonrpc
 
 # We're editing bar.cpp, which includes foo.h.
 # foo() is declared in foo.h and defined in foo.cpp.
 # The background index should allow us to go-to-definition on foo().
 # We should also see indexing progress notifications.
-# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck 
%t/definition.jsonrpc --check-prefixes=CHECK,BUILD
+# RUN: clangd -background-index -lit-test < %/t/definition.jsonrpc | FileCheck 
%/t/definition.jsonrpc --check-prefixes=CHECK,BUILD
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.cache/clangd/index/foo.cpp.*.idx
-# RUN: ls %t/sub_dir/.cache/clangd/index/foo.h.*.idx
+# RUN: ls %/t/.cache/clangd/index/foo.cpp.*.idx
+# RUN: ls %/t/sub_dir/.cache/clangd/index/foo.h.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
-# RUN: rm %t/foo.cpp
-# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck 
%t/definition.jsonrpc --check-prefixes=CHECK,USE
+# RUN: rm %/t/foo.cpp
+# RUN: clangd -background-index -lit-test < %/t/definition.jsonrpc | FileCheck 
%/t/definition.jsonrpc --check-prefixes=CHECK,USE


Index: clang-tools-extra/clangd/test/test-uri-windows.test
===
--- clang-tools-extra/clangd/test/test-uri-windows.test
+++ clang-tools-extra/clangd/test/test-uri-windows.test
@@ -1,5 +1,5 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
-# REQUIRES: windows-gnu || windows-msvc
+# UNSUPPORTED: !(windows-gnu || windows-msvc)
 # Test authority-less URI
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
Index: clang-tools-extra/clangd/test/did-change-configuration-params.test
===
--- clang-tools-extra/clangd/test/did-change-configuration-params.test
+++ clang-tools-extra/clangd/test/did-change-configuration-params.test
@@ -1,5 +1,5 @@
 # RUN: clangd -compile_args_from=lsp -lit-test < %s 2> %t | FileCheck -strict-whitespace %s
-# RUN: cat %t | 

[PATCH] D83759: [clangd] Fixes in lit tests

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

I believe it's okay now on macOS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83759



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


[PATCH] D84303: [analyzer][tests] Fix SATest update functionality

2020-07-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: clang.

Not all projects in the project map file might have newer results
for updating, we should handle this situation gracefully.

Additionally, not every user of the test system would want storing
reference results in git.  For this reason, git functionality is now
optional.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84303

Files:
  clang/utils/analyzer/SATest.py
  clang/utils/analyzer/SATestUpdateDiffs.py


Index: clang/utils/analyzer/SATestUpdateDiffs.py
===
--- clang/utils/analyzer/SATestUpdateDiffs.py
+++ clang/utils/analyzer/SATestUpdateDiffs.py
@@ -15,7 +15,7 @@
 Verbose = 0
 
 
-def update_reference_results(project: ProjectInfo):
+def update_reference_results(project: ProjectInfo, git: bool = False):
 test_info = SATestBuild.TestInfo(project)
 tester = SATestBuild.ProjectTester(test_info)
 project_dir = tester.get_project_dir()
@@ -27,9 +27,10 @@
 created_results_path = tester.get_output_dir()
 
 if not os.path.exists(created_results_path):
-print("New results not found, was SATestBuild.py previously run?",
+print(f"Skipping project '{project.name}', "
+  f"it doesn't have newer results.",
   file=sys.stderr)
-sys.exit(1)
+return
 
 build_log_path = SATestBuild.get_build_log_path(ref_results_path)
 build_log_dir = os.path.dirname(os.path.abspath(build_log_path))
@@ -45,7 +46,8 @@
 # Remove reference results: in git, and then again for a good measure
 # with rm, as git might not remove things fully if there are empty
 # directories involved.
-run_cmd(f"git rm -r -q '{ref_results_path}'")
+if git:
+run_cmd(f"git rm -r -q '{ref_results_path}'")
 shutil.rmtree(ref_results_path)
 
 # Replace reference results with a freshly computed once.
@@ -60,22 +62,11 @@
 # Clean up the generated difference results.
 SATestBuild.cleanup_reference_results(ref_results_path)
 
-run_cmd(f"git add '{ref_results_path}'")
+if git:
+run_cmd(f"git add '{ref_results_path}'")
 
 
-# TODO: use argparse
-def main(argv):
-if len(argv) == 2 and argv[1] in ("-h", "--help"):
-print("Update static analyzer reference results based "
-  "\non the previous run of SATestBuild.py.\n"
-  "\nN.B.: Assumes that SATestBuild.py was just run",
-  file=sys.stderr)
-sys.exit(1)
-
-project_map = ProjectMap()
-for project in project_map.projects:
-update_reference_results(project)
-
-
-if __name__ == '__main__':
-main(sys.argv)
+if __name__ == "__main__":
+print("SATestUpdateDiffs.py should not be used on its own.")
+print("Please use 'SATest.py update' instead")
+sys.exit(1)
Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -78,7 +78,7 @@
 
 project_map = ProjectMap()
 for project in project_map.projects:
-SATestUpdateDiffs.update_reference_results(project)
+SATestUpdateDiffs.update_reference_results(project, args.git)
 
 
 def benchmark(parser, args):
@@ -293,7 +293,8 @@
 "update",
 help="Update static analyzer reference results based on the previous "
 "run of SATest build. Assumes that SATest build was just run.")
-# TODO: add option to decide whether we should use git
+upd_parser.add_argument("--git", action="store_true",
+help="Stage updated results using git.")
 upd_parser.set_defaults(func=update)
 
 # docker subcommand


Index: clang/utils/analyzer/SATestUpdateDiffs.py
===
--- clang/utils/analyzer/SATestUpdateDiffs.py
+++ clang/utils/analyzer/SATestUpdateDiffs.py
@@ -15,7 +15,7 @@
 Verbose = 0
 
 
-def update_reference_results(project: ProjectInfo):
+def update_reference_results(project: ProjectInfo, git: bool = False):
 test_info = SATestBuild.TestInfo(project)
 tester = SATestBuild.ProjectTester(test_info)
 project_dir = tester.get_project_dir()
@@ -27,9 +27,10 @@
 created_results_path = tester.get_output_dir()
 
 if not os.path.exists(created_results_path):
-print("New results not found, was SATestBuild.py previously run?",
+print(f"Skipping project '{project.name}', "
+  f"it doesn't have newer results.",
   file=sys.stderr)
-sys.exit(1)
+return
 
 build_log_path = SATestBuild.get_build_log_path(ref_results_path)
 build_log_dir = os.path.dirname(

[PATCH] D84304: [AST][RecoveryExpr] Build dependent callexpr in C for error-recovery.

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84304

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-recovery.c
  clang/test/Sema/error-dependence.c


Index: clang/test/Sema/error-dependence.c
===
--- clang/test/Sema/error-dependence.c
+++ clang/test/Sema/error-dependence.c
@@ -6,4 +6,8 @@
   // verify "assigning to 'int' from incompatible type ''" is
   // not emitted.
   s = call(); // expected-error {{too few arguments to function call}}
+
+  // verify disgnostic "called object type '' is not a function
+  // or function pointer" is not emitted.
+  (*__builtin_classify_type)(1); // expected-error {{builtin functions must be 
directly called}}
 }
Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -55,3 +55,18 @@
   // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'some_func'
   compoundOp += some_func();
 }
+
+void test3() {
+  // CHECK:  CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:  |-ParenExpr {{.*}} contains-errors lvalue
+  // CHECK-NEXT:  | `-RecoveryExpr {{.*}} contains-errors
+  // CHECK-NEXT:  |   `-DeclRefExpr {{.*}} '__builtin_classify_type'
+  // CHECK-NEXT:  `-IntegerLiteral {{.*}} 'int' 1
+  (*__builtin_classify_type)(1);
+
+  extern void ext();
+  // FIXME: the broken AST will be preserved once we remove the early typo 
correction
+  // in Sema::CheckPlaceholderExpr.
+  // CHECK-NOT: DeclRefExpr {{.*}} 'ext' 'int (int)'
+  ext(undef_var);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -46,6 +46,7 @@
 #include "clang/Sema/SemaFixItUtils.h"
 #include "clang/Sema/SemaInternal.h"
 #include "clang/Sema/Template.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/SaveAndRestore.h"
 using namespace clang;
@@ -6433,6 +6434,17 @@
 checkDirectCallValidity(*this, Fn, FD, ArgExprs);
   }
 
+  if (getLangOpts().CDependence &&
+  (Fn->isTypeDependent() || Expr::hasAnyTypeDependentArguments(ArgExprs))) 
{
+assert(!getLangOpts().CPlusPlus);
+assert(Fn->containsErrors() ||
+   llvm::any_of(ArgExprs,
+[](clang::Expr *E) { return E->containsErrors(); }) &&
+   "should only occur in error-recovery path.");
+return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy,
+VK_RValue, RParenLoc);
+  }
+
   return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
ExecConfig, IsExecConfig);
 }
@@ -6572,7 +6584,7 @@
RParenLoc, NumParams, UsesADL);
   }
 
-  if (!getLangOpts().CPlusPlus) {
+  if (!getLangOpts().CPlusPlus && !getLangOpts().CDependence) {
 // Forget about the nulled arguments since typo correction
 // do not handle them well.
 TheCall->shrinkNumArgs(Args.size());


Index: clang/test/Sema/error-dependence.c
===
--- clang/test/Sema/error-dependence.c
+++ clang/test/Sema/error-dependence.c
@@ -6,4 +6,8 @@
   // verify "assigning to 'int' from incompatible type ''" is
   // not emitted.
   s = call(); // expected-error {{too few arguments to function call}}
+
+  // verify disgnostic "called object type '' is not a function
+  // or function pointer" is not emitted.
+  (*__builtin_classify_type)(1); // expected-error {{builtin functions must be directly called}}
 }
Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -55,3 +55,18 @@
   // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'some_func'
   compoundOp += some_func();
 }
+
+void test3() {
+  // CHECK:  CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:  |-ParenExpr {{.*}} contains-errors lvalue
+  // CHECK-NEXT:  | `-RecoveryExpr {{.*}} contains-errors
+  // CHECK-NEXT:  |   `-DeclRefExpr {{.*}} '__builtin_classify_type'
+  // CHECK-NEXT:  `-IntegerLiteral {{.*}} 'int' 1
+  (*__builtin_classify_type)(1);
+
+  extern void ext();
+  // FIXME: the broken AST will be preserved once we remove the early typo correction
+  // in Sema::CheckPlaceholderExpr.
+  // CHECK-NOT: DeclRefExpr {{.*}} 'ext' 'int (int)'
+  ext(undef_var);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -46,6 +46,7 @@
 #include "clang/Sema/SemaFixItUtils.h"
 #include "clang/Sema/SemaInternal.h"
 #include "clang/Sema/Template.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Con

[PATCH] D84306: [clang-format][NFC] Be more careful about the layout of FormatToken.

2020-07-22 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added a reviewer: MyDeveloperDay.
riccibruno added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The underlying ABI forces `FormatToken` to have a lot of padding. Currently (on 
x86-64 linux) `sizeof(FormatToken) == 288`. After this patch 
`sizeof(FormatToken) == 232`.

No functional changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84306

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/WhitespaceManager.cpp

Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -49,7 +49,7 @@
   bool IsAligned, bool InPPDirective) {
   if (Tok.Finalized)
 return;
-  Tok.Decision = (Newlines > 0) ? FD_Break : FD_Continue;
+  Tok.setDecision((Newlines > 0) ? FD_Break : FD_Continue);
   Changes.push_back(Change(Tok, /*CreateReplacement=*/true, Tok.WhitespaceRange,
Spaces, StartOfTokenColumn, Newlines, "", "",
IsAligned, InPPDirective && !Tok.IsFirst,
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -472,19 +472,19 @@
   // individual members in a type member list, which would normally
   // trigger BK_Block. In both cases, this must be parsed as an inline
   // braced init.
-  Tok->BlockKind = BK_BracedInit;
+  Tok->setBlockKind(BK_BracedInit);
 else if (PrevTok->is(tok::r_paren))
   // `) { }` can only occur in function or method declarations in JS.
-  Tok->BlockKind = BK_Block;
+  Tok->setBlockKind(BK_Block);
   } else {
-Tok->BlockKind = BK_Unknown;
+Tok->setBlockKind(BK_Unknown);
   }
   LBraceStack.push_back(Tok);
   break;
 case tok::r_brace:
   if (LBraceStack.empty())
 break;
-  if (LBraceStack.back()->BlockKind == BK_Unknown) {
+  if (LBraceStack.back()->getBlockKind() == BK_Unknown) {
 bool ProbablyBracedList = false;
 if (Style.Language == FormatStyle::LK_Proto) {
   ProbablyBracedList = NextTok->isOneOf(tok::comma, tok::r_square);
@@ -524,11 +524,11 @@
   }
 }
 if (ProbablyBracedList) {
-  Tok->BlockKind = BK_BracedInit;
-  LBraceStack.back()->BlockKind = BK_BracedInit;
+  Tok->setBlockKind(BK_BracedInit);
+  LBraceStack.back()->setBlockKind(BK_BracedInit);
 } else {
-  Tok->BlockKind = BK_Block;
-  LBraceStack.back()->BlockKind = BK_Block;
+  Tok->setBlockKind(BK_Block);
+  LBraceStack.back()->setBlockKind(BK_Block);
 }
   }
   LBraceStack.pop_back();
@@ -545,8 +545,9 @@
 case tok::kw_switch:
 case tok::kw_try:
 case tok::kw___try:
-  if (!LBraceStack.empty() && LBraceStack.back()->BlockKind == BK_Unknown)
-LBraceStack.back()->BlockKind = BK_Block;
+  if (!LBraceStack.empty() &&
+  LBraceStack.back()->getBlockKind() == BK_Unknown)
+LBraceStack.back()->setBlockKind(BK_Block);
   break;
 default:
   break;
@@ -557,8 +558,8 @@
 
   // Assume other blocks for all unclosed opening braces.
   for (unsigned i = 0, e = LBraceStack.size(); i != e; ++i) {
-if (LBraceStack[i]->BlockKind == BK_Unknown)
-  LBraceStack[i]->BlockKind = BK_Block;
+if (LBraceStack[i]->getBlockKind() == BK_Unknown)
+  LBraceStack[i]->setBlockKind(BK_Block);
   }
 
   FormatTok = Tokens->setPosition(StoredPosition);
@@ -584,7 +585,7 @@
   assert(FormatTok->isOneOf(tok::l_brace, TT_MacroBlockBegin) &&
  "'{' or macro block token expected");
   const bool MacroBlock = FormatTok->is(TT_MacroBlockBegin);
-  FormatTok->BlockKind = BK_Block;
+  FormatTok->setBlockKind(BK_Block);
 
   size_t PPStartHash = computePPHash();
 
@@ -614,7 +615,7 @@
   if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
  : !FormatTok->is(tok::r_brace)) {
 Line->Level = InitialLevel;
-FormatTok->BlockKind = BK_Block;
+FormatTok->setBlockKind(BK_Block);
 return;
   }
 
@@ -690,7 +691,7 @@
 }
 
 void UnwrappedLineParser::parseChildBlock() {
-  FormatTok->BlockKind = BK_Block;
+  FormatTok->setBlockKind(BK_Block);
   nextToken();
   {
 bool SkipIndent = (Style.Language == FormatStyle::LK_JavaScript &&
@@ -1476,7 +1477,7 @@
 // C# needs this change to ensure that array initialisers and object
 // initialisers are indented the same 

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

2020-07-22 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko added a subscriber: walrus.
ilya-golovenko added a comment.

@kbobyrev Kirill, thank you for landing this for me! Unfortunately @walrus is 
my not-used-anymore account...
By the way, do you know is it possible to delete my unused account @walrus to 
avoid such confusions in future?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84172



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


[PATCH] D83759: [clangd] Fixes in lit tests

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



Comment at: clang-tools-extra/clangd/test/background-index.test:6
+# RUN: sed -e "s|DIRECTORY|%/t|" %/t/definition.jsonrpc > 
%/t/definition.jsonrpc.1
+# RUN: sed -i.bak -e "s|DIRECTORY|%/t|" %/t/compile_commands.json
+# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."

i don't think there's much point in dropping `-i` from only some commands.

I would suggest either:
- dropping it from all, by changing the original files to have a `.tmpl` 
suffix, and dropping the suffix in sed'd versions
- keeping it for all comments by adding a `-i.bak` to all


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83759



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2020-07-22 Thread Joachim Protze via Phabricator via cfe-commits
protze.joachim added a comment.

Starting with the commit of this patch, the libomptarget test 
`llvm-project/openmp/libomptarget/test/offloading/target_depend_nowait.cpp` 
fails. Here is a stacktrace of the segfault:

  $ gdb target_depend_nowait.cpp.tmp-x86_64-pc-linux-gnu
  (gdb) run
  ...
  Program received signal SIGSEGV, Segmentation fault.
  (gdb) bt
  #0  0x00400fcf in .omp_outlined._debug__ 
(.global_tid.=0x2aaab96b9be0, .bound_tid.=0x2aaab96b9bd8) at 
target_depend_nowait.cpp:22
  #1  0x00401e8d in .omp_outlined..23 (.global_tid.=0x2aaab96b9be0, 
.bound_tid.=0x2aaab96b9bd8) at target_depend_nowait.cpp:18
  #2  0x2b574213 in __kmp_invoke_microtask () from libomp.so
  #3  0x2b51338e in __kmp_invoke_task_func () from libomp.so
  #4  0x2b5126bf in __kmp_launch_thread () from libomp.so
  #5  0x2b55d3d0 in __kmp_launch_worker(void*) () from libomp.so
  #6  0x2bbd6e65 in start_thread () from libpthread.so.0
  #7  0x2bee988d in clone () from libc.so.6


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67833



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


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

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

In D84172#2166448 , @ilya-golovenko 
wrote:

> @kbobyrev Kirill, thank you for landing this for me! Unfortunately @walrus is 
> my not-used-anymore account...
>  By the way, do you know is it possible to delete my unused account @walrus 
> to avoid such confusions in future?


Not that I'm aware of :( I have way too many accounts myself, I'd be interested 
in that, too. I think not having your email associated with it anymore would be 
good.

Hopefully, reviews move to GitHub at some point and this will not be necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84172



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


[PATCH] D83759: [clangd] Fixes in lit tests

2020-07-22 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX marked an inline comment as done.
ArcsinX added inline comments.



Comment at: clang-tools-extra/clangd/test/background-index.test:6
+# RUN: sed -e "s|DIRECTORY|%/t|" %/t/definition.jsonrpc > 
%/t/definition.jsonrpc.1
+# RUN: sed -i.bak -e "s|DIRECTORY|%/t|" %/t/compile_commands.json
+# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."

kadircet wrote:
> i don't think there's much point in dropping `-i` from only some commands.
> 
> I would suggest either:
> - dropping it from all, by changing the original files to have a `.tmpl` 
> suffix, and dropping the suffix in sed'd versions
> - keeping it for all comments by adding a `-i.bak` to all
For `definition.jsonrpc` we have two `sed` commands and we can keep the file 
name unchanged without `-i` option.
But for `compile_commands.json` we have only one `sed` command and we need `-i` 
option to keep the file name unchanged.


> changing the original files to have a .tmpl suffix
In other tests `.1` suffix is used, that's why I use this suffix here.
E.g. `compile-commands-path-in-initialize.test`
```
# RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1
...
# RUN: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' %t.test.1 > %t.test
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83759



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


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

2020-07-22 Thread Ilya Golovenko via Phabricator via cfe-commits
walrus added a comment.

In D84172#2166496 , @kbobyrev wrote:

> In D84172#2166448 , @ilya-golovenko 
> wrote:
>
> > @kbobyrev Kirill, thank you for landing this for me! Unfortunately @walrus 
> > is my not-used-anymore account...
> >  By the way, do you know is it possible to delete my unused account @walrus 
> > to avoid such confusions in future?
>
>
> Not that I'm aware of :( I have way too many accounts myself, I'd be 
> interested in that, too. I think not having your email associated with it 
> anymore would be good.
>
> Hopefully, reviews move to GitHub at some point and this will not be 
> necessary.


I asked because according to policies all my commits should be attributed to 
Huawei (as this work is done here) and should be committed using my work email: 
ilya.golove...@huawei.com, not with personal ilya.golove...@gmail.com


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84172



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


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

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

In D84172#2166496 , @kbobyrev wrote:

> In D84172#2166448 , @ilya-golovenko 
> wrote:
>
> > @kbobyrev Kirill, thank you for landing this for me! Unfortunately @walrus 
> > is my not-used-anymore account...
> >  By the way, do you know is it possible to delete my unused account @walrus 
> > to avoid such confusions in future?
>
>
> Not that I'm aware of :( I have way too many accounts myself, I'd be 
> interested in that, too. I think not having your email associated with it 
> anymore would be good.
>
> Hopefully, reviews move to GitHub at some point and this will not be 
> necessary.


I asked because according to policies all my commits should be attributed to 
Huawei (as this work is done here) and should be committed using my work email: 
ilya.golove...@huawei.com, not with personal ilya.golove...@gmail.com


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84172



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


[PATCH] D83759: [clangd] Fixes in lit tests

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



Comment at: clang-tools-extra/clangd/test/background-index.test:6
+# RUN: sed -e "s|DIRECTORY|%/t|" %/t/definition.jsonrpc > 
%/t/definition.jsonrpc.1
+# RUN: sed -i.bak -e "s|DIRECTORY|%/t|" %/t/compile_commands.json
+# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."

ArcsinX wrote:
> kadircet wrote:
> > i don't think there's much point in dropping `-i` from only some commands.
> > 
> > I would suggest either:
> > - dropping it from all, by changing the original files to have a `.tmpl` 
> > suffix, and dropping the suffix in sed'd versions
> > - keeping it for all comments by adding a `-i.bak` to all
> For `definition.jsonrpc` we have two `sed` commands and we can keep the file 
> name unchanged without `-i` option.
> But for `compile_commands.json` we have only one `sed` command and we need 
> `-i` option to keep the file name unchanged.
> 
> 
> > changing the original files to have a .tmpl suffix
> In other tests `.1` suffix is used, that's why I use this suffix here.
> E.g. `compile-commands-path-in-initialize.test`
> ```
> # RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1
> ...
> # RUN: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' %t.test.1 > %t.test
> ```
> For definition.jsonrpc we have two sed commands and we can keep the file name 
> unchanged without -i option.

yes for that one we could still move into a `.1` (or `.tmp`) suffixed version.

> In other tests .1 suffix is used, that's why I use this suffix here.

right, I was talking about renaming 
`clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc` to 
`clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc.tmpl` 
(likewise the compile_commands.json). That way you can always do a sed, and 
write to a different file (i.e. the version without the suffix).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83759



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


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

2020-07-22 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

This patch introduced a couple of failures on the Solaris buildbots 
(Solaris/sparcv9  
and Solaris/x86 ).

E.g.

  FAIL: Clang :: Driver/env.c (12768 of 69452)
  [...]
  /vol/llvm/src/llvm-project/dist/clang/test/Driver/env.c:21:21: error: 
CHECK-LD-32-NOT: excluded string found in input
  // CHECK-LD-32-NOT: warning:
  ^
  :5:8: note: found here
  clang: warning: '-fuse-ld=' taking a path is deprecated. Use '--ld-path=' 
instead
 ^~~~

For reasons explained in D84029 , one needs to 
specify the Solaris linker, either via `cmake -DCLANG_DEFAULT_LINKER` (so far) 
or implicitly
as in that patch.

I strongly expect all other uses of `CLANG_DEFAULT_LINKER` to be broken 
similarly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83015



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


[PATCH] D84310: [libTooling] Add assorted `EditGenerator` combinators.

2020-07-22 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: asoffer, gribozavr2.
Herald added a project: clang.

This patch adds various combinators that help in constructing `EditGenerator`s:

- `noEdits`
- `ifBound`, specialized to `ASTEdit`
- `flatten` and `flattenVector` which allow for easy construction from a set of 
sub edits.
- `shrinkTo`, which generates edits to shrink a given range to another that it 
encloses.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84310

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

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -10,6 +10,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
 #include "clang/Tooling/Transformer/RangeSelector.h"
+#include "clang/Tooling/Transformer/RewriteRule.h"
 #include "clang/Tooling/Transformer/Stencil.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
@@ -378,6 +379,41 @@
Input, Expected);
 }
 
+TEST_F(TransformerTest, NoEdits) {
+  using transformer::noEdits;
+  std::string Input = "int f(int x) { return x; }";
+  testRule(makeRule(returnStmt().bind("return"), noEdits()), Input, Input);
+}
+
+TEST_F(TransformerTest, IfBound2Args) {
+  using transformer::ifBound;
+  std::string Input = "int f(int x) { return x; }";
+  std::string Expected = "int f(int x) { CHANGE; }";
+  testRule(makeRule(returnStmt().bind("return"),
+ifBound("return", changeTo(cat("CHANGE;",
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, IfBound3Args) {
+  using transformer::ifBound;
+  std::string Input = "int f(int x) { return x; }";
+  std::string Expected = "int f(int x) { CHANGE; }";
+  testRule(makeRule(returnStmt().bind("return"),
+ifBound("nothing", changeTo(cat("ERROR")),
+changeTo(cat("CHANGE;",
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, ShrinkTo) {
+  using transformer::shrinkTo;
+  std::string Input = "int f(int x) { return x; }";
+  std::string Expected = "return x;";
+  testRule(makeRule(functionDecl(hasDescendant(returnStmt().bind("return")))
+.bind("function"),
+shrinkTo(node("function"), node("return"))),
+   Input, Expected);
+}
+
 TEST_F(TransformerTest, InsertBeforeEdit) {
   std::string Input = R"cc(
 int f() {
@@ -497,6 +533,90 @@
   Input, Expected);
 }
 
+TEST_F(TransformerTest, EditList) {
+  using clang::transformer::editList;
+  std::string Input = R"cc(
+void foo() {
+  if (10 > 1.0)
+log(1) << "oh no!";
+  else
+log(0) << "ok";
+}
+  )cc";
+  std::string Expected = R"(
+void foo() {
+  if (true) { /* then */ }
+  else { /* else */ }
+}
+  )";
+
+  StringRef C = "C", T = "T", E = "E";
+  testRule(makeRule(ifStmt(hasCondition(expr().bind(C)),
+   hasThen(stmt().bind(T)), hasElse(stmt().bind(E))),
+editList({changeTo(node(std::string(C)), cat("true")),
+  changeTo(statement(std::string(T)),
+   cat("{ /* then */ }")),
+  changeTo(statement(std::string(E)),
+   cat("{ /* else */ }"))})),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, Flatten) {
+  using clang::transformer::editList;
+  std::string Input = R"cc(
+void foo() {
+  if (10 > 1.0)
+log(1) << "oh no!";
+  else
+log(0) << "ok";
+}
+  )cc";
+  std::string Expected = R"(
+void foo() {
+  if (true) { /* then */ }
+  else { /* else */ }
+}
+  )";
+
+  StringRef C = "C", T = "T", E = "E";
+  testRule(
+  makeRule(
+  ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+ hasElse(stmt().bind(E))),
+  flatten(changeTo(node(std::string(C)), cat("true")),
+  changeTo(statement(std::string(T)), cat("{ /* then */ }")),
+  changeTo(statement(std::string(E)), cat("{ /* else */ }",
+  Input, Expected);
+}
+
+TEST_F(TransformerTest, FlattenWithMixedArgs) {
+  using clang::transformer::editList;
+  std::string Input = R"cc(
+void foo() {
+  if (10 > 1.0)
+log(1) << "oh no!";
+  else
+log(0) << "ok";
+}
+  )cc";
+  std::string Expected = R"(
+void foo() {
+  if (true) { /* then */ }
+  else { /* else */ }
+}
+  )";
+
+  StringRef C = "C", T = "T", E = "E";
+  testRule(makeRule(ifStmt(hasCondition(expr().bind(C)),
+   hasThen(stmt().bind(T

[PATCH] D84310: [libTooling] Add assorted `EditGenerator` combinators.

2020-07-22 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 279771.
ymandel added a comment.

revert unrelated change in `RangeSelector.h`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84310

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

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -10,6 +10,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
 #include "clang/Tooling/Transformer/RangeSelector.h"
+#include "clang/Tooling/Transformer/RewriteRule.h"
 #include "clang/Tooling/Transformer/Stencil.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
@@ -378,6 +379,41 @@
Input, Expected);
 }
 
+TEST_F(TransformerTest, NoEdits) {
+  using transformer::noEdits;
+  std::string Input = "int f(int x) { return x; }";
+  testRule(makeRule(returnStmt().bind("return"), noEdits()), Input, Input);
+}
+
+TEST_F(TransformerTest, IfBound2Args) {
+  using transformer::ifBound;
+  std::string Input = "int f(int x) { return x; }";
+  std::string Expected = "int f(int x) { CHANGE; }";
+  testRule(makeRule(returnStmt().bind("return"),
+ifBound("return", changeTo(cat("CHANGE;",
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, IfBound3Args) {
+  using transformer::ifBound;
+  std::string Input = "int f(int x) { return x; }";
+  std::string Expected = "int f(int x) { CHANGE; }";
+  testRule(makeRule(returnStmt().bind("return"),
+ifBound("nothing", changeTo(cat("ERROR")),
+changeTo(cat("CHANGE;",
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, ShrinkTo) {
+  using transformer::shrinkTo;
+  std::string Input = "int f(int x) { return x; }";
+  std::string Expected = "return x;";
+  testRule(makeRule(functionDecl(hasDescendant(returnStmt().bind("return")))
+.bind("function"),
+shrinkTo(node("function"), node("return"))),
+   Input, Expected);
+}
+
 TEST_F(TransformerTest, InsertBeforeEdit) {
   std::string Input = R"cc(
 int f() {
@@ -497,6 +533,90 @@
   Input, Expected);
 }
 
+TEST_F(TransformerTest, EditList) {
+  using clang::transformer::editList;
+  std::string Input = R"cc(
+void foo() {
+  if (10 > 1.0)
+log(1) << "oh no!";
+  else
+log(0) << "ok";
+}
+  )cc";
+  std::string Expected = R"(
+void foo() {
+  if (true) { /* then */ }
+  else { /* else */ }
+}
+  )";
+
+  StringRef C = "C", T = "T", E = "E";
+  testRule(makeRule(ifStmt(hasCondition(expr().bind(C)),
+   hasThen(stmt().bind(T)), hasElse(stmt().bind(E))),
+editList({changeTo(node(std::string(C)), cat("true")),
+  changeTo(statement(std::string(T)),
+   cat("{ /* then */ }")),
+  changeTo(statement(std::string(E)),
+   cat("{ /* else */ }"))})),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, Flatten) {
+  using clang::transformer::editList;
+  std::string Input = R"cc(
+void foo() {
+  if (10 > 1.0)
+log(1) << "oh no!";
+  else
+log(0) << "ok";
+}
+  )cc";
+  std::string Expected = R"(
+void foo() {
+  if (true) { /* then */ }
+  else { /* else */ }
+}
+  )";
+
+  StringRef C = "C", T = "T", E = "E";
+  testRule(
+  makeRule(
+  ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+ hasElse(stmt().bind(E))),
+  flatten(changeTo(node(std::string(C)), cat("true")),
+  changeTo(statement(std::string(T)), cat("{ /* then */ }")),
+  changeTo(statement(std::string(E)), cat("{ /* else */ }",
+  Input, Expected);
+}
+
+TEST_F(TransformerTest, FlattenWithMixedArgs) {
+  using clang::transformer::editList;
+  std::string Input = R"cc(
+void foo() {
+  if (10 > 1.0)
+log(1) << "oh no!";
+  else
+log(0) << "ok";
+}
+  )cc";
+  std::string Expected = R"(
+void foo() {
+  if (true) { /* then */ }
+  else { /* else */ }
+}
+  )";
+
+  StringRef C = "C", T = "T", E = "E";
+  testRule(makeRule(ifStmt(hasCondition(expr().bind(C)),
+   hasThen(stmt().bind(T)), hasElse(stmt().bind(E))),
+flatten(changeTo(node(std::string(C)), cat("true")),
+edit(changeTo(statement(std::string(T)),
+  cat("{ /* then */ }"))),
+editList({changeTo(stateme

[PATCH] D83759: [clangd] Fixes in lit tests

2020-07-22 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 279781.
ArcsinX added a comment.

Get rid of `-i` `sed` option


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83759

Files:
  clang-tools-extra/clangd/test/Inputs/background-index/compile_commands.json
  
clang-tools-extra/clangd/test/Inputs/background-index/compile_commands.json.tmpl
  clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc
  clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc.tmpl
  clang-tools-extra/clangd/test/background-index.test
  clang-tools-extra/clangd/test/did-change-configuration-params.test
  clang-tools-extra/clangd/test/test-uri-windows.test

Index: clang-tools-extra/clangd/test/test-uri-windows.test
===
--- clang-tools-extra/clangd/test/test-uri-windows.test
+++ clang-tools-extra/clangd/test/test-uri-windows.test
@@ -1,5 +1,5 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
-# REQUIRES: windows-gnu || windows-msvc
+# UNSUPPORTED: !(windows-gnu || windows-msvc)
 # Test authority-less URI
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
Index: clang-tools-extra/clangd/test/did-change-configuration-params.test
===
--- clang-tools-extra/clangd/test/did-change-configuration-params.test
+++ clang-tools-extra/clangd/test/did-change-configuration-params.test
@@ -1,5 +1,5 @@
 # RUN: clangd -compile_args_from=lsp -lit-test < %s 2> %t | FileCheck -strict-whitespace %s
-# RUN: cat %t | FileCheck --check-prefix=ERR %s
+# RUN: FileCheck --check-prefix=ERR --input-file=%t %s
 # UNSUPPORTED: windows-gnu,windows-msvc
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
Index: clang-tools-extra/clangd/test/background-index.test
===
--- clang-tools-extra/clangd/test/background-index.test
+++ clang-tools-extra/clangd/test/background-index.test
@@ -1,23 +1,23 @@
-# We need to splice paths into file:// URIs for this test.
-# UNSUPPORTED: windows-msvc
-
 # Use a copy of inputs, as we'll mutate it (as will the background index).
-# RUN: rm -rf %t
-# RUN: cp -r %S/Inputs/background-index %t
+# RUN: rm -rf %/t
+# RUN: cp -r %/S/Inputs/background-index %/t
 # Need to embed the correct temp path in the actual JSON-RPC requests.
-# RUN: sed -i -e "s|DIRECTORY|%t|" %t/definition.jsonrpc
-# RUN: sed -i -e "s|DIRECTORY|%t|" %t/compile_commands.json
+# RUN: sed -e "s|DIRECTORY|%/t|" %/t/definition.jsonrpc.tmpl > %/t/definition.jsonrpc.1
+# RUN: sed -e "s|DIRECTORY|%/t|" %/t/compile_commands.json.tmpl > %/t/compile_commands.json
+# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
+# (with the extra slash in the front), so we add it here.
+# RUN: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' %/t/definition.jsonrpc.1 > %/t/definition.jsonrpc
 
 # We're editing bar.cpp, which includes foo.h.
 # foo() is declared in foo.h and defined in foo.cpp.
 # The background index should allow us to go-to-definition on foo().
 # We should also see indexing progress notifications.
-# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc --check-prefixes=CHECK,BUILD
+# RUN: clangd -background-index -lit-test < %/t/definition.jsonrpc | FileCheck %/t/definition.jsonrpc --check-prefixes=CHECK,BUILD
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.cache/clangd/index/foo.cpp.*.idx
-# RUN: ls %t/sub_dir/.cache/clangd/index/foo.h.*.idx
+# RUN: ls %/t/.cache/clangd/index/foo.cpp.*.idx
+# RUN: ls %/t/sub_dir/.cache/clangd/index/foo.h.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
-# RUN: rm %t/foo.cpp
-# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc --check-prefixes=CHECK,USE
+# RUN: rm %/t/foo.cpp
+# RUN: clangd -background-index -lit-test < %/t/definition.jsonrpc | FileCheck %/t/definition.jsonrpc --check-prefixes=CHECK,USE
Index: clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc
===
--- /dev/null
+++ clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc
@@ -1,76 +0,0 @@
-{
-  "jsonrpc": "2.0",
-  "id": 0,
-  "method": "initialize",
-  "params": {
-"processId": 123,
-"rootPath": "clangd",
-"capabilities": { "window": { "workDoneProgress": true, "implicitWorkDoneProgressCreate": true} },
-"trace": "off"
-  }
-}

-{
-  "jsonrpc": "2.0",
-  "method": "textDocument/didOpen",
-  "params": {
-"textDocument": {
-  "uri": "file://DIRECTORY/bar.cpp",
-  "languageId": "cpp",
-  "version": 1,
- 

[PATCH] D83759: [clangd] Fixes in lit tests

2020-07-22 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX marked an inline comment as done.
ArcsinX added inline comments.



Comment at: clang-tools-extra/clangd/test/background-index.test:6
+# RUN: sed -e "s|DIRECTORY|%/t|" %/t/definition.jsonrpc > 
%/t/definition.jsonrpc.1
+# RUN: sed -i.bak -e "s|DIRECTORY|%/t|" %/t/compile_commands.json
+# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."

kadircet wrote:
> ArcsinX wrote:
> > kadircet wrote:
> > > i don't think there's much point in dropping `-i` from only some commands.
> > > 
> > > I would suggest either:
> > > - dropping it from all, by changing the original files to have a `.tmpl` 
> > > suffix, and dropping the suffix in sed'd versions
> > > - keeping it for all comments by adding a `-i.bak` to all
> > For `definition.jsonrpc` we have two `sed` commands and we can keep the 
> > file name unchanged without `-i` option.
> > But for `compile_commands.json` we have only one `sed` command and we need 
> > `-i` option to keep the file name unchanged.
> > 
> > 
> > > changing the original files to have a .tmpl suffix
> > In other tests `.1` suffix is used, that's why I use this suffix here.
> > E.g. `compile-commands-path-in-initialize.test`
> > ```
> > # RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1
> > ...
> > # RUN: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' %t.test.1 > %t.test
> > ```
> > For definition.jsonrpc we have two sed commands and we can keep the file 
> > name unchanged without -i option.
> 
> yes for that one we could still move into a `.1` (or `.tmp`) suffixed version.
> 
> > In other tests .1 suffix is used, that's why I use this suffix here.
> 
> right, I was talking about renaming 
> `clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc` to 
> `clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc.tmpl`
>  (likewise the compile_commands.json). That way you can always do a sed, and 
> write to a different file (i.e. the version without the suffix).
Got it, fixed, thanks.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83759



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


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

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

In D84172#2166503 , @ilya-golovenko 
wrote:

> In D84172#2166496 , @kbobyrev wrote:
>
> > In D84172#2166448 , 
> > @ilya-golovenko wrote:
> >
> > > @kbobyrev Kirill, thank you for landing this for me! Unfortunately 
> > > @walrus is my not-used-anymore account...
> > >  By the way, do you know is it possible to delete my unused account 
> > > @walrus to avoid such confusions in future?
> >
> >
> > Not that I'm aware of :( I have way too many accounts myself, I'd be 
> > interested in that, too. I think not having your email associated with it 
> > anymore would be good.
> >
> > Hopefully, reviews move to GitHub at some point and this will not be 
> > necessary.
>
>
> I asked because according to policies all my commits should be attributed to 
> Huawei (as this work is done here) and should be committed using my work 
> email: ilya.golove...@huawei.com, not with personal ilya.golove...@gmail.com


Uh, I see, sorry for that. I'm afraid we can not rewrite the commit history to 
change the email for the one already submitted, but I think the commits are 
attributed to the primary email for your account, so simply changing it should 
do the trick.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84172



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


[PATCH] D84315: [libTooling] Add a `between` range-selector combinator.

2020-07-22 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: asoffer, gribozavr2.
Herald added a project: clang.

Adds the `between` combinator and registers it with the parser. As a driveby, 
updates some deprecated names to their current versions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84315

Files:
  clang/include/clang/Tooling/Transformer/RangeSelector.h
  clang/lib/Tooling/Transformer/Parsing.cpp
  clang/unittests/Tooling/RangeSelectorTest.cpp

Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -193,8 +193,33 @@
HasValue(EqualsCharSourceRange(ExpectedAfter)));
 }
 
+TEST(RangeSelectorTest, BetweenOp) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(3, /* comment */ 7 /* comment */, 9); }
+  )cc";
+  auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
+  hasArgument(1, expr().bind("a1")));
+  RangeSelector R = between(node("a0"), node("a1"));
+  TestMatch Match = matchCode(Code, Matcher);
+  EXPECT_THAT_EXPECTED(select(R, Match), HasValue(", /* comment */ "));
+}
+
+TEST(RangeSelectorTest, BetweenOpParsed) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(3, /* comment */ 7 /* comment */, 9); }
+  )cc";
+  auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
+  hasArgument(1, expr().bind("a1")));
+  auto R = parseRangeSelector(R"rs(between(node("a0"), node("a1")))rs");
+  ASSERT_THAT_EXPECTED(R, llvm::Succeeded());
+  TestMatch Match = matchCode(Code, Matcher);
+  EXPECT_THAT_EXPECTED(select(*R, Match), HasValue(", /* comment */ "));
+}
+
 // Node-id specific version.
-TEST(RangeSelectorTest, RangeOpNodes) {
+TEST(RangeSelectorTest, EncloseOpNodes) {
   StringRef Code = R"cc(
 int f(int x, int y, int z) { return 3; }
 int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
@@ -206,7 +231,7 @@
   EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
 }
 
-TEST(RangeSelectorTest, RangeOpGeneral) {
+TEST(RangeSelectorTest, EncloseOpGeneral) {
   StringRef Code = R"cc(
 int f(int x, int y, int z) { return 3; }
 int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
@@ -218,7 +243,7 @@
   EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
 }
 
-TEST(RangeSelectorTest, RangeOpNodesParsed) {
+TEST(RangeSelectorTest, EncloseOpNodesParsed) {
   StringRef Code = R"cc(
 int f(int x, int y, int z) { return 3; }
 int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
@@ -231,7 +256,7 @@
   EXPECT_THAT_EXPECTED(select(*R, Match), HasValue("3, 7"));
 }
 
-TEST(RangeSelectorTest, RangeOpGeneralParsed) {
+TEST(RangeSelectorTest, EncloseOpGeneralParsed) {
   StringRef Code = R"cc(
 int f(int x, int y, int z) { return 3; }
 int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
Index: clang/lib/Tooling/Transformer/Parsing.cpp
===
--- clang/lib/Tooling/Transformer/Parsing.cpp
+++ clang/lib/Tooling/Transformer/Parsing.cpp
@@ -109,14 +109,14 @@
 static const llvm::StringMap> &
 getBinaryStringSelectors() {
   static const llvm::StringMap> M = {
-  {"encloseNodes", range}};
+  {"encloseNodes", encloseNodes}};
   return M;
 }
 
 static const llvm::StringMap> &
 getBinaryRangeSelectors() {
   static const llvm::StringMap>
-  M = {{"enclose", range}};
+  M = {{"enclose", enclose}, {"between", between}};
   return M;
 }
 
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -56,6 +56,11 @@
 /// * the TokenRange [B,E'] where the token at E' spans the range [E',E).
 RangeSelector after(RangeSelector Selector);
 
+/// Convenience constructor of the range between two ranges.
+inline RangeSelector between(RangeSelector R1, RangeSelector R2) {
+  return enclose(after(std::move(R1)), before(std::move(R2)));
+}
+
 /// Selects a node, including trailing semicolon (for non-expression
 /// statements). \p ID is the node's binding in the match result.
 RangeSelector node(std::string ID);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-07-22 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Ouch. Let me know how severe this is, because this is a big milestone in my 
project.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82598



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


[PATCH] D83759: [clangd] Fixes in lit tests

2020-07-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.

thanks, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83759



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


[PATCH] D83759: [clangd] Fixes in lit tests

2020-07-22 Thread Aleksandr Platonov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG98b56c09be00: [clangd] Fixes in lit tests (authored by 
ArcsinX).

Changed prior to commit:
  https://reviews.llvm.org/D83759?vs=279781&id=279789#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83759

Files:
  clang-tools-extra/clangd/test/Inputs/background-index/compile_commands.json
  
clang-tools-extra/clangd/test/Inputs/background-index/compile_commands.json.tmpl
  clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc
  clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc.tmpl
  clang-tools-extra/clangd/test/background-index.test
  clang-tools-extra/clangd/test/did-change-configuration-params.test
  clang-tools-extra/clangd/test/test-uri-windows.test


Index: clang-tools-extra/clangd/test/test-uri-windows.test
===
--- clang-tools-extra/clangd/test/test-uri-windows.test
+++ clang-tools-extra/clangd/test/test-uri-windows.test
@@ -1,5 +1,5 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
-# REQUIRES: windows-gnu || windows-msvc
+# UNSUPPORTED: !(windows-gnu || windows-msvc)
 # Test authority-less URI
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
Index: clang-tools-extra/clangd/test/did-change-configuration-params.test
===
--- clang-tools-extra/clangd/test/did-change-configuration-params.test
+++ clang-tools-extra/clangd/test/did-change-configuration-params.test
@@ -1,5 +1,5 @@
 # RUN: clangd -compile_args_from=lsp -lit-test < %s 2> %t | FileCheck 
-strict-whitespace %s
-# RUN: cat %t | FileCheck --check-prefix=ERR %s
+# RUN: FileCheck --check-prefix=ERR --input-file=%t %s
 # UNSUPPORTED: windows-gnu,windows-msvc
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
Index: clang-tools-extra/clangd/test/background-index.test
===
--- clang-tools-extra/clangd/test/background-index.test
+++ clang-tools-extra/clangd/test/background-index.test
@@ -1,23 +1,23 @@
-# We need to splice paths into file:// URIs for this test.
-# UNSUPPORTED: windows-msvc
-
 # Use a copy of inputs, as we'll mutate it (as will the background index).
-# RUN: rm -rf %t
-# RUN: cp -r %S/Inputs/background-index %t
+# RUN: rm -rf %/t
+# RUN: cp -r %/S/Inputs/background-index %/t
 # Need to embed the correct temp path in the actual JSON-RPC requests.
-# RUN: sed -i -e "s|DIRECTORY|%t|" %t/definition.jsonrpc
-# RUN: sed -i -e "s|DIRECTORY|%t|" %t/compile_commands.json
+# RUN: sed -e "s|DIRECTORY|%/t|" %/t/definition.jsonrpc.tmpl > 
%/t/definition.jsonrpc.1
+# RUN: sed -e "s|DIRECTORY|%/t|" %/t/compile_commands.json.tmpl > 
%/t/compile_commands.json
+# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
+# (with the extra slash in the front), so we add it here.
+# RUN: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' 
%/t/definition.jsonrpc.1 > %/t/definition.jsonrpc
 
 # We're editing bar.cpp, which includes foo.h.
 # foo() is declared in foo.h and defined in foo.cpp.
 # The background index should allow us to go-to-definition on foo().
 # We should also see indexing progress notifications.
-# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck 
%t/definition.jsonrpc --check-prefixes=CHECK,BUILD
+# RUN: clangd -background-index -lit-test < %/t/definition.jsonrpc | FileCheck 
%/t/definition.jsonrpc --check-prefixes=CHECK,BUILD
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.cache/clangd/index/foo.cpp.*.idx
-# RUN: ls %t/sub_dir/.cache/clangd/index/foo.h.*.idx
+# RUN: ls %/t/.cache/clangd/index/foo.cpp.*.idx
+# RUN: ls %/t/sub_dir/.cache/clangd/index/foo.h.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
-# RUN: rm %t/foo.cpp
-# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck 
%t/definition.jsonrpc --check-prefixes=CHECK,USE
+# RUN: rm %/t/foo.cpp
+# RUN: clangd -background-index -lit-test < %/t/definition.jsonrpc | FileCheck 
%/t/definition.jsonrpc --check-prefixes=CHECK,USE


Index: clang-tools-extra/clangd/test/test-uri-windows.test
===
--- clang-tools-extra/clangd/test/test-uri-windows.test
+++ clang-tools-extra/clangd/test/test-uri-windows.test
@@ -1,5 +1,5 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
-# REQUIRES: windows-gnu || windows-msvc
+# UNSUPPORTED: !(windows-gnu || windows-msvc)
 # Test authority-less URI
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}

[clang-tools-extra] 98b56c0 - [clangd] Fixes in lit tests

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

Author: Aleksandr Platonov
Date: 2020-07-22T16:00:34+03:00
New Revision: 98b56c09be002855df18dada7debdb1322aad7d9

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

LOG: [clangd] Fixes in lit tests

Summary:
Changes:
- `background-index.test` Add Windows support, don't create redundant `*-e` 
files on macOS
- `did-change-configuration-params.test` Replace `cat | FileCheck` with 
`FileCheck --input-file`
- `test-uri-windows.test` This test did not run on Windows displite `REQUIRES: 
windows-gnu || windows-msvc` (replacement: `UNSUPPORTED: !(windows-gnu || 
windows-msvc)`).

Reviewers: sammccall, kadircet

Reviewed By: kadircet

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

Tags: #clang

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

Added: 

clang-tools-extra/clangd/test/Inputs/background-index/compile_commands.json.tmpl

clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc.tmpl

Modified: 
clang-tools-extra/clangd/test/background-index.test
clang-tools-extra/clangd/test/did-change-configuration-params.test
clang-tools-extra/clangd/test/test-uri-windows.test

Removed: 
clang-tools-extra/clangd/test/Inputs/background-index/compile_commands.json
clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc



diff  --git 
a/clang-tools-extra/clangd/test/Inputs/background-index/compile_commands.json 
b/clang-tools-extra/clangd/test/Inputs/background-index/compile_commands.json.tmpl
similarity index 100%
rename from 
clang-tools-extra/clangd/test/Inputs/background-index/compile_commands.json
rename to 
clang-tools-extra/clangd/test/Inputs/background-index/compile_commands.json.tmpl

diff  --git 
a/clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc 
b/clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc.tmpl
similarity index 100%
rename from 
clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc
rename to 
clang-tools-extra/clangd/test/Inputs/background-index/definition.jsonrpc.tmpl

diff  --git a/clang-tools-extra/clangd/test/background-index.test 
b/clang-tools-extra/clangd/test/background-index.test
index 41184443e947..1983f0957dcc 100644
--- a/clang-tools-extra/clangd/test/background-index.test
+++ b/clang-tools-extra/clangd/test/background-index.test
@@ -1,23 +1,23 @@
-# We need to splice paths into file:// URIs for this test.
-# UNSUPPORTED: windows-msvc
-
 # Use a copy of inputs, as we'll mutate it (as will the background index).
-# RUN: rm -rf %t
-# RUN: cp -r %S/Inputs/background-index %t
+# RUN: rm -rf %/t
+# RUN: cp -r %/S/Inputs/background-index %/t
 # Need to embed the correct temp path in the actual JSON-RPC requests.
-# RUN: sed -i -e "s|DIRECTORY|%t|" %t/definition.jsonrpc
-# RUN: sed -i -e "s|DIRECTORY|%t|" %t/compile_commands.json
+# RUN: sed -e "s|DIRECTORY|%/t|" %/t/definition.jsonrpc.tmpl > 
%/t/definition.jsonrpc.1
+# RUN: sed -e "s|DIRECTORY|%/t|" %/t/compile_commands.json.tmpl > 
%/t/compile_commands.json
+# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
+# (with the extra slash in the front), so we add it here.
+# RUN: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' 
%/t/definition.jsonrpc.1 > %/t/definition.jsonrpc
 
 # We're editing bar.cpp, which includes foo.h.
 # foo() is declared in foo.h and defined in foo.cpp.
 # The background index should allow us to go-to-definition on foo().
 # We should also see indexing progress notifications.
-# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck 
%t/definition.jsonrpc --check-prefixes=CHECK,BUILD
+# RUN: clangd -background-index -lit-test < %/t/definition.jsonrpc | FileCheck 
%/t/definition.jsonrpc --check-prefixes=CHECK,BUILD
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.cache/clangd/index/foo.cpp.*.idx
-# RUN: ls %t/sub_dir/.cache/clangd/index/foo.h.*.idx
+# RUN: ls %/t/.cache/clangd/index/foo.cpp.*.idx
+# RUN: ls %/t/sub_dir/.cache/clangd/index/foo.h.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
-# RUN: rm %t/foo.cpp
-# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck 
%t/definition.jsonrpc --check-prefixes=CHECK,USE
+# RUN: rm %/t/foo.cpp
+# RUN: clangd -background-index -lit-test < %/t/definition.jsonrpc | FileCheck 
%/t/definition.jsonrpc --check-prefixes=CHECK,USE

diff  --git 
a/clang-tools-extra/clangd/test/did-change-configuration-params.test 
b/clang-tools-extra/clangd/test/did-change-configuration-params.test
index 4aef1011b370..19d41d0812e2 100644
--- a/clang-tools-extra/clangd/test/did-change-configuration-params.test
+++ b/clang-tools-extra/clangd/test/did-change-conf

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

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

In D83261#2162561 , @ABataev wrote:

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


Note that that having a separate object defeats the purpose of 
`TrailingObjects` of having just a single allocation per AST node. If we do 
separate objects, we could also have member pointers to arrays.

In D83261#2164929 , @ABataev wrote:

> Sure, we can make `OMPChildren` common for declarative and executable 
> directives. Do you want me to do it?


Yes, I think it would increase its usefulness and remove code duplication of 
handling clauses.

>>> There should be an additional patch, which, I hope, should simplify things 
>>> for loop-based directives.
>> 
>> OK. What does this patch do? Are you going to upload it as well?
> 
> At first, need to deal with this one, at least come to an agreement with the 
> design.

The reviewer list is surprisingly small. Aren't there any others with stakes in 
the class hierarchy?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83261



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


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

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

In D83261#2166766 , @Meinersbur wrote:

> In D83261#2162561 , @ABataev wrote:
>
> > 1. OMPChildren class uses standard TrailingObjects harness instead of 
> > manual calculation.
>
>
> Note that that having a separate object defeats the purpose of 
> `TrailingObjects` of having just a single allocation per AST node. If we do 
> separate objects, we could also have member pointers to arrays.


I know. Will check what I can do about it.

> 
> 
> In D83261#2164929 , @ABataev wrote:
> 
>> Sure, we can make `OMPChildren` common for declarative and executable 
>> directives. Do you want me to do it?
> 
> 
> Yes, I think it would increase its usefulness and remove code duplication of 
> handling clauses.
> 
 There should be an additional patch, which, I hope, should simplify things 
 for loop-based directives.
>>> 
>>> OK. What does this patch do? Are you going to upload it as well?
>> 
>> At first, need to deal with this one, at least come to an agreement with the 
>> design.
> 
> The reviewer list is surprisingly small. Aren't there any others with stakes 
> in the class hierarchy?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83261



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


[PATCH] D84322: [AST][RecoveryExpr] Suppress spurious "typecheck_cond_expect_scalar" diagnostic

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84322

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/error-dependence.c


Index: clang/test/Sema/error-dependence.c
===
--- clang/test/Sema/error-dependence.c
+++ clang/test/Sema/error-dependence.c
@@ -11,3 +11,9 @@
   // or function pointer" is not emitted.
   (*__builtin_classify_type)(1); // expected-error {{builtin functions must be 
directly called}}
 }
+
+void test2(int* ptr, float f) {
+  // verify diagnostic "used type '' where arithmetic or 
pointer
+  // type is required" is not emitted.
+  ptr > f ? ptr : f; // expected-error {{invalid operands to binary 
expression}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8071,6 +8071,16 @@
   VK = VK_RValue;
   OK = OK_Ordinary;
 
+  if (getLangOpts().CDependence &&
+  (Cond.get()->isTypeDependent() || LHS.get()->isTypeDependent() ||
+   RHS.get()->isTypeDependent())) {
+assert(!getLangOpts().CPlusPlus);
+assert(Cond.get()->containsErrors() || LHS.get()->containsErrors() ||
+   RHS.get()->containsErrors() &&
+   "should only occur in error-recovery path.");
+return Context.DependentTy;
+  }
+
   // The OpenCL operator with a vector condition is sufficiently
   // different to merit its own checker.
   if ((getLangOpts().OpenCL && Cond.get()->getType()->isVectorType()) ||


Index: clang/test/Sema/error-dependence.c
===
--- clang/test/Sema/error-dependence.c
+++ clang/test/Sema/error-dependence.c
@@ -11,3 +11,9 @@
   // or function pointer" is not emitted.
   (*__builtin_classify_type)(1); // expected-error {{builtin functions must be directly called}}
 }
+
+void test2(int* ptr, float f) {
+  // verify diagnostic "used type '' where arithmetic or pointer
+  // type is required" is not emitted.
+  ptr > f ? ptr : f; // expected-error {{invalid operands to binary expression}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8071,6 +8071,16 @@
   VK = VK_RValue;
   OK = OK_Ordinary;
 
+  if (getLangOpts().CDependence &&
+  (Cond.get()->isTypeDependent() || LHS.get()->isTypeDependent() ||
+   RHS.get()->isTypeDependent())) {
+assert(!getLangOpts().CPlusPlus);
+assert(Cond.get()->containsErrors() || LHS.get()->containsErrors() ||
+   RHS.get()->containsErrors() &&
+   "should only occur in error-recovery path.");
+return Context.DependentTy;
+  }
+
   // The OpenCL operator with a vector condition is sufficiently
   // different to merit its own checker.
   if ((getLangOpts().OpenCL && Cond.get()->getType()->isVectorType()) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83961: [Analyzer] Fix bug report source locations in minimal output.

2020-07-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: clang/test/Analysis/malloc-plist.c:137-139
 if (y)
-y++;
-}//expected-warning{{Potential leak}}
+  y++; //expected-warning{{Potential leak}}
+}

NoQ wrote:
> This sounds like an expected change: we're now displaying the same report on 
> a different path. Except it's the longer path rather than the shorter path, 
> so it still looks suspicious.
This location may be wrong but it is then another problem. The important thing 
is that after this patch the same location is used for a warning in 
`text-minimal` mode as it is in `text` mode. Without the patch in 
`text-minimal` mode a different location is used for this warning, the one at 
the end of the function. But still in `text` mode (without the patch) the 
location at `y++` is shown. (The warning in function `function_with_leak4` in 
the same test is already at a similar location, not at the end of function.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83961



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


[PATCH] D84322: [AST][RecoveryExpr] Suppress spurious "typecheck_cond_expect_scalar" diagnostic

2020-07-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:8076
+  (Cond.get()->isTypeDependent() || LHS.get()->isTypeDependent() ||
+   RHS.get()->isTypeDependent())) {
+assert(!getLangOpts().CPlusPlus);

This follows the same way of how C++ codepath handles dependent code, see the 
above  Line 8069 
[CXXCheckConditionalOperands](https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaExprCXX.cpp#L6028-L6047).



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84322



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


[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2020-07-22 Thread Lingda Li via Phabricator via cfe-commits
lildmh added a comment.

In D67833#2166478 , @protze.joachim 
wrote:

> Starting with the commit of this patch, the libomptarget test 
> `llvm-project/openmp/libomptarget/test/offloading/target_depend_nowait.cpp` 
> fails. Here is a stacktrace of the segfault:
>
>   $ gdb target_depend_nowait.cpp.tmp-x86_64-pc-linux-gnu
>   (gdb) run
>   ...
>   Program received signal SIGSEGV, Segmentation fault.
>   (gdb) bt
>   #0  0x00400fcf in .omp_outlined._debug__ 
> (.global_tid.=0x2aaab96b9be0, .bound_tid.=0x2aaab96b9bd8) at 
> target_depend_nowait.cpp:22
>   #1  0x00401e8d in .omp_outlined..23 (.global_tid.=0x2aaab96b9be0, 
> .bound_tid.=0x2aaab96b9bd8) at target_depend_nowait.cpp:18
>   #2  0x2b574213 in __kmp_invoke_microtask () from libomp.so
>   #3  0x2b51338e in __kmp_invoke_task_func () from libomp.so
>   #4  0x2b5126bf in __kmp_launch_thread () from libomp.so
>   #5  0x2b55d3d0 in __kmp_launch_worker(void*) () from libomp.so
>   #6  0x2bbd6e65 in start_thread () from libpthread.so.0
>   #7  0x2bee988d in clone () from libc.so.6
>


Thanks. If possible, could you send me an IR generated before this patch and 
one after this patch, so I can probably see the problem?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67833



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


[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis

2020-07-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

I'd like to see some testcases for the C++ side of this. The following things 
all seem like they might be interesting: passing and returning classes and 
unions, especially ones that aren't trivially-copyable, `nullptr_t`, pointers 
to members, `this` parameters, VTTs, the "complete object" flag for MS ABI 
constructors, the `this` return from constructors in the ARM ABI, parameters 
and return values of virtual adjustment thunks.




Comment at: clang/lib/CodeGen/CGCall.cpp:1892
+return true;
+  if (QTy->isScalarType()) {
+if (const ComplexType *Complex = dyn_cast(QTy))

This includes `nullptr_t` (which is never ` noundef`) and member pointers 
(which are sometimes `noundef`, and you'll need to ask the `CXXABI` 
implementation if you don't want to conservatively return `false`).



Comment at: clang/lib/CodeGen/CGCall.cpp:2110
+  DetermineNoUndef(RetTy, getTypes(), DL, RetAI)) {
+RetAttrs.addAttribute(llvm::Attribute::NoUndef);
+  }

This only applies in C++. In C, it's valid for a function to omit its `return` 
statement if the result value is unused, and in that case the returned value 
will legitimately be `undef`.

Even in C++, we're conservative about enforcing the constraint that functions 
return a proper value and control flow doesn't just fall off the bottom of the 
function. See the full set of checks here: 
https://github.com/llvm/llvm-project/blob/master/clang/lib/CodeGen/CodeGenFunction.cpp#L1322


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis

2020-07-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2110
+  DetermineNoUndef(RetTy, getTypes(), DL, RetAI)) {
+RetAttrs.addAttribute(llvm::Attribute::NoUndef);
+  }

rsmith wrote:
> This only applies in C++. In C, it's valid for a function to omit its 
> `return` statement if the result value is unused, and in that case the 
> returned value will legitimately be `undef`.
> 
> Even in C++, we're conservative about enforcing the constraint that functions 
> return a proper value and control flow doesn't just fall off the bottom of 
> the function. See the full set of checks here: 
> https://github.com/llvm/llvm-project/blob/master/clang/lib/CodeGen/CodeGenFunction.cpp#L1322
It would seem sensible to suppress this for `extern "C"` functions too, on the 
basis that the definition of such functions is probably in C code, and thus 
they might return `undef`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D83961: [Analyzer] Fix bug report source locations in minimal output.

2020-07-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Every other test failure comes from RetainCount checker except 
//malloc-plist.c//.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83961



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


[PATCH] D83660: [analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConstraintManager.h.

2020-07-22 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Although I'm not the most experienced one here, I think it's good to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83660



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


[clang] b99898c - Fix target specific InstCombine

2020-07-22 Thread Sebastian Neubauer via cfe-commits

Author: Sebastian Neubauer
Date: 2020-07-22T17:00:46+02:00
New Revision: b99898c1e9c5d8bade1d898e84604d3241b0087c

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

LOG: Fix target specific InstCombine

A clang arm test was failing if clang is compiled without arm support.

Regression was introduced in 2a6c871596ce8bdd23501a96fd22f0f16d3cfcad

Added: 


Modified: 
clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c 
b/clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c
index 2ccfb0ca34c3..6772c37c9723 100644
--- a/clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c
+++ b/clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c
@@ -3,6 +3,8 @@
 // RUN: %clang_cc1 -triple armv8.6a-arm-none-eabi -target-feature +neon 
-target-feature +bf16 -mfloat-abi hard \
 // RUN:  -O2 -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK32
 
+// REQUIRES: arm-registered-target,aarch64-registered-target
+
 #include "arm_neon.h"
 
 bfloat16x4_t test_vld1_bf16(bfloat16_t const *ptr) {



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


[clang] 238bbd4 - Revert abd45154b "[Coverage] Add comment to skipped regions"

2020-07-22 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-22T17:09:20+02:00
New Revision: 238bbd48c5a5f84deca36e5df980241578f7c1df

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

LOG: Revert abd45154b "[Coverage] Add comment to skipped regions"

This casued assertions during Chromium builds. See comment on the code review

> Bug filled here: https://bugs.llvm.org/show_bug.cgi?id=45757.
> Add comment to skipped regions so we don't track execution count for lines 
> containing only comments.
>
> Differential Revision: https://reviews.llvm.org/D84208

This reverts commit abd45154bdb6b76c5b480455eacc8c75b08242aa and the
follow-up 87d725473380652bbe845fd2fbd9c0507a55172f.

Added: 


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

Removed: 
compiler-rt/test/profile/coverage_comments.cpp



diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index b0dd363555ab..5cd017fa925f 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -419,9 +419,6 @@ class Preprocessor {
   /// The number of (LexLevel 0) preprocessor tokens.
   unsigned TokenCount = 0;
 
-  /// Preprocess every token regardless of LexLevel.
-  bool PreprocessToken = false;
-
   /// The maximum number of (LexLevel 0) tokens before issuing a -Wmax-tokens
   /// warning, or zero for unlimited.
   unsigned MaxTokens = 0;
@@ -1041,8 +1038,6 @@ class Preprocessor {
 OnToken = std::move(F);
   }
 
-  void setPreprocessToken(bool Preprocess) { PreprocessToken = Preprocess; }
-
   bool isMacroDefined(StringRef Id) {
 return isMacroDefined(&Identifiers.get(Id));
   }

diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 5a6ce0f5dbd5..55925110708e 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -990,9 +990,11 @@ CodeGenAction::CreateASTConsumer(CompilerInstance &CI, 
StringRef InFile) {
 
   CoverageSourceInfo *CoverageInfo = nullptr;
   // Add the preprocessor callback only when the coverage mapping is generated.
-  if (CI.getCodeGenOpts().CoverageMapping)
-CoverageInfo = CodeGen::CoverageMappingModuleGen::setUpCoverageCallbacks(
-CI.getPreprocessor());
+  if (CI.getCodeGenOpts().CoverageMapping) {
+CoverageInfo = new CoverageSourceInfo;
+CI.getPreprocessor().addPPCallbacks(
+
std::unique_ptr(CoverageInfo));
+  }
 
   std::unique_ptr Result(new BackendConsumer(
   BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),

diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 6729c7f381f5..78b268f423cb 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -35,40 +35,8 @@ using namespace clang;
 using namespace CodeGen;
 using namespace llvm::coverage;
 
-CoverageSourceInfo *
-CoverageMappingModuleGen::setUpCoverageCallbacks(Preprocessor &PP) {
-  CoverageSourceInfo *CoverageInfo = new CoverageSourceInfo;
-  PP.addPPCallbacks(std::unique_ptr(CoverageInfo));
-  PP.addCommentHandler(CoverageInfo);
-  PP.setPreprocessToken(true);
-  PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
-// Update previous token location.
-CoverageInfo->PrevTokLoc =

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

2020-07-22 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

This caused asserts in Chromium's coverage builds: 
https://bugs.chromium.org/p/chromium/issues/detail?id=1108352
I've reverted it in the meantime (238bbd48c5a5f84deca36e5df980241578f7c1df 
).

It also looks like the commit landed with the wrong Phabricator review number.


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

https://reviews.llvm.org/D83592



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


[clang] 89e61e7 - [Sema][AArch64] Add semantics for arm_sve_vector_bits attribute

2020-07-22 Thread Cullen Rhodes via cfe-commits

Author: Cullen Rhodes
Date: 2020-07-22T16:26:23Z
New Revision: 89e61e782b7366083efc6a3c8c54602ddf2dfe8b

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

LOG: [Sema][AArch64] Add semantics for arm_sve_vector_bits attribute

Summary:
This patch implements semantics for the 'arm_sve_vector_bits' type
attribute, defined by the Arm C Language Extensions (ACLE) for SVE [1].
The purpose of this attribute is to define fixed-length (VLST) versions
of existing sizeless types (VLAT).

Implemented in this patch is the the behaviour described in section 3.7.3.2
and minimal parts of sections 3.7.3.3 and 3.7.3.4, this includes:

* Defining VLST globals, structs, unions, and local variables
* Implicit casting between VLAT <=> VLST.
* Diagnosis of ill-formed conditional expressions of the form:

C ?  E1 : E2

  where E1 is a VLAT type and E2 is a VLST, or vice-versa. This
  avoids any ambiguity about the nature of the result type (i.e is
  it sized or sizeless).
* For vectors:
* sizeof(VLST) == N/8
* alignof(VLST) == 16
* For predicates:
* sizeof(VLST) == N/64
* alignof(VLST) == 2

VLSTs have the same representation as VLATs in the AST but are wrapped
with a TypeAttribute. Scalable types are currently emitted in the IR for
uses such as globals and structs which don't support these types, this
is addressed in the next patch with codegen, where VLSTs are lowered to
sized arrays for globals, structs / unions and arrays.

Not implemented in this patch is the behaviour guarded by the feature
macros:

* __ARM_FEATURE_SVE_VECTOR_OPERATORS
* __ARM_FEATURE_SVE_PREDICATE_OPERATORS

As such, the GNU __attribute__((vector_size)) extension is not available
and operators such as binary '+' are not supported for VLSTs. Support
for this is intended to be addressed by later patches.

[1] https://developer.arm.com/documentation/100987/latest

This is patch 2/4 of a patch series.

Reviewers: sdesmalen, rsandifo-arm, efriedma, cameron.mcinally, ctetreau, 
rengolin, aaron.ballman

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Type.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Sema/attr-arm-sve-vector-bits.c

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 2b988be60da9..59e2679ddded 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2086,6 +2086,10 @@ class ASTContext : public RefCountedBase {
 return getTypeSizeInCharsIfKnown(QualType(Ty, 0));
   }
 
+  /// Returns the bitwidth of \p T, an SVE type attributed with
+  /// 'arm_sve_vector_bits'. Should only be called if T->isVLST().
+  unsigned getBitwidthForAttributedSveType(const Type *T) const;
+
   /// Return the ABI-specified alignment of a (complete) type \p T, in
   /// bits.
   unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; }

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 131658fbc8c4..9a745ef20fac 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1925,6 +1925,9 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
   bool isSizelessType() const;
   bool isSizelessBuiltinType() const;
 
+  /// Determines if this is a vector-length-specific type (VLST), i.e. a
+  /// sizeless type with the 'arm_sve_vector_bits' attribute applied.
+  bool isVLST() const;
   /// Determines if this is a sizeless type supported by the
   /// 'arm_sve_vector_bits' type attribute, which can be applied to a single
   /// SVE vector or predicate, excluding tuple types such as svint32x4_t.

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 8e0c57bd2efd..0ee3c5188563 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1534,8 +1534,10 @@ def NeonVectorType : TypeAttr {
 
 def ArmSveVectorBits : TypeAttr {
   let Spellings = [GNU<"arm_sve_vector_bits">];
-  let Args = [IntArgument<"NumBits">];
+  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
+  let Args = [UnsignedArgument<"NumBits">];
   let Documentation = [ArmSveVectorBitsDocs];
+  let PragmaAttributeSupport = 0;
 }
 
 def ArmMveStrictPolymorphism : TypeAttr, TargetSpecificAttr {

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 06cb0b1b8bdc..376765dc1138 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.

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

2020-07-22 Thread Cullen Rhodes via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG89e61e782b73: [Sema][AArch64] Add semantics for 
arm_sve_vector_bits attribute (authored by c-rhodes).

Changed prior to commit:
  https://reviews.llvm.org/D83551?vs=278430&id=279097#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83551

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/attr-arm-sve-vector-bits.c

Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -60,3 +60,168 @@
 typedef float badtype3 __attribute__((arm_sve_vector_bits(N))); // expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'float'}}
 typedef svint8x2_t badtype4 __attribute__((arm_sve_vector_bits(N)));// expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'svint8x2_t' (aka '__clang_svint8x2_t')}}
 typedef svfloat32x3_t badtype5 __attribute__((arm_sve_vector_bits(N))); // expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'svfloat32x3_t' (aka '__clang_svfloat32x3_t')}}
+
+// Attribute only applies to typedefs.
+svint8_t non_typedef_type __attribute__((arm_sve_vector_bits(N)));  // expected-error {{'arm_sve_vector_bits' attribute only applies to typedefs}}
+
+// Test that we can define non-local fixed-length SVE types (unsupported for
+// sizeless types).
+fixed_int8_t global_int8;
+fixed_bfloat16_t global_bfloat16;
+fixed_bool_t global_bool;
+
+extern fixed_int8_t extern_int8;
+extern fixed_bfloat16_t extern_bfloat16;
+extern fixed_bool_t extern_bool;
+
+static fixed_int8_t static_int8;
+static fixed_bfloat16_t static_bfloat16;
+static fixed_bool_t static_bool;
+
+fixed_int8_t *global_int8_ptr;
+extern fixed_int8_t *extern_int8_ptr;
+static fixed_int8_t *static_int8_ptr;
+__thread fixed_int8_t thread_int8;
+
+typedef fixed_int8_t int8_typedef;
+typedef fixed_int8_t *int8_ptr_typedef;
+
+// Test sized expressions
+int sizeof_int8 = sizeof(global_int8);
+int sizeof_int8_var = sizeof(*global_int8_ptr);
+int sizeof_int8_var_ptr = sizeof(global_int8_ptr);
+
+extern fixed_int8_t *extern_int8_ptr;
+
+int alignof_int8 = __alignof__(extern_int8);
+int alignof_int8_var = __alignof__(*extern_int8_ptr);
+int alignof_int8_var_ptr = __alignof__(extern_int8_ptr);
+
+void f(int c) {
+  fixed_int8_t fs8;
+  svint8_t ss8;
+
+  void *sel __attribute__((unused));
+  sel = c ? ss8 : fs8; // expected-error {{incompatible operand types ('svint8_t' (aka '__SVInt8_t') and 'fixed_int8_t' (aka '__SVInt8_t'))}}
+  sel = c ? fs8 : ss8; // expected-error {{incompatible operand types ('fixed_int8_t' (aka '__SVInt8_t') and 'svint8_t' (aka '__SVInt8_t'))}}
+}
+
+// --//
+// Sizeof
+
+#define VECTOR_SIZE ((N / 8))
+#define PRED_SIZE ((N / 64))
+
+_Static_assert(sizeof(fixed_int8_t) == VECTOR_SIZE, "");
+
+_Static_assert(sizeof(fixed_int16_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_int32_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_int64_t) == VECTOR_SIZE, "");
+
+_Static_assert(sizeof(fixed_uint8_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_uint16_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_uint32_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_uint64_t) == VECTOR_SIZE, "");
+
+_Static_assert(sizeof(fixed_float16_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_float32_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_float64_t) == VECTOR_SIZE, "");
+
+_Static_assert(sizeof(fixed_bfloat16_t) == VECTOR_SIZE, "");
+
+_Static_assert(sizeof(fixed_bool_t) == PRED_SIZE, "");
+
+// --//
+// Alignof
+
+#define VECTOR_ALIGN 16
+#define PRED_ALIGN 2
+
+_Static_assert(__alignof__(fixed_int8_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_int16_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_int32_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_int64_t) == VECTOR_ALIGN, "");
+
+_Static_assert(__alignof__(fixed_uint8_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_uint16_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_uint32_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_uint64_t) == VECTOR_ALIGN, "");
+
+_Static_assert(__alignof__(fixed_float16_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_float32_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_float64_t) == VECTOR_ALIGN, "");
+

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

2020-07-22 Thread Cullen Rhodes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG89e61e782b73: [Sema][AArch64] Add semantics for 
arm_sve_vector_bits attribute (authored by c-rhodes).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83551

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/attr-arm-sve-vector-bits.c

Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -60,3 +60,168 @@
 typedef float badtype3 __attribute__((arm_sve_vector_bits(N))); // expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'float'}}
 typedef svint8x2_t badtype4 __attribute__((arm_sve_vector_bits(N)));// expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'svint8x2_t' (aka '__clang_svint8x2_t')}}
 typedef svfloat32x3_t badtype5 __attribute__((arm_sve_vector_bits(N))); // expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'svfloat32x3_t' (aka '__clang_svfloat32x3_t')}}
+
+// Attribute only applies to typedefs.
+svint8_t non_typedef_type __attribute__((arm_sve_vector_bits(N)));  // expected-error {{'arm_sve_vector_bits' attribute only applies to typedefs}}
+
+// Test that we can define non-local fixed-length SVE types (unsupported for
+// sizeless types).
+fixed_int8_t global_int8;
+fixed_bfloat16_t global_bfloat16;
+fixed_bool_t global_bool;
+
+extern fixed_int8_t extern_int8;
+extern fixed_bfloat16_t extern_bfloat16;
+extern fixed_bool_t extern_bool;
+
+static fixed_int8_t static_int8;
+static fixed_bfloat16_t static_bfloat16;
+static fixed_bool_t static_bool;
+
+fixed_int8_t *global_int8_ptr;
+extern fixed_int8_t *extern_int8_ptr;
+static fixed_int8_t *static_int8_ptr;
+__thread fixed_int8_t thread_int8;
+
+typedef fixed_int8_t int8_typedef;
+typedef fixed_int8_t *int8_ptr_typedef;
+
+// Test sized expressions
+int sizeof_int8 = sizeof(global_int8);
+int sizeof_int8_var = sizeof(*global_int8_ptr);
+int sizeof_int8_var_ptr = sizeof(global_int8_ptr);
+
+extern fixed_int8_t *extern_int8_ptr;
+
+int alignof_int8 = __alignof__(extern_int8);
+int alignof_int8_var = __alignof__(*extern_int8_ptr);
+int alignof_int8_var_ptr = __alignof__(extern_int8_ptr);
+
+void f(int c) {
+  fixed_int8_t fs8;
+  svint8_t ss8;
+
+  void *sel __attribute__((unused));
+  sel = c ? ss8 : fs8; // expected-error {{incompatible operand types ('svint8_t' (aka '__SVInt8_t') and 'fixed_int8_t' (aka '__SVInt8_t'))}}
+  sel = c ? fs8 : ss8; // expected-error {{incompatible operand types ('fixed_int8_t' (aka '__SVInt8_t') and 'svint8_t' (aka '__SVInt8_t'))}}
+}
+
+// --//
+// Sizeof
+
+#define VECTOR_SIZE ((N / 8))
+#define PRED_SIZE ((N / 64))
+
+_Static_assert(sizeof(fixed_int8_t) == VECTOR_SIZE, "");
+
+_Static_assert(sizeof(fixed_int16_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_int32_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_int64_t) == VECTOR_SIZE, "");
+
+_Static_assert(sizeof(fixed_uint8_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_uint16_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_uint32_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_uint64_t) == VECTOR_SIZE, "");
+
+_Static_assert(sizeof(fixed_float16_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_float32_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_float64_t) == VECTOR_SIZE, "");
+
+_Static_assert(sizeof(fixed_bfloat16_t) == VECTOR_SIZE, "");
+
+_Static_assert(sizeof(fixed_bool_t) == PRED_SIZE, "");
+
+// --//
+// Alignof
+
+#define VECTOR_ALIGN 16
+#define PRED_ALIGN 2
+
+_Static_assert(__alignof__(fixed_int8_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_int16_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_int32_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_int64_t) == VECTOR_ALIGN, "");
+
+_Static_assert(__alignof__(fixed_uint8_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_uint16_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_uint32_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_uint64_t) == VECTOR_ALIGN, "");
+
+_Static_assert(__alignof__(fixed_float16_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_float32_t) == VECTOR_ALIGN, "");
+_Static_assert(__alignof__(fixed_float64_t) == VECTOR_ALIGN, "");
+
+_Static_assert(__alignof__(fixed_bfloat16_t) == VECTOR_ALIGN, "");
+
+_Static_assert(__alignof__(fixed_bool_t) == PRED_ALIGN, "");
+
+// 

[PATCH] D84048: DR2303: Prefer 'nearer' base classes during template deduction.

2020-07-22 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 279847.
erichkeane marked an inline comment as done.
erichkeane added a comment.

As CWG seems unmoved by my argument as to why CWG2303 should change, I've opted 
to implement it as worded.  As you can see, the implementation is somewhat more 
complicated, but I believe I made it at least reasonably understandable.

I've also now updated the cwg_dr_status.html file via the script, which I also 
updated to acknowledge the current released version.


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

https://reviews.llvm.org/D84048

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/drs/dr23xx.cpp
  clang/www/cxx_dr_status.html
  clang/www/make_cxx_dr_status

Index: clang/www/make_cxx_dr_status
===
--- clang/www/make_cxx_dr_status
+++ clang/www/make_cxx_dr_status
@@ -1,4 +1,5 @@
 #! /usr/bin/env python
+
 import sys, os, re
 
 index = 'cwg_index.html'
@@ -93,7 +94,7 @@
 Available in Clang?
   '''
 
-latest_release = 10
+latest_release = 11
 
 def availability(issue):
   status = status_map.get(issue, 'unknown')
Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1504,7 +1504,7 @@
 https://wg21.link/cwg244";>244
 CD1
 Destructor lookup
-Clang 11
+Clang 11
   
   
 https://wg21.link/cwg245";>245
@@ -2789,7 +2789,7 @@
 https://wg21.link/cwg458";>458
 C++11
 Hiding of member template parameters by other members
-Clang 11
+Clang 11
   
   
 https://wg21.link/cwg459";>459
@@ -3967,7 +3967,7 @@
 https://wg21.link/cwg654";>654
 CD1
 Conversions to and from nullptr_t
-Superseded by 1423
+Superseded by 1423
   
   
 https://wg21.link/cwg655";>655
@@ -8353,7 +8353,7 @@
 https://wg21.link/cwg1423";>1423
 CD3
 Convertibility of nullptr to bool
-Clang 11
+Clang 11
   
   
 https://wg21.link/cwg1424";>1424
@@ -8899,7 +8899,7 @@
 https://wg21.link/cwg1514";>1514
 C++14
 Ambiguity between enumeration definition and zero-length bit-field
-Clang 11
+Clang 11
   
   
 https://wg21.link/cwg1515";>1515
@@ -10333,7 +10333,7 @@
 https://wg21.link/cwg1753";>1753
 CD4
 decltype-specifier in nested-name-specifier of destructor
-Clang 11
+Clang 11
   
   
 https://wg21.link/cwg1754";>1754
@@ -11611,7 +11611,7 @@
 https://wg21.link/cwg1966";>1966
 CD4
 Colon following enumeration elaborated-type-specifier
-Clang 11
+Clang 11
   
   
 https://wg21.link/cwg1967";>1967
@@ -11971,7 +11971,7 @@
 https://wg21.link/cwg2026";>2026
 CD4
 Zero-initialization and constexpr
-Clang 11
+Clang 11
   
   
 https://wg21.link/cwg2027";>2027
@@ -12307,7 +12307,7 @@
 https://wg21.link/cwg2082";>2082
 CD4
 Referring to parameters in unevaluated operands of default arguments
-Clang 11
+Clang 11
   
   
 https://wg21.link/cwg2083";>2083
@@ -12757,7 +12757,7 @@
 https://wg21.link/cwg2157";>2157
 CD4
 Further disambiguation of enumeration elaborated-type-specifier
-Clang 11
+Clang 11
   
   
 https://wg21.link/cwg2158";>2158
@@ -13213,7 +13213,7 @@
 https://wg21.link/cwg2233";>2233
 DRWP
 Function parameter packs following default arguments
-Clang 11
+Clang 11
   
   
 https://wg21.link/cwg2234";>2234
@@ -13633,7 +13633,7 @@
 https://wg21.link/cwg2303";>2303
 DRWP
 Partial ordering and recursive variadic inheritance
-Unknown
+Clang 12
   
   
 https://wg21.link/cwg2304";>2304
@@ -13891,7 +13891,7 @@
 https://wg21.link/cwg2346";>2346
 DRWP
 Local variables in default arguments
-Clang 11
+Clang 11
   
   
 https://wg21.link/cwg2347";>2347
@@ -14499,6 +14499,24 @@
 Unintended description of abbreviated function templates
 Unknown
   
+  
+https://wg21.link/cwg2448";>2448
+open
+Cv-qualification of arithmetic types and deprecation of volatile
+Not resolved
+  
+  
+https://wg21.link/cwg2449";>2449
+open
+Thunks as an implementation technique for pointers to virtual functions
+Not resolved
+  
+  
+https://wg21.link/cwg2450";>2450
+open
+braced-init-list as a template-argument
+Not resolved
+  
 
 
 
Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -113,3 +113,35 @@
   extern template const int d;
 #endif
 }
+
+#if __cplusplus >= 201103L
+namespace dr2303 { // dr2303: 12
+template 
+struct A;
+template <>
+struct A<> {};
+template 
+struct A : A {};
+struct B : A {};
+struct C : A, A {}; // expected-warning {{direct base 'A' is inaccessible}}
+struct D : A, A {}; // expected-warning {{direct base 'A' is inaccessible}}
+stru

[PATCH] D78491: Avoid relying on address space zero default parameter in llvm/IR

2020-07-22 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 279861.
arichardson added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78491

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.h
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/CodeGen/MachineMemOperand.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/DerivedTypes.h
  llvm/include/llvm/IR/Function.h
  llvm/include/llvm/IR/GlobalObject.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Type.h
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/ConstantsContext.h
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/InlineAsm.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Mangler.cpp

Index: llvm/lib/IR/Mangler.cpp
===
--- llvm/lib/IR/Mangler.cpp
+++ llvm/lib/IR/Mangler.cpp
@@ -95,7 +95,7 @@
   // Calculate arguments size total.
   unsigned ArgWords = 0;
 
-  const unsigned PtrSize = DL.getPointerSize();
+  const unsigned PtrSize = DL.getPointerSize(0);
 
   for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
AI != AE; ++AI) {
Index: llvm/lib/IR/Instructions.cpp
===
--- llvm/lib/IR/Instructions.cpp
+++ llvm/lib/IR/Instructions.cpp
@@ -621,12 +621,14 @@
   // Create the call to Malloc.
   BasicBlock *BB = InsertBefore ? InsertBefore->getParent() : InsertAtEnd;
   Module *M = BB->getParent()->getParent();
-  Type *BPTy = Type::getInt8PtrTy(BB->getContext());
+  Type *BPTy = Type::getInt8PtrTy(
+  BB->getContext(), M->getDataLayout().getDefaultGlobalsAddressSpace());
   FunctionCallee MallocFunc = MallocF;
   if (!MallocFunc)
 // prototype malloc as "void *malloc(size_t)"
 MallocFunc = M->getOrInsertFunction("malloc", BPTy, IntPtrTy);
-  PointerType *AllocPtrType = PointerType::getUnqual(AllocTy);
+  PointerType *AllocPtrType = AllocTy->getPointerTo(
+  MallocFunc.getFunctionType()->getReturnType()->getPointerAddressSpace());
   CallInst *MCall = nullptr;
   Instruction *Result = nullptr;
   if (InsertBefore) {
@@ -717,7 +719,8 @@
   Module *M = BB->getParent()->getParent();
 
   Type *VoidTy = Type::getVoidTy(M->getContext());
-  Type *IntPtrTy = Type::getInt8PtrTy(M->getContext());
+  Type *IntPtrTy = Type::getInt8PtrTy(
+  M->getContext(), Source->getType()->getPointerAddressSpace());
   // prototype free as "void free(void*)"
   FunctionCallee FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy);
   CallInst *Result = nullptr;
Index: llvm/lib/IR/InlineAsm.cpp
===
--- llvm/lib/IR/InlineAsm.cpp
+++ llvm/lib/IR/InlineAsm.cpp
@@ -27,10 +27,12 @@
 
 using namespace llvm;
 
+// Note: InlineAsm is currently always in address space zero
+// TODO: should we require it to be DL.getProgramAddressSpace()?
 InlineAsm::InlineAsm(FunctionType *FTy, const std::string &asmString,
  const std::string &constraints, bool hasSideEffects,
  bool isAlignStack, AsmDialect asmDialect)
-: Value(PointerType::getUnqual(FTy), Value::InlineAsmVal),
+: Value(PointerType::get(FTy, 0), Value::InlineAsmVal),
   AsmString(asmString), Constraints(constraints), FTy(FTy),
   HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
   Dialect(asmDialect) {
@@ -45,7 +47,9 @@
   InlineAsmKeyType Key(AsmString, Constraints, FTy, hasSideEffects,
isAlignStack, asmDialect);
   LLVMContextImpl *pImpl = FTy->getContext().pImpl;
-  return pImpl->InlineAsms.getOrCreate(PointerType::getUnqual(FTy), Key);
+  // Note: InlineAsm is currently always in address space zero
+  // TODO: should we require it to be DL.getProgramAddressSpace()?
+  return pImpl->InlineAsms.getOrCreate(PointerType::get(FTy, 0), Key);
 }
 
 void InlineAsm::destroyConstant() {
Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -1125,7 +1125,7 @@
   }
   case IITDescriptor::PtrToArgument: {
 Type *Ty = Tys[D.getArgumentNumber()];
-return PointerType::getUnqual(Ty);
+return PointerType::get(Ty, 0);
   }
   case IITDescriptor::PtrToElt: {
 Type *Ty = Tys[D.getArgumentNumber()];
@@ -1133,7 +1133,7 @@
 if (!VTy)
   llvm_unreachable("Expected an argument of Vector Type");
 Type *EltTy = VTy->getElementType();
-return PointerType::getUnqual(EltTy);
+return PointerType::get(EltTy, 0);
   }
   case IITDescriptor::VecElementArgument: {
 Type *Ty = Tys[D.getArgumentNumber()];
Index: llvm/lib/IR/Core.cpp
===
--- llvm/lib/

[PATCH] D84341: Implement __builtin_eh_return_data_regno for SystemZ

2020-07-22 Thread Slavomír Kučera via Phabricator via cfe-commits
slavek-kucera created this revision.
slavek-kucera added a reviewer: uweigand.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Implement __builtin_eh_return_data_regno for SystemZ. Match behavior of GCC.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84341

Files:
  clang/lib/Basic/Targets/SystemZ.h
  clang/test/CodeGen/builtins-systemz.c


Index: clang/test/CodeGen/builtins-systemz.c
===
--- clang/test/CodeGen/builtins-systemz.c
+++ clang/test/CodeGen/builtins-systemz.c
@@ -142,3 +142,11 @@
   result = __TM_failure_code (tdb);
 }
 
+void test_eh_return_data_regno()
+{
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);  // CHECK: store volatile i32 6
+  res = __builtin_eh_return_data_regno(1);  // CHECK: store volatile i32 7
+  res = __builtin_eh_return_data_regno(2);  // CHECK: store volatile i32 8
+  res = __builtin_eh_return_data_regno(3);  // CHECK: store volatile i32 9
+}
Index: clang/lib/Basic/Targets/SystemZ.h
===
--- clang/lib/Basic/Targets/SystemZ.h
+++ clang/lib/Basic/Targets/SystemZ.h
@@ -157,6 +157,10 @@
   const char *getLongDoubleMangling() const override { return "g"; }
 
   bool hasExtIntType() const override { return true; }
+
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+return RegNo < 4 ? 6 + RegNo : -1;
+  }
 };
 } // namespace targets
 } // namespace clang


Index: clang/test/CodeGen/builtins-systemz.c
===
--- clang/test/CodeGen/builtins-systemz.c
+++ clang/test/CodeGen/builtins-systemz.c
@@ -142,3 +142,11 @@
   result = __TM_failure_code (tdb);
 }
 
+void test_eh_return_data_regno()
+{
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);  // CHECK: store volatile i32 6
+  res = __builtin_eh_return_data_regno(1);  // CHECK: store volatile i32 7
+  res = __builtin_eh_return_data_regno(2);  // CHECK: store volatile i32 8
+  res = __builtin_eh_return_data_regno(3);  // CHECK: store volatile i32 9
+}
Index: clang/lib/Basic/Targets/SystemZ.h
===
--- clang/lib/Basic/Targets/SystemZ.h
+++ clang/lib/Basic/Targets/SystemZ.h
@@ -157,6 +157,10 @@
   const char *getLongDoubleMangling() const override { return "g"; }
 
   bool hasExtIntType() const override { return true; }
+
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+return RegNo < 4 ? 6 + RegNo : -1;
+  }
 };
 } // namespace targets
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84343: [AST] Keep FP options in trailing storage of CallExpr

2020-07-22 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rjmccall, mibintc.
Herald added a subscriber: martong.
Herald added a reviewer: shafik.
Herald added a project: clang.

This change allow a CallExpr to have optional FPOptionsOverride object,
stored in trailing storage. The implementaion is made similar to the way
used in BinaryOperator.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84343

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp

Index: clang/test/AST/ast-dump-fpfeatures.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-fpfeatures.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -ast-dump | FileCheck %s
+
+float func_01(float x);
+
+template 
+T func_02(T x) {
+#pragma STDC FP_CONTRACT ON
+  return func_01(x);
+}
+
+float func_03(float x) {
+#pragma STDC FP_CONTRACT OFF
+  return func_02(x);
+}
+
+// CHECK:  FunctionTemplateDecl {{.*}} func_02
+// CHECK:FunctionDecl {{.*}} func_02 'float (float)'
+// CHECK-NEXT: TemplateArgument type 'float'
+// CHECK-NEXT:   BuiltinType {{.*}} 'float'
+// CHECK-NEXT: ParmVarDecl {{.*}} x 'float'
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT:   ReturnStmt
+// CHECK-NEXT: CallExpr {{.*}} FPContractMode=1
+
+// CHECK:  FunctionDecl {{.*}} func_03 'float (float)'
+// CHECK-NEXT:   ParmVarDecl {{.*}} x 'float'
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT:   ReturnStmt
+// CHECK-NEXT: CallExpr {{.*}} FPContractMode=0
\ No newline at end of file
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -848,12 +848,15 @@
 void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
   VisitExpr(E);
   Record.push_back(E->getNumArgs());
+  Record.push_back(E->hasStoredFPFeatures());
   Record.AddSourceLocation(E->getRParenLoc());
   Record.AddStmt(E->getCallee());
   for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
Arg != ArgEnd; ++Arg)
 Record.AddStmt(*Arg);
   Record.push_back(static_cast(E->getADLCallKind()));
+  if (E->hasStoredFPFeatures())
+Record.push_back(E->getFPFeatures().getAsOpaqueInt());
   Code = serialization::EXPR_CALL;
 }
 
@@ -1550,7 +1553,6 @@
   VisitCallExpr(E);
   Record.push_back(E->getOperator());
   Record.AddSourceRange(E->Range);
-  Record.push_back(E->getFPFeatures().getAsOpaqueInt());
   Code = serialization::EXPR_CXX_OPERATOR_CALL;
 }
 
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -991,12 +991,15 @@
 void ASTStmtReader::VisitCallExpr(CallExpr *E) {
   VisitExpr(E);
   unsigned NumArgs = Record.readInt();
+  bool HasFPFeatures = Record.readInt();
   assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
   E->setRParenLoc(readSourceLocation());
   E->setCallee(Record.readSubExpr());
   for (unsigned I = 0; I != NumArgs; ++I)
 E->setArg(I, Record.readSubExpr());
   E->setADLCallKind(static_cast(Record.readInt()));
+  if (HasFPFeatures)
+E->setStoredFPFeatures(FPOptionsOverride(Record.readInt()));
 }
 
 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
@@ -1662,7 +1665,6 @@
   VisitCallExpr(E);
   E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
   E->Range = Record.readSourceRange();
-  E->setFPFeatures(FPOptionsOverride(Record.readInt()));
 }
 
 void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
@@ -2977,7 +2979,8 @@
 
 case EXPR_CALL:
   S = CallExpr::CreateEmpty(
-  Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
+  Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields],
+  /*HasFPFeatures=*/Record[ASTStmtReader::NumExprFields + 1], Empty);
   break;
 
 case EXPR_RECOVERY:
@@ -3585,12 +3588,14 @@
 
 case EXPR_CXX_OPERATOR_CALL:
   S = CXXOperatorCallExpr::CreateEmpty(
-  Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
+  Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields],
+  /*HasFPFeatures=*/Record[ASTStmtReader::NumExprFields + 1], Empty);

[PATCH] D84343: [AST] Keep FP options in trailing storage of CallExpr

2020-07-22 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: clang/test/AST/ast-dump-fpfeatures.cpp:1
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -ast-dump | FileCheck %s
+

Can you also test the serialization by round-tripping through a PCH (see the 
other AST dump tests for an example)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84343



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


[PATCH] D84345: [AMDGPU] Set the default globals address space to 1

2020-07-22 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added a reviewer: arsenm.
Herald added subscribers: llvm-commits, cfe-commits, kerbowa, hiraditya, t-tye, 
tpr, dstuttard, yaxunl, nhaehnle, wdng, jvesely, kzhuravl.
Herald added projects: clang, LLVM.

This will ensure that passes that add new global variables will create them
in address space 1 once the passes have been updated to no longer default
to the implicit address space zero.
This also changes AutoUpgrade.cpp to add -G1 to the DataLayout if it wasn't
already to present to ensure bitcode backwards compatibility.

Depends on D70947 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84345

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp

Index: llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
===
--- llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
+++ llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
@@ -27,6 +27,10 @@
  "-f80:32-n8:16:32-S32");
   EXPECT_EQ(DL3, "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128"
  "-n32:64-S128");
+
+  // Check that AMDGPU targets add -G1 if it's not present.
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:32:32", "r600"), "e-p:32:32-G1");
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:64:64", "amdgcn"), "e-p:64:64-G1");
 }
 
 TEST(DataLayoutUpgradeTest, NoDataLayoutUpgrade) {
@@ -46,6 +50,12 @@
   EXPECT_EQ(DL2, "e-p:32:32");
   EXPECT_EQ(DL3, "e-m:e-i64:64-n32:64");
   EXPECT_EQ(DL4, "e-m:o-i64:64-i128:128-n32:64-S128");
+
+  // Check that AMDGPU targets don't add -G1 if there is already a -G flag.
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:32:32-G2", "r600"), "e-p:32:32-G2");
+  EXPECT_EQ(UpgradeDataLayoutString("G2", "r600"), "G2");
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:64:64-G2", "amdgcn"), "e-p:64:64-G2");
+  EXPECT_EQ(UpgradeDataLayoutString("G2-e-p:64:64", "amdgcn"), "G2-e-p:64:64");
 }
 
 TEST(DataLayoutUpgradeTest, EmptyDataLayout) {
@@ -54,6 +64,10 @@
   "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128", "");
   EXPECT_EQ(DL1, "");
   EXPECT_EQ(DL2, "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128");
+
+  // Check that AMDGPU targets add G1 if it's not present.
+  EXPECT_EQ(UpgradeDataLayoutString("", "r600"), "G1");
+  EXPECT_EQ(UpgradeDataLayoutString("", "amdgcn"), "G1");
 }
 
 } // end namespace
Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -345,15 +345,15 @@
 static StringRef computeDataLayout(const Triple &TT) {
   if (TT.getArch() == Triple::r600) {
 // 32-bit pointers.
-  return "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
- "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5";
+return "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
+   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1";
   }
 
   // 32-bit private, local, and region pointers. 64-bit global, constant and
   // flat, non-integral buffer fat pointers.
-return "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32"
+  return "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32"
  "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
- "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
+ "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1"
  "-ni:7";
 }
 
Index: llvm/lib/IR/AutoUpgrade.cpp
===
--- llvm/lib/IR/AutoUpgrade.cpp
+++ llvm/lib/IR/AutoUpgrade.cpp
@@ -4291,11 +4291,17 @@
 }
 
 std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) {
-  std::string AddrSpaces = "-p270:32:32-p271:32:32-p272:64:64";
+  Triple T(TT);
+  // For AMDGPU we uprgrade older DataLayouts to include the default globals
+  // address space of 1.
+  if (T.isAMDGPU() && !DL.contains("-G") && !DL.startswith("G")) {
+return DL.empty() ? std::string("G1") : (DL + "-G1").str();
+  }
 
+  std::string AddrSpaces = "-p270:32:32-p271:32:32-p272:64:64";
   // If X86, and the datalayout matches the expected format, add pointer size
   // address spaces to the datalayout.
-  if (!Triple(TT).isX86() || DL.contains(AddrSpaces))
+  if (!T.isX86() || DL.contains(AddrSpaces))
 return std::string(DL);
 
   SmallVector Groups;
Index: clang/lib/Basic/Targets/AMDGPU.cpp
===
--- clang/lib/Basic/Targets/AMDGPU.cpp
+++ clang/lib/Basic/Targets/AMDGPU.cpp
@@ -31,12 +31,12 @@
 
 static const char *const DataLayoutStringR600 =
 "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
-"-v192:256-v256:256-v512:512-v1024:1024-v2048:204

[PATCH] D84341: Implement __builtin_eh_return_data_regno for SystemZ

2020-07-22 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand accepted this revision.
uweigand added a comment.
This revision is now accepted and ready to land.

LGTM with the format fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84341



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


[PATCH] D84345: [AMDGPU] Set the default globals address space to 1

2020-07-22 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/IR/AutoUpgrade.cpp:4297
+  // address space of 1.
+  if (T.isAMDGPU() && !DL.contains("-G") && !DL.startswith("G")) {
+return DL.empty() ? std::string("G1") : (DL + "-G1").str();

I would expect datalayout upgrades to work by parsing the old string, and 
checking the field values inside. I guess directly checking the string isn't a 
new problem here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84345



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


[PATCH] D83660: [analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConstraintManager.h.

2020-07-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D83660#2149470 , @OikawaKirie wrote:

> It seems to be better to write a checker to report assertion failures.


No no no. No no no no no. Assertions don't say "the program crashes if this 
happens", assertions say "this doesn't happen". We should trust them, not argue 
against them. They're god-sent for any static analysis and also they themselves 
constitute a form of dynamic analysis. Like, even if there's `assert(false)` in 
the beginning of a function, we shouldn't flag it; it's merely an indication 
from the user that this function is never called. There are some cases where 
the assertion indeed doesn't make sense but they're extremely rare. It becomes 
even more confusing when people occasionally have code to handle a would-be 
assertion failure gracefully in release builds (i.e., when assertions are 
disabled).

What we should warn about, though, is //precondition// failures. And the 
assertion that we've stepped on here is, in fact, a precondition: "if you call 
this method on an optional, //first// make sure the optional isn't empty". 
I.e., the assertion is put inside the method, but in fact it should be on the 
method boundary, and that's where it makes sense to warn ("method is misused"). 
But as of now C/C++ doesn't have a way of formally differentiating assertions 
from preconditions or postconditions; such feature is known as "contracts" and 
it was recently delayed until C++23. So manually teaching the static analyzer 
about preconditions of `Optional`'s methods is the right solution until we have 
contracts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83660



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


[PATCH] D83660: [analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConstraintManager.h.

2020-07-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D83660#2166917 , @steakhal wrote:

> Although I'm not the most experienced one here, I think it's good to go.


Let's wait for the test to be added, sounds like it's close.

(@OikawaKirie, you can use delta debugging tools like `creduce` or `delta` to 
automatically write test cases for crashes)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83660



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


[PATCH] D84345: [AMDGPU] Set the default globals address space to 1

2020-07-22 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson marked an inline comment as done.
arichardson added a subscriber: akhuang.
arichardson added inline comments.



Comment at: llvm/lib/IR/AutoUpgrade.cpp:4297
+  // address space of 1.
+  if (T.isAMDGPU() && !DL.contains("-G") && !DL.startswith("G")) {
+return DL.empty() ? std::string("G1") : (DL + "-G1").str();

arsenm wrote:
> I would expect datalayout upgrades to work by parsing the old string, and 
> checking the field values inside. I guess directly checking the string isn't 
> a new problem here
I agree that would be less error prone. I wonder if there are cases where the 
old string may fail to parse so you have to do the textual upgrade first. I'm 
happy to make this change.

@akhuang is there a reason you used string parsing in D67631? Any objections to 
changing the code to parse the datalayout and add missing attributes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84345



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


[clang-tools-extra] 1c7037a - [clangd] Disable -Wsuggest-override for unittests/

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

Author: Logan Smith
Date: 2020-07-22T10:49:09-07:00
New Revision: 1c7037a2a5576d0bb083db10ad947a8308e61f65

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

LOG: [clangd] Disable -Wsuggest-override for unittests/

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt 
b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index c25e2b7f8103..8a4a0fb37fc6 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -22,6 +22,10 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 endif()
 
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+  add_definitions("-Wno-suggest-override")
+endif()
+
 if (CLANGD_ENABLE_REMOTE)
   include_directories(${CMAKE_CURRENT_BINARY_DIR}/../index/remote)
   add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)



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


[PATCH] D84348: WIP: Add complete id-expression support to syntax trees

2020-07-22 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84348

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -867,24 +867,47 @@
   }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-namespace a {
+namespace n {
   struct S {
 template
-static T f(){}
+struct TS {
+  static void f();
+};
   };
 }
+template
+struct TS {
+  struct S {
+template
+static U f();
+  };
+};
 void test() {
-  ::  // global-namespace-specifier
-  a:: // namespace-specifier
-  S:: // type-name-specifier
+  :: // global-namespace-specifier
+  n::// namespace-specifier
+  S::// type-name-specifier
+  template TS:: // type-template-instantiation-specifier
+  f();
+
+  n::// namespace-specifier
+  S::// type-name-specifier
+  TS::  // type-template-instantiation-specifier
+  f();
+
+  TS:: // type-name-specifier
+  S::   // type-name-specifier
   f();
+
+  TS:: // type-name-specifier
+  S::   // type-name-specifier
+  template f();
 }
 )cpp",
   R"txt(
 *: TranslationUnit
 |-NamespaceDefinition
 | |-namespace
-| |-a
+| |-n
 | |-{
 | |-SimpleDeclaration
 | | |-struct
@@ -898,19 +921,58 @@
 | | | | `-T
 | | | |->
 | | | `-SimpleDeclaration
-| | |   |-static
-| | |   |-T
-| | |   |-SimpleDeclarator
-| | |   | |-f
-| | |   | `-ParametersAndQualifiers
-| | |   |   |-(
-| | |   |   `-)
-| | |   `-CompoundStatement
-| | | |-{
-| | | `-}
+| | |   |-struct
+| | |   |-TS
+| | |   |-{
+| | |   |-SimpleDeclaration
+| | |   | |-static
+| | |   | |-void
+| | |   | |-SimpleDeclarator
+| | |   | | |-f
+| | |   | | `-ParametersAndQualifiers
+| | |   | |   |-(
+| | |   | |   `-)
+| | |   | `-;
+| | |   |-}
+| | |   `-;
 | | |-}
 | | `-;
 | `-}
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-typename
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-TS
+|   |-{
+|   |-SimpleDeclaration
+|   | |-struct
+|   | |-S
+|   | |-{
+|   | |-TemplateDeclaration
+|   | | |-template
+|   | | |-<
+|   | | |-UnknownDeclaration
+|   | | | |-typename
+|   | | | `-U
+|   | | |->
+|   | | `-SimpleDeclaration
+|   | |   |-static
+|   | |   |-U
+|   | |   |-SimpleDeclarator
+|   | |   | |-f
+|   | |   | `-ParametersAndQualifiers
+|   | |   |   |-(
+|   | |   |   `-)
+|   | |   `-;
+|   | |-}
+|   | `-;
+|   |-}
+|   `-;
 `-SimpleDeclaration
   |-void
   |-SimpleDeclarator
@@ -924,14 +986,82 @@
 | |-UnknownExpression
 | | |-IdExpression
 | | | |-NestedNameSpecifier
-| | | | |-NameSpecifier
+| | | | |-GlobalNameSpecifier
+| | | | | `-::
+| | | | |-NamespaceNameSpecifier
+| | | | | |-n
+| | | | | `-::
+| | | | |-TypeNameSpecifier
+| | | | | |-S
+| | | | | `-::
+| | | | `-TypeWithTemplateNameSpecifier
+| | | |   |-template
+| | | |   |-TS
+| | | |   |-<
+| | | |   |-int
+| | | |   |->
+| | | |   `-::
+| | | `-UnqualifiedId
+| | |   `-f
+| | |-(
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NestedNameSpecifier
+| | | | |-NamespaceNameSpecifier
+| | | | | |-n
+| | | | | `-::
+| | | | |-TypeNameSpecifier
+| | | | | |-S
+| | | | | `-::
+| | | | `-TypeNameSpecifier
+| | | |   |-TS
+| | | |   |-<
+| | | |   |-int
+| | | |   |->
+| | | |   `-::
+| | | `-UnqualifiedId
+| | |   `-f
+| | |-(
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NestedNameSpecifier
+| | | | |-TypeNameSpecifier
+| | | | | |-TS
+| | | | | |-<
+| | | | | |-int
+| | | | | |->
 | | | | | `-::
-| | | | |-NameSpecifier
-| | | | | |-a
+| | | | `-TypeNameSpecifier
+| | | |   |-S
+| | | |   `-::
+| | | `-UnqualifiedId
+| | |   |-f
+| | |   |-<
+| | |   |-int
+| | |   `->
+| | |-(
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NestedNameSpecifier
+| | | | |-TypeNameSpecifier
+| | | | | |-TS
+| | | | | |-<
+| | | | | |-int
+| | | | | |->
 | | | | | `-::
-| | | | `-NameSpecifier
+| | | | `-TypeNameSpecifier
 | | | |   |-S
 | | | |   `-::
+| | | |-template
 | | | `-UnqualifiedId
 | | |   |-f
 | | |   |-<
@@ -944,7 +1074,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, Qualified

[PATCH] D83660: [analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConstraintManager.h.

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

In D83660#2167391 , @NoQ wrote:

> In D83660#2166917 , @steakhal wrote:
>
> > Although I'm not the most experienced one here, I think it's good to go.
>
>
> Let's wait for the test to be added, sounds like it's close.
>
> (@OikawaKirie, you can use delta debugging tools like `creduce` or `delta` to 
> automatically write test cases for crashes)


+1 for the test.  It's not like we don't trust the fix, it is pretty obvious.  
However, it would be good to cover it for the future because it might help with 
tests around this area of code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83660



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


[clang] 3eec657 - Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups.

2020-07-22 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-22T20:23:58+02:00
New Revision: 3eec65782575a1284391e447142fd004dd5de4a9

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

LOG: Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups.

After lots of follow-up fixes, there are still problems, such as
-Wno-suggest-override getting passed to the Windows Resource Compiler
because it was added with add_definitions in the CMake file.

Rather than piling on another fix, let's revert so this can be re-landed
when there's a proper fix.

This reverts commit 21c0b4c1e8d6a171899b31d072a47dac27258fc5.
This reverts commit 81d68ad27b29b1e6bc93807c6e42b14e9a77eade.
This reverts commit a361aa5249856e333a373df90947dabf34cd6aab.
This reverts commit fa42b7cf2949802ff0b8a63a2e111a2a68711067.
This reverts commit 955f87f947fda3072a69b0b00ca83c1f6a0566f6.
This reverts commit 8b16e45f66e24e4c10e2cea1b70d2b85a7ce64d5.
This reverts commit 308a127a38df3940420b98ff45fc1c17715f.
This reverts commit 274b6b0c7a8b584662595762eaeff57d61c6807f.
This reverts commit 1c7037a2a5576d0bb083db10ad947a8308e61f65.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/CMakeLists.txt
clang-tools-extra/unittests/CMakeLists.txt
clang/unittests/CMakeLists.txt
compiler-rt/cmake/Modules/AddCompilerRT.cmake
compiler-rt/cmake/config-ix.cmake
flang/unittests/CMakeLists.txt
libcxx/CMakeLists.txt
libcxxabi/CMakeLists.txt
lld/unittests/CMakeLists.txt
lldb/unittests/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/lib/Testing/Support/CMakeLists.txt
llvm/unittests/CMakeLists.txt
llvm/utils/benchmark/CMakeLists.txt
llvm/utils/unittest/CMakeLists.txt
mlir/unittests/CMakeLists.txt
parallel-libs/acxxel/CMakeLists.txt
polly/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt 
b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index 8a4a0fb37fc6..c25e2b7f8103 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -22,10 +22,6 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 endif()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
-
 if (CLANGD_ENABLE_REMOTE)
   include_directories(${CMAKE_CURRENT_BINARY_DIR}/../index/remote)
   add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)

diff  --git a/clang-tools-extra/unittests/CMakeLists.txt 
b/clang-tools-extra/unittests/CMakeLists.txt
index 751827cd2a0f..086a68e63830 100644
--- a/clang-tools-extra/unittests/CMakeLists.txt
+++ b/clang-tools-extra/unittests/CMakeLists.txt
@@ -5,10 +5,6 @@ function(add_extra_unittest test_dirname)
   add_unittest(ExtraToolsUnitTests ${test_dirname} ${ARGN})
 endfunction()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
-
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-change-namespace)
 add_subdirectory(clang-doc)

diff  --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt
index 64168f44f843..4c222e24599f 100644
--- a/clang/unittests/CMakeLists.txt
+++ b/clang/unittests/CMakeLists.txt
@@ -10,10 +10,6 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 endif()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
-
 # add_clang_unittest(test_dirname file1.cpp file2.cpp)
 #
 # Will compile the list of files together and link against the clang

diff  --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake 
b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index efb660818270..dab55707338a 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -403,7 +403,6 @@ set(COMPILER_RT_GMOCK_CFLAGS
 
 append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 
COMPILER_RT_UNITTEST_CFLAGS)
 append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG 
-Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS)
-append_list_if(COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG -Wno-suggest-override 
COMPILER_RT_UNITTEST_CFLAGS)
 
 if(MSVC)
   # gtest use a lot of stuff marked as deprecated on Windows.

diff  --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index 0a27910ed494..f535123351d6 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -106,7 +106,6 @@ check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor"   
COMPILER_RT_HAS_WNON_VIRT
 check_cxx_compiler_flag("-Werror -Wvariadic-macros"
COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG)
 check_cxx_compiler_flag("-Werror -Wunused-parameter"   
COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG)
 check_cxx_compiler_flag("-Werror -Wcovered-switch-default" 
COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_F

[clang-tools-extra] 3eec657 - Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups.

2020-07-22 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-07-22T20:23:58+02:00
New Revision: 3eec65782575a1284391e447142fd004dd5de4a9

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

LOG: Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups.

After lots of follow-up fixes, there are still problems, such as
-Wno-suggest-override getting passed to the Windows Resource Compiler
because it was added with add_definitions in the CMake file.

Rather than piling on another fix, let's revert so this can be re-landed
when there's a proper fix.

This reverts commit 21c0b4c1e8d6a171899b31d072a47dac27258fc5.
This reverts commit 81d68ad27b29b1e6bc93807c6e42b14e9a77eade.
This reverts commit a361aa5249856e333a373df90947dabf34cd6aab.
This reverts commit fa42b7cf2949802ff0b8a63a2e111a2a68711067.
This reverts commit 955f87f947fda3072a69b0b00ca83c1f6a0566f6.
This reverts commit 8b16e45f66e24e4c10e2cea1b70d2b85a7ce64d5.
This reverts commit 308a127a38df3940420b98ff45fc1c17715f.
This reverts commit 274b6b0c7a8b584662595762eaeff57d61c6807f.
This reverts commit 1c7037a2a5576d0bb083db10ad947a8308e61f65.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/CMakeLists.txt
clang-tools-extra/unittests/CMakeLists.txt
clang/unittests/CMakeLists.txt
compiler-rt/cmake/Modules/AddCompilerRT.cmake
compiler-rt/cmake/config-ix.cmake
flang/unittests/CMakeLists.txt
libcxx/CMakeLists.txt
libcxxabi/CMakeLists.txt
lld/unittests/CMakeLists.txt
lldb/unittests/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/lib/Testing/Support/CMakeLists.txt
llvm/unittests/CMakeLists.txt
llvm/utils/benchmark/CMakeLists.txt
llvm/utils/unittest/CMakeLists.txt
mlir/unittests/CMakeLists.txt
parallel-libs/acxxel/CMakeLists.txt
polly/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt 
b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index 8a4a0fb37fc6..c25e2b7f8103 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -22,10 +22,6 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 endif()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
-
 if (CLANGD_ENABLE_REMOTE)
   include_directories(${CMAKE_CURRENT_BINARY_DIR}/../index/remote)
   add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)

diff  --git a/clang-tools-extra/unittests/CMakeLists.txt 
b/clang-tools-extra/unittests/CMakeLists.txt
index 751827cd2a0f..086a68e63830 100644
--- a/clang-tools-extra/unittests/CMakeLists.txt
+++ b/clang-tools-extra/unittests/CMakeLists.txt
@@ -5,10 +5,6 @@ function(add_extra_unittest test_dirname)
   add_unittest(ExtraToolsUnitTests ${test_dirname} ${ARGN})
 endfunction()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
-
 add_subdirectory(clang-apply-replacements)
 add_subdirectory(clang-change-namespace)
 add_subdirectory(clang-doc)

diff  --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt
index 64168f44f843..4c222e24599f 100644
--- a/clang/unittests/CMakeLists.txt
+++ b/clang/unittests/CMakeLists.txt
@@ -10,10 +10,6 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 endif()
 
-if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
-  add_definitions("-Wno-suggest-override")
-endif()
-
 # add_clang_unittest(test_dirname file1.cpp file2.cpp)
 #
 # Will compile the list of files together and link against the clang

diff  --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake 
b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index efb660818270..dab55707338a 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -403,7 +403,6 @@ set(COMPILER_RT_GMOCK_CFLAGS
 
 append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 
COMPILER_RT_UNITTEST_CFLAGS)
 append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG 
-Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS)
-append_list_if(COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG -Wno-suggest-override 
COMPILER_RT_UNITTEST_CFLAGS)
 
 if(MSVC)
   # gtest use a lot of stuff marked as deprecated on Windows.

diff  --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index 0a27910ed494..f535123351d6 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -106,7 +106,6 @@ check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor"   
COMPILER_RT_HAS_WNON_VIRT
 check_cxx_compiler_flag("-Werror -Wvariadic-macros"
COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG)
 check_cxx_compiler_flag("-Werror -Wunused-parameter"   
COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG)
 check_cxx_compiler_flag("-Werror -Wcovered-switch-default" 
COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_F

  1   2   >