[PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically

2020-07-06 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 created this revision.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, steakhal, 
Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun, whisperity.
Herald added a reviewer: Szelethus.
Herald added a project: clang.

In case a pointer iterator is incremented in a binary plus expression
(operator+), where the iterator is on the RHS, IteratorModeling should
now detect, and track the resulting value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83190

Files:
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/test/Analysis/iterator-modeling.cpp


Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1948,7 +1948,7 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i)); // 
expected-warning{{$c.end() - 2}}
 }
 
-void plus_ptr_iterator(const cont_with_ptr_iterator &c) {
+void lhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) {
   auto i1 = c.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
@@ -1960,6 +1960,18 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // 
expected-warning{{$c.begin() + 2}}
 }
 
+void rhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i1 = c.begin();
+
+  clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
+
+  auto i2 = 2 + i1;
+
+  clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &c); // 
expected-warning{{TRUE}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // 
expected-warning{{$c.begin()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // 
expected-warning{{$c.begin() + 2}}
+}
+
 void minus_ptr_iterator(const cont_with_ptr_iterator &c) {
   auto i1 = c.end();
 
Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -264,16 +264,23 @@
  CheckerContext &C) const {
   ProgramStateRef State = C.getState();
   BinaryOperatorKind OK = BO->getOpcode();
-  SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext());
+  Expr *LHS = BO->getLHS();
+  Expr *RHS = BO->getRHS();
+  SVal LVal = State->getSVal(LHS, C.getLocationContext());
+  SVal RVal = State->getSVal(RHS, C.getLocationContext());
 
   if (isSimpleComparisonOperator(BO->getOpcode())) {
-SVal LVal = State->getSVal(BO->getLHS(), C.getLocationContext());
 SVal Result = State->getSVal(BO, C.getLocationContext());
 handleComparison(C, BO, Result, LVal, RVal,
  BinaryOperator::getOverloadedOperator(OK));
   } else if (isRandomIncrOrDecrOperator(OK)) {
-handlePtrIncrOrDecr(C, BO->getLHS(),
-BinaryOperator::getOverloadedOperator(OK), RVal);
+// In case of operator+ the iterator can be either on the LHS (eg.: it + 
1),
+// or on the RHS (eg.: 1 + it). Both cases are modeled.
+bool IsItOnLHS = BO->getLHS()->getType()->isPointerType();
+Expr *&ItExpr = IsItOnLHS ? LHS : RHS;
+SVal &OffsetVal = IsItOnLHS ? RVal : LVal;
+handlePtrIncrOrDecr(C, ItExpr, BinaryOperator::getOverloadedOperator(OK),
+OffsetVal);
   }
 }
 
@@ -563,7 +570,7 @@
   const SVal &LHS,
   const SVal &RHS) const {
   // Increment or decrement the symbolic expressions which represents the
-  // position of the iterator
+  // position of the iterator.
   auto State = C.getState();
 
   const auto *Pos = getIteratorPosition(State, LHS);


Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1948,7 +1948,7 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning{{$c.end() - 2}}
 }
 
-void plus_ptr_iterator(const cont_with_ptr_iterator &c) {
+void lhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) {
   auto i1 = c.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
@@ -1960,6 +1960,18 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}}
 }
 
+void rhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i1 = c.begin();
+
+  clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
+
+  auto i2 = 2 + i1;
+
+  clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &c); // expected-warning{{TRUE}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$c.begin()}}
+  clang_analyzer_express(clang

[PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically

2020-07-06 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 275595.
gamesh411 added a comment.

remove unrelated comment formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83190

Files:
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/test/Analysis/iterator-modeling.cpp


Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1948,7 +1948,7 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i)); // 
expected-warning{{$c.end() - 2}}
 }
 
-void plus_ptr_iterator(const cont_with_ptr_iterator &c) {
+void lhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) {
   auto i1 = c.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
@@ -1960,6 +1960,18 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // 
expected-warning{{$c.begin() + 2}}
 }
 
+void rhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i1 = c.begin();
+
+  clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
+
+  auto i2 = 2 + i1;
+
+  clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &c); // 
expected-warning{{TRUE}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // 
expected-warning{{$c.begin()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // 
expected-warning{{$c.begin() + 2}}
+}
+
 void minus_ptr_iterator(const cont_with_ptr_iterator &c) {
   auto i1 = c.end();
 
Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -264,16 +264,23 @@
  CheckerContext &C) const {
   ProgramStateRef State = C.getState();
   BinaryOperatorKind OK = BO->getOpcode();
-  SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext());
+  Expr *LHS = BO->getLHS();
+  Expr *RHS = BO->getRHS();
+  SVal LVal = State->getSVal(LHS, C.getLocationContext());
+  SVal RVal = State->getSVal(RHS, C.getLocationContext());
 
   if (isSimpleComparisonOperator(BO->getOpcode())) {
-SVal LVal = State->getSVal(BO->getLHS(), C.getLocationContext());
 SVal Result = State->getSVal(BO, C.getLocationContext());
 handleComparison(C, BO, Result, LVal, RVal,
  BinaryOperator::getOverloadedOperator(OK));
   } else if (isRandomIncrOrDecrOperator(OK)) {
-handlePtrIncrOrDecr(C, BO->getLHS(),
-BinaryOperator::getOverloadedOperator(OK), RVal);
+// In case of operator+ the iterator can be either on the LHS (eg.: it + 
1),
+// or on the RHS (eg.: 1 + it). Both cases are modeled.
+bool IsItOnLHS = BO->getLHS()->getType()->isPointerType();
+Expr *&ItExpr = IsItOnLHS ? LHS : RHS;
+SVal &OffsetVal = IsItOnLHS ? RVal : LVal;
+handlePtrIncrOrDecr(C, ItExpr, BinaryOperator::getOverloadedOperator(OK),
+OffsetVal);
   }
 }
 


Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1948,7 +1948,7 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning{{$c.end() - 2}}
 }
 
-void plus_ptr_iterator(const cont_with_ptr_iterator &c) {
+void lhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) {
   auto i1 = c.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
@@ -1960,6 +1960,18 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}}
 }
 
+void rhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i1 = c.begin();
+
+  clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
+
+  auto i2 = 2 + i1;
+
+  clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &c); // expected-warning{{TRUE}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$c.begin()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}}
+}
+
 void minus_ptr_iterator(const cont_with_ptr_iterator &c) {
   auto i1 = c.end();
 
Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -264,16 +264,23 @@
  CheckerContext &C) const {
   ProgramStateRef State = C.getState();
   BinaryOperatorKind OK = BO->getOpcode();
-  SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext());
+  Expr *LHS = BO->getLHS();

[clang] df3bda0 - [VE] Correct stack alignment

2020-07-06 Thread Kazushi Marukawa via cfe-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-07-06T17:25:29+09:00
New Revision: df3bda047d5abe9190bdd0422270328140556bd4

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

LOG: [VE] Correct stack alignment

Summary:
Change stack alignment from 64 bits to 128 bits to follow ABI correctly.
And add a regression test for datalayout.

Reviewers: simoll, k-ishizaka

Reviewed By: simoll

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #llvm, #ve, #clang

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

Added: 


Modified: 
clang/lib/Basic/Targets/VE.h
clang/test/CodeGen/target-data.c
llvm/lib/Target/VE/VETargetMachine.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/VE.h b/clang/lib/Basic/Targets/VE.h
index 7e50e7daeb90..f863a0af0acb 100644
--- a/clang/lib/Basic/Targets/VE.h
+++ b/clang/lib/Basic/Targets/VE.h
@@ -45,7 +45,7 @@ class LLVM_LIBRARY_VISIBILITY VETargetInfo : public 
TargetInfo {
 WCharType = UnsignedInt;
 WIntType = UnsignedInt;
 UseZeroLengthBitfieldAlignment = true;
-resetDataLayout("e-m:e-i64:64-n32:64-S64");
+resetDataLayout("e-m:e-i64:64-n32:64-S128");
   }
 
   void getTargetDefines(const LangOptions &Opts,

diff  --git a/clang/test/CodeGen/target-data.c 
b/clang/test/CodeGen/target-data.c
index e619843f4bdb..8c740119cd1b 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -250,3 +250,7 @@
 // RUN: %clang_cc1 -triple bpfeb -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=BPFEB
 // BPFEB: target datalayout = "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
+
+// RUN: %clang_cc1 -triple ve -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=VE
+// VE: target datalayout = "e-m:e-i64:64-n32:64-S128"

diff  --git a/llvm/lib/Target/VE/VETargetMachine.cpp 
b/llvm/lib/Target/VE/VETargetMachine.cpp
index a0c8ae0c82d7..08b55eebbc98 100644
--- a/llvm/lib/Target/VE/VETargetMachine.cpp
+++ b/llvm/lib/Target/VE/VETargetMachine.cpp
@@ -41,8 +41,8 @@ static std::string computeDataLayout(const Triple &T) {
   // VE supports 32 bit and 64 bits integer on registers
   Ret += "-n32:64";
 
-  // Stack alignment is 64 bits
-  Ret += "-S64";
+  // Stack alignment is 128 bits
+  Ret += "-S128";
 
   return Ret;
 }



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


[clang] bd50cf9 - Fix indentation in FixedPoint.h. NFC.

2020-07-06 Thread Bevin Hansson via cfe-commits

Author: Bevin Hansson
Date: 2020-07-06T10:57:21+02:00
New Revision: bd50cf905fa7c0c7caa134301c6ca0658c81eeb1

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

LOG: Fix indentation in FixedPoint.h. NFC.

Added: 


Modified: 
clang/include/clang/Basic/FixedPoint.h

Removed: 




diff  --git a/clang/include/clang/Basic/FixedPoint.h 
b/clang/include/clang/Basic/FixedPoint.h
index 8937bccb0edb..0d181f30907f 100644
--- a/clang/include/clang/Basic/FixedPoint.h
+++ b/clang/include/clang/Basic/FixedPoint.h
@@ -93,52 +93,52 @@ class FixedPointSemantics {
 /// point types and should eventually be moved to LLVM if fixed point types 
gain
 /// native IR support.
 class APFixedPoint {
- public:
-   APFixedPoint(const llvm::APInt &Val, const FixedPointSemantics &Sema)
-   : Val(Val, !Sema.isSigned()), Sema(Sema) {
- assert(Val.getBitWidth() == Sema.getWidth() &&
-"The value should have a bit width that matches the Sema width");
-   }
-
-   APFixedPoint(uint64_t Val, const FixedPointSemantics &Sema)
-   : APFixedPoint(llvm::APInt(Sema.getWidth(), Val, Sema.isSigned()),
-  Sema) {}
-
-   // Zero initialization.
-   APFixedPoint(const FixedPointSemantics &Sema) : APFixedPoint(0, Sema) {}
-
-   llvm::APSInt getValue() const { return llvm::APSInt(Val, !Sema.isSigned()); 
}
-   inline unsigned getWidth() const { return Sema.getWidth(); }
-   inline unsigned getScale() const { return Sema.getScale(); }
-   inline bool isSaturated() const { return Sema.isSaturated(); }
-   inline bool isSigned() const { return Sema.isSigned(); }
-   inline bool hasPadding() const { return Sema.hasUnsignedPadding(); }
-   FixedPointSemantics getSemantics() const { return Sema; }
-
-   bool getBoolValue() const { return Val.getBoolValue(); }
-
-   // Convert this number to match the semantics provided. If the overflow
-   // parameter is provided, set this value to true or false to indicate if 
this
-   // operation results in an overflow.
-   APFixedPoint convert(const FixedPointSemantics &DstSema,
-bool *Overflow = nullptr) const;
-
-   // Perform binary operations on a fixed point type. The resulting fixed 
point
-   // value will be in the common, full precision semantics that can represent
-   // the precision and ranges of both input values. See convert() for an
-   // explanation of the Overflow parameter.
-   APFixedPoint add(const APFixedPoint &Other, bool *Overflow = nullptr) const;
-   APFixedPoint sub(const APFixedPoint &Other, bool *Overflow = nullptr) const;
-   APFixedPoint mul(const APFixedPoint &Other, bool *Overflow = nullptr) const;
-   APFixedPoint div(const APFixedPoint &Other, bool *Overflow = nullptr) const;
-
-   /// Perform a unary negation (-X) on this fixed point type, taking into
-   /// account saturation if applicable.
-   APFixedPoint negate(bool *Overflow = nullptr) const;
-
-   APFixedPoint shr(unsigned Amt) const {
- return APFixedPoint(Val >> Amt, Sema);
-   }
+public:
+  APFixedPoint(const llvm::APInt &Val, const FixedPointSemantics &Sema)
+  : Val(Val, !Sema.isSigned()), Sema(Sema) {
+assert(Val.getBitWidth() == Sema.getWidth() &&
+   "The value should have a bit width that matches the Sema width");
+  }
+
+  APFixedPoint(uint64_t Val, const FixedPointSemantics &Sema)
+  : APFixedPoint(llvm::APInt(Sema.getWidth(), Val, Sema.isSigned()),
+ Sema) {}
+
+  // Zero initialization.
+  APFixedPoint(const FixedPointSemantics &Sema) : APFixedPoint(0, Sema) {}
+
+  llvm::APSInt getValue() const { return llvm::APSInt(Val, !Sema.isSigned()); }
+  inline unsigned getWidth() const { return Sema.getWidth(); }
+  inline unsigned getScale() const { return Sema.getScale(); }
+  inline bool isSaturated() const { return Sema.isSaturated(); }
+  inline bool isSigned() const { return Sema.isSigned(); }
+  inline bool hasPadding() const { return Sema.hasUnsignedPadding(); }
+  FixedPointSemantics getSemantics() const { return Sema; }
+
+  bool getBoolValue() const { return Val.getBoolValue(); }
+
+  // Convert this number to match the semantics provided. If the overflow
+  // parameter is provided, set this value to true or false to indicate if this
+  // operation results in an overflow.
+  APFixedPoint convert(const FixedPointSemantics &DstSema,
+   bool *Overflow = nullptr) const;
+
+  // Perform binary operations on a fixed point type. The resulting fixed point
+  // value will be in the common, full precision semantics that can represent
+  // the precision and ranges of both input values. See convert() for an
+  // explanation of the Overflow parameter.
+  APFixedPoint add(const APFixedPoint &Other, bool *Overflow = nullptr) const;
+  APFixedPoint sub(const APFixedPoint

[clang] 690ff37 - [analyzer] Force dependency checkers to be hidden

2020-07-06 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-07-06T13:05:45+02:00
New Revision: 690ff37a286991f142584f25842e50c6cb23aba6

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

LOG: [analyzer] Force dependency checkers to be hidden

Since strong dependencies aren't user-facing (its hardly ever legal to disable
them), lets enforce that they are hidden. Modeling checkers that aren't
dependencies are of course not impacted, but there is only so much you can do
against developers shooting themselves in the foot :^)

I also made some changes to the test files, reversing the "test" package for,
well, testing.

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 0ceedfb8771b..c1baa52a69b6 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -130,7 +130,8 @@ def CallAndMessageModeling : 
Checker<"CallAndMessageModeling">,
"function/method call. For instance, if we can't reason about the "
"nullability of the implicit this parameter after a method call, "
"this checker conservatively assumes it to be non-null">,
-  Documentation;
+  Documentation,
+  Hidden;
 
 def CallAndMessageChecker : Checker<"CallAndMessage">,
   HelpText<"Check for logical errors for function calls and Objective-C "
@@ -220,7 +221,8 @@ def StackAddrEscapeChecker : Checker<"StackAddressEscape">,
 
 def DynamicTypePropagation : Checker<"DynamicTypePropagation">,
   HelpText<"Generate dynamic type information">,
-  Documentation;
+  Documentation,
+  Hidden;
 
 def NonnullGlobalConstantsChecker: Checker<"NonnilStringConstants">,
   HelpText<"Assume that const string-like globals are non-null">,
@@ -363,7 +365,8 @@ def StdCLibraryFunctionsChecker : 
Checker<"StdCLibraryFunctions">,
   "false",
   InAlpha>
   ]>,
-  Documentation;
+  Documentation,
+  Hidden;
 
 def TrustNonnullChecker : Checker<"TrustNonnull">,
   HelpText<"Trust that returns from framework methods annotated with _Nonnull "

diff  --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp 
b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
index a68820523eaf..528284ca8985 100644
--- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -310,6 +310,13 @@ template  void 
CheckerRegistry::resolveDependencies() {
DependencyIt->FullName == Entry.second &&
"Failed to find the dependency of a checker!");
 
+// We do allow diagnostics from unit test/example dependency checkers.
+assert((DependencyIt->FullName.startswith("test") ||
+DependencyIt->FullName.startswith("example") || IsWeak ||
+DependencyIt->IsHidden) &&
+   "Strong dependencies are modeling checkers, and as such "
+   "non-user facing! Mark them hidden in Checkers.td!");
+
 if (IsWeak)
   CheckerIt->WeakDependencies.emplace_back(&*DependencyIt);
 else

diff  --git a/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp 
b/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
index c7c75955f97f..60b8aafa0d84 100644
--- a/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ b/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -42,17 +42,16 @@ class CustomChecker : public Checker {
 
 void addCustomChecker(AnalysisASTConsumer &AnalysisConsumer,
   AnalyzerOptions &AnOpts) {
-  AnOpts.CheckersAndPackages = {{"custom.CustomChecker", true}};
+  AnOpts.CheckersAndPackages = {{"test.CustomChecker", true}};
   AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
-Registry.addChecker("custom.CustomChecker", "Description",
-   "");
+Registry.addChecker("test.CustomChecker", "Description", 
"");
   });
 }
 
 TEST(RegisterCustomCheckers, RegisterChecker) {
   std::string Diags;
   EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags));
-  EXPECT_EQ(Diags, "custom.CustomChecker:Custom diagnostic description\n");
+  EXPECT_EQ(Diags, "test.CustomChecker:Custom diagnostic description\n");
 }
 
 
//===--===//
@@ -121,7 +120,7 @@ bool shouldRegisterCheckerRegistrationOrderPrinter(const 
CheckerManager &mgr) {
 void addCheckerRegistrationOrderPrinter(CheckerRegistry &Registry) {
   Registry.addC

[clang] c19c6b1 - Make RecursiveASTVisitor call WalkUpFrom for unary and binary operators in post-order traversal mode

2020-07-06 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-07-06T13:38:01+02:00
New Revision: c19c6b1722e5f71200c09cdb096245b98f03dce0

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

LOG: Make RecursiveASTVisitor call WalkUpFrom for unary and binary operators in 
post-order traversal mode

Reviewers: ymandel, eduucaldas, rsmith

Reviewed By: eduucaldas, rsmith

Subscribers: gribozavr2, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/RecursiveASTVisitor.h
clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Removed: 




diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 464a80d15cef..9d93f1e99666 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -593,7 +593,6 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S,
 
   BINOP_LIST()
 #undef OPERATOR
-#undef BINOP_LIST
 
 #define OPERATOR(NAME) 
\
   case BO_##NAME##Assign:  
\
@@ -601,7 +600,6 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S,
 
   CAO_LIST()
 #undef OPERATOR
-#undef CAO_LIST
 }
   } else if (UnaryOperator *UnOp = dyn_cast(S)) {
 switch (UnOp->getOpcode()) {
@@ -611,7 +609,6 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S,
 
   UNARYOP_LIST()
 #undef OPERATOR
-#undef UNARYOP_LIST
 }
   }
 
@@ -633,27 +630,70 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt 
*S,
 
 template 
 bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) {
+  // In pre-order traversal mode, each Traverse##STMT method is responsible for
+  // calling WalkUpFrom. Therefore, if the user overrides Traverse##STMT and
+  // does not call the default implementation, the WalkUpFrom callback is not
+  // called. Post-order traversal mode should provide the same behavior
+  // regarding method overrides.
+  //
+  // In post-order traversal mode the Traverse##STMT method, when it receives a
+  // DataRecursionQueue, can't call WalkUpFrom after traversing children 
because
+  // it only enqueues the children and does not traverse them. TraverseStmt
+  // traverses the enqueued children, and we call WalkUpFrom here.
+  //
+  // However, to make pre-order and post-order modes identical with regards to
+  // whether they call WalkUpFrom at all, we call WalkUpFrom if and only if the
+  // user did not override the Traverse##STMT method. We implement the override
+  // check with isSameMethod calls below.
+
+  if (BinaryOperator *BinOp = dyn_cast(S)) {
+switch (BinOp->getOpcode()) {
+#define OPERATOR(NAME) 
\
+  case BO_##NAME:  
\
+if (::clang::detail::isSameMethod(&RecursiveASTVisitor::TraverseBin##NAME, 
\
+  &Derived::TraverseBin##NAME)) {  
\
+  TRY_TO(WalkUpFromBin##NAME(static_cast(S)));   
\
+}  
\
+return true;
+
+  BINOP_LIST()
+#undef OPERATOR
+
+#define OPERATOR(NAME) 
\
+  case BO_##NAME##Assign:  
\
+if (::clang::detail::isSameMethod( 
\
+&RecursiveASTVisitor::TraverseBin##NAME##Assign,   
\
+&Derived::TraverseBin##NAME##Assign)) {
\
+  TRY_TO(WalkUpFromBin##NAME##Assign(  
\
+  static_cast(S)));  
\
+}  
\
+return true;
+
+  CAO_LIST()
+#undef OPERATOR
+}
+  } else if (UnaryOperator *UnOp = dyn_cast(S)) {
+switch (UnOp->getOpcode()) {
+#define OPERATOR(NAME) 
\
+  case UO_##NAME:  
\
+if (::clang::detail::isSameMethod( 
\
+&RecursiveASTVisitor::TraverseUnary##NAME, 
\
+&Derived::TraverseUnary##NAME)) {  
\
+  TRY_TO(WalkUpFromUnary##NAME(static_cast(S)));  
\
+}  
\
+return true;
+
+  UNARYOP_LIST()
+#undef OPERATOR
+}
+  }
+
   switch (S->getStmtClass()) {
   case Stmt::NoStmtClass:
 break;
 #define ABSTRACT_STMT(STMT)
 #define STMT(C

[clang] 5689b38 - Removed a RecursiveASTVisitor feature to visit operator kinds with different methods

2020-07-06 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-07-06T13:38:01+02:00
New Revision: 5689b38c6a4220cc5f6ba68a56486229b10071bf

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

LOG: Removed a RecursiveASTVisitor feature to visit operator kinds with 
different methods

Summary:
This feature was only used in two places, but contributed a non-trivial
amount to the complexity of RecursiveASTVisitor, and was buggy (see my
recent patches where I was fixing the bugs that I noticed). I don't
think the convenience benefit of this feature is worth the complexity.

Besides complexity, another issue with the current state of
RecursiveASTVisitor is the non-uniformity in how it handles different
AST nodes. All AST nodes follow a regular pattern, but operators are
special -- and this special behavior not documented. Correct usage of
RecursiveASTVisitor relies on shadowing member functions with specific
names and signatures. Near misses don't cause any compile-time errors,
incorrectly named or typed methods are just silently ignored. Therefore,
predictability of RecursiveASTVisitor API is quite important.

This change reduces the size of the `clang` binary by 38 KB (0.2%) in
release mode, and by 7 MB (0.3%) in debug mode. The `clang-tidy` binary
is reduced by 205 KB (0.3%) in release mode, and by 5 MB (0.4%) in debug
mode. I don't think these code size improvements are significant enough
to justify this change on its own (for me, the primary motivation is
reducing code complexity), but they I think are a nice side-effect.

Reviewers: rsmith, sammccall, ymandel, aaron.ballman

Reviewed By: rsmith, sammccall, ymandel, aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/RecursiveASTVisitor.h
clang/lib/ARCMigrate/TransProperties.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp 
b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
index 67f281b3ed1f..56d4cceb6002 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -500,7 +500,7 @@ void ForLoopIndexUseVisitor::addUsage(const Usage &U) {
 /// int k = *i + 2;
 ///   }
 /// \endcode
-bool ForLoopIndexUseVisitor::TraverseUnaryDeref(UnaryOperator *Uop) {
+bool ForLoopIndexUseVisitor::TraverseUnaryOperator(UnaryOperator *Uop) {
   // If we dereference an iterator that's actually a pointer, count the
   // occurrence.
   if (isDereferenceOfUop(Uop, IndexVar)) {

diff  --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h 
b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
index b2cba8c0172a..4f75c9c7522f 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
@@ -346,7 +346,7 @@ class ForLoopIndexUseVisitor
   bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C,
  Expr *Init);
   bool TraverseMemberExpr(MemberExpr *Member);
-  bool TraverseUnaryDeref(UnaryOperator *Uop);
+  bool TraverseUnaryOperator(UnaryOperator *Uop);
   bool VisitDeclRefExpr(DeclRefExpr *E);
   bool VisitDeclStmt(DeclStmt *S);
   bool TraverseStmt(Stmt *S);

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d0328b0ef54c..8a9a58aa01f8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -243,6 +243,34 @@ These are major API changes that have happened since the 
10.0.0 release of
 Clang. If upgrading an external codebase that uses Clang as a library,
 this section should help get you past the largest hurdles of upgrading.
 
+- ``RecursiveASTVisitor`` no longer calls separate methods to visit specific
+  operator kinds. Previously, ``RecursiveASTVisitor`` treated unary, binary,
+  and compound assignment operators as if they were subclasses of the
+  corresponding AST node. For example, the binary operator plus was treated as
+  if it was a ``BinAdd`` subclass of the ``BinaryOperator`` class: during AST
+  traversal of a ``BinaryOperator`` AST node that had a ``BO_Add`` opcode,
+  ``RecursiveASTVisitor`` was calling the ``TraverseBinAdd`` method instead of
+  ``TraverseBinaryOperator``. This feature was contributing a non-trivial
+  amount of complexity to the implementation of ``RecursiveASTVisitor``, it was
+  used only in a minor way in Clang, was not tested, and as a result it was
+  buggy. Furthermore, this feature was creating a non-uni

[clang] 8e750b1 - Make RecursiveASTVisitor call WalkUpFrom for operators when the data recursion queue is absent

2020-07-06 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-07-06T13:38:01+02:00
New Revision: 8e750b1f0a2b6b5174dc49adf20e6f863c28e3cd

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

LOG: Make RecursiveASTVisitor call WalkUpFrom for operators when the data 
recursion queue is absent

Reviewers: eduucaldas, ymandel, rsmith

Reviewed By: eduucaldas

Subscribers: gribozavr2, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/RecursiveASTVisitor.h
clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Removed: 




diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 9d93f1e99666..0d7c2b81512c 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -416,6 +416,8 @@ template  class RecursiveASTVisitor {
 if (!getDerived().shouldTraversePostOrder())   
\
   TRY_TO(WalkUpFromUnary##NAME(S));
\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  
\
+if (!Queue && getDerived().shouldTraversePostOrder())  
\
+  TRY_TO(WalkUpFromUnary##NAME(S));
\
 return true;   
\
   }
\
   bool WalkUpFromUnary##NAME(UnaryOperator *S) {   
\
@@ -437,6 +439,8 @@ template  class RecursiveASTVisitor {
   TRY_TO(WalkUpFromBin##NAME(S));  
\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS());  
\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS());  
\
+if (!Queue && getDerived().shouldTraversePostOrder())  
\
+  TRY_TO(WalkUpFromBin##NAME(S));  
\
 return true;   
\
   }
\
   bool WalkUpFromBin##NAME(BINOP_TYPE *S) {
\

diff  --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
index 0a4e9aa1e9e8..70c7eb37ad4c 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -606,14 +606,13 @@ TraverseUnaryMinus UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // UnaryOperator(-).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -675,7 +674,6 @@ WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromUnaryMinus.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -684,6 +682,9 @@ WalkUpFromExpr IntegerLiteral(1)
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromUnaryMinus UnaryOperator(-)
+WalkUpFromExpr UnaryOperator(-)
+  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
@@ -996,8 +997,6 @@ TraverseBinAdd BinaryOperator(+)
 WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // BinaryOperator(+).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1005,6 +1004,7 @@ WalkUpFromStmt IntegerLiteral(1)
 TraverseBinAdd BinaryOperator(+)
   WalkUpFromStmt IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(3)
+  WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -1067,7 +1067,6 @@ WalkUpFromExpr IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromBinAdd.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1078,6 +1077,9 @@ TraverseBinAdd BinaryOperator(+)
 WalkUpFromStmt Inte

[clang] 7349479 - RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order traversal

2020-07-06 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-07-06T13:38:01+02:00
New Revision: 7349479f2244c32c0184ca545af04adb171c8077

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

LOG: RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order 
traversal

Summary:
How does RecursiveASTVisitor call the WalkUp callback for expressions?

* In pre-order traversal mode, RecursiveASTVisitor calls the WalkUp
  callback from the default implementation of Traverse callbacks.

* In post-order traversal mode when we don't have a DataRecursionQueue,
  RecursiveASTVisitor also calls the WalkUp callback from the default
  implementation of Traverse callbacks.

* However, in post-order traversal mode when we have a DataRecursionQueue,
  RecursiveASTVisitor calls the WalkUp callback from PostVisitStmt.

As a result, when the user overrides the Traverse callback, in pre-order
traversal mode they never get the corresponding WalkUp callback. However
in the post-order traversal mode the WalkUp callback is invoked or not
depending on whether the data recursion optimization could be applied.

I had to adjust the implementation of TraverseCXXForRangeStmt in the
syntax tree builder to call the WalkUp method directly, as it was
relying on this behavior. There is an existing test for this
functionality and it prompted me to make this extra fix.

In addition, I had to fix the default implementation implementation of
RecursiveASTVisitor::TraverseSynOrSemInitListExpr to call WalkUpFrom in
the same manner as the implementation generated by the DEF_TRAVERSE_STMT
macro. Without this fix, the InitListExprIsPostOrderNoQueueVisitedTwice
test was failing because WalkUpFromInitListExpr was never called.

Reviewers: eduucaldas, ymandel

Reviewed By: eduucaldas, ymandel

Subscribers: gribozavr2, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/RecursiveASTVisitor.h
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Removed: 




diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index b16c1ae1e483..464a80d15cef 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -83,6 +83,42 @@ namespace clang {
   return false;
\
   } while (false)
 
+namespace detail {
+
+template 
+struct has_same_member_pointer_type : std::false_type {};
+template 
+struct has_same_member_pointer_type
+: std::true_type {};
+
+template  struct is_same_method_impl {
+  template 
+  static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
+   SecondMethodPtrTy SecondMethodPtr) {
+return false;
+  }
+};
+
+template <> struct is_same_method_impl {
+  template 
+  static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
+   SecondMethodPtrTy SecondMethodPtr) {
+return FirstMethodPtr == SecondMethodPtr;
+  }
+};
+
+/// Returns true if and only if \p FirstMethodPtr and \p SecondMethodPtr
+/// are pointers to the same non-static member function.
+template 
+bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
+  SecondMethodPtrTy SecondMethodPtr) {
+  return is_same_method_impl::value>::isSameMethod(FirstMethodPtr, 
SecondMethodPtr);
+}
+
+} // end namespace detail
+
 /// A class that does preorder or postorder
 /// depth-first traversal on the entire Clang AST and visits each node.
 ///
@@ -325,23 +361,17 @@ template  class RecursiveASTVisitor {
   Stmt::child_range getStmtChildren(Stmt *S) { return S->children(); }
 
 private:
-  template
-  struct has_same_member_pointer_type : std::false_type {};
-  template
-  struct has_same_member_pointer_type
-  : std::true_type {};
-
   // Traverse the given statement. If the most-derived traverse function takes 
a
   // data recursion queue, pass it on; otherwise, discard it. Note that the
   // first branch of this conditional must compile whether or not the derived
   // class can take a queue, so if we're taking the second arm, make the first
   // arm call our function rather than the derived class version.
 #define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE)
\
-  (has_same_member_pointer_type::value 
\
+  (::clang::detail::has_same_member_pointer_type<  
\
+   decltype(&RecursiveASTVisitor::Traverse##NAME), 
\
+   decltype(&Derived::Traverse##NAME)>::value  
\
? static_cast::value,   
\
  Derived &, RecursiveASTVisitor &>>(*this) 
\
@@ -609,17 +

[clang] b295607 - [analyzer][NFC] Don't allow dependency checkers to emit diagnostics

2020-07-06 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-07-06T14:51:37+02:00
New Revision: b2956076976cd0f435c46257f7cf9a0e5376d0fa

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

LOG: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics

The thrilling conclusion to the barrage of patches I uploaded lately! This is a
big milestone towards the goal set out in 
http://lists.llvm.org/pipermail/cfe-dev/2019-August/063070.html.
I hope to accompany this with a patch where the a coreModeling package is added,
from which package diagnostics aren't allowed either, is an implicit dependency
of all checkers, and the core package for the first time can be safely disabled.

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
clang/lib/StaticAnalyzer/Core/BugReporter.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 51565524db1e..27bc0dda1f1c 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -19,6 +19,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -135,7 +136,7 @@ class BugReport {
   SmallVector Fixits;
 
   BugReport(Kind kind, const BugType &bt, StringRef desc)
-  : K(kind), BT(bt), Description(desc) {}
+  : BugReport(kind, bt, "", desc) {}
 
   BugReport(Kind K, const BugType &BT, StringRef ShortDescription,
 StringRef Description)
@@ -369,16 +370,13 @@ class PathSensitiveBugReport : public BugReport {
 public:
   PathSensitiveBugReport(const BugType &bt, StringRef desc,
  const ExplodedNode *errorNode)
-  : BugReport(Kind::PathSensitive, bt, desc), ErrorNode(errorNode),
-ErrorNodeRange(getStmt() ? getStmt()->getSourceRange()
- : SourceRange()) {}
+  : PathSensitiveBugReport(bt, desc, desc, errorNode) {}
 
   PathSensitiveBugReport(const BugType &bt, StringRef shortDesc, StringRef 
desc,
  const ExplodedNode *errorNode)
-  : BugReport(Kind::PathSensitive, bt, shortDesc, desc),
-ErrorNode(errorNode),
-ErrorNodeRange(getStmt() ? getStmt()->getSourceRange()
- : SourceRange()) {}
+  : PathSensitiveBugReport(bt, shortDesc, desc, errorNode,
+   /*LocationToUnique*/ {},
+   /*DeclToUnique*/ nullptr) {}
 
   /// Create a PathSensitiveBugReport with a custom uniqueing location.
   ///
@@ -391,11 +389,13 @@ class PathSensitiveBugReport : public BugReport {
  const ExplodedNode *errorNode,
  PathDiagnosticLocation LocationToUnique,
  const Decl *DeclToUnique)
-  : BugReport(Kind::PathSensitive, bt, desc), ErrorNode(errorNode),
-ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() : 
SourceRange()),
-UniqueingLocation(LocationToUnique), UniqueingDecl(DeclToUnique) {
-assert(errorNode);
-  }
+  : PathSensitiveBugReport(bt, desc, desc, errorNode, LocationToUnique,
+   DeclToUnique) {}
+
+  PathSensitiveBugReport(const BugType &bt, StringRef shortDesc, StringRef 
desc,
+ const ExplodedNode *errorNode,
+ PathDiagnosticLocation LocationToUnique,
+ const Decl *DeclToUnique);
 
   static bool classof(const BugReport *R) {
 return R->getKind() == Kind::PathSensitive;

diff  --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index f4fd495956aa..a832b90ddf0e 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -34,6 +34,7 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/CheckerRegistryData.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
@@ -2107,6 +2108,32 @@ void BuiltinBug::anchor() {}
 // Methods for BugR

[clang] cfd6b4b - [analyzer] Don't allow hidden checkers to emit diagnostics

2020-07-06 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-07-06T15:34:51+02:00
New Revision: cfd6b4b811aa8bb193f744264e36e83de4bb3650

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

LOG: [analyzer] Don't allow hidden checkers to emit diagnostics

Hidden checkers (those marked with Hidden in Checkers.td) are meant for
development purposes only, and are only displayed under
-analyzer-checker-help-developer, so users shouldn't see reports from them.

I moved StdLibraryFunctionsArg checker to the unix package from apiModeling as
it violated this rule. I believe this change doesn't deserve a different
revision because it is in alpha, and the name is so bad anyways I don't
immediately care where it is, because we'll have to revisit it soon enough.

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/test/Analysis/std-c-library-functions-arg-constraints.c
clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
clang/test/Analysis/weak-dependencies.c

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index c1baa52a69b6..dc1269890f93 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -375,18 +375,6 @@ def TrustNonnullChecker : Checker<"TrustNonnull">,
 
 } // end "apiModeling"
 
-let ParentPackage = APIModelingAlpha in {
-
-def StdCLibraryFunctionArgsChecker : Checker<"StdCLibraryFunctionArgs">,
-  HelpText<"Check constraints of arguments of C standard library functions, "
-   "such as whether the parameter of isalpha is in the range [0, 255] "
-   "or is EOF.">,
-  Dependencies<[StdCLibraryFunctionsChecker]>,
-  WeakDependencies<[NonNullParamChecker]>,
-  Documentation;
-
-} // end "alpha.apiModeling"
-
 
//===--===//
 // Evaluate "builtin" functions.
 
//===--===//
@@ -545,6 +533,14 @@ def BlockInCriticalSectionChecker : 
Checker<"BlockInCriticalSection">,
   HelpText<"Check for calls to blocking functions inside a critical section">,
   Documentation;
 
+def StdCLibraryFunctionArgsChecker : Checker<"StdCLibraryFunctionArgs">,
+  HelpText<"Check constraints of arguments of C standard library functions, "
+   "such as whether the parameter of isalpha is in the range [0, 255] "
+   "or is EOF.">,
+  Dependencies<[StdCLibraryFunctionsChecker]>,
+  WeakDependencies<[NonNullParamChecker]>,
+  Documentation;
+
 } // end "alpha.unix"
 
 
//===--===//

diff  --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index a832b90ddf0e..7df8dea56055 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2108,8 +2108,8 @@ void BuiltinBug::anchor() {}
 // Methods for BugReport and subclasses.
 
//===--===//
 
-static bool isDependency(const CheckerRegistryData &Registry,
- StringRef CheckerName) {
+LLVM_ATTRIBUTE_USED static bool
+isDependency(const CheckerRegistryData &Registry, StringRef CheckerName) {
   for (const std::pair &Pair : Registry.Dependencies) {
 if (Pair.second == CheckerName)
   return true;
@@ -2117,6 +2117,17 @@ static bool isDependency(const CheckerRegistryData 
&Registry,
   return false;
 }
 
+LLVM_ATTRIBUTE_USED static bool isHidden(const CheckerRegistryData &Registry,
+ StringRef CheckerName) {
+  for (const CheckerInfo &Checker : Registry.Checkers) {
+if (Checker.FullName == CheckerName)
+  return Checker.IsHidden;
+  }
+  llvm_unreachable(
+  "Checker name not found in CheckerRegistry -- did you retrieve it "
+  "correctly from CheckerManager::getCurrentCheckerName?");
+}
+
 PathSensitiveBugReport::PathSensitiveBugReport(
 const BugType &bt, StringRef shortDesc, StringRef desc,
 const ExplodedNode *errorNode, PathDiagnosticLocation LocationToUnique,
@@ -2132,6 +2143,16 @@ PathSensitiveBugReport::PathSensitiveBugReport(
  "Some checkers depend on this one! We don't allow dependency "
  "checkers to emit warnings, because checkers should depend on "
  "*modeling*, not *diagnostics*.");
+
+  assert(
+  bt.getCheckerName().startswith("debug") ||
+  !isHidden(ErrorNode->getState()
+->getAnalysisManager()
+

[clang-tools-extra] fc3c693 - [clang-tidy] Added alias llvm-else-after-return.

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

Author: Nathan James
Date: 2020-07-06T14:39:03+01:00
New Revision: fc3c693b617fc5fde8939a3aec7e7372ace07693

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

LOG: [clang-tidy] Added alias llvm-else-after-return.

Added an alias llvm-else-after-return from readability-else-after-return to 
help enforce one of the llvm coding guidelines.

Reviewed By: aaron.ballman

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

Added: 
clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst

Modified: 
clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp 
b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
index 2aaf07639267..0310a8e07a2d 100644
--- a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "../readability/ElseAfterReturnCheck.h"
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/QualifiedAutoCheck.h"
 #include "HeaderGuardCheck.h"
@@ -24,6 +25,8 @@ namespace llvm_check {
 class LLVMModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"llvm-else-after-return");
 CheckFactories.registerCheck("llvm-header-guard");
 CheckFactories.registerCheck("llvm-include-order");
 CheckFactories.registerCheck(
@@ -40,6 +43,9 @@ class LLVMModule : public ClangTidyModule {
   ClangTidyOptions getModuleOptions() override {
 ClangTidyOptions Options;
 Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0";
+Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "0";
+Options.CheckOptions["llvm-else-after-return.RefactorConditionVariables"] =
+"0";
 return Options;
   }
 };

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 7593554d896d..c66d5eb6069e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -192,6 +192,11 @@ New check aliases
   :doc:`bugprone-signed-char-misuse
   ` was added.
 
+- New alias :doc:`llvm-else-after-return
+  ` to
+  :doc:`readability-else-after-return
+  ` was added.
+
 Changes in existing checks
 ^^
 

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst 
b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index baa142e28e7f..7356c585d20c 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -423,4 +423,5 @@ Clang-Tidy Checks
`hicpp-use-nullptr `_, `modernize-use-nullptr 
`_, "Yes"
`hicpp-use-override `_, `modernize-use-override 
`_, "Yes"
`hicpp-vararg `_, `cppcoreguidelines-pro-type-vararg 
`_,
+   `llvm-else-after-return `_, 
`readability-else-after-return `_, "Yes"
`llvm-qualified-auto `_, 
`readability-qualified-auto `_, "Yes"

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst 
b/clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst
new file mode 100644
index ..f9af610fe50d
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst
@@ -0,0 +1,11 @@
+.. title:: clang-tidy - llvm-else-after-return
+.. meta::
+   :http-equiv=refresh: 5;URL=readability-else-after-return.html
+
+llvm-else-after-return
+==
+
+The llvm-else-after-return check is an alias, please see
+`readability-else-after-return `_
+for more information.
+

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst 
b/clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
index fccb01d0e6b2..4adcd7bbfa26 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
@@ -77,3 +77,13 @@ Options
the ``if`` statement is the last statement in its parents scope.
Default value is `true`.
 
+
+LLVM alias
+--
+
+There is an alias of this check called llvm-else-after-return.
+In that version the options :option:`WarnOnUnfixable` and 
+:option:`WarnOnConditionVariables` are both set to `false` by default.
+
+This check helps to enforce this `LLVM Coding Standards recommendation
+`_.



_

[clang-tools-extra] 0196600 - [clang-tidy] Fix incorrect default option in fc3c693b61

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

Author: Nathan James
Date: 2020-07-06T14:44:03+01:00
New Revision: 01966003674d49e06632495fec2a5a7b3fd58a80

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

LOG: [clang-tidy] Fix incorrect default option in fc3c693b61

Added: 


Modified: 
clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp 
b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
index 0310a8e07a2d..bf871e21f501 100644
--- a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
@@ -44,7 +44,7 @@ class LLVMModule : public ClangTidyModule {
 ClangTidyOptions Options;
 Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0";
 Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "0";
-Options.CheckOptions["llvm-else-after-return.RefactorConditionVariables"] =
+Options.CheckOptions["llvm-else-after-return.WarnOnConditionVariables"] =
 "0";
 return Options;
   }



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


[clang] cd9a241 - [clang] Fix the incorrect dependence bits for DependentExtIntType.

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

Author: Haojian Wu
Date: 2020-07-06T16:42:56+02:00
New Revision: cd9a241f165013902fc060ace88c66e402c7767a

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

LOG: [clang] Fix the incorrect dependence bits for DependentExtIntType.

The error-bit was missing, and the unexpandedpack bit seemed to be
set incorrectly.

Reviewed By: sammccall, erichkeane

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

Added: 


Modified: 
clang/lib/AST/Type.cpp
clang/test/Sema/invalid-bitwidth-expr.mm

Removed: 




diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 05962f34bbf1..10a6a2610130 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -347,15 +347,7 @@ ExtIntType::ExtIntType(bool IsUnsigned, unsigned NumBits)
 DependentExtIntType::DependentExtIntType(const ASTContext &Context,
  bool IsUnsigned, Expr *NumBitsExpr)
 : Type(DependentExtInt, QualType{},
-   ((NumBitsExpr->isValueDependent() || NumBitsExpr->isTypeDependent())
-? TypeDependence::Dependent
-: TypeDependence::None) |
-   (NumBitsExpr->isInstantiationDependent()
-? TypeDependence::Instantiation
-: TypeDependence::None) |
-   (NumBitsExpr->containsUnexpandedParameterPack()
-? TypeDependence::VariablyModified
-: TypeDependence::None)),
+   toTypeDependence(NumBitsExpr->getDependence())),
   Context(Context), ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
 
 bool DependentExtIntType::isUnsigned() const {

diff  --git a/clang/test/Sema/invalid-bitwidth-expr.mm 
b/clang/test/Sema/invalid-bitwidth-expr.mm
index a38ebbbd6755..41ca9496de4f 100644
--- a/clang/test/Sema/invalid-bitwidth-expr.mm
+++ b/clang/test/Sema/invalid-bitwidth-expr.mm
@@ -32,3 +32,8 @@ auto func() {
   int X : func(); // expected-note {{in instantiation of function 
template}}
 };
 constexpr int  = sizeof(Z);
+
+struct Z2 {
+  int X : sizeof(_ExtInt(invalid())); // expected-error {{use of undeclared 
identifier}}
+};
+constexpr int s = sizeof(Z2);



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


[clang-tools-extra] 254b016 - [clangd] More complete fix for hover crashes on invalid record.

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

Author: Haojian Wu
Date: 2020-07-06T17:12:39+02:00
New Revision: 254b016c6561e4ec4d145b81c4d0aaf3d2c7fca6

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

LOG: [clangd] More complete fix for hover crashes on invalid record.

 We should not call getFieldOffset on invalid record decls.

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

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index f495052d2d30..cba933508fd5 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -659,8 +659,10 @@ bool isHardLineBreakAfter(llvm::StringRef Line, 
llvm::StringRef Rest) {
 }
 
 void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) {
-  const auto &Ctx = ND.getASTContext();
+  if (ND.isInvalidDecl())
+return;
 
+  const auto &Ctx = ND.getASTContext();
   if (auto *RD = llvm::dyn_cast(&ND)) {
 if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl()))
   HI.Size = Size->getQuantity();
@@ -671,11 +673,10 @@ void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) {
 const auto *Record = FD->getParent();
 if (Record)
   Record = Record->getDefinition();
-if (Record && !Record->isDependentType()) {
+if (Record && !Record->isInvalidDecl() && !Record->isDependentType()) {
+  HI.Offset = Ctx.getFieldOffset(FD) / 8;
   if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
 HI.Size = Size->getQuantity();
-  if (!FD->isInvalidDecl())
-HI.Offset = Ctx.getFieldOffset(FD) / 8;
 }
 return;
   }

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 3be796a6fb89..43f1e7142550 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -784,11 +784,24 @@ class Foo {})cpp";
  HI.NamespaceScope = "";
  HI.Definition = "int xx";
  HI.LocalScope = "Foo::";
- HI.Size = 4;
  HI.Type = "int";
  HI.AccessSpecifier = "public";
}},
-  };
+  {R"cpp(
+// error-ok
+struct Foo {
+  Bar xx;
+  int [[y^y]];
+};)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "yy";
+ HI.Kind = index::SymbolKind::Field;
+ HI.NamespaceScope = "";
+ HI.Definition = "int yy";
+ HI.LocalScope = "Foo::";
+ HI.Type = "int";
+ HI.AccessSpecifier = "public";
+   }}};
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
 



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


[clang] e80b81d - [Support] Fix formatted_raw_ostream for UTF-8

2020-07-06 Thread Oliver Stannard via cfe-commits

Author: Oliver Stannard
Date: 2020-07-06T16:18:15+01:00
New Revision: e80b81d1cbf85dcd427759369978afdb48f0998f

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

LOG: [Support] Fix formatted_raw_ostream for UTF-8

* The getLine and getColumn functions need to update the position, or
  they will return stale data for buffered streams. This fixes a bug in
  the clang -analyzer-checker-option-help option, which was not wrapping
  the help text correctly when stdout is not a TTY.
* If the stream contains multi-byte UTF-8 sequences, then the whole
  sequence needs to be considered to be a single character. This has the
  edge case that the buffer might fill up and be flushed part way
  through a character.
* If the stream contains East Asian wide characters, these will be
  rendered twice as wide as other characters, so we need to increase the
  column count to match.

This doesn't attempt to handle everything unicode can do (combining
characters, right-to-left markers, ...), but hopefully covers most
things likely to be common in messages and source code we might want to
print.

Differential revision: https://reviews.llvm.org/D76291

Added: 


Modified: 
clang/test/Analysis/checker-plugins.c
llvm/include/llvm/Support/FormattedStream.h
llvm/lib/Support/FormattedStream.cpp
llvm/test/MC/ARM/lsl-zero.s
llvm/unittests/Support/formatted_raw_ostream_test.cpp

Removed: 




diff  --git a/clang/test/Analysis/checker-plugins.c 
b/clang/test/Analysis/checker-plugins.c
index fbc9c9bd1c22..69fab8fa6eed 100644
--- a/clang/test/Analysis/checker-plugins.c
+++ b/clang/test/Analysis/checker-plugins.c
@@ -116,4 +116,5 @@ void caller() {
 // RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-CHECKER-OPTION-HELP
 
 // CHECK-CHECKER-OPTION-HELP: example.MyChecker:ExampleOption  (bool) This is 
an
-// CHECK-CHECKER-OPTION-HELP-SAME: example checker opt. (default: false)
+// CHECK-CHECKER-OPTION-HELP-SAME: example checker opt. (default:
+// CHECK-CHECKER-OPTION-HELP-NEXT: false)

diff  --git a/llvm/include/llvm/Support/FormattedStream.h 
b/llvm/include/llvm/Support/FormattedStream.h
index b49c8d86531d..5f937cfa7984 100644
--- a/llvm/include/llvm/Support/FormattedStream.h
+++ b/llvm/include/llvm/Support/FormattedStream.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_SUPPORT_FORMATTEDSTREAM_H
 #define LLVM_SUPPORT_FORMATTEDSTREAM_H
 
+#include "llvm/ADT/SmallString.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -21,8 +22,11 @@ namespace llvm {
 
 /// formatted_raw_ostream - A raw_ostream that wraps another one and keeps 
track
 /// of line and column position, allowing padding out to specific column
-/// boundaries and querying the number of lines written to the stream.
-///
+/// boundaries and querying the number of lines written to the stream. This
+/// assumes that the contents of the stream is valid UTF-8 encoded text. This
+/// doesn't attempt to handle everything Unicode can do (combining characters,
+/// right-to-left markers, etc), but should cover the cases likely to appear in
+/// source code or diagnostic messages.
 class formatted_raw_ostream : public raw_ostream {
   /// TheStream - The real stream we output to. We set it to be
   /// unbuffered, since we're already doing our own buffering.
@@ -40,6 +44,14 @@ class formatted_raw_ostream : public raw_ostream {
   ///
   const char *Scanned;
 
+  /// PartialUTF8Char - Either empty or a prefix of a UTF-8 code unit sequence
+  /// for a Unicode scalar value which should be prepended to the buffer for 
the
+  /// next call to ComputePosition. This is needed when the buffer is flushed
+  /// when it ends part-way through the UTF-8 encoding of a Unicode scalar
+  /// value, so that we can compute the display width of the character once we
+  /// have the rest of it.
+  SmallString<4> PartialUTF8Char;
+
   void write_impl(const char *Ptr, size_t Size) override;
 
   /// current_pos - Return the current position within the stream,
@@ -52,10 +64,16 @@ class formatted_raw_ostream : public raw_ostream {
   }
 
   /// ComputePosition - Examine the given output buffer and figure out the new
-  /// position after output.
-  ///
+  /// position after output. This is safe to call multiple times on the same
+  /// buffer, as it records the most recently scanned character and resumes 
from
+  /// there when the buffer has not been flushed.
   void ComputePosition(const char *Ptr, size_t size);
 
+  /// UpdatePosition - scan the characters in [Ptr, Ptr+Size), and update the
+  /// line and column numbers. Unlike ComputePosition, this must be called
+  /// exactly once on each region of the buffer.
+  void UpdatePosition(const char *Ptr, size_t Size);
+
   void setStream(raw_ostream &Stream) {
 releaseStream();
 
@@ -105,11 +123,17 @@ class formatted_ra

[clang] 7308e14 - [clang] Fix modules build after D82585

2020-07-06 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2020-07-06T17:51:53+02:00
New Revision: 7308e1432624f02d4e652ffa70e40d0eaa89fdb3

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

LOG: [clang] Fix modules build after D82585

Just getting the bots running again.

See the D82585 for more info.

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h
clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h 
b/clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h
index e7a7671a7576..43248d8e6bb8 100644
--- a/clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h
+++ b/clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h
@@ -76,7 +76,7 @@ struct CmdLineOption {
"Invalid development status!");
   }
 
-  LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); }
+  LLVM_DUMP_METHOD void dump() const;
   LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out) const;
 };
 
@@ -135,7 +135,7 @@ struct CheckerInfo {
   // Used for lower_bound.
   explicit CheckerInfo(StringRef FullName) : FullName(FullName) {}
 
-  LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); }
+  LLVM_DUMP_METHOD void dump() const;
   LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out) const;
 };
 
@@ -155,7 +155,7 @@ struct PackageInfo {
 
   explicit PackageInfo(StringRef FullName) : FullName(FullName) {}
 
-  LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); }
+  LLVM_DUMP_METHOD void dump() const;
   LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out) const;
 };
 

diff  --git a/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp 
b/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp
index 7d5bfb2f9cdb..1b3e8b11549d 100644
--- a/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp
@@ -18,6 +18,10 @@ using namespace ento;
 // Methods of CmdLineOption, PackageInfo and CheckerInfo.
 
//===--===//
 
+LLVM_DUMP_METHOD void CmdLineOption::dump() const {
+  dumpToStream(llvm::errs());
+}
+
 LLVM_DUMP_METHOD void
 CmdLineOption::dumpToStream(llvm::raw_ostream &Out) const {
   // The description can be just checked in Checkers.inc, the point here is to
@@ -39,6 +43,8 @@ static StringRef toString(StateFromCmdLine Kind) {
   llvm_unreachable("Unhandled StateFromCmdLine enum");
 }
 
+LLVM_DUMP_METHOD void CheckerInfo::dump() const { dumpToStream(llvm::errs()); }
+
 LLVM_DUMP_METHOD void CheckerInfo::dumpToStream(llvm::raw_ostream &Out) const {
   // The description can be just checked in Checkers.inc, the point here is to
   // debug whether we succeeded in parsing it. Same with documentation uri.
@@ -60,6 +66,8 @@ LLVM_DUMP_METHOD void 
CheckerInfo::dumpToStream(llvm::raw_ostream &Out) const {
   }
 }
 
+LLVM_DUMP_METHOD void PackageInfo::dump() const { dumpToStream(llvm::errs()); }
+
 LLVM_DUMP_METHOD void PackageInfo::dumpToStream(llvm::raw_ostream &Out) const {
   Out << FullName << "\n";
   Out << "  Options:\n";



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


[clang] cf0b3af - [clang][utils] make-ast-dump-check.sh: strip line and column numbers when generating serialization tests

2020-07-06 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-07-06T16:52:35+01:00
New Revision: cf0b3affed47811b02127383c7eec27285ac35a3

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

LOG: [clang][utils] make-ast-dump-check.sh: strip line and column numbers when 
generating serialization tests

Added: 


Modified: 
clang/utils/make-ast-dump-check.sh

Removed: 




diff  --git a/clang/utils/make-ast-dump-check.sh 
b/clang/utils/make-ast-dump-check.sh
index f0c268c883e9..365f227cc1c6 100755
--- a/clang/utils/make-ast-dump-check.sh
+++ b/clang/utils/make-ast-dump-check.sh
@@ -70,6 +70,10 @@ BEGIN {
   if ($generate_serialization_test == 1) {
 gsub(" imported", "{{( imported)?}}", s)
 gsub(" ", "{{( )?}}", s)
+gsub("line:[0-9]+:[0-9]+", "line:{{.*}}", s)
+gsub("line:[0-9]+", "line:{{.*}}", s)
+gsub("col:[0-9]+", "col:{{.*}}", s)
+gsub(":[0-9]+:[0-9]+", "{{.*}}", s)
   }
 }
 



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


[clang] 39d2ae0 - [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-07-06 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-07-06T13:32:49-04:00
New Revision: 39d2ae0afb2312a15e4d15a0855b35b4e1c49fc4

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

LOG: [FPEnv][Clang][Driver] Disable constrained floating point on targets 
lacking support.

We currently have strict floating point/constrained floating point enabled
for all targets. Constrained SDAG nodes get converted to the regular ones
before reaching the target layer. In theory this should be fine.

However, the changes are exposed to users through multiple clang options
already in use in the field, and the changes are _completely_ _untested_
on almost all of our targets. Bugs have already been found, like
"https://bugs.llvm.org/show_bug.cgi?id=45274";.

This patch disables constrained floating point options in clang everywhere
except X86 and SystemZ. A warning will be printed when this happens.

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

Added: 
clang/test/CodeGen/fp-strictfp.cpp

Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/SystemZ.h
clang/lib/Basic/Targets/X86.h
clang/lib/Frontend/CompilerInstance.cpp
clang/test/CodeGen/aarch64-neon-misc-constrained.c
clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
clang/test/CodeGen/arm64-vrnd-constrained.c
clang/test/CodeGen/builtins-ppc-fpconstrained.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 83c13e0dbbe0..db334a7899c4 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -37,6 +37,12 @@ def note_fe_backend_plugin: Note<"%0">, BackendInfo;
 def warn_fe_override_module : Warning<
 "overriding the module target triple with %0">,
 InGroup>;
+def warn_fe_backend_unsupported_fp_rounding : Warning<
+"overriding currently unsupported rounding mode on this target">,
+InGroup;
+def warn_fe_backend_unsupported_fp_exceptions : Warning<
+"overriding currently unsupported use of floating point exceptions "
+"on this target">, InGroup;
 
 def remark_fe_backend_optimization_remark : Remark<"%0">, BackendInfo,
 InGroup;

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 37e0b77e79ed..ff07608c81e4 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -107,6 +107,7 @@ def DoublePromotion : DiagGroup<"double-promotion">;
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;
 def UnsupportedAbs : DiagGroup<"unsupported-abs">;
+def UnsupportedFPOpt : DiagGroup<"unsupported-floating-point-opt">;
 def UnsupportedCB : DiagGroup<"unsupported-cb">;
 def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">;
 def UnsupportedTargetOpt : DiagGroup<"unsupported-target-opt">;

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 140f55ff66b1..2ee3b1659630 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -192,6 +192,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   bool HasFloat128;
   bool HasFloat16;
   bool HasBFloat16;
+  bool HasStrictFP;
 
   unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
   unsigned short SimdDefaultAlign;
@@ -577,6 +578,9 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Determine whether the _BFloat16 type is supported on this target.
   virtual bool hasBFloat16Type() const { return HasBFloat16; }
 
+  /// Determine whether constrained floating point is supported on this target.
+  virtual bool hasStrictFP() const { return HasStrictFP; }
+
   /// Return the alignment that is suitable for storing any
   /// object with a fundamental alignment requirement.
   unsigned getSuitableAlign() const { return SuitableAlign; }

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 7f360b715da9..eccdc21d724a 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -37,6 +37,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), 
Triple(T) {
   HasFloat128 = false;
   HasFloat16 = false;
   HasBFloat16 = false;
+  HasStrictFP = false;
   PointerWidth = PointerAlign = 32;
   BoolWidth = BoolAlign = 8;
   IntWidth = IntAlign = 32;

diff  --git a/clang/lib/Basic/T

[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-07-06 Thread Kevin P. Neal 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 rG39d2ae0afb23: [FPEnv][Clang][Driver] Disable constrained 
floating point on targets lacking… (authored by kpn).

Changed prior to commit:
  https://reviews.llvm.org/D80952?vs=272530&id=275760#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80952

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/test/CodeGen/aarch64-neon-misc-constrained.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
  clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
  clang/test/CodeGen/arm64-vrnd-constrained.c
  clang/test/CodeGen/builtins-ppc-fpconstrained.c
  clang/test/CodeGen/fp-strictfp.cpp

Index: clang/test/CodeGen/fp-strictfp.cpp
===
--- /dev/null
+++ clang/test/CodeGen/fp-strictfp.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -ffp-exception-behavior=strict -O2 -verify=exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -O2 -verify=rounding -emit-llvm -o - %s | FileCheck %s
+//
+// Verify that constrained intrinsics are not used.
+// As more targets gain support for constrained intrinsics the triple
+// in this test will need to change.
+
+// rounding-warning@* {{overriding currently unsupported rounding mode on this target}}
+// exception-warning@* {{overriding currently unsupported use of floating point exceptions on this target}}
+float fp_precise_1(float a, float b, float c) {
+// CHECK: _Z12fp_precise_1fff
+// CHECK: %[[M:.+]] = fmul float{{.*}}
+// CHECK: fadd float %[[M]], %c
+  return a * b + c;
+}
+
+
Index: clang/test/CodeGen/builtins-ppc-fpconstrained.c
===
--- clang/test/CodeGen/builtins-ppc-fpconstrained.c
+++ clang/test/CodeGen/builtins-ppc-fpconstrained.c
@@ -12,6 +12,9 @@
 // RUN: -o - %s | FileCheck --check-prefix=CHECK-ASM \
 // RUN: --check-prefix=FIXME-CHECK  %s
 
+// Disabled until constrained floating point is completed for PowerPC.
+// XFAIL: *
+
 typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
 typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
 
Index: clang/test/CodeGen/arm64-vrnd-constrained.c
===
--- clang/test/CodeGen/arm64-vrnd-constrained.c
+++ clang/test/CodeGen/arm64-vrnd-constrained.c
@@ -9,6 +9,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 float64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); }
Index: clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
===
--- clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
+++ clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
@@ -32,6 +32,9 @@
 
 // REQUIRES: arm-registered-target,aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vrndi_f32
Index: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
@@ -19,6 +19,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vsqrt_f16
Index: clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
+++ clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/test/CodeGen/aarch64-neon-misc-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-misc-constrained.c
+++ clang/test/CodeGen/aarc

[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

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

Delete `enable-npm-call-graph-profile` option for NPM, using 
`enable-call-graph-profile` for both LPM and NPM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
  llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Instrumentation/CGProfile.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Instrumentation/cgprofile.ll
  llvm/test/Other/new-pm-cgprofile.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/NewPMDriver.h
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -278,6 +278,10 @@
 cl::desc("Specify time trace file destination"),
 cl::value_desc("filename"));
 
+static cl::opt EnableCallGraphProfile(
+"enable-call-graph-profile", cl::init(true), cl::Hidden,
+cl::desc("Enable call graph profile pass (default = on)"));
+
 static cl::opt RemarksWithHotness(
 "pass-remarks-with-hotness",
 cl::desc("With PGO, include profile count in optimization remarks"),
@@ -414,6 +418,8 @@
 
   Builder.SLPVectorize = OptLevel > 1 && SizeLevel < 2;
 
+  Builder.CallGraphProfile = EnableCallGraphProfile;
+
   if (TM)
 TM->adjustPassManager(Builder);
 
@@ -767,7 +773,8 @@
RemarksFile.get(), PassPipeline, Passes, OK, VK,
PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
-   EmitModuleHash, EnableDebugify, Coroutines)
+   EmitModuleHash, EnableDebugify, Coroutines,
+   EnableCallGraphProfile)
? 0
: 1;
   }
Index: llvm/tools/opt/NewPMDriver.h
===
--- llvm/tools/opt/NewPMDriver.h
+++ llvm/tools/opt/NewPMDriver.h
@@ -66,7 +66,8 @@
  bool ShouldPreserveAssemblyUseListOrder,
  bool ShouldPreserveBitcodeUseListOrder,
  bool EmitSummaryIndex, bool EmitModuleHash,
- bool EnableDebugify, bool Coroutines);
+ bool EnableDebugify, bool Coroutines,
+ bool CallGraphProfile);
 } // namespace llvm
 
 #endif
Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -220,7 +220,8 @@
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
bool EmitSummaryIndex, bool EmitModuleHash,
-   bool EnableDebugify, bool Coroutines) {
+   bool EnableDebugify, bool Coroutines,
+   bool CallGraphProfile) {
   bool VerifyEachPass = VK == VK_VerifyEachPass;
 
   Optional P;
@@ -266,6 +267,7 @@
   SI.registerCallbacks(PIC);
 
   PipelineTuningOptions PTO;
+  PTO.CallGraphProfile = CallGraphProfile;
   // LoopUnrolling defaults on to true and DisableLoopUnrolling is initialized
   // to false above so we shouldn't necessarily need to check whether or not the
   // option has been enabled.
Index: llvm/test/Other/opt-Os-pipeline.ll
===
--- llvm/test/Other/opt-Os-pipeline.ll
+++ llvm/test/Other/opt-Os-pipeline.ll
@@ -266,6 +266,13 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: Dead Global Elimination
 ; CHECK-NEXT: Merge Duplicate Global Constants
+; CHECK-NEXT: Call Graph Profile
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Post-Dominator Tree Construction
+; CHECK-NEXT: Branch Probability Analysis
+; CHECK-NEXT: Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Natural Loop Information
Index: llvm/test/Other/opt-O3-pipeline.ll
===
--- llvm/test/Other/opt-O3-pipeline.ll
+++ llvm/test/Other/opt-O3-pipeline.ll
@@ -285,6 +285,13 @@
 ; CHECK-NEXT: Strip Unused Function Prototypes
 ; CHECK-NEXT: 

[PATCH] D82425: [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty function body.

2020-07-06 Thread Zequan Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG054704082b46: [SemaCXX] Fix false positive of 
-Wuninitialized-const-reference in empty… (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82425

Files:
  clang/lib/Analysis/UninitializedValues.cpp
  clang/test/SemaCXX/warn-uninitialized-const-reference.cpp


Index: clang/test/SemaCXX/warn-uninitialized-const-reference.cpp
===
--- clang/test/SemaCXX/warn-uninitialized-const-reference.cpp
+++ clang/test/SemaCXX/warn-uninitialized-const-reference.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wuninitialized-const-reference -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions 
-Wuninitialized-const-reference -verify %s
 
 class A {
 public:
@@ -9,6 +9,16 @@
   bool operator!=(const A &);
 };
 
+template 
+void ignore_template(const T &) {}
+void ignore(const int &i) {}
+void dont_ignore_non_empty(const int &i) { ; } // Calling this won't silence 
the warning for you
+void dont_ignore_block(const int &i) {
+  {}
+} // Calling this won't silence the warning for you
+void ignore_function_try_block_maybe_who_knows(const int &) try {
+} catch (...) {
+}
 A const_ref_use_A(const A &a);
 int const_ref_use(const int &i);
 A const_use_A(const A a);
@@ -33,4 +43,13 @@
   if (a < 42)
 m = 1;
   const_ref_use(m);
+
+  int l;
+  ignore_template(l); // This is a pattern to avoid "unused variable" warnings 
(e.g. boost::ignore_unused).
+  ignore(l);
+  dont_ignore_non_empty(l); // expected-warning {{variable 'l' is 
uninitialized when passed as a const reference argument here}}
+  int l1;
+  dont_ignore_block(l1); // expected-warning {{variable 'l1' is uninitialized 
when passed as a const reference argument here}}
+  int l2;
+  ignore_function_try_block_maybe_who_knows(l2); // expected-warning 
{{variable 'l2' is uninitialized when passed as a const reference argument 
here}}
 }
Index: clang/lib/Analysis/UninitializedValues.cpp
===
--- clang/lib/Analysis/UninitializedValues.cpp
+++ clang/lib/Analysis/UninitializedValues.cpp
@@ -405,6 +405,15 @@
   return QT->isAnyPointerType() && QT->getPointeeType().isConstQualified();
 }
 
+static bool hasTrivialBody(CallExpr *CE) {
+  if (FunctionDecl *FD = CE->getDirectCallee()) {
+if (FunctionTemplateDecl *FTD = FD->getPrimaryTemplate())
+  return FTD->getTemplatedDecl()->hasTrivialBody();
+return FD->hasTrivialBody();
+  }
+  return false;
+}
+
 void ClassifyRefs::VisitCallExpr(CallExpr *CE) {
   // Classify arguments to std::move as used.
   if (CE->isCallToStdMove()) {
@@ -413,7 +422,7 @@
   classify(CE->getArg(0), Use);
 return;
   }
-
+  bool isTrivialBody = hasTrivialBody(CE);
   // If a value is passed by const pointer to a function,
   // we should not assume that it is initialized by the call, and we
   // conservatively do not assume that it is used.
@@ -423,7 +432,7 @@
I != E; ++I) {
 if ((*I)->isGLValue()) {
   if ((*I)->getType().isConstQualified())
-classify((*I), ConstRefUse);
+classify((*I), isTrivialBody ? Ignore : ConstRefUse);
 } else if (isPointerToConst((*I)->getType())) {
   const Expr *Ex = stripCasts(DC->getParentASTContext(), *I);
   const auto *UO = dyn_cast(Ex);


Index: clang/test/SemaCXX/warn-uninitialized-const-reference.cpp
===
--- clang/test/SemaCXX/warn-uninitialized-const-reference.cpp
+++ clang/test/SemaCXX/warn-uninitialized-const-reference.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wuninitialized-const-reference -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wuninitialized-const-reference -verify %s
 
 class A {
 public:
@@ -9,6 +9,16 @@
   bool operator!=(const A &);
 };
 
+template 
+void ignore_template(const T &) {}
+void ignore(const int &i) {}
+void dont_ignore_non_empty(const int &i) { ; } // Calling this won't silence the warning for you
+void dont_ignore_block(const int &i) {
+  {}
+} // Calling this won't silence the warning for you
+void ignore_function_try_block_maybe_who_knows(const int &) try {
+} catch (...) {
+}
 A const_ref_use_A(const A &a);
 int const_ref_use(const int &i);
 A const_use_A(const A a);
@@ -33,4 +43,13 @@
   if (a < 42)
 m = 1;
   const_ref_use(m);
+
+  int l;
+  ignore_template(l); // This is a pattern to avoid "unused variable" warnings (e.g. boost::ignore_unused).
+  ignore(l);
+  dont_ignore_non_empty(l); // expected-warning {{variable 'l' is uninitialized when passed as a const reference argument here}}
+  int l1;
+  dont_ignore_block(l1); // expected-warning {{variable 'l1' is uninitialized when passed as a const reference argument here}}
+  int l2;
+  ignore_function_try_block_maybe_wh

[clang] 0547040 - [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty function body.

2020-07-06 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2020-07-06T10:52:05-07:00
New Revision: 054704082b461418d3dac3a379792cdaf52d40b3

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

LOG: [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty 
function body.

Summary:
Some libraries use empty function to ignore unused variable warnings, which 
gets a new warning from `-Wuninitialized-const-reference`, discussed here 
https://reviews.llvm.org/D79895#2107604.
This patch should fix that.

Reviewers: hans, nick, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: aaron.ballman, riccibruno, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Analysis/UninitializedValues.cpp
clang/test/SemaCXX/warn-uninitialized-const-reference.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UninitializedValues.cpp 
b/clang/lib/Analysis/UninitializedValues.cpp
index 3d44d1c070fe..67cd39728c35 100644
--- a/clang/lib/Analysis/UninitializedValues.cpp
+++ b/clang/lib/Analysis/UninitializedValues.cpp
@@ -405,6 +405,15 @@ static bool isPointerToConst(const QualType &QT) {
   return QT->isAnyPointerType() && QT->getPointeeType().isConstQualified();
 }
 
+static bool hasTrivialBody(CallExpr *CE) {
+  if (FunctionDecl *FD = CE->getDirectCallee()) {
+if (FunctionTemplateDecl *FTD = FD->getPrimaryTemplate())
+  return FTD->getTemplatedDecl()->hasTrivialBody();
+return FD->hasTrivialBody();
+  }
+  return false;
+}
+
 void ClassifyRefs::VisitCallExpr(CallExpr *CE) {
   // Classify arguments to std::move as used.
   if (CE->isCallToStdMove()) {
@@ -413,7 +422,7 @@ void ClassifyRefs::VisitCallExpr(CallExpr *CE) {
   classify(CE->getArg(0), Use);
 return;
   }
-
+  bool isTrivialBody = hasTrivialBody(CE);
   // If a value is passed by const pointer to a function,
   // we should not assume that it is initialized by the call, and we
   // conservatively do not assume that it is used.
@@ -423,7 +432,7 @@ void ClassifyRefs::VisitCallExpr(CallExpr *CE) {
I != E; ++I) {
 if ((*I)->isGLValue()) {
   if ((*I)->getType().isConstQualified())
-classify((*I), ConstRefUse);
+classify((*I), isTrivialBody ? Ignore : ConstRefUse);
 } else if (isPointerToConst((*I)->getType())) {
   const Expr *Ex = stripCasts(DC->getParentASTContext(), *I);
   const auto *UO = dyn_cast(Ex);

diff  --git a/clang/test/SemaCXX/warn-uninitialized-const-reference.cpp 
b/clang/test/SemaCXX/warn-uninitialized-const-reference.cpp
index 292793ba483a..d24b561441d8 100644
--- a/clang/test/SemaCXX/warn-uninitialized-const-reference.cpp
+++ b/clang/test/SemaCXX/warn-uninitialized-const-reference.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wuninitialized-const-reference -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions 
-Wuninitialized-const-reference -verify %s
 
 class A {
 public:
@@ -9,6 +9,16 @@ class A {
   bool operator!=(const A &);
 };
 
+template 
+void ignore_template(const T &) {}
+void ignore(const int &i) {}
+void dont_ignore_non_empty(const int &i) { ; } // Calling this won't silence 
the warning for you
+void dont_ignore_block(const int &i) {
+  {}
+} // Calling this won't silence the warning for you
+void ignore_function_try_block_maybe_who_knows(const int &) try {
+} catch (...) {
+}
 A const_ref_use_A(const A &a);
 int const_ref_use(const int &i);
 A const_use_A(const A a);
@@ -33,4 +43,13 @@ void f(int a) {
   if (a < 42)
 m = 1;
   const_ref_use(m);
+
+  int l;
+  ignore_template(l); // This is a pattern to avoid "unused variable" warnings 
(e.g. boost::ignore_unused).
+  ignore(l);
+  dont_ignore_non_empty(l); // expected-warning {{variable 'l' is 
uninitialized when passed as a const reference argument here}}
+  int l1;
+  dont_ignore_block(l1); // expected-warning {{variable 'l1' is uninitialized 
when passed as a const reference argument here}}
+  int l2;
+  ignore_function_try_block_maybe_who_knows(l2); // expected-warning 
{{variable 'l2' is uninitialized when passed as a const reference argument 
here}}
 }



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-06 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

In D83013#2132088 , @aeubanks wrote:

> In D83013#2132070 , @echristo wrote:
>
> > Adding Chandler and Alina here as well.
> >
> > In general, I don't think that this is such a great idea. Being able to 
> > have this sort of thing work more reliably is one of the reasons for the 
> > new pass manager. I think I'd like to see this split out into an old versus 
> > new pass manager pass to avoid the difficulty of cleaning this up after we 
> > finish migrating llvm to the new pass manager. This also seems to add some 
> > technical debt around options and other enablement which is also less than 
> > ideal. Is this compelling to add right now versus finishing work migrating 
> > llvm completely to the new pass manager and removing the old one? From 
> > speaking with Alina I think that work should be done in a short while.
> >
> > Thanks.
> >
> > -eric
>
>
> I don't think we're that close yet, probably at least a couple months out, 
> there are lots of loose ends to be tied up. I'll make a post soon in llvm-dev 
> (maybe first we can sync up again) about what I think needs to be done before 
> the NPM switch.


+1 to sync up again and make progress towards the NPM switch.

I don't want to block this patch, but I do agree with Eric's point. We *really* 
want to focus more on the switch then invest into more LPM infra. Short term 
resolutions to unblock folks, with the best split possible, sure, keeping in 
mind they'll need to be cleaned up. But I don't want us to lose focus on tying 
up the remaining loose ends for the switch.
I think it's critical for LLVM's codebase health to focus on the NPM switch in 
the next couple of months.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


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

2020-07-06 Thread Gui Andrade via Phabricator via cfe-commits
guiand updated this revision to Diff 275771.
guiand added a comment.

Another wave of test updates


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82317

Files:
  clang/test/ARCMT/objcmt-instancetype.m
  clang/test/ARCMT/objcmt-instancetype.m.result
  clang/test/ARCMT/objcmt-numeric-literals.m
  clang/test/ARCMT/objcmt-numeric-literals.m.result
  clang/test/AST/ast-dump-openmp-begin-declare-variant_6.c
  clang/test/AST/gen_ast_dump_json_test.py
  clang/test/ASTMerge/unnamed_fields/test.cpp
  clang/test/Analysis/casts.c
  clang/test/Analysis/inlining/DynDispatchBifurcate.m
  clang/test/Analysis/inlining/InlineObjCClassMethod.m
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/missing-bind-temporary.cpp
  clang/test/Analysis/silence-checkers-and-packages-core-all.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p4.cpp
  clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp
  clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp
  clang/test/CXX/drs/dr0xx.cpp
  clang/test/CXX/except/except.spec/p14-ir.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
  clang/test/CXX/modules-ts/codegen-basics.cppm
  clang/test/CXX/special/class.copy/p3.cpp
  clang/test/CodeGen/2004-02-13-Memset.c
  clang/test/CodeGen/2004-06-17-UnorderedCompares.c
  clang/test/CodeGen/2006-05-19-SingleEltReturn.c
  clang/test/CodeGen/2007-02-25-C-DotDotDot.c
  clang/test/CodeGen/2007-06-18-SextAttrAggregate.c
  clang/test/CodeGen/2008-03-05-syncPtr.c
  clang/test/CodeGen/2008-07-29-override-alias-decl.c
  clang/test/CodeGen/2008-07-30-implicit-initialization.c
  clang/test/CodeGen/2008-07-31-promotion-of-compound-pointer-arithmetic.c
  clang/test/CodeGen/2009-02-13-zerosize-union-field.c
  clang/test/CodeGen/2009-05-04-EnumInreg.c
  clang/test/CodeGen/2009-09-24-SqrtErrno.c
  clang/test/CodeGen/3dnow-builtins.c
  clang/test/CodeGen/64bit-swiftcall.c
  clang/test/CodeGen/PR3589-freestanding-libcalls.c
  clang/test/CodeGen/_Bool-conversion.c
  clang/test/CodeGen/aapcs-align.cpp
  clang/test/CodeGen/aapcs-bitfield.c
  clang/test/CodeGen/aapcs64-align.cpp
  clang/test/CodeGen/aarch64-args.cpp
  clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
  clang/test/CodeGen/aarch64-byval-temp.c
  clang/test/CodeGen/aarch64-neon-3v.c
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-dot-product.c
  clang/test/CodeGen/aarch64-neon-extract.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-fp16fml.c
  clang/test/CodeGen/aarch64-neon-ldst-one.c
  clang/test/CodeGen/aarch64-neon-scalar-copy.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-neon-vcombine.c
  clang/test/CodeGen/aarch64-neon-vget-hilo.c
  clang/test/CodeGen/aarch64-neon-vget.c
  clang/test/CodeGen/aarch64-poly128.c
  clang/test/CodeGen/aarch64-poly64.c
  clang/test/CodeGen/aarch64-varargs-ms.c
  clang/test/CodeGen/aarch64-varargs.c
  clang/test/CodeGen/address-space-avr.c
  clang/test/CodeGen/address-space-field1.c
  clang/test/CodeGen/address-space.c
  clang/test/CodeGen/aggregate-assign-call.c
  clang/test/CodeGen/aix-return.c
  clang/test/CodeGen/aix-struct-arg.c
  clang/test/CodeGen/aix-vaargs.c
  clang/test/CodeGen/alias.c
  clang/test/CodeGen/align-param.c
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/arc/arguments.c
  clang/test/CodeGen/arc/struct-align.c
  clang/test/CodeGen/arm-aapcs-vfp.c
  clang/test/CodeGen/arm-abi-vector.c
  clang/test/CodeGen/arm-arguments.c
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/CodeGen/arm-byval-align.c
  clang/test/CodeGen/arm-cmse-attr.c
  clang/test/CodeGen/arm-cmse-call.c
  clang/test/CodeGen/arm-float-helpers.c
  clang/test/CodeGen/arm-fp16-arguments.c
  clang/test/CodeGen/arm-homogenous.c
  clang/test/CodeGen/arm-mangle-bf16.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vld24.c
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm-neon-dot-product.c
  clang/test/CodeGen/arm-neon-fma.c
  clang/test/CodeGen/arm-neon-numeric-maxmin.c
  clang/test/CodeGen/arm-neon-vcvtX.c
  clang/test/CodeGen/arm-pcs.c
  clang/test/CodeGen/arm-swiftcall.c
  clang/test/CodeGen/arm-varargs.c
  clang/test/CodeGen/arm-vector-arguments.c
  clang/test/CodeGen/arm-vfp16-arguments.c
  clang/test/CodeGen/arm-vfp16-arguments2.cpp
  clang/test/CodeGen/arm64-aapcs-arguments.c
  clang/test/CodeGen/arm64-abi-vector.c
  clang/test/CodeGen/arm64-arguments.c
  clang/test/CodeGen/arm64-microsoft-arguments.cpp
  clang/test/CodeGen/arm64-microsoft-intrinsics.c
  clang/test/CodeGen/arm64-mte.c
  clang/test/CodeGen/arm64_32-vaarg.c
  clang/test/CodeGen/arm64_32.c
  clang/

[clang] bfdafa3 - [FPEnv][Clang][Driver] Failing tests are now expected failures.

2020-07-06 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-07-06T14:20:49-04:00
New Revision: bfdafa32a0fa4b2745627fe57dd253db10ac3fcf

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

LOG: [FPEnv][Clang][Driver] Failing tests are now expected failures.

These are now expected failures on PowerPC. They can be reenabled when
PowerPC is ready.

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

Added: 


Modified: 
clang/test/CodeGen/fpconstrained-cmp-double.c
clang/test/CodeGen/fpconstrained-cmp-float.c
clang/test/CodeGen/fpconstrained.c
clang/test/CodeGen/fpconstrained.cpp

Removed: 




diff  --git a/clang/test/CodeGen/fpconstrained-cmp-double.c 
b/clang/test/CodeGen/fpconstrained-cmp-double.c
index 2819970a3fcf..d2744d283c84 100644
--- a/clang/test/CodeGen/fpconstrained-cmp-double.c
+++ b/clang/test/CodeGen/fpconstrained-cmp-double.c
@@ -5,6 +5,9 @@
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP
 
+// Disabled until constrained floating point is completed for PowerPC.
+// XFAIL: *
+
 _Bool QuietEqual(double f1, double f2) {
   // CHECK-LABEL: define {{.*}}i1 @QuietEqual(double %f1, double %f2)
 

diff  --git a/clang/test/CodeGen/fpconstrained-cmp-float.c 
b/clang/test/CodeGen/fpconstrained-cmp-float.c
index 0265fc54c02b..2403e542b929 100644
--- a/clang/test/CodeGen/fpconstrained-cmp-float.c
+++ b/clang/test/CodeGen/fpconstrained-cmp-float.c
@@ -5,6 +5,9 @@
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP
 
+// Disabled until constrained floating point is completed for PowerPC.
+// XFAIL: *
+
 _Bool QuietEqual(float f1, float f2) {
   // CHECK-LABEL: define {{.*}}i1 @QuietEqual(float %f1, float %f2)
 

diff  --git a/clang/test/CodeGen/fpconstrained.c 
b/clang/test/CodeGen/fpconstrained.c
index 902d6b5baf49..e268af46a2de 100644
--- a/clang/test/CodeGen/fpconstrained.c
+++ b/clang/test/CodeGen/fpconstrained.c
@@ -5,6 +5,10 @@
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s 
-check-prefix=FAST
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s 
-check-prefix=EXCEPT
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s 
-check-prefix=MAYTRAP
+
+// Disabled until constrained floating point is completed for PowerPC.
+// XFAIL: *
+
 float f0, f1, f2;
 
 void foo() {

diff  --git a/clang/test/CodeGen/fpconstrained.cpp 
b/clang/test/CodeGen/fpconstrained.cpp
index e914abcc6926..8db68533d37c 100644
--- a/clang/test/CodeGen/fpconstrained.cpp
+++ b/clang/test/CodeGen/fpconstrained.cpp
@@ -5,6 +5,10 @@
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions 
-ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | 
FileCheck %s -check-prefix=FAST
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions 
-ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | 
FileCheck %s -check-prefix=EXCEPT
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions 
-ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | 
FileCheck %s -check-prefix=MAYTRAP
+
+// Disabled until constrained floating point is completed for PowerPC.
+// XFAIL: *
+
 float f0, f1, f2;
 
   template 



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


[PATCH] D82087: AMDGPU/clang: Add builtins for llvm.amdgcn.ballot

2020-07-06 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


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

https://reviews.llvm.org/D82087



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


[PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST)

2020-07-06 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/lib/Parse/ParseExpr.cpp:1933
 }
+if (getLangOpts().OpenMP >= 50 && Tok.is(tok::colon)) {
+  // Consume ':'

cchen wrote:
> ABataev wrote:
> > Seems to me, it is too broad. According to the standard, it must be allowed 
> > only in to/from clauses. 
> I did the check in Sema, I'll move the check here. Thanks
We didn't pass OpenMP clause information here. Do you think I should put the 
analysis in ParseOpenMPVarList or put the check in SemaOpenMP?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82800



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


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-07-06 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This seems to break tests everywhere, eg 
http://45.33.8.238/linux/22152/step_7.txt or 
http://lab.llvm.org:8011/builders/clang-x86_64-debian-new-pass-manager-fast/builds/11251

Please take a look and revert if the fix takes a while.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80952



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


[clang] 2b35511 - [FPEnv][Clang][Driver] Failing tests are now expected failures only on PowerPC

2020-07-06 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-07-06T14:44:06-04:00
New Revision: 2b35511350454dd22997f129ee529e3fdb129ac2

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

LOG: [FPEnv][Clang][Driver] Failing tests are now expected failures only on 
PowerPC

Mark these tests as only failing on PowerPC. Avoids unexpected passes on
other bots.

Fingers crossed.

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

Added: 


Modified: 
clang/test/CodeGen/fpconstrained-cmp-double.c
clang/test/CodeGen/fpconstrained-cmp-float.c
clang/test/CodeGen/fpconstrained.c
clang/test/CodeGen/fpconstrained.cpp

Removed: 




diff  --git a/clang/test/CodeGen/fpconstrained-cmp-double.c 
b/clang/test/CodeGen/fpconstrained-cmp-double.c
index d2744d283c84..7c4d04677842 100644
--- a/clang/test/CodeGen/fpconstrained-cmp-double.c
+++ b/clang/test/CodeGen/fpconstrained-cmp-double.c
@@ -6,7 +6,7 @@
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP
 
 // Disabled until constrained floating point is completed for PowerPC.
-// XFAIL: *
+// XFAIL: powerpc, powerpc64, powerpc64le
 
 _Bool QuietEqual(double f1, double f2) {
   // CHECK-LABEL: define {{.*}}i1 @QuietEqual(double %f1, double %f2)

diff  --git a/clang/test/CodeGen/fpconstrained-cmp-float.c 
b/clang/test/CodeGen/fpconstrained-cmp-float.c
index 2403e542b929..964725080a7e 100644
--- a/clang/test/CodeGen/fpconstrained-cmp-float.c
+++ b/clang/test/CodeGen/fpconstrained-cmp-float.c
@@ -6,7 +6,7 @@
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP
 
 // Disabled until constrained floating point is completed for PowerPC.
-// XFAIL: *
+// XFAIL: powerpc, powerpc64, powerpc64le
 
 _Bool QuietEqual(float f1, float f2) {
   // CHECK-LABEL: define {{.*}}i1 @QuietEqual(float %f1, float %f2)

diff  --git a/clang/test/CodeGen/fpconstrained.c 
b/clang/test/CodeGen/fpconstrained.c
index e268af46a2de..3ce9b6fa1a55 100644
--- a/clang/test/CodeGen/fpconstrained.c
+++ b/clang/test/CodeGen/fpconstrained.c
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s 
-check-prefix=MAYTRAP
 
 // Disabled until constrained floating point is completed for PowerPC.
-// XFAIL: *
+// XFAIL: powerpc, powerpc64, powerpc664le
 
 float f0, f1, f2;
 

diff  --git a/clang/test/CodeGen/fpconstrained.cpp 
b/clang/test/CodeGen/fpconstrained.cpp
index 8db68533d37c..39634dd96994 100644
--- a/clang/test/CodeGen/fpconstrained.cpp
+++ b/clang/test/CodeGen/fpconstrained.cpp
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions 
-ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | 
FileCheck %s -check-prefix=MAYTRAP
 
 // Disabled until constrained floating point is completed for PowerPC.
-// XFAIL: *
+// XFAIL: powerpc, powerpc64, powerpc64le
 
 float f0, f1, f2;
 



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


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-07-06 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

Already on it. I hope I got it now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80952



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


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

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

Note also that @arsenm is still a blocking reviewer. It is generally expected 
that all feedback is acknowledged. @kpn you should probably wait for @arsenm to 
explicitly clear the blocker.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80952



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


[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-07-06 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:121
 "bugprone-narrowing-conversions");
+CheckFactories.registerCheck("bugprone-no-escape");
 CheckFactories.registerCheck(

aaron.ballman wrote:
> Given that this is limited to Objective-C, why register this under `bugprone` 
> as opposed to the `objc` module? Alternatively, why limit to Objective-C when 
> blocks can be used in other modes like C or C++ with `-fblocks`?
Thats a good point, maybe restrict this to `LangOptions::ObjC || 
LangOptions::Blocks` Then it can be left in bugprone.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904



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


[PATCH] D83084: DomTree: Remove the releaseMemory() method

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

@arsenm - if you can, please include some text whenever approving a patch via 
phabricator, otherwise no email indicating approval is sent to the mailing 
lists (which makes auditing reviews difficult)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83084



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


[PATCH] D82728: [clang] Add -Wsuggest-override

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

Generally Clang tries to avoid stylistic warnings like this (& they are left to 
be addressed by tools like clang-tidy), hence why 
-Winconsistent-missing-override was implemented that way (the presence of at 
least one "override" being a signal the user intended to use override and 
missed some, rather than that maybe the user hadn't intended to use it at all 
(because they were compiling their code with multiple versions, etc)). (but I 
wouldn't outright rule this out - just mentioning the general principle here, 
perhaps @rsmith or others have other ideas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[clang] 916e2ca - Revert "[FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support."

2020-07-06 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-07-06T14:57:45-04:00
New Revision: 916e2ca99785d34db73945940923a487efad32ad

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

LOG: Revert "[FPEnv][Clang][Driver] Disable constrained floating point on 
targets lacking support."

My mistake, I had a blocking reviewer.

This reverts commit 39d2ae0afb2312a15e4d15a0855b35b4e1c49fc4.
This reverts commit bfdafa32a0fa4b2745627fe57dd253db10ac3fcf.
This reverts commit 2b35511350454dd22997f129ee529e3fdb129ac2.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/SystemZ.h
clang/lib/Basic/Targets/X86.h
clang/lib/Frontend/CompilerInstance.cpp
clang/test/CodeGen/aarch64-neon-misc-constrained.c
clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
clang/test/CodeGen/arm64-vrnd-constrained.c
clang/test/CodeGen/builtins-ppc-fpconstrained.c
clang/test/CodeGen/fpconstrained-cmp-double.c
clang/test/CodeGen/fpconstrained-cmp-float.c
clang/test/CodeGen/fpconstrained.c
clang/test/CodeGen/fpconstrained.cpp

Removed: 
clang/test/CodeGen/fp-strictfp.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index db334a7899c4..83c13e0dbbe0 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -37,12 +37,6 @@ def note_fe_backend_plugin: Note<"%0">, BackendInfo;
 def warn_fe_override_module : Warning<
 "overriding the module target triple with %0">,
 InGroup>;
-def warn_fe_backend_unsupported_fp_rounding : Warning<
-"overriding currently unsupported rounding mode on this target">,
-InGroup;
-def warn_fe_backend_unsupported_fp_exceptions : Warning<
-"overriding currently unsupported use of floating point exceptions "
-"on this target">, InGroup;
 
 def remark_fe_backend_optimization_remark : Remark<"%0">, BackendInfo,
 InGroup;

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index ff07608c81e4..37e0b77e79ed 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -107,7 +107,6 @@ def DoublePromotion : DiagGroup<"double-promotion">;
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;
 def UnsupportedAbs : DiagGroup<"unsupported-abs">;
-def UnsupportedFPOpt : DiagGroup<"unsupported-floating-point-opt">;
 def UnsupportedCB : DiagGroup<"unsupported-cb">;
 def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">;
 def UnsupportedTargetOpt : DiagGroup<"unsupported-target-opt">;

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 2ee3b1659630..140f55ff66b1 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -192,7 +192,6 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   bool HasFloat128;
   bool HasFloat16;
   bool HasBFloat16;
-  bool HasStrictFP;
 
   unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
   unsigned short SimdDefaultAlign;
@@ -578,9 +577,6 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Determine whether the _BFloat16 type is supported on this target.
   virtual bool hasBFloat16Type() const { return HasBFloat16; }
 
-  /// Determine whether constrained floating point is supported on this target.
-  virtual bool hasStrictFP() const { return HasStrictFP; }
-
   /// Return the alignment that is suitable for storing any
   /// object with a fundamental alignment requirement.
   unsigned getSuitableAlign() const { return SuitableAlign; }

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index eccdc21d724a..7f360b715da9 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -37,7 +37,6 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), 
Triple(T) {
   HasFloat128 = false;
   HasFloat16 = false;
   HasBFloat16 = false;
-  HasStrictFP = false;
   PointerWidth = PointerAlign = 32;
   BoolWidth = BoolAlign = 8;
   IntWidth = IntAlign = 32;

diff  --git a/clang/lib/Basic/Targets/SystemZ.h 
b/clang/lib/Basic/Targets/SystemZ.h
index d7869e3754a8..134b0313b86a 100644
--- a/clang/lib/Basic/Targets/SystemZ.h
+++ b/clang/lib/Basic/Targets/SystemZ.h
@@ -48,7 +48,6 @@ class LLVM_LI

[PATCH] D82791: [lit] Improve lit's output with default settings and --verbose.

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

The changes here are for text printed for failing tests, right?
And `showAllOutput` is orthogonal and just shows everything even for 
non-failing tests?




Comment at: llvm/utils/lit/lit/OutputSettings.py:34
+ONLY_FAILING_COMMAND = CommandOutputStyle("OnlyFailing")
+UP_TO_AND_INCLUDING_FAILING_COMMAND = CommandOutputStyle("UpToAndIncluding")
+

I really like the "communicating intent" part of this infrastructure.  However, 
this is a lot of code and `if`s considering we really only have to distinguish 
two cases.  From your commit message:

- default (no flags): no script, show only failing line in command output
- `-v`: full script, adds 'set +x', shows command output

Am I missing something or could everything be keyed off a single verbose 
(reading from the code below `showAllOutput` implies verbose) flag.  Do we 
anticipate other combinations being useful? (In general I would argue for 
striving for the simplest implementation that gives us what we currently want 
and not try to anticipate future extensions.)

Have you considered (or started out with) just using a single verbose flag to 
base your decisions in the implementation functions?  



Comment at: llvm/utils/lit/lit/TestRunner.py:1499
 
+def locate_last_run_line(output_str):
+"""

I feel like this function is the most complex part of this patch.  I don't 
fully follow it, but you experimented and believe this is the best approach and 
wrote a whole test suite so I am happy with it.



Comment at: llvm/utils/lit/lit/TestRunner.py:1503-1508
+Returns a pair of:
+- The index in ``output_str`` pointing to immediately after the preceding
+  newline, i.e. the start of the RUN line, before any shell-specific
+  prefix.
+- The matched substring itself, including the number at the end,
+  starting with 'RUN', skipping the shell-specific prefix.

Why use a complicated parser-like return value? Our only caller below could 
just receive the potentially found RUN line.



Comment at: llvm/utils/lit/lit/TestRunner.py:1593
+assert(lit_config.script_output_style == OutputSettings.FULL_SCRIPT)
+return default_output()
+

Why are we using two local functions here?

The whole thing could be (already assuming just one verbose flag):

```
def make_script_output(lit_config, script_lines, exit_code):
if not lit_config.verbose:
return ""
return ...
```



Comment at: llvm/utils/lit/lit/TestRunner.py:1614-1617
+line_start, run_line_str = locate_last_run_line(cmd_output)
+# maybe there was an error, or maybe we are not truncating anything
+if run_line_str is None or line_start == 0:
+return default_output()

This block should be pushed into the `lit_config.command_output_style == 
OutputSettings.ONLY_FAILING_COMMAND` case, otherwise we are always searching 
for the last line, even if we don't really use the result of the computation.

Also: if we fail to find the RUN line, we might print the note to use 
`--verbose` even if the user already specified it.



Comment at: llvm/utils/lit/lit/TestRunner.py:1624
+   == OutputSettings.UP_TO_AND_INCLUDING_FAILING_COMMAND)
+return make_output(cmd_output, is_truncated=False)
 

Please try to simplify this a bit, maybe the following?

```
def make_command_output():
if not lit_config.quiet:
return ""

verbose = lit_config.verbose
output = "header {} ...".format(", truncated" if verbose else "")
if verbose:
output += cmd_output
else:
run_line = locate_last_run_line() # then deal with "not found" case
output += ...
output += "Note:  try to use --verbose"

 return output
```



Comment at: llvm/utils/lit/lit/cl_arguments.py:56
 action="store_true")
+# TODO(python3): Use aliases kwarg for add_argument above.
 format_group.add_argument("-vv", "--echo-all-commands",

I think aliases kwarg is something else (seems to be related to subparsers).  
You could just add `"-vv", "--echo-all-commands"` after `"--verbose"` to allow 
for additional names for the flag, but I think I prefer to have it separate 
(makes it easer to remove it if we ever decide to drop the alias in the future).

So long comment short: just drop this comment please.



Comment at: llvm/utils/lit/lit/cl_arguments.py:178
+opts.command_output_style = OutputSettings.ONLY_FAILING_COMMAND
+opts.echo_all_commands = True
+

Unconditionally overwritten below



Comment at: llvm/utils/lit/lit/cl_arguments.py:195
+cmd_output_style == OutputSettings.UP_TO_AND_INCLUDING_FAILING_COMMAND
+or cmd_output_style == OutputSettings.ONLY_FAILING_COMMAND)
 

`opts.echo_all_commands = opts.command_

[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-07-06 Thread Ellis Hoag via Phabricator via cfe-commits
ellis marked an inline comment as done.
ellis added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:82
 "bugprone-bool-pointer-implicit-conversion");
-CheckFactories.registerCheck(
-"bugprone-branch-clone");
+CheckFactories.registerCheck("bugprone-branch-clone");
 CheckFactories.registerCheck(

aaron.ballman wrote:
> It looks like unrelated formatting changes may have snuck in?
The script `add_new_check.py` doesn't format the code that it generated so a 
few lines aren't linted. Would you like me to undo these extra formatted lines?



Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:121
 "bugprone-narrowing-conversions");
+CheckFactories.registerCheck("bugprone-no-escape");
 CheckFactories.registerCheck(

njames93 wrote:
> aaron.ballman wrote:
> > Given that this is limited to Objective-C, why register this under 
> > `bugprone` as opposed to the `objc` module? Alternatively, why limit to 
> > Objective-C when blocks can be used in other modes like C or C++ with 
> > `-fblocks`?
> Thats a good point, maybe restrict this to `LangOptions::ObjC || 
> LangOptions::Blocks` Then it can be left in bugprone.
Ok, I'll include `LangOptions::Blocks`.



Comment at: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp:37
+if (Var && Var->hasAttr()) {
+  diag(MatchedEscapingBlock->getBeginLoc(),
+   "pointer %0 with attribute 'noescape' is captured by an "

aaron.ballman wrote:
> Given that the capture is the issue (not the block), why not point to the use 
> of the captured variable?
I actually agree that pointing to the use of the captured variable would be 
easier to read, but honestly I couldn't figure out how to grab the location of 
that use. All I could get was the definition of the variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904



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


[PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST)

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



Comment at: clang/lib/Parse/ParseExpr.cpp:1933
 }
+if (getLangOpts().OpenMP >= 50 && Tok.is(tok::colon)) {
+  // Consume ':'

cchen wrote:
> cchen wrote:
> > ABataev wrote:
> > > Seems to me, it is too broad. According to the standard, it must be 
> > > allowed only in to/from clauses. 
> > I did the check in Sema, I'll move the check here. Thanks
> We didn't pass OpenMP clause information here. Do you think I should put the 
> analysis in ParseOpenMPVarList or put the check in SemaOpenMP?
Try to pass it somehow. Maybe, create a parser data member with the current 
kind of the clause we trying to parse?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82800



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


[PATCH] D83183: [clang] Rework how and when APValues are dumped

2020-07-06 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 275783.
riccibruno added a comment.

Make `dumpAPValueChildren` a private member function and remove 
`TextNodeDumper::getOS`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83183

Files:
  clang/include/clang/AST/APValue.h
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/JSONNodeDumper.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/lib/AST/APValue.cpp
  clang/lib/AST/ASTDumper.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/test/AST/alignas_maybe_odr_cleanup.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-APValue-arithmetic.cpp
  clang/test/AST/ast-dump-APValue-array.cpp
  clang/test/AST/ast-dump-APValue-struct.cpp
  clang/test/AST/ast-dump-APValue-todo.cpp
  clang/test/AST/ast-dump-APValue-union.cpp
  clang/test/AST/ast-dump-APValue-vector.cpp
  clang/test/AST/ast-dump-attr.cpp
  clang/test/AST/ast-dump-color.cpp
  clang/test/AST/ast-dump-constant-expr.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-records.cpp
  clang/test/AST/ast-dump-stmt.cpp
  clang/test/AST/pr43983.cpp
  clang/test/Import/switch-stmt/test.cpp
  clang/test/Tooling/clang-check-ast-dump.cpp

Index: clang/test/Tooling/clang-check-ast-dump.cpp
===
--- clang/test/Tooling/clang-check-ast-dump.cpp
+++ clang/test/Tooling/clang-check-ast-dump.cpp
@@ -33,6 +33,7 @@
 // CHECK-ATTR-NEXT: FieldDecl{{.*}}n
 // CHECK-ATTR-NEXT:   AlignedAttr
 // CHECK-ATTR-NEXT: ConstantExpr
+// CHECK-ATTR-NEXT:   value: Int 2
 // CHECK-ATTR-NEXT:   BinaryOperator
 //
 // RUN: clang-check -ast-dump -ast-dump-filter test_namespace::AfterNullNode "%s" -- 2>&1 | FileCheck -check-prefix CHECK-AFTER-NULL %s
Index: clang/test/Import/switch-stmt/test.cpp
===
--- clang/test/Import/switch-stmt/test.cpp
+++ clang/test/Import/switch-stmt/test.cpp
@@ -5,20 +5,26 @@
 // CHECK-NEXT: CompoundStmt
 // CHECK-NEXT: CaseStmt
 // CHECK-NEXT: ConstantExpr
+// CHECK-NEXT: value: Int 1
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: CaseStmt
 // CHECK-NEXT: ConstantExpr
+// CHECK-NEXT: value: Int 2
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: BreakStmt
 // CHECK-NEXT: CaseStmt
 // CHECK-NEXT: ConstantExpr
+// CHECK-NEXT: value: Int 3
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: ConstantExpr
+// CHECK-NEXT: value: Int 4
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: CaseStmt
 // CHECK-NEXT: ConstantExpr
+// CHECK-NEXT: value: Int 5
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: ConstantExpr
+// CHECK-NEXT: value: Int 5
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: BreakStmt
 
@@ -30,16 +36,20 @@
 // CHECK-NEXT: CompoundStmt
 // CHECK-NEXT: CaseStmt
 // CHECK-NEXT: ConstantExpr
+// CHECK-NEXT: value: Int 1
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: BreakStmt
 // CHECK-NEXT: CaseStmt
 // CHECK-NEXT: ConstantExpr
+// CHECK-NEXT: value: Int 2
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: BreakStmt
 // CHECK-NEXT: CaseStmt
 // CHECK-NEXT: ConstantExpr
+// CHECK-NEXT: value: Int 3
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: ConstantExpr
+// CHECK-NEXT: value: Int 5
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: BreakStmt
 
Index: clang/test/AST/pr43983.cpp
===
--- clang/test/AST/pr43983.cpp
+++ clang/test/AST/pr43983.cpp
@@ -9,6 +9,7 @@
 
 struct B { _Alignas(64) struct { int b; };   };
 
-// CHECK: AlignedAttr {{.*}} _Alignas
-// CHECK: ConstantExpr {{.*}} 64
-// CHECK: IntegerLiteral {{.*}} 64
+// CHECK:  | `-AlignedAttr {{.*}}  _Alignas
+// CHECK-NEXT:  |   `-ConstantExpr {{.*}}  'int'
+// CHECK-NEXT:  | |-value: Int 64
+// CHECK-NEXT:  | `-IntegerLiteral {{.*}}  'int' 64
Index: clang/test/AST/ast-dump-stmt.cpp
===
--- clang/test/AST/ast-dump-stmt.cpp
+++ clang/test/AST/ast-dump-stmt.cpp
@@ -130,6 +130,7 @@
 ;
   // CHECK: IfStmt 0x{{[^ ]*}} 
   // CHECK-NEXT: ConstantExpr 0x{{[^ ]*}}  'bool'
+  // CHECK-NEXT: value: Int 1
   // CHECK-NEXT: BinaryOperator
   // CHECK-NEXT: UnaryExprOrTypeTraitExpr
   // CHECK-NEXT: ParenExpr
@@ -144,6 +145,7 @@
 ;
   // CHECK: IfStmt 0x{{[^ ]*}}  has_else
   // CHECK-NEXT: ConstantExpr 0x{{[^ ]*}}  'bool'
+  // CHECK-NEXT: value: Int 1
   // CHECK-NEXT: BinaryOperator
   // CHECK-NEXT: UnaryExprOrTypeTraitExpr
   // CHECK-NEXT: ParenExpr
Index: clang/test/AST/ast-dump-records.cpp
===
--- clang/test/AST/ast-dump-records.cpp
+++ clang/test/AST/ast-dump-records.cpp
@@ -15,7 +15,7 @@
 // CHECK: CXXRecordDecl 0x{{[^ ]*}}  col:8 referenced struct B
 
 struct A {
-  // CHECK: CXXRecordDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}}  line:[[@LINE-1]]:8 struct A definition
+  // CHECK: CXXRecord

[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-07-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:82
 "bugprone-bool-pointer-implicit-conversion");
-CheckFactories.registerCheck(
-"bugprone-branch-clone");
+CheckFactories.registerCheck("bugprone-branch-clone");
 CheckFactories.registerCheck(

ellis wrote:
> aaron.ballman wrote:
> > It looks like unrelated formatting changes may have snuck in?
> The script `add_new_check.py` doesn't format the code that it generated so a 
> few lines aren't linted. Would you like me to undo these extra formatted 
> lines?
Yes, please. The way I usually do this, btw, is to run the patch through 
clang-format-diff so that only the lines I've touched get formatted: 
https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting



Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:121
 "bugprone-narrowing-conversions");
+CheckFactories.registerCheck("bugprone-no-escape");
 CheckFactories.registerCheck(

ellis wrote:
> njames93 wrote:
> > aaron.ballman wrote:
> > > Given that this is limited to Objective-C, why register this under 
> > > `bugprone` as opposed to the `objc` module? Alternatively, why limit to 
> > > Objective-C when blocks can be used in other modes like C or C++ with 
> > > `-fblocks`?
> > Thats a good point, maybe restrict this to `LangOptions::ObjC || 
> > LangOptions::Blocks` Then it can be left in bugprone.
> Ok, I'll include `LangOptions::Blocks`.
I think the only option you need is `LangOptions::Blocks` (it should be enabled 
automatically in ObjC language mode).



Comment at: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp:37
+if (Var && Var->hasAttr()) {
+  diag(MatchedEscapingBlock->getBeginLoc(),
+   "pointer %0 with attribute 'noescape' is captured by an "

ellis wrote:
> aaron.ballman wrote:
> > Given that the capture is the issue (not the block), why not point to the 
> > use of the captured variable?
> I actually agree that pointing to the use of the captured variable would be 
> easier to read, but honestly I couldn't figure out how to grab the location 
> of that use. All I could get was the definition of the variable.
Ah, yeah, I just looked at the class and it looks like we don't track that 
information yet and it would be somewhat involved to get it. Can you add a 
FIXME comment above the call to `diag()` mentioning that we'd prefer to 
diagnose the use of the capture rather than the block?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904



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


[PATCH] D82937: Fix `isInfixBinaryOp` that returned true for postfix ++

2020-07-06 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/unittests/Tooling/CXXOperatorCallExprTest.cpp:21
+  const std::string Code = R"cpp(
+  struct X{
+friend X operator+(X, X);

Please add a space before "{".



Comment at: clang/unittests/Tooling/CXXOperatorCallExprTest.cpp:24
+  };
+  void test(X x){
+x + x;

Please add a space before "{". (Throughout the patch.)



Comment at: clang/unittests/Tooling/CXXOperatorCallExprTest.cpp:1
+//===- unittests/Tooling/CXXOperatorCallExprTest.cpp 
--===//
+//

eduucaldas wrote:
> This file is in the `unittests/Tooling` instead in the `unittests/AST` 
> directory because I wanted to have access to the `TestVisitor` 
> infrastructure. I know the solution is not optimal and I am looking for 
> suggestions
Could you make a separate patch where you move `TestVisitor.h` under 
`clang/include/clang/Testing`? Then you can place this test into 
`unittests/AST`.

OTOH, since the test is not testing the visitation, WDYT about changing the 
test to use AST matchers instead? It would seem to lead to more straightforward 
tests: get the AST node, act on it. See `clang/unittests/AST/MatchVerifier.h`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82937



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


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-07-06 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D80952#2133693 , @MaskRay wrote:

> Note also that @arsenm is still a blocking reviewer. It is generally expected 
> that all feedback is acknowledged. @kpn you should probably have waited for 
> @arsenm to explicitly clear the blocker.


I think this is one of the finer points of phabricator usage that are generally 
ignored.

I'd still like to have a way to force this on unhandled targets, but I don't 
care that much about this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80952



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


[PATCH] D83250: [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver

2020-07-06 Thread Zixu Wang via Phabricator via cfe-commits
zixuw created this revision.
zixuw added reviewers: arphaman, ributzka.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Add clang option `-Wundef-prefix=TARGET_OS_` and `-Werror=undef-prefix`
to Darwin driver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83250

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -954,6 +954,10 @@
 : Darwin(D, Triple, Args) {}
 
 void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const {
+  // Always error about undefined 'TARGET_OS_*' macros.
+  CC1Args.push_back("-Wundef-prefix=TARGET_OS_");
+  CC1Args.push_back("-Werror=undef-prefix");
+
   // For modern targets, promote certain warnings to errors.
   if (isTargetWatchOSBased() || getTriple().isArch64Bit()) {
 // Always enable -Wdeprecated-objc-isa-usage and promote it


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -954,6 +954,10 @@
 : Darwin(D, Triple, Args) {}
 
 void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const {
+  // Always error about undefined 'TARGET_OS_*' macros.
+  CC1Args.push_back("-Wundef-prefix=TARGET_OS_");
+  CC1Args.push_back("-Werror=undef-prefix");
+
   // For modern targets, promote certain warnings to errors.
   if (isTargetWatchOSBased() || getTriple().isArch64Bit()) {
 // Always enable -Wdeprecated-objc-isa-usage and promote it
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82791: [lit] Improve lit's output with default settings and --verbose.

2020-07-06 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple marked 2 inline comments as done.
varungandhi-apple added a comment.

Thanks for the review, it's a big patch. 😅 I'm a bit busy at the moment, I will 
respond to the other comments later this week or sometime next week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82791



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


[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-07-06 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

The test was failing on Linux if I set LLVM_DEFAULT_TARGET_TRIPLE. For example 
if I set it to`powerpc64le-linux-gnu` clang actually uses 
"powerpc64le-unknown-linux-gnu".

Would you be able to provide a fix to this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79842



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


[PATCH] D83183: [clang] Rework how and when APValues are dumped

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

LGTM!




Comment at: clang/test/Import/switch-stmt/test.cpp:8
 // CHECK-NEXT: ConstantExpr
+// CHECK-NEXT: value: Int 1
 // CHECK-NEXT: IntegerLiteral

riccibruno wrote:
> aaron.ballman wrote:
> > I sort of wonder whether we want both the text and the JSON dumpers to dump 
> > these as: `value(type): `, as that seems like it produces results that 
> > are a bit more well-structured. WDYT?
> I'm not sure I follow. The `value` is just a label for the child of the 
> `VarDecl`.
> If you look at a more complex example such as:
> ```
> VarDecl {{.*}}  col:{{.*}} s4 'const S4'
> |-value: Struct
> | |-base: Struct
> | | `-fields: Int 0, Union .j Int 0
> | |-fields: Int 1, Int 2, Int 3
> | |-field: Struct
> | `-fields: Int 4, Int 5, Int 6
> ```
> 
> There is no other `value` label.
Ah, I was misunderstanding the ouput.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83183



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


[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-06 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In D82728#2133720 , @dblaikie wrote:

> (the presence of at least one "override" being a signal the user intended to 
> use override and missed some [...]


I'm in favor of `-Wsuggest-override`, and would definitely use it if it 
existed. The problem I see with `-Wmissing-override`, as it's been implemented, 
is that it uses the wrong granularity for "intent": it looks only across the 
methods of a single class, rather than across all the classes of a single 
header, or across a single translation unit, or across my entire codebase. In 
real life, I //always// want to look across my entire codebase (excluding 
system headers). If //any// class in my project uses `override`, I want Clang 
to take that as a clear declaration of intent to use `override` throughout; I 
don't want Clang treating class A differently from class B. But of course Clang 
can't look at my whole codebase simultaneously. So the next best thing is to 
give the user a simple way to "preload the intent flag": to say "As soon as you 
start processing //any// class, please act as if intent has been declared for 
that class." Adding `-Wsuggest-override` to my build line seems like a perfect 
way to implement that "preload" facility.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:3075
+  : diag::
+warn_inconsistent_function_marked_not_override_overriding);
+else

These linebreaks are super unfortunate. Could they be improved by doing it like 
this?
```
auto EmitDiag = [this, MD](unsigned DiagDtor, unsigned DiagFn) {
  unsigned DiagID = isa(MD) ? DiagDtor : DiagFn;
  Diag(MD->getLocation(), DiagID) << MD->getDeclName();
  const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
  Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
};
if (Inconsistent)
  
EmitDiag(diag::warn_inconsistent_destructor_marked_not_override_overriding,
   diag::warn_inconsistent_function_marked_not_override_overriding);
else
  EmitDiag(diag::warn_suggest_destructor_marked_not_override_overriding
   diag::warn_suggest_function_marked_not_override_overriding);
```



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6764
+  if (HasOverridingMethodWithoutOverrideControl) {
+bool InconsistentOverrideControl = HasMethodWithOverrideControl;
 for (auto *M : Record->methods())

Can you s/InconsistentOverrideControl/HasInconsistentOverrideControl/ without 
causing bad linebreaks?



Comment at: clang/test/SemaCXX/warn-suggest-destructor-override:6
+  ~A() {}
+  void virtual run() {}
+};

Surely this doesn't compile?!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[clang] 16d83c3 - [WebAssembly] Added 64-bit memory.grow/size/copy/fill

2020-07-06 Thread Wouter van Oortmerssen via cfe-commits

Author: Wouter van Oortmerssen
Date: 2020-07-06T12:49:50-07:00
New Revision: 16d83c395a1f8660fc583a66e1927a5c433fbbe1

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

LOG: [WebAssembly] Added 64-bit memory.grow/size/copy/fill

This covers both the existing memory functions as well as the new bulk memory 
proposal.
Added new test files since changes where also required in the inputs.

Also removes unused init/drop intrinsics rather than trying to make them work 
for 64-bit.

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

Added: 
llvm/test/CodeGen/WebAssembly/bulk-memory64.ll
llvm/test/CodeGen/WebAssembly/memory-addr64.ll

Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyInstrBulkMemory.td
llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td
llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp
llvm/test/MC/WebAssembly/bulk-memory-encodings.s

Removed: 
llvm/test/CodeGen/WebAssembly/bulk-memory-intrinsics.ll



diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 5e6f0d90ab46..ecee7782920f 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -25,10 +25,6 @@
 BUILTIN(__builtin_wasm_memory_size, "zIi", "n")
 BUILTIN(__builtin_wasm_memory_grow, "zIiz", "n")
 
-// Bulk memory builtins
-TARGET_BUILTIN(__builtin_wasm_memory_init, "vIUiIUiv*UiUi", "", "bulk-memory")
-TARGET_BUILTIN(__builtin_wasm_data_drop, "vIUi", "", "bulk-memory")
-
 // Thread-local storage
 TARGET_BUILTIN(__builtin_wasm_tls_size, "z", "nc", "bulk-memory")
 TARGET_BUILTIN(__builtin_wasm_tls_align, "z", "nc", "bulk-memory")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 265fee392a82..91969267cdb9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -16101,30 +16101,6 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_memory_grow, 
ResultType);
 return Builder.CreateCall(Callee, Args);
   }
-  case WebAssembly::BI__builtin_wasm_memory_init: {
-llvm::APSInt SegConst;
-if (!E->getArg(0)->isIntegerConstantExpr(SegConst, getContext()))
-  llvm_unreachable("Constant arg isn't actually constant?");
-llvm::APSInt MemConst;
-if (!E->getArg(1)->isIntegerConstantExpr(MemConst, getContext()))
-  llvm_unreachable("Constant arg isn't actually constant?");
-if (!MemConst.isNullValue())
-  ErrorUnsupported(E, "non-zero memory index");
-Value *Args[] = {llvm::ConstantInt::get(getLLVMContext(), SegConst),
- llvm::ConstantInt::get(getLLVMContext(), MemConst),
- EmitScalarExpr(E->getArg(2)), 
EmitScalarExpr(E->getArg(3)),
- EmitScalarExpr(E->getArg(4))};
-Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_memory_init);
-return Builder.CreateCall(Callee, Args);
-  }
-  case WebAssembly::BI__builtin_wasm_data_drop: {
-llvm::APSInt SegConst;
-if (!E->getArg(0)->isIntegerConstantExpr(SegConst, getContext()))
-  llvm_unreachable("Constant arg isn't actually constant?");
-Value *Arg = llvm::ConstantInt::get(getLLVMContext(), SegConst);
-Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_data_drop);
-return Builder.CreateCall(Callee, {Arg});
-  }
   case WebAssembly::BI__builtin_wasm_tls_size: {
 llvm::Type *ResultType = ConvertType(E->getType());
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_tls_size, ResultType);

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index 36d259f7405d..f7e3dc1ea5e7 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -26,18 +26,6 @@ __SIZE_TYPE__ memory_grow(__SIZE_TYPE__ delta) {
   // WEBASSEMBLY64: call i64 @llvm.wasm.memory.grow.i64(i32 0, i64 %{{.*}})
 }
 
-void memory_init(void *dest, int offset, int size) {
-  __builtin_wasm_memory_init(3, 0, dest, offset, size);
-  // WEBASSEMBLY32: call void @llvm.wasm.memory.init(i32 3, i32 0, i8* 
%{{.*}}, i32 %{{.*}}, i32 %{{.*}})
-  // WEBASSEMBLY64: call void @llvm.wasm.memory.init(i32 3, i32 0, i8* 
%{{.*}}, i32 %{{.*}}, i32 %{{.*}})
-}
-
-void data_drop() {
-  __builtin_wasm_data_drop(3);
-  // WEBASSEMBLY32: call void @llvm.wasm.data.drop(i32 3)
-  // WEBASSEMBLY64: call void @llvm.wasm.data.drop(i32 3)
-}
-
 __SIZE_TYPE__ tls_size() {
   return __builtin_wasm_tls_size();
   // WEBASSEMBLY32: call i32 @llvm.wasm.tls.size.i32()

diff  --git a/llv

[PATCH] D82821: [WebAssembly] Added 64-bit memory.grow/size/init/copy/fill

2020-07-06 Thread Wouter van Oortmerssen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG16d83c395a1f: [WebAssembly] Added 64-bit 
memory.grow/size/copy/fill (authored by aardappel).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D82821?vs=275785&id=275804#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82821

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrBulkMemory.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td
  llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp
  llvm/test/CodeGen/WebAssembly/bulk-memory-intrinsics.ll
  llvm/test/CodeGen/WebAssembly/bulk-memory64.ll
  llvm/test/CodeGen/WebAssembly/memory-addr64.ll
  llvm/test/MC/WebAssembly/bulk-memory-encodings.s

Index: llvm/test/MC/WebAssembly/bulk-memory-encodings.s
===
--- llvm/test/MC/WebAssembly/bulk-memory-encodings.s
+++ llvm/test/MC/WebAssembly/bulk-memory-encodings.s
@@ -1,4 +1,5 @@
 # RUN: llvm-mc -show-encoding -triple=wasm32-unknown-unknown -mattr=+bulk-memory < %s | FileCheck %s
+# RUN: llvm-mc -show-encoding -triple=wasm64-unknown-unknown -mattr=+bulk-memory < %s | FileCheck %s
 
 main:
 .functype main () -> ()
Index: llvm/test/CodeGen/WebAssembly/memory-addr64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/memory-addr64.ll
@@ -0,0 +1,27 @@
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s
+
+; Test that basic memory operations assemble as expected with 64-bit addresses.
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm64-unknown-unknown"
+
+declare i64 @llvm.wasm.memory.size.i64(i32) nounwind readonly
+declare i64 @llvm.wasm.memory.grow.i64(i32, i64) nounwind
+
+; CHECK-LABEL: memory_size:
+; CHECK-NEXT: .functype memory_size () -> (i64){{$}}
+; CHECK-NEXT: memory.size $push0=, 0{{$}}
+; CHECK-NEXT: return $pop0{{$}}
+define i64 @memory_size() {
+  %a = call i64 @llvm.wasm.memory.size.i64(i32 0)
+  ret i64 %a
+}
+
+; CHECK-LABEL: memory_grow:
+; CHECK-NEXT: .functype memory_grow (i64) -> (i64){{$}}
+; CHECK: memory.grow $push0=, 0, $0{{$}}
+; CHECK-NEXT: return $pop0{{$}}
+define i64 @memory_grow(i64 %n) {
+  %a = call i64 @llvm.wasm.memory.grow.i64(i32 0, i64 %n)
+  ret i64 %a
+}
Index: llvm/test/CodeGen/WebAssembly/bulk-memory64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/bulk-memory64.ll
@@ -0,0 +1,210 @@
+; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+bulk-memory | FileCheck %s --check-prefixes CHECK,BULK-MEM
+; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=-bulk-memory | FileCheck %s --check-prefixes CHECK,NO-BULK-MEM
+
+; Test that basic bulk memory codegen works correctly
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm64-unknown-unknown"
+
+declare void @llvm.memcpy.p0i8.p0i8.i8(i8*, i8*, i8, i1)
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i1)
+declare void @llvm.memcpy.p0i32.p0i32.i64(i32*, i32*, i64, i1)
+
+declare void @llvm.memmove.p0i8.p0i8.i8(i8*, i8*, i8, i1)
+declare void @llvm.memmove.p0i8.p0i8.i64(i8*, i8*, i64, i1)
+declare void @llvm.memmove.p0i32.p0i32.i64(i32*, i32*, i64, i1)
+
+declare void @llvm.memset.p0i8.i8(i8*, i8, i8, i1)
+declare void @llvm.memset.p0i8.i64(i8*, i8, i64, i1)
+declare void @llvm.memset.p0i32.i64(i32*, i8, i64, i1)
+
+; CHECK-LABEL: memcpy_i8:
+; NO-BULK-MEM-NOT: memory.copy
+; BULK-MEM-NEXT: .functype memcpy_i8 (i64, i64, i32) -> ()
+; BULK-MEM-NEXT: i64.extend_i32_u $push0=, $2
+; BULK-MEM-NEXT: memory.copy 0, 0, $0, $1, $pop0
+; BULK-MEM-NEXT: return
+define void @memcpy_i8(i8* %dest, i8* %src, i8 zeroext %len) {
+  call void @llvm.memcpy.p0i8.p0i8.i8(i8* %dest, i8* %src, i8 %len, i1 0)
+  ret void
+}
+
+; CHECK-LABEL: memmove_i8:
+; NO-BULK-MEM-NOT: memory.copy
+; BULK-MEM-NEXT: .functype memmove_i8 (i64, i64, i32) -> ()
+; BULK-MEM-NEXT: i64.extend_i32_u $push0=, $2
+; BULK-MEM-NEXT: memory.copy 0, 0, $0, $1, $pop0
+; BULK-MEM-NEXT: return
+define void @memmove_i8(i8* %dest, i8* %src, i8 zeroext %len) {
+  call void @llvm.memmove.p0i8.p0i8.i8(i8* %dest, i8* %src, i8 %len, i1 0)
+  ret void
+}
+
+; CHECK-LABEL: memset_i8:
+; NO-BULK-MEM-NOT: memory.fill
+; BULK-MEM-NEXT: .functype memset_i8 (i64, i32, i32) -> ()
+; BULK-MEM-NEXT: i64.extend_i32_u $pus

[PATCH] D83250: [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver

2020-07-06 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Please add a test-case as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83250



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

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

In D83013#2132070 , @echristo wrote:

> Adding Chandler and Alina here as well.
>
> In general, I don't think that this is such a great idea. Being able to have 
> this sort of thing work more reliably is one of the reasons for the new pass 
> manager. I think I'd like to see this split out into an old versus new pass 
> manager pass to avoid the difficulty of cleaning this up after we finish 
> migrating llvm to the new pass manager. This also seems to add some technical 
> debt around options and other enablement which is also less than ideal. Is 
> this compelling to add right now versus finishing work migrating llvm 
> completely to the new pass manager and removing the old one? From speaking 
> with Alina I think that work should be done in a short while.


Given how long the new pass manager has been in progress, we definitely don't 
want to block on enabling it. So yes, porting this pass to the current pass 
manager is compelling to do right now. I also don't see why it should be a big 
deal.

As for splitting it into separate passes, this patch technically does that, 
although it extracts and changes the core code a bit so it can be shared 
between the passes. I think that's how most passes have been adapted to work 
with both pass managers, no?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


[PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically

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



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:267
   BinaryOperatorKind OK = BO->getOpcode();
-  SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext());
+  Expr *LHS = BO->getLHS();
+  Expr *RHS = BO->getRHS();

You should probably use const where applicable.
Especially where the refs value depends on a condition operator (eg. few lines 
below) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83190



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


[PATCH] D83173: [VE] Correct stack alignment

2020-07-06 Thread Kazushi Marukawa via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf3bda047d5a: [VE] Correct stack alignment (authored by 
kaz7).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83173

Files:
  clang/lib/Basic/Targets/VE.h
  clang/test/CodeGen/target-data.c
  llvm/lib/Target/VE/VETargetMachine.cpp


Index: llvm/lib/Target/VE/VETargetMachine.cpp
===
--- llvm/lib/Target/VE/VETargetMachine.cpp
+++ llvm/lib/Target/VE/VETargetMachine.cpp
@@ -41,8 +41,8 @@
   // VE supports 32 bit and 64 bits integer on registers
   Ret += "-n32:64";
 
-  // Stack alignment is 64 bits
-  Ret += "-S64";
+  // Stack alignment is 128 bits
+  Ret += "-S128";
 
   return Ret;
 }
Index: clang/test/CodeGen/target-data.c
===
--- clang/test/CodeGen/target-data.c
+++ clang/test/CodeGen/target-data.c
@@ -250,3 +250,7 @@
 // RUN: %clang_cc1 -triple bpfeb -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=BPFEB
 // BPFEB: target datalayout = "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
+
+// RUN: %clang_cc1 -triple ve -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=VE
+// VE: target datalayout = "e-m:e-i64:64-n32:64-S128"
Index: clang/lib/Basic/Targets/VE.h
===
--- clang/lib/Basic/Targets/VE.h
+++ clang/lib/Basic/Targets/VE.h
@@ -45,7 +45,7 @@
 WCharType = UnsignedInt;
 WIntType = UnsignedInt;
 UseZeroLengthBitfieldAlignment = true;
-resetDataLayout("e-m:e-i64:64-n32:64-S64");
+resetDataLayout("e-m:e-i64:64-n32:64-S128");
   }
 
   void getTargetDefines(const LangOptions &Opts,


Index: llvm/lib/Target/VE/VETargetMachine.cpp
===
--- llvm/lib/Target/VE/VETargetMachine.cpp
+++ llvm/lib/Target/VE/VETargetMachine.cpp
@@ -41,8 +41,8 @@
   // VE supports 32 bit and 64 bits integer on registers
   Ret += "-n32:64";
 
-  // Stack alignment is 64 bits
-  Ret += "-S64";
+  // Stack alignment is 128 bits
+  Ret += "-S128";
 
   return Ret;
 }
Index: clang/test/CodeGen/target-data.c
===
--- clang/test/CodeGen/target-data.c
+++ clang/test/CodeGen/target-data.c
@@ -250,3 +250,7 @@
 // RUN: %clang_cc1 -triple bpfeb -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=BPFEB
 // BPFEB: target datalayout = "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
+
+// RUN: %clang_cc1 -triple ve -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=VE
+// VE: target datalayout = "e-m:e-i64:64-n32:64-S128"
Index: clang/lib/Basic/Targets/VE.h
===
--- clang/lib/Basic/Targets/VE.h
+++ clang/lib/Basic/Targets/VE.h
@@ -45,7 +45,7 @@
 WCharType = UnsignedInt;
 WIntType = UnsignedInt;
 UseZeroLengthBitfieldAlignment = true;
-resetDataLayout("e-m:e-i64:64-n32:64-S64");
+resetDataLayout("e-m:e-i64:64-n32:64-S128");
   }
 
   void getTargetDefines(const LangOptions &Opts,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically

2020-07-06 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 marked 2 inline comments as done.
gamesh411 added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:279
+// or on the RHS (eg.: 1 + it). Both cases are modeled.
+bool IsItOnLHS = BO->getLHS()->getType()->isPointerType();
+Expr *&ItExpr = IsItOnLHS ? LHS : RHS;

What do you think about this detection strategy? This assumes that the Iterator 
being detected is a pointer (and not a used-defined type like STL iterators 
etc.). Would you say that this assumption holds every time because the 
pointer-iterators are only handled in this checkPostStmt callback and the 
traditional iterators in another callback?



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:282
+SVal &OffsetVal = IsItOnLHS ? RVal : LVal;
+handlePtrIncrOrDecr(C, ItExpr, BinaryOperator::getOverloadedOperator(OK),
+OffsetVal);

During the development of this patch, I saw something related. At the beginning 
of handlePtrIncrOrDecr, there is a branch on whether the Expr (2nd argument) is 
a pointer. I think that branch could just be an assertion. What do you think? 
(or maybe I should create a patch to show what I mean?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83190



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


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

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

Fix review remarks


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,150 @@
+// 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 testPromotionOnlyTypes(int a, char b) {
+  if (a == b) {
+// FIXME: support transferring char ranges onto equal int symbols
+//when char is promoted to int

[PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker

2020-07-06 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 275605.
gamesh411 added a comment.
Herald added subscribers: ASDenysPetrov, martong.

change license


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69318

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp
  clang/test/Analysis/sufficient-size-array-indexing-32bit.c
  clang/test/Analysis/sufficient-size-array-indexing-64bit.c

Index: clang/test/Analysis/sufficient-size-array-indexing-64bit.c
===
--- /dev/null
+++ clang/test/Analysis/sufficient-size-array-indexing-64bit.c
@@ -0,0 +1,127 @@
+// RUN: %clang_analyze_cc1 -triple x86_64 -analyzer-checker=core,alpha.cplusplus.SufficientSizeArrayIndexing %s -verify
+
+#include "Inputs/system-header-simulator.h"
+
+const unsigned long long one_byte_signed_max = (1ULL << 7) - 1;
+const unsigned long long two_byte_signed_max = (1ULL << 15) - 1;
+const unsigned long long four_byte_signed_max = (1ULL << 31) - 1;
+
+const unsigned long long one_byte_unsigned_max = (1ULL << 8) - 1;
+const unsigned long long two_byte_unsigned_max = (1ULL << 16) - 1;
+const unsigned long long four_byte_unsigned_max = (1ULL << 32) - 1;
+
+char smaller_than_1byte_signed_range[one_byte_signed_max];
+char exactly_1byte_signed_range[one_byte_signed_max + 1];
+char greater_than_1byte_signed_range[one_byte_signed_max + 2];
+
+char smaller_than_2byte_signed_range[two_byte_signed_max];
+char exactly_2byte_signed_range[two_byte_signed_max + 1];
+char greater_than_2byte_signed_range[two_byte_signed_max + 2];
+
+char smaller_than_4byte_signed_range[four_byte_signed_max];
+char exactly_4byte_signed_range[four_byte_signed_max + 1];
+char greater_than_4byte_signed_range[four_byte_signed_max + 2];
+
+char smaller_than_1byte_unsigned_range[one_byte_unsigned_max];
+char exactly_1byte_unsigned_range[one_byte_unsigned_max + 1];
+char greater_than_1byte_unsigned_range[one_byte_unsigned_max + 2];
+
+char smaller_than_2byte_unsigned_range[two_byte_unsigned_max];
+char exactly_2byte_unsigned_range[two_byte_unsigned_max + 1];
+char greater_than_2byte_unsigned_range[two_byte_unsigned_max + 2];
+
+char smaller_than_4byte_unsigned_range[four_byte_unsigned_max];
+char exactly_4byte_unsigned_range[four_byte_unsigned_max + 1];
+char greater_than_4byte_unsigned_range[four_byte_unsigned_max + 2];
+
+const char one_byte_signed_index = 1;  // sizeof(char) == 1
+const short two_byte_signed_index = 1; // sizeof(short) == 2
+const int four_byte_signed_index = 1;  // sizeof(int) == 4
+
+const unsigned char one_byte_unsigned_index = 1;
+const unsigned short two_byte_unsigned_index = 1;
+const unsigned int four_byte_unsigned_index = 1;
+
+void ignore_literal_indexing() {
+  char a = exactly_4byte_unsigned_range[32]; // nowarning
+}
+
+void ignore_literal_indexing_with_parens() {
+  char a = exactly_4byte_unsigned_range[(32)]; // nowarning
+}
+
+void range_check_one_byte_index() {
+  char r;
+  char *pr = &r;
+  *pr = smaller_than_1byte_signed_range[one_byte_signed_index]; // nowarning
+  *pr = exactly_1byte_signed_range[one_byte_signed_index];  // nowarning
+  *pr = greater_than_1byte_signed_range[one_byte_signed_index]; // expected-warning{{Indexing array with type 'char' cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+  *pr = smaller_than_1byte_unsigned_range[one_byte_unsigned_index]; // nowarning
+  *pr = exactly_1byte_unsigned_range[one_byte_unsigned_index];  // nowarning
+  *pr = greater_than_1byte_unsigned_range[one_byte_unsigned_index]; // expected-warning{{Indexing array with type 'unsigned char' cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+}
+
+void range_check_two_byte_index() {
+  char r;
+  char *pr = &r;
+  *pr = smaller_than_2byte_signed_range[two_byte_signed_index]; // nowarning
+  *pr = exactly_2byte_signed_range[two_byte_signed_index];  // nowarning
+  *pr = greater_than_2byte_signed_range[two_byte_signed_index]; // expected-warning{{Indexing array with type 'short' cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+  *pr = smaller_than_2byte_unsigned_range[two_byte_unsigned_index]; // nowarning
+  *pr = exactly_2byte_unsigned_range[two_byte_unsigned_index];  // nowarning
+  *pr = greater_than_2byte_unsigned_range[two_byte_unsigned_index]; // expected-warning{{Indexing array with type 'unsigned short' cannot cover the whole range of the array's index set, which may result in memory 

[PATCH] D83189: [clangd] More complete fix for hover crashes on invalid record.

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

thanks for doing this !




Comment at: clang-tools-extra/clangd/Hover.cpp:665
   if (auto *RD = llvm::dyn_cast(&ND)) {
 if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl()))
   HI.Size = Size->getQuantity();

i think we should bail out for invalid decls in here too. it won't crash but 
will provide spurious results. so i think an early exit for 
`ND.isInvalidDecl()` at the beginning of the function would be nice.



Comment at: clang-tools-extra/clangd/Hover.cpp:677
 HI.Size = Size->getQuantity();
-  if (!FD->isInvalidDecl())
 HI.Offset = Ctx.getFieldOffset(FD) / 8;
+  }

could you move this out of the if statement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83189



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


[PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker

2020-07-06 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 275611.
gamesh411 added a comment.

move to core.alpha


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69318

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp
  clang/test/Analysis/sufficient-size-array-indexing-32bit.c
  clang/test/Analysis/sufficient-size-array-indexing-64bit.c

Index: clang/test/Analysis/sufficient-size-array-indexing-64bit.c
===
--- /dev/null
+++ clang/test/Analysis/sufficient-size-array-indexing-64bit.c
@@ -0,0 +1,127 @@
+// RUN: %clang_analyze_cc1 -triple x86_64 -analyzer-checker=core,alpha.core.SufficientSizeArrayIndexing %s -verify
+
+#include "Inputs/system-header-simulator.h"
+
+const unsigned long long one_byte_signed_max = (1ULL << 7) - 1;
+const unsigned long long two_byte_signed_max = (1ULL << 15) - 1;
+const unsigned long long four_byte_signed_max = (1ULL << 31) - 1;
+
+const unsigned long long one_byte_unsigned_max = (1ULL << 8) - 1;
+const unsigned long long two_byte_unsigned_max = (1ULL << 16) - 1;
+const unsigned long long four_byte_unsigned_max = (1ULL << 32) - 1;
+
+char smaller_than_1byte_signed_range[one_byte_signed_max];
+char exactly_1byte_signed_range[one_byte_signed_max + 1];
+char greater_than_1byte_signed_range[one_byte_signed_max + 2];
+
+char smaller_than_2byte_signed_range[two_byte_signed_max];
+char exactly_2byte_signed_range[two_byte_signed_max + 1];
+char greater_than_2byte_signed_range[two_byte_signed_max + 2];
+
+char smaller_than_4byte_signed_range[four_byte_signed_max];
+char exactly_4byte_signed_range[four_byte_signed_max + 1];
+char greater_than_4byte_signed_range[four_byte_signed_max + 2];
+
+char smaller_than_1byte_unsigned_range[one_byte_unsigned_max];
+char exactly_1byte_unsigned_range[one_byte_unsigned_max + 1];
+char greater_than_1byte_unsigned_range[one_byte_unsigned_max + 2];
+
+char smaller_than_2byte_unsigned_range[two_byte_unsigned_max];
+char exactly_2byte_unsigned_range[two_byte_unsigned_max + 1];
+char greater_than_2byte_unsigned_range[two_byte_unsigned_max + 2];
+
+char smaller_than_4byte_unsigned_range[four_byte_unsigned_max];
+char exactly_4byte_unsigned_range[four_byte_unsigned_max + 1];
+char greater_than_4byte_unsigned_range[four_byte_unsigned_max + 2];
+
+const char one_byte_signed_index = 1;  // sizeof(char) == 1
+const short two_byte_signed_index = 1; // sizeof(short) == 2
+const int four_byte_signed_index = 1;  // sizeof(int) == 4
+
+const unsigned char one_byte_unsigned_index = 1;
+const unsigned short two_byte_unsigned_index = 1;
+const unsigned int four_byte_unsigned_index = 1;
+
+void ignore_literal_indexing() {
+  char a = exactly_4byte_unsigned_range[32]; // nowarning
+}
+
+void ignore_literal_indexing_with_parens() {
+  char a = exactly_4byte_unsigned_range[(32)]; // nowarning
+}
+
+void range_check_one_byte_index() {
+  char r;
+  char *pr = &r;
+  *pr = smaller_than_1byte_signed_range[one_byte_signed_index]; // nowarning
+  *pr = exactly_1byte_signed_range[one_byte_signed_index];  // nowarning
+  *pr = greater_than_1byte_signed_range[one_byte_signed_index]; // expected-warning{{Indexing array with type 'char' cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+  *pr = smaller_than_1byte_unsigned_range[one_byte_unsigned_index]; // nowarning
+  *pr = exactly_1byte_unsigned_range[one_byte_unsigned_index];  // nowarning
+  *pr = greater_than_1byte_unsigned_range[one_byte_unsigned_index]; // expected-warning{{Indexing array with type 'unsigned char' cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+}
+
+void range_check_two_byte_index() {
+  char r;
+  char *pr = &r;
+  *pr = smaller_than_2byte_signed_range[two_byte_signed_index]; // nowarning
+  *pr = exactly_2byte_signed_range[two_byte_signed_index];  // nowarning
+  *pr = greater_than_2byte_signed_range[two_byte_signed_index]; // expected-warning{{Indexing array with type 'short' cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+  *pr = smaller_than_2byte_unsigned_range[two_byte_unsigned_index]; // nowarning
+  *pr = exactly_2byte_unsigned_range[two_byte_unsigned_index];  // nowarning
+  *pr = greater_than_2byte_unsigned_range[two_byte_unsigned_index]; // expected-warning{{Indexing array with type 'unsigned short' cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider usi

[PATCH] D82938: [clangd] Implement path and URI translation for remote index

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



Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:61
+  if (IndexedProjectRoot.empty())
+return static_cast(Result);
+  llvm::sys::path::replace_path_prefix(Result, IndexedProjectRoot, "");

sammccall wrote:
> static_cast is a pretty surprising/uncommon way to write this conversion
> I'd suggest either Result.str.str() or std::string(result)
Okay, sure! I just thought `.str().str()` looks really weird, but `std::string` 
is probably a good choice.



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:43
   for (auto &Sym : Symbols) {
-const auto ProtobufMeessage = toProtobuf(Sym);
-const auto SymToProtobufAndBack = fromProtobuf(ProtobufMeessage, &Strings);
+const auto ProtobufMessage = toProtobuf(Sym, "");
+const auto SymToProtobufAndBack = fromProtobuf(

sammccall wrote:
> Is passing the empty string here actually valid? I think you probably want to 
> pass testRoot() or some unixified equivalent
Why testroot? That's what I'm stripping from URI body, the URI is 
`unittest:///TestTU.h`, hence I'm stripping from `/TestTU.h`, there is no 
`/clangd-test` there. Could you elaborate?



Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:45
+const auto SymToProtobufAndBack = fromProtobuf(
+ProtobufMessage, &Strings, std::string(testRoot()) + '/', "unittest");
 EXPECT_TRUE(SymToProtobufAndBack.hasValue());

sammccall wrote:
> this is `testPath("unittest")`, isn't it?
> 
> I mean, forward vs backslashes are going to differ, but the current 
> expression is going to produce `C:\test/unittest` which doesn't seem better.
I don't understand: `std::string(testRoot()) + '/'` is `/clangd-test/` on unix 
and `testPath("unittest")` is `/clangd-test/unittest`. I understand the slashes 
argument, but could you please elaborate on the former?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82938



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


[PATCH] D83201: [AST][RecoveryExpr] Fix the value category for recovery expr.

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

RecoveryExpr was always lvalue, but it is wrong if we use it to model
broken function calls, function call expression has more compliated rules:

- a call to a function whose return type is an lvalue reference yields an 
lvalue;
- a call to a function whose return type is an rvalue reference yields an 
xvalue;
- a call to a function whose return type is nonreference type yields a prvalue;

This patch makes the recovery-expr align with the function call if it is
modeled a broken call.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83201

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp

Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -62,3 +62,9 @@
  // expected-note {{in instantiation of member function}} \
  // expected-note {{in call to}}
 }
+
+// verify no assertion failure on violating value category.
+namespace test4 {
+int&&f(int); // expected-note {{candidate function not viable}}
+int&& k = f(); // expected-error {{no matching function for call}}
+}
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -4,7 +4,6 @@
 int some_func(int *);
 
 // CHECK: VarDecl {{.*}} invalid_call
-// CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'int' contains-errors
 // CHECK-NEXT:  `-RecoveryExpr {{.*}} 'int' contains-errors
 // CHECK-NEXT:|-UnresolvedLookupExpr {{.*}} 'some_func'
 // CHECK-NEXT:`-IntegerLiteral {{.*}} 123
@@ -34,7 +33,6 @@
 int ambig_func(float);
 
 // CHECK: VarDecl {{.*}} ambig_call
-// CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'int' contains-errors
 // CHECK-NEXT:  `-RecoveryExpr {{.*}} 'int' contains-errors
 // CHECK-NEXT:|-UnresolvedLookupExpr {{.*}} 'ambig_func'
 // CHECK-NEXT:`-IntegerLiteral {{.*}} 123
@@ -211,3 +209,16 @@
 } NoCrashOnInvalidInitList = {
   .abc = nullptr,
 };
+
+// Verify the value category of recovery expression.
+int f1(int);
+int& f2(int);
+int&& f3(int);
+void ValueCategory() {
+  // CHECK:  RecoveryExpr {{.*}} 'int' contains-errors
+  f1(); // call to a function (nonreference return type) yields a prvalue (not print by default)
+  // CHECK:  RecoveryExpr {{.*}} 'int' contains-errors lvalue
+  f2(); // call to a function (lvalue reference return type) yields an lvalue.
+  // CHECK:  RecoveryExpr {{.*}} 'int' contains-errors xvalue
+  f3(); // call to a function (rvalue reference return type) yields an xvalue.
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -12818,7 +12818,7 @@
   auto ConsiderCandidate = [&](const OverloadCandidate &Candidate) {
 if (!Candidate.Function)
   return;
-QualType T = Candidate.Function->getCallResultType();
+QualType T = Candidate.Function->getReturnType();
 if (T.isNull())
   return;
 if (!Result)
@@ -12938,8 +12938,15 @@
   // Overload resolution failed, try to recover.
   SmallVector SubExprs = {Fn};
   SubExprs.append(Args.begin(), Args.end());
-  return SemaRef.CreateRecoveryExpr(Fn->getBeginLoc(), RParenLoc, SubExprs,
-chooseRecoveryType(*CandidateSet, Best));
+  auto ReturnType = chooseRecoveryType(*CandidateSet, Best);
+  auto Recovery = SemaRef.CreateRecoveryExpr(
+  Fn->getBeginLoc(), RParenLoc, SubExprs,
+  ReturnType.isNull()
+  ? ReturnType
+  // set the call result type.
+  : ReturnType.getNonLValueExprType(SemaRef.getASTContext()),
+  ReturnType.isNull() ? VK_LValue : Expr::getValueKindForType(ReturnType));
+  return Recovery;
 }
 
 static void markUnaddressableCandidatesUnviable(Sema &S,
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19209,7 +19209,8 @@
 }
 
 ExprResult Sema::CreateRecoveryExpr(SourceLocation Begin, SourceLocation End,
-ArrayRef SubExprs, QualType T) {
+ArrayRef SubExprs, QualType T,
+ExprValueKind VK) {
   // FIXME: enable it for C++, RecoveryExpr is type-dependent to suppress
   // bogus diagnostics and this trick does not work in C.
   // FIXME: use containsErrors() to suppress unwanted diags in C.
@@ -19219,8 +19

[PATCH] D82938: [clangd] Implement path and URI translation for remote index

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

Store the progress so that I don't lose it. Still WIP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82938

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

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -7,8 +7,10 @@
 //===--===//
 
 #include "../TestTU.h"
+#include "TestFS.h"
 #include "index/Serialization.h"
 #include "index/remote/marshalling/Marshalling.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/Support/StringSaver.h"
 #include "gtest/gtest.h"
 
@@ -40,8 +42,9 @@
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
   for (auto &Sym : Symbols) {
-const auto ProtobufMeessage = toProtobuf(Sym);
-const auto SymToProtobufAndBack = fromProtobuf(ProtobufMeessage, &Strings);
+const auto ProtobufMessage = toProtobuf(Sym, "/");
+const auto SymToProtobufAndBack = fromProtobuf(
+ProtobufMessage, &Strings, std::string(testRoot()), "unittest");
 EXPECT_TRUE(SymToProtobufAndBack.hasValue());
 EXPECT_EQ(toYAML(Sym), toYAML(*SymToProtobufAndBack));
   }
@@ -80,12 +83,46 @@
   EXPECT_GE(References.numRefs(), 5UL);
   for (const auto &SymbolWithRefs : References) {
 for (const auto &Ref : SymbolWithRefs.second) {
-  const auto RefToProtobufAndBack = fromProtobuf(toProtobuf(Ref), &Strings);
+  const auto RefToProtobufAndBack = fromProtobuf(
+  toProtobuf(Ref, "/"), &Strings, std::string(testRoot()), "unittest");
   EXPECT_TRUE(RefToProtobufAndBack.hasValue());
   EXPECT_EQ(toYAML(Ref), toYAML(*RefToProtobufAndBack));
 }
   }
-} // namespace
+}
+
+TEST(RemoteMarshallingTest, URITranslation) {
+  llvm::BumpPtrAllocator Arena;
+  llvm::UniqueStringSaver Strings(Arena);
+  clangd::Ref Original;
+  const std::string RemoteIndexPrefix = testPath("remote/machine/project/");
+  std::string RelativePath = "llvm-project/clang-tools-extra/clangd/"
+ "unittests/remote/MarshallingTests.cpp";
+  llvm::SmallString<256> NativePath = StringRef(RelativePath);
+  llvm::sys::path::native(NativePath);
+  RelativePath = std::string(NativePath);
+  const auto URI = URI::createFile(RemoteIndexPrefix + RelativePath);
+  Original.Location.FileURI = Strings.save(URI.toString()).begin();
+  Ref Serialized = toProtobuf(Original, RemoteIndexPrefix);
+  EXPECT_EQ(Serialized.location().file_path(), RelativePath);
+  const std::string LocalIndexPrefix = testPath("local/machine/project/");
+  auto Deserialized = fromProtobuf(Serialized, &Strings, LocalIndexPrefix);
+  EXPECT_TRUE(Deserialized);
+  EXPECT_EQ(Deserialized->Location.FileURI,
+URI::createFile(LocalIndexPrefix + RelativePath).toString());
+
+  clangd::Ref WithInvalidURI;
+  WithInvalidURI.Location.FileURI = "This is not a URI";
+  Serialized = toProtobuf(WithInvalidURI, RemoteIndexPrefix);
+  // Invalid URI results in empty path.
+  EXPECT_EQ(Serialized.location().file_path(), "");
+
+  Ref WithAbsolutePath;
+  *WithAbsolutePath.mutable_location()->mutable_file_path() = "/usr/local/bin/";
+  Deserialized = fromProtobuf(WithAbsolutePath, &Strings, LocalIndexPrefix);
+  // Can not build URI given absolute path.
+  EXPECT_EQ(std::string(Deserialized->Location.FileURI), "");
+}
 
 } // namespace
 } // namespace remote
Index: clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
===
--- clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
+++ clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
@@ -8,12 +8,14 @@
 
 #include "index/remote/Client.h"
 #include "support/Logger.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace clang {
 namespace clangd {
 namespace remote {
 
-std::unique_ptr getClient(llvm::StringRef Address) {
+std::unique_ptr getClient(llvm::StringRef Address,
+   llvm::StringRef IndexRoot) {
   elog("Can't create SymbolIndex client without Remote Index support.");
   return nullptr;
 }
Index: cl

[PATCH] D81676: [MSP430] Align the toolchain definition with the TI's msp430-gcc v9.2.0

2020-07-06 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added a comment.

Thank you!
LGTM, except some minor nits below.




Comment at: clang/lib/Driver/ToolChains/MSP430.cpp:154
 
+  SmallString<128> MultilibInclude(GCCInstallation.getInstallPath());
+  llvm::sys::path::append(MultilibInclude, "include");

I'd guard this by `if (GCCInstallation.isValid())` to avoid adding include 
directories with relative paths if `GCCInstallation.getInstallPath()` is empty.



Comment at: clang/lib/Driver/ToolChains/MSP430.cpp:239
+  Arg *SspFlag = Args.getLastArg(
+  options::OPT_fno_stack_protector, options::OPT_fstack_protector,
+  options::OPT_fstack_protector_all, options::OPT_fstack_protector_strong);

Is the check for `fno-stack-protector` necessary here? Looks as the checks for 
'positive' options should be enough to do the trick.



Comment at: clang/test/Driver/msp430-toolchain.c:5
+
+// Test for include paths (cannot use -###)
+

This way looks okay to me, but I believe you should be able to check cc1 
command (though -###) for `-internal-isystem`, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81676



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


[PATCH] D76291: [Support] Fix formatted_raw_ostream for UTF-8

2020-07-06 Thread Kristof Beyls via Phabricator via cfe-commits
kristof.beyls accepted this revision.
kristof.beyls added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76291



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


[PATCH] D83178: [clangd] Send EOF before resetting diagnostics consumer

2020-07-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 275627.
kadircet added a comment.

- Add unittest to DiagnosticsTest via llvm-include-order


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83178

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


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -29,6 +29,8 @@
 namespace {
 
 using ::testing::_;
+using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::Field;
 using ::testing::IsEmpty;
@@ -278,6 +280,23 @@
   "use a trailing return type for this function");
 }
 
+TEST(DiagnosticsTest, ClangTidyEOF) {
+  // clang-format off
+  Annotations Test(R"cpp(
+  [[#]]include 
+  #include "a.h")cpp");
+  // clang-format on
+  auto TU = TestTU::withCode(Test.code());
+  TU.ExtraArgs = {"-isystem."};
+  TU.AdditionalFiles["a.h"] = TU.AdditionalFiles["b.h"] = "";
+  TU.ClangTidyChecks = "-*, llvm-include-order";
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  Contains(AllOf(Diag(Test.range(), "#includes are not sorted properly"),
+ DiagSource(Diag::ClangTidy),
+ DiagName("llvm-include-order";
+}
+
 TEST(DiagnosticTest, TemplatesInHeaders) {
   // Diagnostics from templates defined in headers are placed at the expansion.
   Annotations Main(R"cpp(
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -428,15 +428,15 @@
 CTFinder.matchAST(Clang->getASTContext());
   }
 
+  // XXX: This is messy: clang-tidy checks flush some diagnostics at EOF.
+  // However Action->EndSourceFile() would destroy the ASTContext!
+  // So just inform the preprocessor of EOF, while keeping everything alive.
+  Clang->getPreprocessor().EndSourceFile();
   // UnitDiagsConsumer is local, we can not store it in CompilerInstance that
   // has a longer lifetime.
   Clang->getDiagnostics().setClient(new IgnoreDiagnostics);
   // CompilerInstance won't run this callback, do it directly.
   ASTDiags.EndSourceFile();
-  // XXX: This is messy: clang-tidy checks flush some diagnostics at EOF.
-  // However Action->EndSourceFile() would destroy the ASTContext!
-  // So just inform the preprocessor of EOF, while keeping everything alive.
-  Clang->getPreprocessor().EndSourceFile();
 
   std::vector Diags = CompilerInvocationDiags;
   // Add diagnostics from the preamble, if any.


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -29,6 +29,8 @@
 namespace {
 
 using ::testing::_;
+using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::Field;
 using ::testing::IsEmpty;
@@ -278,6 +280,23 @@
   "use a trailing return type for this function");
 }
 
+TEST(DiagnosticsTest, ClangTidyEOF) {
+  // clang-format off
+  Annotations Test(R"cpp(
+  [[#]]include 
+  #include "a.h")cpp");
+  // clang-format on
+  auto TU = TestTU::withCode(Test.code());
+  TU.ExtraArgs = {"-isystem."};
+  TU.AdditionalFiles["a.h"] = TU.AdditionalFiles["b.h"] = "";
+  TU.ClangTidyChecks = "-*, llvm-include-order";
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  Contains(AllOf(Diag(Test.range(), "#includes are not sorted properly"),
+ DiagSource(Diag::ClangTidy),
+ DiagName("llvm-include-order";
+}
+
 TEST(DiagnosticTest, TemplatesInHeaders) {
   // Diagnostics from templates defined in headers are placed at the expansion.
   Annotations Main(R"cpp(
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -428,15 +428,15 @@
 CTFinder.matchAST(Clang->getASTContext());
   }
 
+  // XXX: This is messy: clang-tidy checks flush some diagnostics at EOF.
+  // However Action->EndSourceFile() would destroy the ASTContext!
+  // So just inform the preprocessor of EOF, while keeping everything alive.
+  Clang->getPreprocessor().EndSourceFile();
   // UnitDiagsConsumer is local, we can not store it in CompilerInstance that
   // has a longer lifetime.
   Clang->getDiagnostics().setClient(new IgnoreDiagnostics);
   // CompilerInstance won't run this callback, do it directly.
   ASTDiags.EndSourceFile();
-  // XXX: This is messy: clang-tidy checks flush some diagnostics at EOF.
-  // Howeve

[PATCH] D83178: [clangd] Send EOF before resetting diagnostics consumer

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

Yeah concerns around header-guard checks are real (and likely to be annoying), 
so will wait for D78038 .

I suppose we can split that into multiple patches, and at least land the bit 
around preserving conditional stack at the end of preamble, WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83178



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


[PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker

2020-07-06 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 275625.
gamesh411 added a comment.

make single bug-type
fix checker registration


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69318

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp
  clang/test/Analysis/sufficient-size-array-indexing-32bit.c
  clang/test/Analysis/sufficient-size-array-indexing-64bit.c

Index: clang/test/Analysis/sufficient-size-array-indexing-64bit.c
===
--- /dev/null
+++ clang/test/Analysis/sufficient-size-array-indexing-64bit.c
@@ -0,0 +1,127 @@
+// RUN: %clang_analyze_cc1 -triple x86_64 -analyzer-checker=core,alpha.core.SufficientSizeArrayIndexing %s -verify
+
+#include "Inputs/system-header-simulator.h"
+
+const unsigned long long one_byte_signed_max = (1ULL << 7) - 1;
+const unsigned long long two_byte_signed_max = (1ULL << 15) - 1;
+const unsigned long long four_byte_signed_max = (1ULL << 31) - 1;
+
+const unsigned long long one_byte_unsigned_max = (1ULL << 8) - 1;
+const unsigned long long two_byte_unsigned_max = (1ULL << 16) - 1;
+const unsigned long long four_byte_unsigned_max = (1ULL << 32) - 1;
+
+char smaller_than_1byte_signed_range[one_byte_signed_max];
+char exactly_1byte_signed_range[one_byte_signed_max + 1];
+char greater_than_1byte_signed_range[one_byte_signed_max + 2];
+
+char smaller_than_2byte_signed_range[two_byte_signed_max];
+char exactly_2byte_signed_range[two_byte_signed_max + 1];
+char greater_than_2byte_signed_range[two_byte_signed_max + 2];
+
+char smaller_than_4byte_signed_range[four_byte_signed_max];
+char exactly_4byte_signed_range[four_byte_signed_max + 1];
+char greater_than_4byte_signed_range[four_byte_signed_max + 2];
+
+char smaller_than_1byte_unsigned_range[one_byte_unsigned_max];
+char exactly_1byte_unsigned_range[one_byte_unsigned_max + 1];
+char greater_than_1byte_unsigned_range[one_byte_unsigned_max + 2];
+
+char smaller_than_2byte_unsigned_range[two_byte_unsigned_max];
+char exactly_2byte_unsigned_range[two_byte_unsigned_max + 1];
+char greater_than_2byte_unsigned_range[two_byte_unsigned_max + 2];
+
+char smaller_than_4byte_unsigned_range[four_byte_unsigned_max];
+char exactly_4byte_unsigned_range[four_byte_unsigned_max + 1];
+char greater_than_4byte_unsigned_range[four_byte_unsigned_max + 2];
+
+const char one_byte_signed_index = 1;  // sizeof(char) == 1
+const short two_byte_signed_index = 1; // sizeof(short) == 2
+const int four_byte_signed_index = 1;  // sizeof(int) == 4
+
+const unsigned char one_byte_unsigned_index = 1;
+const unsigned short two_byte_unsigned_index = 1;
+const unsigned int four_byte_unsigned_index = 1;
+
+void ignore_literal_indexing() {
+  char a = exactly_4byte_unsigned_range[32]; // nowarning
+}
+
+void ignore_literal_indexing_with_parens() {
+  char a = exactly_4byte_unsigned_range[(32)]; // nowarning
+}
+
+void range_check_one_byte_index() {
+  char r;
+  char *pr = &r;
+  *pr = smaller_than_1byte_signed_range[one_byte_signed_index]; // nowarning
+  *pr = exactly_1byte_signed_range[one_byte_signed_index];  // nowarning
+  *pr = greater_than_1byte_signed_range[one_byte_signed_index]; // expected-warning{{Index type cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+  *pr = smaller_than_1byte_unsigned_range[one_byte_unsigned_index]; // nowarning
+  *pr = exactly_1byte_unsigned_range[one_byte_unsigned_index];  // nowarning
+  *pr = greater_than_1byte_unsigned_range[one_byte_unsigned_index]; // expected-warning{{Index type cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+}
+
+void range_check_two_byte_index() {
+  char r;
+  char *pr = &r;
+  *pr = smaller_than_2byte_signed_range[two_byte_signed_index]; // nowarning
+  *pr = exactly_2byte_signed_range[two_byte_signed_index];  // nowarning
+  *pr = greater_than_2byte_signed_range[two_byte_signed_index]; // expected-warning{{Index type cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+  *pr = smaller_than_2byte_unsigned_range[two_byte_unsigned_index]; // nowarning
+  *pr = exactly_2byte_unsigned_range[two_byte_unsigned_index];  // nowarning
+  *pr = greater_than_2byte_unsigned_range[two_byte_unsigned_index]; // expected-warning{{Index type cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+}
+
+void range_check_four_byte_index

[PATCH] D80301: [yaml][clang-tidy] Fix multiline YAML serialization

2020-07-06 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@njames93 and @aaron.ballman - please take a look to this diff. Multiline 
replacements in YAML are broken and cannot be applied correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80301



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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-07-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Thank you @JohelEGP please keep them coming, I'll try and update the patch as 
soon as I have some fixes, I kind of feel like we are addressing what would 
have just been downstream bugs anyway. (some are quite bizarre!) so lets squish 
as many of them as we can before we land this.

My assumption is you are giving me valid c++ code, if so that is great I'll try 
and address them, but your examples are probably beyond my own concepts 
knowledge. (This is actually why I started to add this to clang-format, I 
wanted a way to learn about concepts)


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

https://reviews.llvm.org/D79773



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


[PATCH] D83157: [clangd] Extract BackgroundIndex::Options struct. NFC

2020-07-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked an inline comment as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:184
+TFS, CDB,
 BackgroundIndexStorage::createDiskBackedStorageFactory(
 [&CDB](llvm::StringRef File) { return CDB.getProjectInfo(File); }),

sammccall wrote:
> kadircet wrote:
> > I think we should move storage factory into options too ?
> The storage factory isn't optional, nor does it have a good default. So it 
> seems mechanically awkward to put it in the struct, and I'm not sure there's 
> much benefit... 
> 
> How would you see this being initialized?
I thought we were exposing `NullStorage` so I was planning for it to be the 
default for ignorant call sites. But seeing it is not exposed, and this only 
being used by ClangdServer (and tests), I suppose it is not that important.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83157



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


[PATCH] D82943: [SVE] Add more warnings checks to clang and LLVM SVE tests

2020-07-06 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin accepted this revision.
kmclaughlin added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82943



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


[PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM

2020-07-06 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson created this revision.
LukeGeeson added a reviewer: t.p.northover.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, hiraditya, 
kristof.beyls.
Herald added projects: clang, LLVM.

This patch adds support for the Arm-v8 Cortex-A78 and Cortex-X1
processors for AArch64 and ARM.

In detail:

- Adding cortex-a78 and cortex-x1 as cpu options for aarch64 and arm targets in 
clang
- Adding Cortex-A78 and Cortex-X1 CPU names and ProcessorModels in llvm

details of the CPU can be found here:
https://www.arm.com/products/cortex-x

https://www.arm.com/products/silicon-ip-cpu/cortex-a/cortex-a78

The following people contributed to this patch:

- Luke Geeson
- Mikhail Maltsev


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83206

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -262,6 +262,18 @@
  ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
  ARM::AEK_RAS | ARM::AEK_DOTPROD,
  "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_RAS | ARM::AEK_DOTPROD |
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_RAS | ARM::AEK_DOTPROD |
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | 
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
   EXPECT_TRUE(testARMCPU("neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
@@ -310,7 +322,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 87;
+static constexpr unsigned NumARMCPUArchs = 89;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -865,6 +877,20 @@
   AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
   AArch64::AEK_RCPC | AArch64::AEK_SSBS, "8.2-A"));
   EXPECT_TRUE(testAArch64CPU(
+  "cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO  | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS,
+  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS,
+  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
   "cyclone", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
   EXPECT_TRUE(testAArch64CPU(
@@ -1002,7 +1028,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 40;
+static constexpr unsigned NumAArch64CPUArchs = 42;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/lib/Target/ARM/ARMSubtarget.h
===
--- llvm/lib/Target/ARM/ARMSubtarget.h
+++ llvm/lib/Target/ARM/ARMSubtarget.h
@@ -74,7 +74,9 @@
 Krait,
 Kryo,
 NeoverseN1,
-Swift
+Swift,
+CortexX1,
+CortexA78
   };
   enum ARMProcClassEnum {
 None,
Index: llvm/lib/Target/ARM/ARMSubtarget.cpp
===
--- llvm/lib/Target/ARM/ARMSubtarget.cpp
+++ llvm/lib/Target/ARM/ARMSubtarget.cpp
@@ -319,6 +319,9 @@
 PreISelOperandLatencyAdjustment = 1;
 PartialUpdateClearance = 12;
 break;
+  case CortexX1:
+  case CortexA78:
+break;
   }
 }
 
Index: llvm/lib/Target/ARM/ARM.td
===
--- llvm/lib/Target/ARM/ARM.td
+++ llvm/lib/Target/ARM/ARM.td
@@ -596,6 +596,10 @@
 

[PATCH] D83099: Revert "[clangd] Store index in '.clangd/index' instead of '.clangd-index'"

2020-07-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 275643.
sammccall added a comment.

Slightly different layout after getting input on discourse and elsewhere


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83099

Files:
  .gitignore
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/clangd/test/background-index.test
  llvm/.gitignore


Index: llvm/.gitignore
===
--- llvm/.gitignore
+++ llvm/.gitignore
@@ -59,8 +59,6 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd index
-.clangd
 
 
#==#
 # Files created in tree by the Go bindings.
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
@@ -15,8 +15,8 @@
 # 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/.clangd/index/foo.cpp.*.idx
-# RUN: ls %t/sub_dir/.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
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -95,8 +95,8 @@
 };
 
 // Creates and owns IndexStorages for multiple CDBs.
-// When a CDB root is found, shards are stored in $ROOT/.clangd/index.
-// When no root is found, the fallback path is ~/.cache/clangd/index.
+// When a CDB root is found, shards are stored in $ROOT/.cache/clangd/index/.
+// When no root is found, the fallback path is ~/.cache/clangd/index/.
 class DiskBackedIndexStorageManager {
 public:
   DiskBackedIndexStorageManager(
@@ -115,7 +115,7 @@
 llvm::SmallString<128> StorageDir(FallbackDir);
 if (auto PI = GetProjectInfo(File)) {
   StorageDir = PI->SourceRoot;
-  llvm::sys::path::append(StorageDir, ".clangd", "index");
+  llvm::sys::path::append(StorageDir, ".cache", "clangd", "index");
 }
 auto &IndexStorage = IndexStorageMap[StorageDir];
 if (!IndexStorage)
Index: clang-tools-extra/clangd/index/Background.h
===
--- clang-tools-extra/clangd/index/Background.h
+++ clang-tools-extra/clangd/index/Background.h
@@ -56,9 +56,9 @@
   using Factory = llvm::unique_function;
 
   // Creates an Index Storage that saves shards into disk. Index storage uses
-  // CDBDirectory + ".clangd/index/" as the folder to save shards. CDBDirectory
-  // is the first directory containing a CDB in parent directories of a file, 
or
-  // user's home directory if none was found, e.g. standard library headers.
+  // CDBDirectory + ".cache/clangd/index/" as the folder to save shards.
+  // CDBDirectory is the first directory containing a CDB in parent directories
+  // of a file, or user's home directory if none was found, e.g. stdlib 
headers.
   static Factory createDiskBackedStorageFactory(
   std::function(PathRef)> GetProjectInfo);
 };
Index: .gitignore
===
--- .gitignore
+++ .gitignore
@@ -53,10 +53,11 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd index
-.clangd
+# clangd index. (".clangd" is a config file now, thus trailing slash)
+.clangd/
+.cache
 # static analyzer regression testing project files
 /clang/utils/analyzer/projects/*/CachedSource
 /clang/utils/analyzer/projects/*/PatchedSource
 /clang/utils/analyzer/projects/*/ScanBuildResults
-/clang/utils/analyzer/projects/*/RefScanBuildResults
\ No newline at end of file
+/clang/utils/analyzer/projects/*/RefScanBuildResults


Index: llvm/.gitignore
===
--- llvm/.gitignore
+++ llvm/.gitignore
@@ -59,8 +59,6 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd index
-.clangd
 
 #==#
 # Files created in tree by the Go bindings.
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
@@ -15,8 +15,8 @@
 # RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc --check-prefixes=CHECK,BUILD
 
 # Test that the

[PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences

2020-07-06 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

LGTM! You packed a lot of punch into this patch, and I like it very much. I 
read the code and everything looks great. I nitpicked on one thing, the 
`updateTrackedRegion` function is a bit awkward, but if you place a `TODO` 
there, I'm happy to have that addressed in a later patch. I don't think this is 
reason to postpone the landing on this patch any further.




Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:202-219
+ProgramStateRef
+SmartPtrModeling::updateTrackedRegion(const CallEvent &Call, CheckerContext &C,
+  const MemRegion *ThisValRegion) const {
+  ProgramStateRef State = C.getState();
+  auto NumArgs = Call.getNumArgs();
+
+  if (NumArgs == 0) {

Hmm, this function feels clunky. So, if the call has no arguments, we set the 
smart pointer to null, otherwise if its a single-argument then we set it to 
whatever the argument is? 

How about `operator[]`, that also takes a single argument, but isn't a memory 
region? `get`, `get_deleter` don't take any arguments, but they don't set the 
internal pointee to null either. The name `updateTrackedRegion` however 
suggests that whatever operation was done, this is the one-tool-to-solve-it-all 
function to take care of it.

I think this function handles too many things as once, and the name and lack of 
documentation obfuscates its purpose. How about we put the relevant code to 
`handleRelease`, and repurpose the rest of the function like this:

`updateOwnedRegion(CallEvent, CheckerContext, MemRegion of the smart pointer, 
MemRegion to take ownership of)`

What do you think?


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

https://reviews.llvm.org/D81315



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


[PATCH] D69778: Make -fmodules-codegen and -fmodules-debuginfo work also with precompiled headers

2020-07-06 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

Ping ...


Repository:
  rC Clang

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

https://reviews.llvm.org/D69778



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


[PATCH] D83209: Factor out call to EXTRACTOR in generateCC1CommandLine

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83209

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

Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -156,6 +156,7 @@
   : MarshallingInfo {
   code NormalizerRetTy = ty;
   code Normalizer = "normalizeSimpleFlag";
+  code Denormalizer = "denormalizeSimpleFlag";
 }
 
 class MarshallingInfoBitfieldFlag : MarshallingInfoFlag {
@@ -164,6 +165,20 @@
   code ValueExtractor = "(extractMaskValue)";
 }
 
+class MarshallingInfoBooleanTrueFlag
+  : MarshallingInfoFlag {
+  bit ShouldAlwaysEmit = 1;
+  code Normalizer = "normalizeBooleanTrueFlag";
+  code Denormalizer = "denormalizeBooleanFlag";
+}
+
+class MarshallingInfoBooleanFalseFlag
+  : MarshallingInfoFlag {
+  bit ShouldAlwaysEmit = 1;
+  code Normalizer = "normalizeBooleanFalseFlag";
+  code Denormalizer = "denormalizeBooleanFlag";
+}
+
 // Mixins for additional marshalling attributes.
 
 class IsNegative {
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -138,6 +138,13 @@
   return !Args.hasArg(Opt);
 }
 
+void denormalizeSimpleFlag(SmallVectorImpl &Args,
+   const char *Spelling,
+   CompilerInvocation::StringAllocator SA,
+   unsigned TableIndex, unsigned Value) {
+  Args.push_back(Spelling);
+}
+
 template 
 static llvm::Optional
 normalizeFlagToValue(OptSpecifier Opt, unsigned TableIndex, const ArgList &Args,
@@ -147,6 +154,33 @@
   return None;
 }
 
+template 
+static Optional
+normalizeBooleanTrueFlag(OptSpecifier PosOpt, unsigned TableIndex,
+ const ArgList &Args, DiagnosticsEngine &Diags) {
+  if (const Arg *A = Args.getLastArg(PosOpt, NegOpt))
+return A->getOption().matches(PosOpt);
+  return None;
+}
+
+template 
+static Optional
+normalizeBooleanFalseFlag(OptSpecifier NegOpt, unsigned TableIndex,
+  const ArgList &Args, DiagnosticsEngine &Diags) {
+  if (const Arg *A = Args.getLastArg(PosOpt, NegOpt))
+return A->getOption().matches(PosOpt);
+  return None;
+}
+
+template 
+static void denormalizeBooleanFlag(SmallVectorImpl &Args,
+   const char *Spelling,
+   CompilerInvocation::StringAllocator SA,
+   unsigned TableIndex, unsigned Value) {
+  if (Value == IsPositive)
+Args.push_back(Spelling);
+}
+
 static llvm::Optional normalizeSimpleEnum(OptSpecifier Opt,
 unsigned TableIndex,
 const ArgList &Args,
@@ -169,12 +203,14 @@
 }
 
 static void denormalizeSimpleEnum(SmallVectorImpl &Args,
+  const char *Spelling,
   CompilerInvocation::StringAllocator SA,
   unsigned TableIndex, unsigned Value) {
   assert(TableIndex < SimpleEnumValueTablesSize);
   const SimpleEnumValueTable &Table = SimpleEnumValueTables[TableIndex];
   for (int I = 0, E = Table.Size; I != E; ++I) {
 if (Value == Table.Table[I].Value) {
+  Args.push_back(Spelling);
   Args.push_back(Table.Table[I].Name);
   return;
 }
@@ -185,8 +221,10 @@
 }
 
 static void denormalizeString(SmallVectorImpl &Args,
+  const char *Spelling,
   CompilerInvocation::StringAllocator SA,
   unsigned TableIndex, const std::string &Value) {
+  Args.push_back(Spelling);
   Args.push_back(SA(Value));
 }
 
@@ -782,10 +820,6 @@
 }
   }
 
-  Opts.ExperimentalNewPassManager = Args.hasFlag(
-  OPT_fexperimental_new_pass_manager, OPT_fno_experimental_new_pass_manager,
-  /* Default */ ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER);
-
   Opts.DebugPassManager =
   Args.hasFlag(OPT_fdebug_pass_manager, OPT_fno_debug_pass_manager,
/* Default */ false);
@@ -3893,15 +3927,10 @@
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
 TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)\
-  if (((FLAGS)&options::CC1Option) &&  \
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {\
-if (Option::KIND##Class == Option::FlagClass) {   

[PATCH] D83211: Factor out call to EXTRACTOR in generateCC1CommandLine

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83211

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3927,9 +3927,10 @@
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)
\
-  if (((FLAGS)&options::CC1Option) &&  
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {
\
-DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   
\
+  if ((FLAGS)&options::CC1Option) {
\
+const auto &Extracted = EXTRACTOR(this->KEYPATH);  
\
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) 
\
+  DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);
\
   }
 
 #include "clang/Driver/Options.inc"


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3927,9 +3927,10 @@
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
 TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)\
-  if (((FLAGS)&options::CC1Option) &&  \
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {\
-DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   \
+  if ((FLAGS)&options::CC1Option) {\
+const auto &Extracted = EXTRACTOR(this->KEYPATH);  \
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) \
+  DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);\
   }
 
 #include "clang/Driver/Options.inc"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically

2020-07-06 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Nice work, but please implement this feature also for non-pointer iterators for 
the matter of consistence.




Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:279
+// or on the RHS (eg.: 1 + it). Both cases are modeled.
+bool IsItOnLHS = BO->getLHS()->getType()->isPointerType();
+Expr *&ItExpr = IsItOnLHS ? LHS : RHS;

gamesh411 wrote:
> What do you think about this detection strategy? This assumes that the 
> Iterator being detected is a pointer (and not a used-defined type like STL 
> iterators etc.). Would you say that this assumption holds every time because 
> the pointer-iterators are only handled in this checkPostStmt callback and the 
> traditional iterators in another callback?
Instead of `It` please use `Iter`, beacause `It` can be understood as the 
English //it// pronoun: "Is //it// on the left-hand side?"



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:282
+SVal &OffsetVal = IsItOnLHS ? RVal : LVal;
+handlePtrIncrOrDecr(C, ItExpr, BinaryOperator::getOverloadedOperator(OK),
+OffsetVal);

gamesh411 wrote:
> During the development of this patch, I saw something related. At the 
> beginning of handlePtrIncrOrDecr, there is a branch on whether the Expr (2nd 
> argument) is a pointer. I think that branch could just be an assertion. What 
> do you think? (or maybe I should create a patch to show what I mean?)
I wonder whether this should be implemented here in `checkPostStmt()` ot in 
`handlePtrIncrOrDecr()`. Your current implementation is in `checkPostStmt()`, 
in this case we can assert in `handlePtrIncrOrDecl()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83190



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


[PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index'

2020-07-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 275645.
sammccall retitled this revision from "Revert "[clangd] Store index in 
'.clangd/index' instead of '.clangd-index'"" to "[clangd] Store index in 
'.cache/clangd/index' instead of '.clangd/index'".
sammccall edited the summary of this revision.
sammccall added a comment.

Updating description


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83099

Files:
  .gitignore
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/clangd/test/background-index.test
  llvm/.gitignore


Index: llvm/.gitignore
===
--- llvm/.gitignore
+++ llvm/.gitignore
@@ -59,8 +59,6 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd index
-.clangd
 
 
#==#
 # Files created in tree by the Go bindings.
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
@@ -15,8 +15,8 @@
 # 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/.clangd/index/foo.cpp.*.idx
-# RUN: ls %t/sub_dir/.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
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -95,8 +95,8 @@
 };
 
 // Creates and owns IndexStorages for multiple CDBs.
-// When a CDB root is found, shards are stored in $ROOT/.clangd/index.
-// When no root is found, the fallback path is ~/.cache/clangd/index.
+// When a CDB root is found, shards are stored in $ROOT/.cache/clangd/index/.
+// When no root is found, the fallback path is ~/.cache/clangd/index/.
 class DiskBackedIndexStorageManager {
 public:
   DiskBackedIndexStorageManager(
@@ -115,7 +115,7 @@
 llvm::SmallString<128> StorageDir(FallbackDir);
 if (auto PI = GetProjectInfo(File)) {
   StorageDir = PI->SourceRoot;
-  llvm::sys::path::append(StorageDir, ".clangd", "index");
+  llvm::sys::path::append(StorageDir, ".cache", "clangd", "index");
 }
 auto &IndexStorage = IndexStorageMap[StorageDir];
 if (!IndexStorage)
Index: clang-tools-extra/clangd/index/Background.h
===
--- clang-tools-extra/clangd/index/Background.h
+++ clang-tools-extra/clangd/index/Background.h
@@ -56,9 +56,9 @@
   using Factory = llvm::unique_function;
 
   // Creates an Index Storage that saves shards into disk. Index storage uses
-  // CDBDirectory + ".clangd/index/" as the folder to save shards. CDBDirectory
-  // is the first directory containing a CDB in parent directories of a file, 
or
-  // user's home directory if none was found, e.g. standard library headers.
+  // CDBDirectory + ".cache/clangd/index/" as the folder to save shards.
+  // CDBDirectory is the first directory containing a CDB in parent directories
+  // of a file, or user's home directory if none was found, e.g. stdlib 
headers.
   static Factory createDiskBackedStorageFactory(
   std::function(PathRef)> GetProjectInfo);
 };
Index: .gitignore
===
--- .gitignore
+++ .gitignore
@@ -53,10 +53,11 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd index
-.clangd
+# clangd index. (".clangd" is a config file now, thus trailing slash)
+.clangd/
+.cache
 # static analyzer regression testing project files
 /clang/utils/analyzer/projects/*/CachedSource
 /clang/utils/analyzer/projects/*/PatchedSource
 /clang/utils/analyzer/projects/*/ScanBuildResults
-/clang/utils/analyzer/projects/*/RefScanBuildResults
\ No newline at end of file
+/clang/utils/analyzer/projects/*/RefScanBuildResults


Index: llvm/.gitignore
===
--- llvm/.gitignore
+++ llvm/.gitignore
@@ -59,8 +59,6 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd index
-.clangd
 
 #==#
 # Files created in tree by the Go bindings.
Index: clang-tools-extra/clangd/test/background-index.test
===
--- clang-tools-extra/clangd/test/background-index.test
+++ clang-tools-extra/clangd/t

[PATCH] D81761: [analyzer] Force dependency checkers to be hidden

2020-07-06 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG690ff37a2869: [analyzer] Force dependency checkers to be 
hidden (authored by Szelethus).

Changed prior to commit:
  https://reviews.llvm.org/D81761?vs=274466&id=275651#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81761

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Index: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
===
--- clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -42,17 +42,16 @@
 
 void addCustomChecker(AnalysisASTConsumer &AnalysisConsumer,
   AnalyzerOptions &AnOpts) {
-  AnOpts.CheckersAndPackages = {{"custom.CustomChecker", true}};
+  AnOpts.CheckersAndPackages = {{"test.CustomChecker", true}};
   AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
-Registry.addChecker("custom.CustomChecker", "Description",
-   "");
+Registry.addChecker("test.CustomChecker", "Description", "");
   });
 }
 
 TEST(RegisterCustomCheckers, RegisterChecker) {
   std::string Diags;
   EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags));
-  EXPECT_EQ(Diags, "custom.CustomChecker:Custom diagnostic description\n");
+  EXPECT_EQ(Diags, "test.CustomChecker:Custom diagnostic description\n");
 }
 
 //===--===//
@@ -121,7 +120,7 @@
 void addCheckerRegistrationOrderPrinter(CheckerRegistry &Registry) {
   Registry.addChecker(registerCheckerRegistrationOrderPrinter,
   shouldRegisterCheckerRegistrationOrderPrinter,
-  "custom.RegistrationOrder", "Description", "", false);
+  "test.RegistrationOrder", "Description", "", false);
 }
 
 #define UNITTEST_CHECKER(CHECKER_NAME, DIAG_MSG)   \
@@ -142,7 +141,7 @@
   }\
   void add##CHECKER_NAME(CheckerRegistry &Registry) {  \
 Registry.addChecker(register##CHECKER_NAME, shouldRegister##CHECKER_NAME,  \
-"custom." #CHECKER_NAME, "Description", "", false);\
+"test." #CHECKER_NAME, "Description", "", false);  \
   }
 
 UNITTEST_CHECKER(StrongDep, "Strong")
@@ -155,22 +154,22 @@
 
 void addDep(AnalysisASTConsumer &AnalysisConsumer,
   AnalyzerOptions &AnOpts) {
-  AnOpts.CheckersAndPackages = {{"custom.Dep", true},
-{"custom.RegistrationOrder", true}};
+  AnOpts.CheckersAndPackages = {{"test.Dep", true},
+{"test.RegistrationOrder", true}};
   AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
 Registry.addChecker(registerStrongDep, shouldRegisterStrongFALSE,
-"custom.Strong", "Description", "", false);
+"test.Strong", "Description", "", false);
 addStrongDep(Registry);
 addDep(Registry);
 addCheckerRegistrationOrderPrinter(Registry);
-Registry.addDependency("custom.Dep", "custom.Strong");
+Registry.addDependency("test.Dep", "test.Strong");
   });
 }
 
 TEST(RegisterDeps, UnsatisfiedDependency) {
   std::string Diags;
   EXPECT_TRUE(runCheckerOnCode("void f() {int i;}", Diags));
-  EXPECT_EQ(Diags, "custom.RegistrationOrder:custom.RegistrationOrder\n");
+  EXPECT_EQ(Diags, "test.RegistrationOrder:test.RegistrationOrder\n");
 }
 
 //===--===//
@@ -181,52 +180,52 @@
 
 void addWeakDepCheckerBothEnabled(AnalysisASTConsumer &AnalysisConsumer,
   AnalyzerOptions &AnOpts) {
-  AnOpts.CheckersAndPackages = {{"custom.Dep", true},
-{"custom.WeakDep", true},
-{"custom.RegistrationOrder", true}};
+  AnOpts.CheckersAndPackages = {{"test.Dep", true},
+{"test.WeakDep", true},
+{"test.RegistrationOrder", true}};
   AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) {
 addWeakDep(Registry);
 addDep(Registry);
 addCheckerRegistrationOrderPrinter(Registry);
-Registry.addWeakDependency("custom.Dep", "custom.WeakDep");
+Registry.addWeakDependency("test.Dep", "test.WeakDep");
   });
 }
 
 void addWeakDepCheckerBothEnabledSwitched(AnalysisASTConsumer &AnalysisConsumer,
   AnalyzerOptions &AnOpts) {
-  AnOpts.CheckersAndPackages = {{"custom.Dep", true},
-   

[PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM

2020-07-06 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64Subtarget.h:72
+ThunderX3T110,
+CortexX1,
+CortexA78

I think the new CPUs should be grouped with other Cortex-A CPUs. 



Comment at: llvm/lib/Target/ARM/ARMSubtarget.h:78
+Swift,
+CortexX1,
+CortexA78

Please keep the list sorted in alphabetical order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83206



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


[PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations.

2020-07-06 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan updated this revision to Diff 275657.
ebevhan added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82663

Files:
  clang/include/clang/Basic/FixedPoint.h
  clang/lib/Basic/FixedPoint.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/Frontend/fixed_point_add.c
  clang/test/Frontend/fixed_point_comparisons.c
  clang/test/Frontend/fixed_point_compound.c
  clang/test/Frontend/fixed_point_div.c
  clang/test/Frontend/fixed_point_mul.c
  clang/test/Frontend/fixed_point_sub.c
  clang/test/Frontend/fixed_point_unary.c

Index: clang/test/Frontend/fixed_point_unary.c
===
--- clang/test/Frontend/fixed_point_unary.c
+++ clang/test/Frontend/fixed_point_unary.c
@@ -68,28 +68,28 @@
 // CHECK: [[TMP18:%.*]] = load i32, i32* @sua, align 4
 // SIGNED-NEXT:   [[TMP19:%.*]] = call i32 @llvm.uadd.sat.i32(i32 [[TMP18]], i32 65536)
 // SIGNED-NEXT:   store i32 [[TMP19]], i32* @sua, align 4
-// UNSIGNED-NEXT: [[RESIZE:%.*]] = trunc i32 [[TMP18]] to i31
-// UNSIGNED-NEXT: [[TMP19:%.*]] = call i31 @llvm.uadd.sat.i31(i31 [[RESIZE]], i31 32768)
-// UNSIGNED-NEXT: [[RESIZE1:%.*]] = zext i31 [[TMP19]] to i32
-// UNSIGNED-NEXT: store i32 [[RESIZE1]], i32* @sua, align 4
+// UNSIGNED-NEXT: [[TMP19:%.*]] = call i32 @llvm.sadd.sat.i32(i32 [[TMP18]], i32 32768)
+// UNSIGNED-NEXT: [[TMP20:%.*]] = icmp slt i32 [[TMP19]], 0
+// UNSIGNED-NEXT: [[SATMIN:%.*]] = select i1 [[TMP20]], i32 0, i32 [[TMP19]]
+// UNSIGNED-NEXT: store i32 [[SATMIN]], i32* @sua, align 4
   sua++;
 
 // CHECK: [[TMP20:%.*]] = load i16, i16* @susa, align 2
 // SIGNED-NEXT:   [[TMP21:%.*]] = call i16 @llvm.uadd.sat.i16(i16 [[TMP20]], i16 256)
 // SIGNED-NEXT:   store i16 [[TMP21]], i16* @susa, align 2
-// UNSIGNED-NEXT: [[RESIZE2:%.*]] = trunc i16 [[TMP20]] to i15
-// UNSIGNED-NEXT: [[TMP21:%.*]] = call i15 @llvm.uadd.sat.i15(i15 [[RESIZE2]], i15 128)
-// UNSIGNED-NEXT: [[RESIZE3:%.*]] = zext i15 [[TMP21]] to i16
-// UNSIGNED-NEXT: store i16 [[RESIZE3]], i16* @susa, align 2
+// UNSIGNED-NEXT: [[TMP22:%.*]] = call i16 @llvm.sadd.sat.i16(i16 [[TMP20]], i16 128)
+// UNSIGNED-NEXT: [[TMP23:%.*]] = icmp slt i16 [[TMP22]], 0
+// UNSIGNED-NEXT: [[SATMIN1:%.*]] = select i1 [[TMP23]], i16 0, i16 [[TMP22]]
+// UNSIGNED-NEXT: store i16 [[SATMIN1]], i16* @susa, align 2
   susa++;
 
 // CHECK: [[TMP22:%.*]] = load i16, i16* @suf, align 2
 // SIGNED-NEXT:   [[TMP23:%.*]] = call i16 @llvm.uadd.sat.i16(i16 [[TMP22]], i16 -1)
 // SIGNED-NEXT:   store i16 [[TMP23]], i16* @suf, align 2
-// UNSIGNED-NEXT: [[RESIZE4:%.*]] = trunc i16 [[TMP22]] to i15
-// UNSIGNED-NEXT: [[TMP23:%.*]] = call i15 @llvm.uadd.sat.i15(i15 [[RESIZE4]], i15 -1)
-// UNSIGNED-NEXT: [[RESIZE5:%.*]] = zext i15 [[TMP23]] to i16
-// UNSIGNED-NEXT: store i16 [[RESIZE5]], i16* @suf, align 2
+// UNSIGNED-NEXT: [[TMP25:%.*]] = call i16 @llvm.sadd.sat.i16(i16 [[TMP22]], i16 32767)
+// UNSIGNED-NEXT: [[TMP26:%.*]] = icmp slt i16 [[TMP25]], 0
+// UNSIGNED-NEXT: [[SATMIN2:%.*]] = select i1 [[TMP26]], i16 0, i16 [[TMP25]]
+// UNSIGNED-NEXT: store i16 [[SATMIN2]], i16* @suf, align 2
   suf++;
 }
 
@@ -146,28 +146,28 @@
 // CHECK: [[TMP18:%.*]] = load i32, i32* @sua, align 4
 // SIGNED-NEXT:   [[TMP19:%.*]] = call i32 @llvm.usub.sat.i32(i32 [[TMP18]], i32 65536)
 // SIGNED-NEXT:   store i32 [[TMP19]], i32* @sua, align 4
-// UNSIGNED-NEXT: [[RESIZE:%.*]] = trunc i32 [[TMP18]] to i31
-// UNSIGNED-NEXT: [[TMP19:%.*]] = call i31 @llvm.usub.sat.i31(i31 [[RESIZE]], i31 32768)
-// UNSIGNED-NEXT: [[RESIZE1:%.*]] = zext i31 [[TMP19]] to i32
-// UNSIGNED-NEXT: store i32 [[RESIZE1]], i32* @sua, align 4
+// UNSIGNED-NEXT: [[TMP19:%.*]] = call i32 @llvm.ssub.sat.i32(i32 [[TMP18]], i32 32768)
+// UNSIGNED-NEXT: [[TMP20:%.*]] = icmp slt i32 [[TMP19]], 0
+// UNSIGNED-NEXT: [[SATMIN:%.*]] = select i1 [[TMP20]], i32 0, i32 [[TMP19]]
+// UNSIGNED-NEXT: store i32 [[SATMIN]], i32* @sua, align 4
   sua--;
 
 // CHECK: [[TMP20:%.*]] = load i16, i16* @susa, align 2
 // SIGNED-NEXT:   [[TMP21:%.*]] = call i16 @llvm.usub.sat.i16(i16 [[TMP20]], i16 256)
 // SIGNED-NEXT:   store i16 [[TMP21]], i16* @susa, align 2
-// UNSIGNED-NEXT: [[RESIZE2:%.*]] = trunc i16 [[TMP20]] to i15
-// UNSIGNED-NEXT: [[TMP21:%.*]] = call i15 @llvm.usub.sat.i15(i15 [[RESIZE2]], i15 128)
-// UNSIGNED-NEXT: [[RESIZE3:%.*]] = zext i15 [[TMP21]] to i16
-// UNSIGNED-NEXT: store i16 [[RESIZE3]], i16* @susa, align 2
+// UNSIGNED-NEXT: [[TMP22:%.*]] = call i16 @llvm.ssub.sat.i16(i16 [[TMP20]], i16 128)
+// UNSIGNED-NEXT: [[TMP23:%.*]] = icmp slt i16 [[TMP22]], 0
+// UNSIGNED-NEXT: [[SATMIN1:%.*]] = select i1 [[TMP23]], i16 0, i16 [[TMP22]]
+// UNSIGNED-NEXT: store i16 [[SATMIN1]], i16* @susa, align 2
   susa--;
 
 // CHECK: [[TMP22:%.*]] = load i16, i16* @suf, align 2
 // SIGNED-NEXT:   [[TMP23:%.*]] = call i16 @llvm.usub.sat.i16(i16 [[TMP22]], i16 -1)
 // SIGNED-NEXT: 

[PATCH] D82921: Removed a RecursiveASTVisitor feature to visit operator kinds with different methods

2020-07-06 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5689b38c6a42: Removed a RecursiveASTVisitor feature to visit 
operator kinds with different… (authored by gribozavr).

Changed prior to commit:
  https://reviews.llvm.org/D82921?vs=275064&id=275663#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82921

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/ARCMigrate/TransProperties.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -403,622 +403,40 @@
 }
 )cpp";
 
-  // TraverseUnaryOperator is not called because RecursiveASTVisitor treats
-  // individual operators as subclasses, for which it calls their Traverse
-  // methods.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::No), Code,
   R"txt(
 WalkUpFromStmt CompoundStmt
 WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromStmt UnaryOperator(-)
-WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromStmt IntegerLiteral(3)
-)txt"));
-
-  EXPECT_TRUE(visitorCallbackLogEqual(
-  RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
-  R"txt(
-WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromStmt UnaryOperator(-)
-WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt CompoundStmt
-)txt"));
-}
-
-TEST(RecursiveASTVisitor,
- StmtCallbacks_TraverseUnaryOperator_WalkUpFromUnaryOperator) {
-  class RecordingVisitor : public RecordingVisitorBase {
-  public:
-RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
-: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
-
-bool TraverseUnaryOperator(UnaryOperator *UO) {
-  recordCallback(__func__, UO, [&]() {
-RecordingVisitorBase::TraverseUnaryOperator(UO);
-  });
-  return true;
-}
-
-bool WalkUpFromStmt(Stmt *S) {
-  recordCallback(__func__, S,
- [&]() { RecordingVisitorBase::WalkUpFromStmt(S); });
-  return true;
-}
-
-bool WalkUpFromExpr(Expr *E) {
-  recordCallback(__func__, E,
- [&]() { RecordingVisitorBase::WalkUpFromExpr(E); });
-  return true;
-}
-
-bool WalkUpFromUnaryOperator(UnaryOperator *UO) {
-  recordCallback(__func__, UO, [&]() {
-RecordingVisitorBase::WalkUpFromUnaryOperator(UO);
-  });
-  return true;
-}
-  };
-
-  StringRef Code = R"cpp(
-void test() {
-  1;
-  -2;
-  3;
-}
-)cpp";
-
-  // TraverseUnaryOperator is not called because RecursiveASTVisitor treats
-  // individual operators as subclasses, for which it calls their Traverse
-  // methods.
-  EXPECT_TRUE(visitorCallbackLogEqual(
-  RecordingVisitor(ShouldTraversePostOrder::No), Code,
-  R"txt(
-WalkUpFromStmt CompoundStmt
-WalkUpFromExpr IntegerLiteral(1)
-  WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromUnaryOperator UnaryOperator(-)
-  WalkUpFromExpr UnaryOperator(-)
-WalkUpFromStmt UnaryOperator(-)
-WalkUpFromExpr IntegerLiteral(2)
-  WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromExpr IntegerLiteral(3)
-  WalkUpFromStmt IntegerLiteral(3)
-)txt"));
-
-  EXPECT_TRUE(visitorCallbackLogEqual(
-  RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
-  R"txt(
-WalkUpFromExpr IntegerLiteral(1)
-  WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromExpr IntegerLiteral(2)
-  WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromUnaryOperator UnaryOperator(-)
-  WalkUpFromExpr UnaryOperator(-)
-WalkUpFromStmt UnaryOperator(-)
-WalkUpFromExpr IntegerLiteral(3)
-  WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt CompoundStmt
-)txt"));
-}
-
-TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromUnaryOperator) {
-  class RecordingVisitor : public RecordingVisitorBase {
-  public:
-RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
-: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
-
-bool WalkUpFromStmt(Stmt *S) {
-  recordCallback(__func__, S,
- [&]() { RecordingVisitorBase::WalkUpFromStmt(S); });
-  return true;
-}
-
-bool WalkUpFromExpr(Expr *E) {
-  recordCallback(__func__, E,
- [&]() { RecordingVisitorBase::WalkUpFromExpr(E); });
-  return true;
-}
-
-bool WalkUpFromUnaryOperator(UnaryOperator *UO) {
-  recordCallback(__func__, UO, [&]() {
-RecordingVisitorBase::WalkUpFromUnaryOperator(UO);
-  });
-  return true;
-}
-  };
-
-  StringRef Code = R"cpp(
-void test() {
-  1;
-  -2;
-  3;
-}
-)cpp";
-
-  EXPECT_TRUE(vis

[PATCH] D83212: [Fixed Point] Add fixed-point shift operations and consteval.

2020-07-06 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan created this revision.
ebevhan added reviewers: rjmccall, leonardchan, bjope.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83212

Files:
  clang/include/clang/Basic/FixedPoint.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/FixedPoint.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Frontend/fixed_point_errors.c
  clang/test/Frontend/fixed_point_shift.c

Index: clang/test/Frontend/fixed_point_shift.c
===
--- /dev/null
+++ clang/test/Frontend/fixed_point_shift.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
+// RUN: %clang_cc1 -ffixed-point -fpadding-on-unsigned-fixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED
+
+short _Accum sa_const1 = 1.0hk << 2;   // CHECK-DAG: @sa_const1 = global i16 512
+short _Accum sa_const2 = 0.5hk << 2;   // CHECK-DAG: @sa_const2 = global i16 256
+short _Accum sa_const3 = 10.0hk >> 3;  // CHECK-DAG: @sa_const3 = global i16 160
+short _Accum sa_const4 = 0.0546875hk << 8; // CHECK-DAG: @sa_const4 = global i16 1792
+short _Accum sa_const5 = -1.0hk << 2;  // CHECK-DAG: @sa_const5 = global i16 -512
+short _Accum sa_const6 = -255.0hk >> 8;// CHECK-DAG: @sa_const6 = global i16 -128
+
+_Fract f_const1 = -1.0r >> 5;  // CHECK-DAG: @f_const1 = global i16 -1024
+_Fract f_const2 = 0.0052490234375r >> 3;   // CHECK-DAG: @f_const2 = global i16 21
+_Fract f_const3 = -0.0001r << 5;   // CHECK-DAG: @f_const3 = global i16 -96
+_Fract f_const4 = -0.75r >> 15;// CHECK-DAG: @f_const4 = global i16 -1
+_Fract f_const5 = 0.078216552734375r << 3; // CHECK-DAG: @f_const5 = global i16 20504
+
+unsigned _Fract uf_const1 = 0.375ur >> 13;
+// SIGNED-DAG:   @uf_const1 = global i16 3
+// UNSIGNED-DAG: @uf_const1 = global i16 1
+unsigned _Fract uf_const2 = 0.0546875ur << 3;
+// SIGNED-DAG:   @uf_const2 = global i16 28672
+// UNSIGNED-DAG: @uf_const2 = global i16 14336
+
+_Sat short _Accum ssa_const1 = (_Sat short _Accum)31.875hk << 4; // CHECK-DAG: @ssa_const1 = global i16 32767
+_Sat short _Accum ssa_const2 = (_Sat short _Accum) - 1.0hk << 8; // CHECK-DAG: @ssa_const2 = global i16 -32768
+_Sat short _Accum ssa_const3 = (_Sat short _Accum)128.0hk << 8;  // CHECK-DAG: @ssa_const3 = global i16 32767
+_Sat short _Fract ssf_const1 = (_Sat short _Fract) - 0.5hr << 3; // CHECK-DAG: @ssf_const1 = global i8 -128
+
+_Sat unsigned _Fract suf_const1 = (_Sat unsigned _Fract)0.5r << 1;
+// SIGNED-DAG:   @suf_const1 = global i16 -1
+// UNSIGNED-DAG: @suf_const1 = global i16 32767
+_Sat unsigned _Fract suf_const2 = (_Sat unsigned _Fract)0.25r << 1;
+// SIGNED-DAG:   @suf_const2 = global i16 -32768
+// UNSIGNED-DAG: @suf_const2 = global i16 16384
+_Sat unsigned _Accum sua_const2 = (_Sat unsigned _Accum)128.0uk << 10;
+// SIGNED-DAG:   @sua_const2 = global i32 -1
+// UNSIGNED-DAG: @sua_const2 = global i32 2147483647
Index: clang/test/Frontend/fixed_point_errors.c
===
--- clang/test/Frontend/fixed_point_errors.c
+++ clang/test/Frontend/fixed_point_errors.c
@@ -259,11 +259,30 @@
 short _Accum mul_ovf2 = (-0.5hr - 0.5hr) * (-0.5hr - 0.5hr);  // expected-warning {{overflow in expression; result is -1.0 with type 'short _Fract'}}
 short _Accum div_ovf1 = 255.0hk / 0.5hk;  // expected-warning {{overflow in expression; result is -2.0 with type 'short _Accum'}}
 
+short _Accum shl_ovf1 = 255.0hk << 8;   // expected-warning {{overflow in expression; result is -256.0 with type 'short _Accum'}}
+short _Fract shl_ovf2 = -0.25hr << 3;   // expected-warning {{overflow in expression; result is 0.0 with type 'short _Fract'}}
+unsigned short _Accum shl_ovf3 = 100.5uhk << 3; // expected-warning {{overflow in expression; result is 36.0 with type 'unsigned short _Accum'}}
+short _Fract shl_ovf4 = 0.25hr << 2;// expected-warning {{overflow in expression; result is -1.0 with type 'short _Fract'}}
+
+_Accum shl_bw1 = 0.91552734375k << 32;   // expected-warning {{shift count >= width of type}} \
+ expected-warning {{overflow in expression; result is -65536.0 with type '_Accum'}}
+unsigned _Fract shl_bw2 = 0.65ur << 16;  // expected-warning {{shift count >= width of type}} \
+ expected-warning {{overflow in expression; result is 0.0 with type 'unsigned _Fract'}}
+_Sat short _Accum shl_bw3 = (_Sat short _Accum)80.0hk << 17; // expected-warning {{shift count >= width of type}}
+short _Accum shr_bw1 = 1.0hk >> 17;  // expected-warning {{shift count >= width of type}}
+
+_Accum shl_neg1 = 25.5k << -5;  // expected-warning {{shift count is nega

[PATCH] D82442: [Coroutines] Warning if the return type of coroutine_handle::address is not void*

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



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10531
+def warn_coroutine_handle_address_invalid_return_type : Warning <
+  "return type of 'coroutine_handle<>::address should be 'void*' (have %0) in 
order to get capability with existing async C API.">,
+  InGroup;

Should this be something like `[...] for compatibility with existing async C 
APIs` instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82442



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


[PATCH] D83215: [AST][RecoveryExpr] Clarify the documentation of RecoveryExpr.

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

Fix some out-of-date doc/FIXMEs, and be clear about our plan.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83215

Files:
  clang/include/clang/AST/Expr.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19211,9 +19211,6 @@
 ExprResult Sema::CreateRecoveryExpr(SourceLocation Begin, SourceLocation End,
 ArrayRef SubExprs, QualType T,
 ExprValueKind VK) {
-  // FIXME: enable it for C++, RecoveryExpr is type-dependent to suppress
-  // bogus diagnostics and this trick does not work in C.
-  // FIXME: use containsErrors() to suppress unwanted diags in C.
   if (!Context.getLangOpts().RecoveryAST)
 return ExprError();
 
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -495,11 +495,19 @@
 }
 
 ExprDependence clang::computeDependence(RecoveryExpr *E) {
-  // Mark the expression as value- and instantiation- dependent to reuse
-  // existing suppressions for dependent code, e.g. avoiding
-  // constant-evaluation.
-  // FIXME: drop type+value+instantiation once Error is sufficient to suppress
-  // bogus dianostics.
+  // RecoveryExpr dependence-bits setting:
+  //   - type-dep is set if we don't know about the type (fallback to an opaque
+  // dependent type);
+  //   - value-dep is always set to avoid constant-evaluation;
+  //   - instantiation-dep bit is not set to disinguish with regular template
+  // dependent expressions;
+  //
+  // Explanations:
+  //   - "type-dependent" + "contains-errors": depends on an error and we don't
+  // know the type
+  //   - "contains-errors": depends on an error and we know the type
+  //   - "type-depdendent" + "instantiation-dependent": a regular dependent
+  // expression which involves template parameters (not a recovery expr)
   auto D = toExprDependence(E->getType()->getDependence()) |
ExprDependence::Value | ExprDependence::Error;
   for (auto *S : E->subExpressions())
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -6212,19 +6212,22 @@
 /// subexpressions of some expression that we could not construct and source
 /// range covered by the expression.
 ///
-/// By default, RecoveryExpr is type-, value- and instantiation-dependent to
-/// take advantage of existing machinery to deal with dependent code in C++,
-/// e.g. RecoveryExpr is preserved in `decltype()` as part of the
-/// `DependentDecltypeType`. In addition to that, clang does not report most
-/// errors on dependent expressions, so we get rid of bogus errors for free.
-/// However, note that unlike other dependent expressions, RecoveryExpr can be
-/// produced in non-template contexts.
+/// By default, RecoveryExpr uses dependence-bits to take advantage of existing
+/// machinery to deal with dependent code in C++, e.g. RecoveryExpr is 
preserved
+/// in `decltype()` as part of the `DependentDecltypeType`. In
+/// addition to that, clang does not report most errors on dependent
+/// expressions, so we get rid of bogus errors for free. However, note that
+/// unlike other dependent expressions, RecoveryExpr can be produced in
+/// non-template contexts.
 /// In addition, we will preserve the type in RecoveryExpr when the type is
 /// known, e.g. preserving the return type for a broken non-overloaded function
 /// call, a overloaded call where all candidates have the same return type.
 ///
 /// One can also reliably suppress all bogus errors on expressions containing
 /// recovery expressions by examining results of Expr::containsErrors().
+///
+/// FIXME: RecoveryExpr is C++ only, make it work for C by supporting 
dependence
+/// mechanism for C language in clang.
 class RecoveryExpr final : public Expr,
private llvm::TrailingObjects 
{
 public:


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19211,9 +19211,6 @@
 ExprResult Sema::CreateRecoveryExpr(SourceLocation Begin, SourceLocation End,
 ArrayRef SubExprs, QualType T,
 ExprValueKind VK) {
-  // FIXME: enable it for C++, RecoveryExpr is type-dependent to suppress
-  // bogus diagnostics and this trick does not work in C.
-  // FIXME: use containsErrors() to suppress unwanted diags in C.
   if (!Context.getLangOpts().RecoveryAST)
 return ExprError();
 
Inde

[PATCH] D82938: [clangd] Implement path and URI translation for remote index

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

Use std::string() instead of static_cast()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82938

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

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -7,16 +7,30 @@
 //===--===//
 
 #include "../TestTU.h"
+#include "TestFS.h"
 #include "index/Serialization.h"
 #include "index/remote/marshalling/Marshalling.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
 namespace remote {
 namespace {
 
+const char *unittestURIToFilesystem(const char *UnittestURI,
+llvm::UniqueStringSaver &Strings) {
+  auto URI = URI::parse(UnittestURI);
+  EXPECT_TRUE(bool(URI));
+  const auto FileSystemURI =
+  URI::createFile(testPath(llvm::sys::path::relative_path(URI->body(;
+  return Strings.save(FileSystemURI.toString()).begin();
+}
+
 TEST(RemoteMarshallingTest, SymbolSerialization) {
   const auto *Header = R"(
   // This is a class.
@@ -39,9 +53,20 @@
   EXPECT_GE(Symbols.size(), 5UL);
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
-  for (auto &Sym : Symbols) {
-const auto ProtobufMeessage = toProtobuf(Sym);
-const auto SymToProtobufAndBack = fromProtobuf(ProtobufMeessage, &Strings);
+  llvm::SmallString<256> RootPath = llvm::StringRef("/");
+  llvm::sys::path::native(RootPath);
+  for (auto Sym : Symbols) {
+Sym.CanonicalDeclaration.FileURI =
+unittestURIToFilesystem(Sym.CanonicalDeclaration.FileURI, Strings);
+if (std::strlen(Sym.Definition.FileURI))
+  Sym.Definition.FileURI =
+  unittestURIToFilesystem(Sym.Definition.FileURI, Strings);
+for (auto &Header : Sym.IncludeHeaders)
+  Header.IncludeHeader =
+  unittestURIToFilesystem(Header.IncludeHeader.str().c_str(), Strings);
+auto ProtobufMessage = toProtobuf(Sym, RootPath);
+const auto SymToProtobufAndBack =
+fromProtobuf(ProtobufMessage, &Strings, RootPath);
 EXPECT_TRUE(SymToProtobufAndBack.hasValue());
 EXPECT_EQ(toYAML(Sym), toYAML(*SymToProtobufAndBack));
   }
@@ -76,16 +101,54 @@
   const auto References = TU.headerRefs();
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
+  llvm::SmallString<256> RootPath = llvm::StringRef("/");
+  llvm::sys::path::native(RootPath);
   // Sanity check: there are more than 5 references available.
   EXPECT_GE(References.numRefs(), 5UL);
   for (const auto &SymbolWithRefs : References) {
-for (const auto &Ref : SymbolWithRefs.second) {
-  const auto RefToProtobufAndBack = fromProtobuf(toProtobuf(Ref), &Strings);
+for (auto Ref : SymbolWithRefs.second) {
+  Ref.Location.FileURI =
+  unittestURIToFilesystem(Ref.Location.FileURI, Strings);
+  const auto RefToProtobufAndBack =
+  fromProtobuf(toProtobuf(Ref, RootPath), &Strings, RootPath);
   EXPECT_TRUE(RefToProtobufAndBack.hasValue());
   EXPECT_EQ(toYAML(Ref), toYAML(*RefToProtobufAndBack));
 }
   }
-} // namespace
+}
+
+TEST(RemoteMarshallingTest, URITranslation) {
+  llvm::BumpPtrAllocator Arena;
+  llvm::UniqueStringSaver Strings(Arena);
+  clangd::Ref Original;
+  const std::string RemoteIndexPrefix = testPath("remote/machine/project/");
+  std::string RelativePath = "llvm-project/clang-tools-extra/clangd/"
+ "unittests/remote/MarshallingTests.cpp";
+  llvm::SmallString<256> NativePath = StringRef(RelativePath);
+  llvm::sys::path::native(NativePath);
+  RelativePath = std::string(NativePath);
+  const auto URI = URI::createFile(RemoteIndexPrefix + RelativePath);
+  Original.Location.FileURI = Strings.save(URI.toString()).begin();
+  Ref Serialized = toProtobuf(Original, RemoteIndexPrefix);
+  EXPECT_EQ(Serialized.location().file_path(), RelativePath);
+  const std::string LocalIndexPrefix = testPath("local/machine/project/");
+  auto Deserialized = fromProtobuf(Serialized, &Strings, LocalIn

[PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker

2020-07-06 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 275678.
gamesh411 added a comment.

modernize the memory modeling code, still WIP


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69318

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp
  clang/test/Analysis/sufficient-size-array-indexing-32bit.c
  clang/test/Analysis/sufficient-size-array-indexing-64bit.c

Index: clang/test/Analysis/sufficient-size-array-indexing-64bit.c
===
--- /dev/null
+++ clang/test/Analysis/sufficient-size-array-indexing-64bit.c
@@ -0,0 +1,127 @@
+// RUN: %clang_analyze_cc1 -triple x86_64 -analyzer-checker=core,alpha.core.SufficientSizeArrayIndexing %s -verify
+
+#include "Inputs/system-header-simulator.h"
+
+const unsigned long long one_byte_signed_max = (1ULL << 7) - 1;
+const unsigned long long two_byte_signed_max = (1ULL << 15) - 1;
+const unsigned long long four_byte_signed_max = (1ULL << 31) - 1;
+
+const unsigned long long one_byte_unsigned_max = (1ULL << 8) - 1;
+const unsigned long long two_byte_unsigned_max = (1ULL << 16) - 1;
+const unsigned long long four_byte_unsigned_max = (1ULL << 32) - 1;
+
+char smaller_than_1byte_signed_range[one_byte_signed_max];
+char exactly_1byte_signed_range[one_byte_signed_max + 1];
+char greater_than_1byte_signed_range[one_byte_signed_max + 2];
+
+char smaller_than_2byte_signed_range[two_byte_signed_max];
+char exactly_2byte_signed_range[two_byte_signed_max + 1];
+char greater_than_2byte_signed_range[two_byte_signed_max + 2];
+
+char smaller_than_4byte_signed_range[four_byte_signed_max];
+char exactly_4byte_signed_range[four_byte_signed_max + 1];
+char greater_than_4byte_signed_range[four_byte_signed_max + 2];
+
+char smaller_than_1byte_unsigned_range[one_byte_unsigned_max];
+char exactly_1byte_unsigned_range[one_byte_unsigned_max + 1];
+char greater_than_1byte_unsigned_range[one_byte_unsigned_max + 2];
+
+char smaller_than_2byte_unsigned_range[two_byte_unsigned_max];
+char exactly_2byte_unsigned_range[two_byte_unsigned_max + 1];
+char greater_than_2byte_unsigned_range[two_byte_unsigned_max + 2];
+
+char smaller_than_4byte_unsigned_range[four_byte_unsigned_max];
+char exactly_4byte_unsigned_range[four_byte_unsigned_max + 1];
+char greater_than_4byte_unsigned_range[four_byte_unsigned_max + 2];
+
+const char one_byte_signed_index = 1;  // sizeof(char) == 1
+const short two_byte_signed_index = 1; // sizeof(short) == 2
+const int four_byte_signed_index = 1;  // sizeof(int) == 4
+
+const unsigned char one_byte_unsigned_index = 1;
+const unsigned short two_byte_unsigned_index = 1;
+const unsigned int four_byte_unsigned_index = 1;
+
+void ignore_literal_indexing() {
+  char a = exactly_4byte_unsigned_range[32]; // nowarning
+}
+
+void ignore_literal_indexing_with_parens() {
+  char a = exactly_4byte_unsigned_range[(32)]; // nowarning
+}
+
+void range_check_one_byte_index() {
+  char r;
+  char *pr = &r;
+  *pr = smaller_than_1byte_signed_range[one_byte_signed_index]; // nowarning
+  *pr = exactly_1byte_signed_range[one_byte_signed_index];  // nowarning
+  *pr = greater_than_1byte_signed_range[one_byte_signed_index]; // expected-warning{{Index type cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+  *pr = smaller_than_1byte_unsigned_range[one_byte_unsigned_index]; // nowarning
+  *pr = exactly_1byte_unsigned_range[one_byte_unsigned_index];  // nowarning
+  *pr = greater_than_1byte_unsigned_range[one_byte_unsigned_index]; // expected-warning{{Index type cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+}
+
+void range_check_two_byte_index() {
+  char r;
+  char *pr = &r;
+  *pr = smaller_than_2byte_signed_range[two_byte_signed_index]; // nowarning
+  *pr = exactly_2byte_signed_range[two_byte_signed_index];  // nowarning
+  *pr = greater_than_2byte_signed_range[two_byte_signed_index]; // expected-warning{{Index type cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+  *pr = smaller_than_2byte_unsigned_range[two_byte_unsigned_index]; // nowarning
+  *pr = exactly_2byte_unsigned_range[two_byte_unsigned_index];  // nowarning
+  *pr = greater_than_2byte_unsigned_range[two_byte_unsigned_index]; // expected-warning{{Index type cannot cover the whole range of the array's index set, which may result in memory waste in form of unindexable elements. Consider using a type with greater maximum value}}
+}
+
+void range_check_four_byte_index

[PATCH] D83189: [clangd] More complete fix for hover crashes on invalid record.

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



Comment at: clang-tools-extra/clangd/Hover.cpp:677
 HI.Size = Size->getQuantity();
-  if (!FD->isInvalidDecl())
 HI.Offset = Ctx.getFieldOffset(FD) / 8;
+  }

kadircet wrote:
> could you move this out of the if statement.
I'm not sure  whether Size and Offset should be be independent, IIUC your fix 
seems to change it as a side effect, this just preserves the old behavior. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83189



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


[PATCH] D82938: [clangd] Implement path and URI translation for remote index

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

Remove IndexRoot conversion to UNIX slashes from the Marshalling hot path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82938

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

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -7,16 +7,30 @@
 //===--===//
 
 #include "../TestTU.h"
+#include "TestFS.h"
 #include "index/Serialization.h"
 #include "index/remote/marshalling/Marshalling.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
 namespace remote {
 namespace {
 
+const char *unittestURIToFilesystem(const char *UnittestURI,
+llvm::UniqueStringSaver &Strings) {
+  auto URI = URI::parse(UnittestURI);
+  EXPECT_TRUE(bool(URI));
+  const auto FileSystemURI =
+  URI::createFile(testPath(llvm::sys::path::relative_path(URI->body(;
+  return Strings.save(FileSystemURI.toString()).begin();
+}
+
 TEST(RemoteMarshallingTest, SymbolSerialization) {
   const auto *Header = R"(
   // This is a class.
@@ -39,9 +53,20 @@
   EXPECT_GE(Symbols.size(), 5UL);
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
-  for (auto &Sym : Symbols) {
-const auto ProtobufMeessage = toProtobuf(Sym);
-const auto SymToProtobufAndBack = fromProtobuf(ProtobufMeessage, &Strings);
+  llvm::SmallString<256> RootPath = llvm::StringRef("/");
+  llvm::sys::path::native(RootPath);
+  for (auto Sym : Symbols) {
+Sym.CanonicalDeclaration.FileURI =
+unittestURIToFilesystem(Sym.CanonicalDeclaration.FileURI, Strings);
+if (std::strlen(Sym.Definition.FileURI))
+  Sym.Definition.FileURI =
+  unittestURIToFilesystem(Sym.Definition.FileURI, Strings);
+for (auto &Header : Sym.IncludeHeaders)
+  Header.IncludeHeader =
+  unittestURIToFilesystem(Header.IncludeHeader.str().c_str(), Strings);
+auto ProtobufMessage = toProtobuf(Sym, RootPath);
+const auto SymToProtobufAndBack =
+fromProtobuf(ProtobufMessage, &Strings, RootPath);
 EXPECT_TRUE(SymToProtobufAndBack.hasValue());
 EXPECT_EQ(toYAML(Sym), toYAML(*SymToProtobufAndBack));
   }
@@ -76,16 +101,54 @@
   const auto References = TU.headerRefs();
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
+  llvm::SmallString<256> RootPath = llvm::StringRef("/");
+  llvm::sys::path::native(RootPath);
   // Sanity check: there are more than 5 references available.
   EXPECT_GE(References.numRefs(), 5UL);
   for (const auto &SymbolWithRefs : References) {
-for (const auto &Ref : SymbolWithRefs.second) {
-  const auto RefToProtobufAndBack = fromProtobuf(toProtobuf(Ref), &Strings);
+for (auto Ref : SymbolWithRefs.second) {
+  Ref.Location.FileURI =
+  unittestURIToFilesystem(Ref.Location.FileURI, Strings);
+  const auto RefToProtobufAndBack =
+  fromProtobuf(toProtobuf(Ref, RootPath), &Strings, RootPath);
   EXPECT_TRUE(RefToProtobufAndBack.hasValue());
   EXPECT_EQ(toYAML(Ref), toYAML(*RefToProtobufAndBack));
 }
   }
-} // namespace
+}
+
+TEST(RemoteMarshallingTest, URITranslation) {
+  llvm::BumpPtrAllocator Arena;
+  llvm::UniqueStringSaver Strings(Arena);
+  clangd::Ref Original;
+  const std::string RemoteIndexPrefix = testPath("remote/machine/project/");
+  std::string RelativePath = "llvm-project/clang-tools-extra/clangd/"
+ "unittests/remote/MarshallingTests.cpp";
+  llvm::SmallString<256> NativePath = StringRef(RelativePath);
+  llvm::sys::path::native(NativePath);
+  RelativePath = std::string(NativePath);
+  const auto URI = URI::createFile(RemoteIndexPrefix + RelativePath);
+  Original.Location.FileURI = Strings.save(URI.toString()).begin();
+  Ref Serialized = toProtobuf(Original, RemoteIndexPrefix);
+  EXPECT_EQ(Serialized.location().file_path(), RelativePath);
+  const std::string LocalIndexPrefix = testPath("local/machine/project/");
+  auto Deserialized = fromProtob

[PATCH] D82938: [clangd] Implement path and URI translation for remote index

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

Resolve the rest of patch comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82938

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

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -7,16 +7,30 @@
 //===--===//
 
 #include "../TestTU.h"
+#include "TestFS.h"
 #include "index/Serialization.h"
 #include "index/remote/marshalling/Marshalling.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
 namespace remote {
 namespace {
 
+const char *unittestURIToFilesystem(const char *UnittestURI,
+llvm::UniqueStringSaver &Strings) {
+  auto URI = URI::parse(UnittestURI);
+  EXPECT_TRUE(bool(URI));
+  const auto FileSystemURI =
+  URI::createFile(testPath(llvm::sys::path::relative_path(URI->body(;
+  return Strings.save(FileSystemURI.toString()).begin();
+}
+
 TEST(RemoteMarshallingTest, SymbolSerialization) {
   const auto *Header = R"(
   // This is a class.
@@ -39,9 +53,20 @@
   EXPECT_GE(Symbols.size(), 5UL);
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
-  for (auto &Sym : Symbols) {
-const auto ProtobufMeessage = toProtobuf(Sym);
-const auto SymToProtobufAndBack = fromProtobuf(ProtobufMeessage, &Strings);
+  llvm::SmallString<256> RootPath = llvm::StringRef("/");
+  llvm::sys::path::native(RootPath);
+  for (auto Sym : Symbols) {
+Sym.CanonicalDeclaration.FileURI =
+unittestURIToFilesystem(Sym.CanonicalDeclaration.FileURI, Strings);
+if (std::strlen(Sym.Definition.FileURI))
+  Sym.Definition.FileURI =
+  unittestURIToFilesystem(Sym.Definition.FileURI, Strings);
+for (auto &Header : Sym.IncludeHeaders)
+  Header.IncludeHeader =
+  unittestURIToFilesystem(Header.IncludeHeader.str().c_str(), Strings);
+auto ProtobufMessage = toProtobuf(Sym, RootPath);
+const auto SymToProtobufAndBack =
+fromProtobuf(ProtobufMessage, &Strings, RootPath);
 EXPECT_TRUE(SymToProtobufAndBack.hasValue());
 EXPECT_EQ(toYAML(Sym), toYAML(*SymToProtobufAndBack));
   }
@@ -76,16 +101,54 @@
   const auto References = TU.headerRefs();
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
+  llvm::SmallString<256> RootPath = llvm::StringRef("/");
+  llvm::sys::path::native(RootPath);
   // Sanity check: there are more than 5 references available.
   EXPECT_GE(References.numRefs(), 5UL);
   for (const auto &SymbolWithRefs : References) {
-for (const auto &Ref : SymbolWithRefs.second) {
-  const auto RefToProtobufAndBack = fromProtobuf(toProtobuf(Ref), &Strings);
+for (auto Ref : SymbolWithRefs.second) {
+  Ref.Location.FileURI =
+  unittestURIToFilesystem(Ref.Location.FileURI, Strings);
+  const auto RefToProtobufAndBack =
+  fromProtobuf(toProtobuf(Ref, RootPath), &Strings, RootPath);
   EXPECT_TRUE(RefToProtobufAndBack.hasValue());
   EXPECT_EQ(toYAML(Ref), toYAML(*RefToProtobufAndBack));
 }
   }
-} // namespace
+}
+
+TEST(RemoteMarshallingTest, URITranslation) {
+  llvm::BumpPtrAllocator Arena;
+  llvm::UniqueStringSaver Strings(Arena);
+  clangd::Ref Original;
+  const std::string RemoteIndexPrefix = testPath("remote/machine/project/");
+  std::string RelativePath = "llvm-project/clang-tools-extra/clangd/"
+ "unittests/remote/MarshallingTests.cpp";
+  llvm::SmallString<256> NativePath = StringRef(RelativePath);
+  llvm::sys::path::native(NativePath);
+  RelativePath = std::string(NativePath);
+  const auto URI = URI::createFile(RemoteIndexPrefix + RelativePath);
+  Original.Location.FileURI = Strings.save(URI.toString()).begin();
+  Ref Serialized = toProtobuf(Original, RemoteIndexPrefix);
+  EXPECT_EQ(Serialized.location().file_path(), RelativePath);
+  const std::string LocalIndexPrefix = testPath("local/machine/project/");
+  auto Deserialized = fromP

[PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit.

2020-07-06 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/D83213

Files:
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp


Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3397,7 +3397,7 @@
   if (!IncludePossibleEffects && getExprLoc().isMacroID())
 return false;
 
-  if (isInstantiationDependent())
+  if (isInstantiationDependent() || containsErrors())
 return IncludePossibleEffects;
 
   switch (getStmtClass()) {
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -501,7 +501,7 @@
   // FIXME: drop type+value+instantiation once Error is sufficient to suppress
   // bogus dianostics.
   auto D = toExprDependence(E->getType()->getDependence()) |
-   ExprDependence::ValueInstantiation | ExprDependence::Error;
+   ExprDependence::Value | ExprDependence::Error;
   for (auto *S : E->subExpressions())
 D |= S->getDependence();
   return D;


Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3397,7 +3397,7 @@
   if (!IncludePossibleEffects && getExprLoc().isMacroID())
 return false;
 
-  if (isInstantiationDependent())
+  if (isInstantiationDependent() || containsErrors())
 return IncludePossibleEffects;
 
   switch (getStmtClass()) {
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -501,7 +501,7 @@
   // FIXME: drop type+value+instantiation once Error is sufficient to suppress
   // bogus dianostics.
   auto D = toExprDependence(E->getType()->getDependence()) |
-   ExprDependence::ValueInstantiation | ExprDependence::Error;
+   ExprDependence::Value | ExprDependence::Error;
   for (auto *S : E->subExpressions())
 D |= S->getDependence();
   return D;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83189: [clangd] More complete fix for hover crashes on invalid record.

2020-07-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 275664.
hokein marked 2 inline comments as done.
hokein added a comment.

address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83189

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -784,11 +784,24 @@
  HI.NamespaceScope = "";
  HI.Definition = "int xx";
  HI.LocalScope = "Foo::";
- HI.Size = 4;
  HI.Type = "int";
  HI.AccessSpecifier = "public";
}},
-  };
+  {R"cpp(
+// error-ok
+struct Foo {
+  Bar xx;
+  int [[y^y]];
+};)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "yy";
+ HI.Kind = index::SymbolKind::Field;
+ HI.NamespaceScope = "";
+ HI.Definition = "int yy";
+ HI.LocalScope = "Foo::";
+ HI.Type = "int";
+ HI.AccessSpecifier = "public";
+   }}};
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
 
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -659,8 +659,10 @@
 }
 
 void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) {
-  const auto &Ctx = ND.getASTContext();
+  if (ND.isInvalidDecl())
+return;
 
+  const auto &Ctx = ND.getASTContext();
   if (auto *RD = llvm::dyn_cast(&ND)) {
 if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl()))
   HI.Size = Size->getQuantity();
@@ -671,11 +673,11 @@
 const auto *Record = FD->getParent();
 if (Record)
   Record = Record->getDefinition();
-if (Record && !Record->isDependentType()) {
-  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
+if (Record && !Record->isInvalidDecl() && !Record->isDependentType()) {
+  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) {
 HI.Size = Size->getQuantity();
-  if (!FD->isInvalidDecl())
 HI.Offset = Ctx.getFieldOffset(FD) / 8;
+  }
 }
 return;
   }


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -784,11 +784,24 @@
  HI.NamespaceScope = "";
  HI.Definition = "int xx";
  HI.LocalScope = "Foo::";
- HI.Size = 4;
  HI.Type = "int";
  HI.AccessSpecifier = "public";
}},
-  };
+  {R"cpp(
+// error-ok
+struct Foo {
+  Bar xx;
+  int [[y^y]];
+};)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "yy";
+ HI.Kind = index::SymbolKind::Field;
+ HI.NamespaceScope = "";
+ HI.Definition = "int yy";
+ HI.LocalScope = "Foo::";
+ HI.Type = "int";
+ HI.AccessSpecifier = "public";
+   }}};
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
 
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -659,8 +659,10 @@
 }
 
 void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) {
-  const auto &Ctx = ND.getASTContext();
+  if (ND.isInvalidDecl())
+return;
 
+  const auto &Ctx = ND.getASTContext();
   if (auto *RD = llvm::dyn_cast(&ND)) {
 if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl()))
   HI.Size = Size->getQuantity();
@@ -671,11 +673,11 @@
 const auto *Record = FD->getParent();
 if (Record)
   Record = Record->getDefinition();
-if (Record && !Record->isDependentType()) {
-  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
+if (Record && !Record->isInvalidDecl() && !Record->isDependentType()) {
+  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) {
 HI.Size = Size->getQuantity();
-  if (!FD->isInvalidDecl())
 HI.Offset = Ctx.getFieldOffset(FD) / 8;
+  }
 }
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83218: Hand Allocator and IdentifierTable into FormatTokenLexer.

2020-07-06 Thread Manuel Klimek via Phabricator via cfe-commits
klimek created this revision.
klimek added a reviewer: sammccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This allows us to share the allocator in the future so we can create tokens 
while parsing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83218

Files:
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenLexer.h
  clang/lib/Format/TokenAnalyzer.cpp

Index: clang/lib/Format/TokenAnalyzer.cpp
===
--- clang/lib/Format/TokenAnalyzer.cpp
+++ clang/lib/Format/TokenAnalyzer.cpp
@@ -64,11 +64,16 @@
 
 std::pair TokenAnalyzer::process() {
   tooling::Replacements Result;
-  FormatTokenLexer Tokens(Env.getSourceManager(), Env.getFileID(),
-  Env.getFirstStartColumn(), Style, Encoding);
+  llvm::SpecificBumpPtrAllocator Allocator;
+  IdentifierTable IdentTable(getFormattingLangOpts(Style));
+  FormatTokenLexer Lex(Env.getSourceManager(), Env.getFileID(),
+   Env.getFirstStartColumn(), Style, Encoding, Allocator,
 
-  UnwrappedLineParser Parser(Style, Tokens.getKeywords(),
- Env.getFirstStartColumn(), Tokens.lex(), *this);
+   IdentTable);
+  ArrayRef Toks(Lex.lex());
+  SmallVector Tokens(Toks.begin(), Toks.end());
+  UnwrappedLineParser Parser(Style, Lex.getKeywords(),
+ Env.getFirstStartColumn(), Tokens, *this);
   Parser.parse();
   assert(UnwrappedLines.rbegin()->empty());
   unsigned Penalty = 0;
@@ -76,14 +81,14 @@
 LLVM_DEBUG(llvm::dbgs() << "Run " << Run << "...\n");
 SmallVector AnnotatedLines;
 
-TokenAnnotator Annotator(Style, Tokens.getKeywords());
+TokenAnnotator Annotator(Style, Lex.getKeywords());
 for (unsigned i = 0, e = UnwrappedLines[Run].size(); i != e; ++i) {
   AnnotatedLines.push_back(new AnnotatedLine(UnwrappedLines[Run][i]));
   Annotator.annotate(*AnnotatedLines.back());
 }
 
 std::pair RunResult =
-analyze(Annotator, AnnotatedLines, Tokens);
+analyze(Annotator, AnnotatedLines, Lex);
 
 LLVM_DEBUG({
   llvm::dbgs() << "Replacements for run " << Run << ":\n";
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -38,7 +38,9 @@
 class FormatTokenLexer {
 public:
   FormatTokenLexer(const SourceManager &SourceMgr, FileID ID, unsigned Column,
-   const FormatStyle &Style, encoding::Encoding Encoding);
+   const FormatStyle &Style, encoding::Encoding Encoding,
+   llvm::SpecificBumpPtrAllocator &Allocator,
+   IdentifierTable &IdentTable);
 
   ArrayRef lex();
 
@@ -103,10 +105,9 @@
   const SourceManager &SourceMgr;
   FileID ID;
   const FormatStyle &Style;
-  IdentifierTable IdentTable;
+  IdentifierTable &IdentTable;
   AdditionalKeywords Keywords;
   encoding::Encoding Encoding;
-  llvm::SpecificBumpPtrAllocator Allocator;
   // Index (in 'Tokens') of the last token that starts a new line.
   unsigned FirstInLineIndex;
   SmallVector Tokens;
@@ -117,6 +118,7 @@
 
   llvm::Regex MacroBlockBeginRegex;
   llvm::Regex MacroBlockEndRegex;
+  llvm::SpecificBumpPtrAllocator &Allocator;
 
   // Targets that may appear inside a C# attribute.
   static const llvm::StringSet<> CSharpAttributeTargets;
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -22,15 +22,17 @@
 namespace clang {
 namespace format {
 
-FormatTokenLexer::FormatTokenLexer(const SourceManager &SourceMgr, FileID ID,
-   unsigned Column, const FormatStyle &Style,
-   encoding::Encoding Encoding)
+FormatTokenLexer::FormatTokenLexer(
+const SourceManager &SourceMgr, FileID ID, unsigned Column,
+const FormatStyle &Style, encoding::Encoding Encoding,
+llvm::SpecificBumpPtrAllocator &Allocator,
+IdentifierTable &IdentTable)
 : FormatTok(nullptr), IsFirstToken(true), StateStack({LexerState::NORMAL}),
   Column(Column), TrailingWhitespace(0), SourceMgr(SourceMgr), ID(ID),
-  Style(Style), IdentTable(getFormattingLangOpts(Style)),
-  Keywords(IdentTable), Encoding(Encoding), FirstInLineIndex(0),
-  FormattingDisabled(false), MacroBlockBeginRegex(Style.MacroBlockBegin),
-  MacroBlockEndRegex(Style.MacroBlockEnd) {
+  Style(Style), IdentTable(IdentTable), Keywords(IdentTable),
+  Encoding(Encoding), FirstInLineIndex(0), FormattingDisabled(false),
+  MacroBlockBeginRegex(Style.MacroBlockBegin),
+  MacroBlockEndRegex(Style.MacroBlockEnd), Allocator(Allocator) {
   Lex.reset(new Lexer(ID, SourceMgr.getBuffer(ID), SourceMgr,
   getFormattingLangOpts(St

[PATCH] D78126: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics

2020-07-06 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb2956076976c: [analyzer][NFC] Don't allow dependency 
checkers to emit diagnostics (authored by Szelethus).

Changed prior to commit:
  https://reviews.llvm.org/D78126?vs=270372&id=275687#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78126

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -34,6 +34,7 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/CheckerRegistryData.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
@@ -2107,6 +2108,32 @@
 // Methods for BugReport and subclasses.
 //===--===//
 
+static bool isDependency(const CheckerRegistryData &Registry,
+ StringRef CheckerName) {
+  for (const std::pair &Pair : Registry.Dependencies) {
+if (Pair.second == CheckerName)
+  return true;
+  }
+  return false;
+}
+
+PathSensitiveBugReport::PathSensitiveBugReport(
+const BugType &bt, StringRef shortDesc, StringRef desc,
+const ExplodedNode *errorNode, PathDiagnosticLocation LocationToUnique,
+const Decl *DeclToUnique)
+: BugReport(Kind::PathSensitive, bt, shortDesc, desc), ErrorNode(errorNode),
+  ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() : SourceRange()),
+  UniqueingLocation(LocationToUnique), UniqueingDecl(DeclToUnique) {
+  assert(!isDependency(ErrorNode->getState()
+   ->getAnalysisManager()
+   .getCheckerManager()
+   ->getCheckerRegistryData(),
+   bt.getCheckerName()) &&
+ "Some checkers depend on this one! We don't allow dependency "
+ "checkers to emit warnings, because checkers should depend on "
+ "*modeling*, not *diagnostics*.");
+}
+
 void PathSensitiveBugReport::addVisitor(
 std::unique_ptr visitor) {
   if (!visitor)
@@ -2195,12 +,12 @@
   return;
 case bugreporter::TrackingKind::Condition:
   return;
-  }
+}
 
-  llvm_unreachable(
-  "BugReport::markInteresting currently can only handle 2 different "
-  "tracking kinds! Please define what tracking kind should this entitiy"
-  "have, if it was already marked as interesting with a different kind!");
+llvm_unreachable(
+"BugReport::markInteresting currently can only handle 2 different "
+"tracking kinds! Please define what tracking kind should this entitiy"
+"have, if it was already marked as interesting with a different kind!");
 }
 
 void PathSensitiveBugReport::markInteresting(SymbolRef sym,
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
===
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -19,6 +19,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -135,7 +136,7 @@
   SmallVector Fixits;
 
   BugReport(Kind kind, const BugType &bt, StringRef desc)
-  : K(kind), BT(bt), Description(desc) {}
+  : BugReport(kind, bt, "", desc) {}
 
   BugReport(Kind K, const BugType &BT, StringRef ShortDescription,
 StringRef Description)
@@ -369,16 +370,13 @@
 public:
   PathSensitiveBugReport(const BugType &bt, StringRef desc,
  const ExplodedNode *errorNode)
-  : BugReport(Kind::PathSensitive, bt, desc), ErrorNode(errorNode),
-ErrorNodeRange(getStmt() ? getStmt()->getSourceRange()
- : SourceRange()) {}
+  : PathSensitiveBugReport(bt, desc, desc, errorNode) {}
 
   PathSensitiveBugReport(const BugType &bt, StringRef shortDesc, StringRef desc,
  const ExplodedNode *errorNode)
-  : BugReport(Kind::PathSensitive, bt, shortDesc, desc),
-ErrorNode(errorNode),
-ErrorNodeRange(getStmt() ? getStmt()->getSourceRange()

[PATCH] D83114: [clang] Fix the incorrect dependence bits for DependentExtIntType.

2020-07-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added inline comments.



Comment at: clang/lib/AST/Type.cpp:356
-: TypeDependence::None) |
-   (NumBitsExpr->containsUnexpandedParameterPack()
-? TypeDependence::VariablyModified

sammccall wrote:
> @erichkeane was there any intent behind translating "num bits contains 
> unexpanded pack" into "extint is variably modified", or was this an 
> oversight? (My guess is the latter, just want to double check)
Ah, I think this was a result of a messy/not completely understood rebase.  The 
'toTypeDependence' parts appeared in the middle of my review, so I must have 
just merged the change incorrectly.

This patch seems like the right thing.  Thanks! 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83114



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


[PATCH] D80858: [HIP] Support accessing static device variable in host code

2020-07-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 10 inline comments as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Driver/Action.h:216
   const llvm::opt::Arg &Input;
-
+  unsigned Id;
   virtual void anchor();

rjmccall wrote:
> Allowing an arbitrary string might be more adaptable.
done



Comment at: clang/lib/AST/ASTContext.cpp:10064
   return GVA_StrongODR;
+// Externalize device side static file-scope variable for HIP.
+if (Context.getLangOpts().HIP && Context.getLangOpts().HIPCUID &&

rjmccall wrote:
> This needs to be a clearer statement of why this is necessary.
added comments to explain why



Comment at: clang/lib/AST/ASTContext.cpp:10068
+isa(D) && cast(D)->isFileVarDecl() &&
+cast(D)->getStorageClass() == SC_Static) {
+  return GVA_StrongExternal;

rjmccall wrote:
> Are you sure this doesn't apply to e.g. local statics?  Can't you have kernel 
> lambdas, or am I confusing HIP with another language?
function-scope static var in a device function is only visible to the device 
function. Host code cannot access it, therefore no need to externalize it.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1094
+  if ((VD->hasAttr() || VD->hasAttr()) &&
+  VD->isFileVarDecl() && VD->getStorageClass() == SC_Static) {
+Out << ".hip.static." << CGM.getLangOpts().HIPCUID;

rjmccall wrote:
> Please extract this "(device || constant) && file && static" predicate 
> instead of repeating it in three different places.
extracted as ASTContext::shouldExternalizeStaticVar



Comment at: clang/lib/Driver/Action.cpp:170
+  if (!Id)
+Id = llvm::sys::Process::GetRandomNumber();
+}

rjmccall wrote:
> I'm sure GetRandomNumber can return 0, so this logic is faulty.
> 
> This also seems like an unfortunate intrusion of HIP-specific semantics on 
> the rest of the driver.  Maybe HIP can generate the shared id when it's 
> setting up and cloning the job.
Changed type of ID to string. Now empty ID means disabled. 0 is now allowed as 
a usual ID.

Moved initialization of ID to HIP action builder.


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

https://reviews.llvm.org/D80858



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


[PATCH] D83178: [clangd] Send EOF before resetting diagnostics consumer

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

In D83178#2132490 , @kadircet wrote:

> Yeah concerns around header-guard checks are real (and likely to be 
> annoying), so will wait for D78038 .
>
> I suppose we can split that into multiple patches, and at least land the bit 
> around preserving conditional stack at the end of preamble, WDYT?


If there are issues with D78038  then I'd say 
this could be landed so long as header-guard (and other) checks were manually 
disabled til that can be sorted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83178



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


[PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source

2020-07-06 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

In D83008#2131796 , @tschuett wrote:

> You could try:
>
>   clangxx_host -Xclang -fdump-record-layouts %p/Inputs/layout.cpp -emit-llvm 
> -o /dev/null
>
>
> You could commit the record layouts without your fix to show the differences 
> that you patch makes.


Yeah that's I think the proper way to check the results, but IIRC the problem 
with testing this in Clang is that `foverride-record-layout=` (the testing 
approach for this code) doesn't support specifying base class offset), so we 
can't even *trigger* the bug itself in Clang itself. That what I was referring 
to with "layout overwrite JSON file" in my comment above.


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

https://reviews.llvm.org/D83008



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


[PATCH] D82767: clang-format: Explicitly use python3

2020-07-06 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

We may not be consistent across all of LLVM

  $ find . -name '*.py' -print -exec /usr/bin/head -2 {} \; | grep "#!" | sort 
| uniq -c
6 #! /usr/bin/env python
2 #! /usr/bin/env python3
2 #! /usr/bin/python
1 #!/bin/env python
  133 #!/usr/bin/env python
   13 #!/usr/bin/env python3
   49 #!/usr/bin/python


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

https://reviews.llvm.org/D82767



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


  1   2   3   >