[PATCH] D66490: [NewPM] Enable the New Pass Manager by Default in Clang

2019-08-20 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In D66490#1638162 , @rupprecht wrote:

> We already know that we don't want this enabled for tsan builds due to 
> https://bugs.llvm.org/show_bug.cgi?id=42877, but I don't even know if anyone 
> else will hit it (it's only when building one particular library).


Under the circumstances, that seems like one particular library too many. 
PR42877 looks like a generic bug, so if we're hitting it here, I see no reason 
to suspect that others would not hit it elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66490



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


[PATCH] D66423: [analyzer] CastValueChecker: Model isa(), isa_and_nonnull()

2019-08-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Thanks for the reviews so far! I had a contradiction in my mind about regions, 
but now everything is okay and the notes are not misleading.




Comment at: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp:183
+  if (Body)
+DRE = dyn_cast(Body);
+

NoQ wrote:
> A body of a function is always either a `CompoundStmt` or (shockingly) a 
> `CXXTryStmt`. This cast will always fail.
I do not remember what I did here, but that was a working solution.



Comment at: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp:188
+
+  QualType CastToTy = DRE->getTemplateArgs()->getArgument().getAsType();
+  QualType CastFromTy = getRecordType(Call.parameters()[0]->getType());

NoQ wrote:
> I suspect that `DRE` may still be null (eg., when calling `isa` through 
> function pointer).
> 
> I think you should just lookup `Call.getDecl()`'s template arguments instead. 
> It's going to be the declaration of the specific instantiation, so it'll have 
> all the arguments.
That was the plan, just I did not realized I am a `FunctionDecl` away to 
achieve that. Thanks!


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

https://reviews.llvm.org/D66423



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


[PATCH] D66423: [analyzer] CastValueChecker: Model isa(), isa_and_nonnull()

2019-08-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 216322.
Charusso marked 7 inline comments as done.
Charusso added a comment.

- Simplify the template argument obtaining.
- Added a tiny new test case.


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

https://reviews.llvm.org/D66423

Files:
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/test/Analysis/Inputs/llvm.h
  clang/test/Analysis/cast-value-logic.cpp
  clang/test/Analysis/cast-value-notes.cpp

Index: clang/test/Analysis/cast-value-notes.cpp
===
--- clang/test/Analysis/cast-value-notes.cpp
+++ clang/test/Analysis/cast-value-notes.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 \
-// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue \
+// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
 // RUN:  -analyzer-output=text -verify %s
 
 #include "Inputs/llvm.h"
@@ -43,16 +43,21 @@
 return;
   }
 
-  if (dyn_cast_or_null(C)) {
+  if (isa(C)) {
 // expected-note@-1 {{'C' is not a 'Triangle'}}
 // expected-note@-2 {{Taking false branch}}
 return;
   }
 
-  (void)(1 / !C);
-  // expected-note@-1 {{'C' is non-null}}
-  // expected-note@-2 {{Division by zero}}
-  // expected-warning@-3 {{Division by zero}}
+  if (isa(C)) {
+// expected-note@-1 {{'C' is a 'Circle'}}
+// expected-note@-2 {{Taking true branch}}
+
+(void)(1 / !C);
+// expected-note@-1 {{'C' is non-null}}
+// expected-note@-2 {{Division by zero}}
+// expected-warning@-3 {{Division by zero}}
+  }
 }
 
 void evalNonNullParamNonNullReturn(const Shape *S) {
@@ -60,7 +65,13 @@
   // expected-note@-1 {{'S' is a 'Circle'}}
   // expected-note@-2 {{'C' initialized here}}
 
-  if (!cast(C)) {
+  if (!isa(C)) {
+// expected-note@-1 {{Assuming 'C' is a 'Triangle'}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  }
+
+  if (!isa(C)) {
 // expected-note@-1 {{'C' is a 'Triangle'}}
 // expected-note@-2 {{Taking false branch}}
 return;
Index: clang/test/Analysis/cast-value-logic.cpp
===
--- clang/test/Analysis/cast-value-logic.cpp
+++ clang/test/Analysis/cast-value-logic.cpp
@@ -23,11 +23,16 @@
 using namespace llvm;
 using namespace clang;
 
-void test_regions(const Shape *A, const Shape *B) {
+void test_regions_dyn_cast(const Shape *A, const Shape *B) {
   if (dyn_cast(A) && !dyn_cast(B))
 clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
 }
 
+void test_regions_isa(const Shape *A, const Shape *B) {
+  if (isa(A) && !isa(B))
+clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}
+
 namespace test_cast {
 void evalLogic(const Shape *S) {
   const Circle *C = cast(S);
Index: clang/test/Analysis/Inputs/llvm.h
===
--- clang/test/Analysis/Inputs/llvm.h
+++ clang/test/Analysis/Inputs/llvm.h
@@ -16,4 +16,10 @@
 const X *dyn_cast_or_null(Y *Value);
 template 
 const X *dyn_cast_or_null(Y );
+
+template 
+bool isa(Y Value);
+
+template 
+bool isa_and_nonnull(Y Value);
 } // namespace llvm
Index: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
@@ -16,6 +16,7 @@
 //
 //===--===//
 
+#include "clang/AST/DeclTemplate.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
@@ -31,7 +32,7 @@
 
 namespace {
 class CastValueChecker : public Checker {
-  enum class CallKind { Function, Method };
+  enum class CallKind { Function, Method, InstanceOf };
 
   using CastCheck =
   std::functiongetAsFunction();
+  QualType CastToTy = FD->getTemplateSpecializationArgs()->get(0).getAsType();
+  QualType CastFromTy = getRecordType(Call.parameters()[0]->getType());
+
+  const MemRegion *MR = DV.getAsRegion();
+  const DynamicCastInfo *CastInfo =
+  getDynamicCastInfo(State, MR, CastFromTy, CastToTy);
+
+  bool CastSucceeds;
+  if (CastInfo)
+CastSucceeds = IsInstanceOf && CastInfo->succeeds();
+  else
+CastSucceeds = IsInstanceOf || CastFromTy == CastToTy;
+
+  if (isInfeasibleCast(CastInfo, CastSucceeds)) {
+C.generateSink(State, C.getPredecessor());
+return;
+  }
+
+  // Store the type and the cast information.
+  bool IsKnownCast = CastInfo || CastFromTy == CastToTy;
+  if (!IsKnownCast)
+State = setDynamicTypeAndCastInfo(State, MR, CastFromTy, CastToTy,
+  Call.getResultType(), IsInstanceOf);
+
+  std::string ObjectName = Lexer::getSourceText(
+  CharSourceRange::getTokenRange(Call.getArgExpr(0)->getSourceRange()),
+  C.getSourceManager(), 

[PATCH] D66512: [OpenCL] Fix declaration of enqueue_marker

2019-08-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, bader, b-sumner.

https://reviews.llvm.org/D66512

Files:
  lib/Headers/opencl-c.h


Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -15752,7 +15752,7 @@
 ndrange_t __ovld ndrange_3D(const size_t[3], const size_t[3]);
 ndrange_t __ovld ndrange_3D(const size_t[3], const size_t[3], const size_t[3]);
 
-int __ovld enqueue_marker(queue_t, uint, const __private clk_event_t*, 
__private clk_event_t*);
+int __ovld enqueue_marker(queue_t, uint, const clk_event_t*, clk_event_t*);
 
 void __ovld retain_event(clk_event_t);
 


Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -15752,7 +15752,7 @@
 ndrange_t __ovld ndrange_3D(const size_t[3], const size_t[3]);
 ndrange_t __ovld ndrange_3D(const size_t[3], const size_t[3], const size_t[3]);
 
-int __ovld enqueue_marker(queue_t, uint, const __private clk_event_t*, __private clk_event_t*);
+int __ovld enqueue_marker(queue_t, uint, const clk_event_t*, clk_event_t*);
 
 void __ovld retain_event(clk_event_t);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66325: [analyzer] CastValueChecker: Store the dynamic types and casts

2019-08-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 216317.
Charusso added a comment.

- Make the check-clang pass and simplify a test case.


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

https://reviews.llvm.org/D66325

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicCastInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/DynamicType.cpp
  clang/lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/test/Analysis/Inputs/llvm.h
  clang/test/Analysis/cast-value-logic.cpp
  clang/test/Analysis/cast-value-notes.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cast-value.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Analysis/expr-inspection.c

Index: clang/test/Analysis/expr-inspection.c
===
--- clang/test/Analysis/expr-inspection.c
+++ clang/test/Analysis/expr-inspection.c
@@ -38,6 +38,7 @@
 // CHECK-NEXT: { "symbol": "reg_$0", "range": "{ [-2147483648, 13] }" }
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "dynamic_types": null,
+// CHECK-NEXT:   "dynamic_casts": null,
 // CHECK-NEXT:   "constructing_objects": null,
 // CHECK-NEXT:   "checker_messages": null
 // CHECK-NEXT: }
Index: clang/test/Analysis/dump_egraph.cpp
===
--- clang/test/Analysis/dump_egraph.cpp
+++ clang/test/Analysis/dump_egraph.cpp
@@ -24,4 +24,5 @@
 
 // CHECK: \"cluster\": \"t\", \"pointer\": \"{{0x[0-9a-f]+}}\", \"items\": [\l\{ \"kind\": \"Default\", \"offset\": 0, \"value\": \"conj_$2\{int, LC5, no stmt, #1\}\"
 
-// CHECK: \"dynamic_types\": [\l\{ \"region\": \"HeapSymRegion\{conj_$1\{struct S *, LC1, S{{[0-9]+}}, #1\}\}\", \"dyn_type\": \"struct S\", \"sub_classable\": false\}\l
+// CHECK: \"dynamic_types\": [\l\{ \"region\": \"HeapSymRegion\{conj_$1\{struct S *, LC1, S{{[0-9]+}}, #1\}\}\", \"dyn_type\": \"struct S\", \"sub_classable\": false \}\l
+
Index: clang/test/Analysis/cast-value.cpp
===
--- clang/test/Analysis/cast-value.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-// RUN: %clang_analyze_cc1 \
-// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
-// RUN:  -verify=logic %s
-// RUN: %clang_analyze_cc1 \
-// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue \
-// RUN:  -analyzer-output=text -verify %s
-
-void clang_analyzer_numTimesReached();
-void clang_analyzer_warnIfReached();
-void clang_analyzer_eval(bool);
-
-namespace llvm {
-template 
-const X *cast(Y Value);
-
-template 
-const X *dyn_cast(Y *Value);
-template 
-const X _cast(Y );
-
-template 
-const X *cast_or_null(Y Value);
-
-template 
-const X *dyn_cast_or_null(Y *Value);
-template 
-const X *dyn_cast_or_null(Y );
-} // namespace llvm
-
-namespace clang {
-struct Shape {
-  template 
-  const T *castAs() const;
-
-  template 
-  const T *getAs() const;
-};
-class Triangle : public Shape {};
-class Circle : public Shape {};
-} // namespace clang
-
-using namespace llvm;
-using namespace clang;
-
-namespace test_cast {
-void evalLogic(const Shape *S) {
-  const Circle *C = cast(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{1}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // no-warning
-
-  if (!S)
-clang_analyzer_warnIfReached(); // no-warning
-}
-} // namespace test_cast
-
-namespace test_dyn_cast {
-void evalLogic(const Shape *S) {
-  const Circle *C = dyn_cast(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{2}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // logic-warning {{REACHABLE}}
-
-  if (!S)
-clang_analyzer_warnIfReached(); // no-warning
-}
-} // namespace test_dyn_cast
-
-namespace test_cast_or_null {
-void evalLogic(const Shape *S) {
-  const Circle *C = cast_or_null(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{2}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // no-warning
-
-  if (!S)
-clang_analyzer_eval(!C); // logic-warning {{TRUE}}
-}
-} // namespace test_cast_or_null
-
-namespace test_dyn_cast_or_null {
-void evalLogic(const Shape *S) {
-  const Circle *C = dyn_cast_or_null(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{3}}
-
-  if (S && C)

[PATCH] D66325: [analyzer] CastValueChecker: Store the dynamic types and casts

2019-08-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 216314.
Charusso added a comment.

- Remove `CastFromTy` finally from the `getNoteTag()` API as it was 
uninformative.


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

https://reviews.llvm.org/D66325

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicCastInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/DynamicType.cpp
  clang/lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/test/Analysis/Inputs/llvm.h
  clang/test/Analysis/cast-value-logic.cpp
  clang/test/Analysis/cast-value-notes.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cast-value.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Analysis/expr-inspection.c

Index: clang/test/Analysis/expr-inspection.c
===
--- clang/test/Analysis/expr-inspection.c
+++ clang/test/Analysis/expr-inspection.c
@@ -38,6 +38,7 @@
 // CHECK-NEXT: { "symbol": "reg_$0", "range": "{ [-2147483648, 13] }" }
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "dynamic_types": null,
+// CHECK-NEXT:   "dynamic_casts": null,
 // CHECK-NEXT:   "constructing_objects": null,
 // CHECK-NEXT:   "checker_messages": null
 // CHECK-NEXT: }
Index: clang/test/Analysis/dump_egraph.cpp
===
--- clang/test/Analysis/dump_egraph.cpp
+++ clang/test/Analysis/dump_egraph.cpp
@@ -24,4 +24,5 @@
 
 // CHECK: \"cluster\": \"t\", \"pointer\": \"{{0x[0-9a-f]+}}\", \"items\": [\l\{ \"kind\": \"Default\", \"offset\": 0, \"value\": \"conj_$2\{int, LC5, no stmt, #1\}\"
 
-// CHECK: \"dynamic_types\": [\l\{ \"region\": \"HeapSymRegion\{conj_$1\{struct S *, LC1, S{{[0-9]+}}, #1\}\}\", \"dyn_type\": \"struct S\", \"sub_classable\": false\}\l
+// CHECK: \"dynamic_types\": [\l\{ \"region\": \"HeapSymRegion\{conj_$1\{struct S *, LC1, S{{[0-9]+}}, #1\}\}\", \"dyn_type\": \"struct S\", \"sub_classable\": false \}\l
+
Index: clang/test/Analysis/cast-value.cpp
===
--- clang/test/Analysis/cast-value.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-// RUN: %clang_analyze_cc1 \
-// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
-// RUN:  -verify=logic %s
-// RUN: %clang_analyze_cc1 \
-// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue \
-// RUN:  -analyzer-output=text -verify %s
-
-void clang_analyzer_numTimesReached();
-void clang_analyzer_warnIfReached();
-void clang_analyzer_eval(bool);
-
-namespace llvm {
-template 
-const X *cast(Y Value);
-
-template 
-const X *dyn_cast(Y *Value);
-template 
-const X _cast(Y );
-
-template 
-const X *cast_or_null(Y Value);
-
-template 
-const X *dyn_cast_or_null(Y *Value);
-template 
-const X *dyn_cast_or_null(Y );
-} // namespace llvm
-
-namespace clang {
-struct Shape {
-  template 
-  const T *castAs() const;
-
-  template 
-  const T *getAs() const;
-};
-class Triangle : public Shape {};
-class Circle : public Shape {};
-} // namespace clang
-
-using namespace llvm;
-using namespace clang;
-
-namespace test_cast {
-void evalLogic(const Shape *S) {
-  const Circle *C = cast(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{1}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // no-warning
-
-  if (!S)
-clang_analyzer_warnIfReached(); // no-warning
-}
-} // namespace test_cast
-
-namespace test_dyn_cast {
-void evalLogic(const Shape *S) {
-  const Circle *C = dyn_cast(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{2}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // logic-warning {{REACHABLE}}
-
-  if (!S)
-clang_analyzer_warnIfReached(); // no-warning
-}
-} // namespace test_dyn_cast
-
-namespace test_cast_or_null {
-void evalLogic(const Shape *S) {
-  const Circle *C = cast_or_null(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{2}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // no-warning
-
-  if (!S)
-clang_analyzer_eval(!C); // logic-warning {{TRUE}}
-}
-} // namespace test_cast_or_null
-
-namespace test_dyn_cast_or_null {
-void evalLogic(const Shape *S) {
-  const Circle *C = dyn_cast_or_null(S);
-  clang_analyzer_numTimesReached(); // 

[PATCH] D66325: [analyzer] CastValueChecker: Store the dynamic types and casts

2019-08-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked an inline comment as done.
Charusso added inline comments.



Comment at: clang/test/Analysis/cast-value-notes.cpp:34
+  if (dyn_cast_or_null(C)) {
+// no-note: 'Assuming 'C' is a 'Circle', not a 'Circle''
+return;

NoQ wrote:
> A circle is always a circle.
I have removed that contradiction test case as being silly, but yes, that was 
the `no-warning` test properly.


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

https://reviews.llvm.org/D66325



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


[PATCH] D66325: [analyzer] CastValueChecker: Store the dynamic types and casts

2019-08-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicCastInfo.h:19
+public:
+  enum CastKind { Success, Fail };
+

NoQ wrote:
> I suggest `enum CastResult { Success, Failure }` ("a fail" is slang, also 
> "result" because it's basically a result).
> 
> Also TODO: The success information should ideally go straight into the 
> dynamic type map.
The successful cast is going to the type map, and the failure will not. Why 
would we need to store the failing casts in the type map? Therefore no 
differentiation is necessary I believe so that nor `TODO`.



Comment at: clang/test/Analysis/cast-value-state-dump.cpp:30
+  if (dyn_cast_or_null(C)) {
+// expected-note@-1 {{Assuming dynamic cast from 'Circle' to 'Triangle' 
fails}}
+// expected-note@-2 {{Taking false branch}}

NoQ wrote:
> We're not assuming it, right? We already know it's gonna fail because we 
> already know that it's a circle.
We have no knowledge what is what. At the top we see that: `Shape -> Circle`, 
and then `Triangle -> Circle` is something new, so we have to assume that. It 
is an implementation detail we are allowing only one cast to be succeed. From 
the user point of view it is an assumption as the current state of the checker 
could not provide more/better information. It is the same logic from the 
`ConditionBRVisitor`.


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

https://reviews.llvm.org/D66325



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


[PATCH] D66325: [analyzer] CastValueChecker: Store the dynamic types and casts

2019-08-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 216312.
Charusso marked 3 inline comments as done.
Charusso added a comment.

- Fix more and publish the previously forgotten comments.


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

https://reviews.llvm.org/D66325

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicCastInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/DynamicType.cpp
  clang/lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/test/Analysis/Inputs/llvm.h
  clang/test/Analysis/cast-value-logic.cpp
  clang/test/Analysis/cast-value-notes.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cast-value.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Analysis/expr-inspection.c

Index: clang/test/Analysis/expr-inspection.c
===
--- clang/test/Analysis/expr-inspection.c
+++ clang/test/Analysis/expr-inspection.c
@@ -38,6 +38,7 @@
 // CHECK-NEXT: { "symbol": "reg_$0", "range": "{ [-2147483648, 13] }" }
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "dynamic_types": null,
+// CHECK-NEXT:   "dynamic_casts": null,
 // CHECK-NEXT:   "constructing_objects": null,
 // CHECK-NEXT:   "checker_messages": null
 // CHECK-NEXT: }
Index: clang/test/Analysis/dump_egraph.cpp
===
--- clang/test/Analysis/dump_egraph.cpp
+++ clang/test/Analysis/dump_egraph.cpp
@@ -24,4 +24,5 @@
 
 // CHECK: \"cluster\": \"t\", \"pointer\": \"{{0x[0-9a-f]+}}\", \"items\": [\l\{ \"kind\": \"Default\", \"offset\": 0, \"value\": \"conj_$2\{int, LC5, no stmt, #1\}\"
 
-// CHECK: \"dynamic_types\": [\l\{ \"region\": \"HeapSymRegion\{conj_$1\{struct S *, LC1, S{{[0-9]+}}, #1\}\}\", \"dyn_type\": \"struct S\", \"sub_classable\": false\}\l
+// CHECK: \"dynamic_types\": [\l\{ \"region\": \"HeapSymRegion\{conj_$1\{struct S *, LC1, S{{[0-9]+}}, #1\}\}\", \"dyn_type\": \"struct S\", \"sub_classable\": false \}\l
+
Index: clang/test/Analysis/cast-value.cpp
===
--- clang/test/Analysis/cast-value.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-// RUN: %clang_analyze_cc1 \
-// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
-// RUN:  -verify=logic %s
-// RUN: %clang_analyze_cc1 \
-// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue \
-// RUN:  -analyzer-output=text -verify %s
-
-void clang_analyzer_numTimesReached();
-void clang_analyzer_warnIfReached();
-void clang_analyzer_eval(bool);
-
-namespace llvm {
-template 
-const X *cast(Y Value);
-
-template 
-const X *dyn_cast(Y *Value);
-template 
-const X _cast(Y );
-
-template 
-const X *cast_or_null(Y Value);
-
-template 
-const X *dyn_cast_or_null(Y *Value);
-template 
-const X *dyn_cast_or_null(Y );
-} // namespace llvm
-
-namespace clang {
-struct Shape {
-  template 
-  const T *castAs() const;
-
-  template 
-  const T *getAs() const;
-};
-class Triangle : public Shape {};
-class Circle : public Shape {};
-} // namespace clang
-
-using namespace llvm;
-using namespace clang;
-
-namespace test_cast {
-void evalLogic(const Shape *S) {
-  const Circle *C = cast(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{1}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // no-warning
-
-  if (!S)
-clang_analyzer_warnIfReached(); // no-warning
-}
-} // namespace test_cast
-
-namespace test_dyn_cast {
-void evalLogic(const Shape *S) {
-  const Circle *C = dyn_cast(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{2}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // logic-warning {{REACHABLE}}
-
-  if (!S)
-clang_analyzer_warnIfReached(); // no-warning
-}
-} // namespace test_dyn_cast
-
-namespace test_cast_or_null {
-void evalLogic(const Shape *S) {
-  const Circle *C = cast_or_null(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{2}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // no-warning
-
-  if (!S)
-clang_analyzer_eval(!C); // logic-warning {{TRUE}}
-}
-} // namespace test_cast_or_null
-
-namespace test_dyn_cast_or_null {
-void evalLogic(const Shape *S) {
-  const Circle *C = dyn_cast_or_null(S);
-  

[PATCH] D66511: [clang-scan-deps] Skip UTF-8 BOM in source minimizer

2019-08-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: arphaman, dexonsmith, Bigcheese.
aganea added a project: clang.
Herald added a subscriber: tschuett.

As per title.


Repository:
  rC Clang

https://reviews.llvm.org/D66511

Files:
  lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  test/Lexer/minimize_source_to_dependency_directives_utf8bom.c


Index: test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
===
--- test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
+++ test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
@@ -0,0 +1,10 @@
+// Test UTF8 BOM at start of file
+// RUN: printf '\xef\xbb\xbf' > %t.c
+// RUN: echo '#ifdef TEST\n' >> %t.c
+// RUN: echo '#include ' >> %t.c
+// RUN: echo '#endif' >> %t.c
+// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %t.c 
2>&1 | FileCheck %s
+
+// CHECK:  #ifdef TEST
+// CHECK-NEXT: #include 
+// CHECK-NEXT: #endif
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -812,7 +812,14 @@
   return lexDefault(Kind, Id.Name, First, End);
 }
 
+static void skipUTF8ByteOrderMark(const char *, const char *const End) {
+  if ((End - First) >= 3 && First[0] == '\xef' && First[1] == '\xbb' &&
+  First[2] == '\xbf')
+First += 3;
+}
+
 bool Minimizer::minimizeImpl(const char *First, const char *const End) {
+  skipUTF8ByteOrderMark(First, End);
   while (First != End)
 if (lexPPLine(First, End))
   return true;


Index: test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
===
--- test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
+++ test/Lexer/minimize_source_to_dependency_directives_utf8bom.c
@@ -0,0 +1,10 @@
+// Test UTF8 BOM at start of file
+// RUN: printf '\xef\xbb\xbf' > %t.c
+// RUN: echo '#ifdef TEST\n' >> %t.c
+// RUN: echo '#include ' >> %t.c
+// RUN: echo '#endif' >> %t.c
+// RUN: %clang_cc1 -DTEST -print-dependency-directives-minimized-source %t.c 2>&1 | FileCheck %s
+
+// CHECK:  #ifdef TEST
+// CHECK-NEXT: #include 
+// CHECK-NEXT: #endif
Index: lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -812,7 +812,14 @@
   return lexDefault(Kind, Id.Name, First, End);
 }
 
+static void skipUTF8ByteOrderMark(const char *, const char *const End) {
+  if ((End - First) >= 3 && First[0] == '\xef' && First[1] == '\xbb' &&
+  First[2] == '\xbf')
+First += 3;
+}
+
 bool Minimizer::minimizeImpl(const char *First, const char *const End) {
+  skipUTF8ByteOrderMark(First, End);
   while (First != End)
 if (lexPPLine(First, End))
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62571: Implement codegen for MSVC unions with reference members

2019-08-20 Thread Dominic Ferreira via Phabricator via cfe-commits
domdom added a comment.

Ping!

Cheers,
Dom


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

https://reviews.llvm.org/D62571



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


[PATCH] D66488: [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1 under the new pass manager

2019-08-20 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

Lgtm. Thanks for fixing this! Not sure how I missed doing this for both PMs.

As an aside, please upload future patches with context, it makes reviewing much 
easier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66488



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


[PATCH] D66122: [CodeGen] Emit dynamic initializers for static TLS vars in outlined scopes

2019-08-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:479
+return a_deps.find(b) != a_deps.end() 
+|| b->getLocation() < a->getLocation(); // ensure deterministic 
ordering
+  });

Prince781 wrote:
> efriedma wrote:
> > Is the call to a_deps.find() here actually necessary?  It shouldn't be 
> > possible for an initializer to directly refer to a variable declared later.
> > 
> > "<" on SourceLocations isn't source order, in general; you need 
> > isBeforeInTranslationUnit.  (This should be documented somewhere, but I'm 
> > not finding the documentation, unfortunately.  Any suggestions for where it 
> > should be documented?)
> > It shouldn't be possible for an initializer to directly refer to a variable 
> > declared later.
> 
> That's true. I was using `deps.find()` to order the initialization of the 
> variables. But since you mention `isBeforeInTranslationUnit`, I can use that 
> instead. It appears to be documented [[ 
> https://clang.llvm.org/doxygen/classclang_1_1SourceManager.html#af0ffe5c3a34c93204accb74f0f4717c5
>  | here ]].
The documentation question was more referring to the lack of documentation for 
operator< on SourceLocation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66122



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


Buildbot numbers for the week of 08/04/2019 - 08/10/2019

2019-08-20 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 08/04/2019 - 08/10/2019.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  |  was_red
---+--
 aosp-O3-polly-before-vectorizer-unprofitable  | 120:05:45
 clang-cuda-build  | 59:02:05
 sanitizer-x86_64-linux-bootstrap-msan | 57:42:22
 sanitizer-x86_64-linux| 50:22:54
 clang-cmake-armv8-lld | 36:56:49
 clang-cmake-thumbv8-full-sh   | 35:20:50
 clang-cmake-armv7-full| 35:17:06
 clang-cmake-armv8-selfhost-neon   | 35:08:13
 clang-cmake-armv8-global-isel | 34:06:15
 clang-cmake-aarch64-full  | 33:50:57
 clang-cmake-thumbv7-full-sh   | 33:09:48
 clang-cmake-armv7-quick   | 32:35:52
 clang-cmake-armv7-selfhost-neon   | 32:31:44
 clang-cmake-armv7-selfhost| 32:07:33
 clang-cmake-armv8-full| 30:32:10
 clang-cmake-armv8-quick   | 30:28:35
 sanitizer-x86_64-linux-fast   | 30:16:21
 sanitizer-windows | 30:06:01
 clang-cmake-armv7-global-isel | 27:24:31
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan | 26:18:12
 sanitizer-x86_64-linux-android| 26:09:46
 clang-x64-windows-msvc| 24:24:23
 clang-lld-x86_64-2stage   | 24:06:58
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 24:03:10
 llvm-clang-x86_64-expensive-checks-win| 23:08:45
 clang-cmake-aarch64-lld   | 23:04:21
 clang-hexagon-elf | 21:10:53
 sanitizer-x86_64-linux-gn | 20:35:51
 clang-cmake-aarch64-global-isel   | 19:50:41
 clang-cmake-aarch64-quick | 19:50:31
 openmp-clang-x86_64-linux-debian  | 18:52:39
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a| 17:30:53
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan| 16:15:03
 clang-ppc64le-linux-lnt   | 08:53:51
 clang-with-lto-ubuntu | 07:52:21
 clang-s390x-linux-lnt | 07:50:56
 clang-ppc64le-linux-multistage| 07:14:01
 clang-s390x-linux | 07:05:19
 clang-with-thin-lto-ubuntu| 06:52:42
 clang-cmake-x86_64-avx2-linux | 05:56:33
 clang-ppc64le-linux   | 05:27:41
 clang-x86_64-debian-fast  | 05:24:08
 clang-s390x-linux-multistage  | 05:22:43
 clang-cmake-x86_64-sde-avx512-linux   | 05:17:44
 lld-x86_64-ubuntu-fast| 05:15:51
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 05:13:33
 sanitizer-x86_64-linux-bootstrap  | 05:11:21
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14| 05:10:44
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17| 04:53:32
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11| 04:52:41
 libcxx-libcxxabi-libunwind-armv8-linux| 04:43:07
 libcxx-libcxxabi-libunwind-aarch64-linux  | 04:41:18
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions   | 04:41:14
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 04:38:26
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan | 04:30:36
 ppc64le-lld-multistage-test   | 04:21:18
 llvm-hexagon-elf  | 04:16:41
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu| 04:16:14
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit| 04:11:13
 openmp-gcc-x86_64-linux-debian| 04:09:56
 sanitizer-x86_64-linux-bootstrap-ubsan| 04:08:32
 sanitizer-ppc64le-linux   | 04:02:04
 clang-ppc64be-linux-multistage| 03:55:31
 libcxx-libcxxabi-libunwind-armv7-linux| 03:48:17
 

Buildbot numbers for the week of 08/11/2019 - 08/17/2019

2019-08-20 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 08/11/2019 -
08/17/2019.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
buildername| was_red
---+-
 polly-amd64-linux | 93:12:33
 llvm-sphinx-docs  | 85:36:31
 reverse-iteration | 63:37:38
 lldb-x64-windows-ninja| 56:00:31
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan | 41:45:06
 clang-lld-x86_64-2stage   | 39:49:07
 libcxx-libcxxabi-x86_64-linux-debian  | 31:15:23
 clang-cmake-x86_64-avx2-linux | 30:21:12
 clang-cmake-x86_64-sde-avx512-linux   | 28:40:45
 clang-ppc64be-linux-multistage| 15:03:40
 clang-x86_64-debian-fast  | 14:50:07
 clang-ppc64be-linux-lnt   | 14:40:47
 clang-ppc64be-linux   | 14:40:09
 clang-ppc64le-linux-lnt   | 13:58:35
 clang-ppc64le-linux-multistage| 13:56:02
 clang-cmake-thumbv8-full-sh   | 13:21:28
 clang-ppc64le-linux   | 12:17:43
 clang-x64-windows-msvc| 12:01:03
 clang-cmake-armv7-selfhost-neon   | 11:29:32
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 11:07:10
 llvm-clang-x86_64-expensive-checks-win| 11:06:57
 llvm-clang-x86_64-win-fast| 11:03:33
 sanitizer-x86_64-linux-bootstrap  | 10:45:38
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 10:23:51
 clang-cmake-thumbv7-full-sh   | 10:19:47
 clang-cmake-armv8-selfhost-neon   | 09:55:13
 sanitizer-ppc64le-linux   | 08:23:00
 sanitizer-x86_64-linux-bootstrap-msan | 08:20:02
 sanitizer-x86_64-linux-fast   | 08:05:40
 sanitizer-x86_64-linux| 07:56:54
 clang-cmake-armv8-full| 07:32:49
 clang-cmake-aarch64-full  | 07:14:31
 clang-with-lto-ubuntu | 07:12:06
 clang-with-thin-lto-ubuntu| 07:06:22
 clang-cmake-armv7-full| 07:01:20
 sanitizer-x86_64-linux-gn | 06:46:32
 sanitizer-x86_64-linux-android| 06:46:30
 clang-cmake-armv7-quick   | 06:44:12
 clang-hexagon-elf | 06:38:14
 clang-cmake-armv8-quick   | 06:38:11
 sanitizer-ppc64be-linux   | 06:35:57
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17| 06:33:21
 clang-cmake-armv8-lld | 06:30:24
 clang-cmake-armv8-global-isel | 06:27:14
 sanitizer-x86_64-linux-bootstrap-ubsan| 06:03:35
 sanitizer-x86_64-linux-autoconf   | 05:25:34
 clang-cmake-aarch64-global-isel   | 05:25:17
 clang-cmake-aarch64-quick | 05:24:41
 clang-cmake-armv7-global-isel | 05:15:29
 clang-atom-d525-fedora-rel| 04:54:27
 clang-cmake-armv7-lnt | 04:49:31
 lld-x86_64-ubuntu-fast| 03:56:19
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan| 03:54:57
 clang-cuda-build  | 03:50:28
 llvm-hexagon-elf  | 03:49:51
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a| 03:11:11
 lld-x86_64-darwin13   | 01:37:29
 lld-x86_64-freebsd| 01:29:51
 sanitizer-x86_64-linux-fuzzer | 01:29:43
 lld-x86_64-win7   | 01:10:55
 lld-perf-testsuite| 01:10:50
 clang-cmake-x86_64-avx2-linux-perf| 00:56:07
 sanitizer-windows | 00:40:24
 clang-x86_64-linux-abi-test   | 00:31:06
 clang-armv7-linux-build-cache | 00:22:46
 clang-aarch64-linux-build-cache   | 00:20:24
 libcxx-libcxxabi-libunwind-x86_64-linux-debian| 00:09:57
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions | 00:09:52
(68 rows)


"Status change 

[PATCH] D65919: [clang-tidy] Add llvm-prefer-register-over-unsigned check and apply it to LLVM

2019-08-20 Thread Daniel Sanders via Phabricator via cfe-commits
dsanders updated this revision to Diff 216290.
dsanders marked 2 inline comments as done.
dsanders added a comment.

- registerCheck<> order


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65919

Files:
  clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp
  clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/llvm-prefer-register-over-unsigned.rst
  clang-tools-extra/test/clang-tidy/llvm-prefer-register-over-unsigned.cpp
  clang-tools-extra/test/clang-tidy/llvm-prefer-register-over-unsigned2.cpp
  clang-tools-extra/test/clang-tidy/llvm-prefer-register-over-unsigned3.cpp

Index: clang-tools-extra/test/clang-tidy/llvm-prefer-register-over-unsigned3.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/llvm-prefer-register-over-unsigned3.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s llvm-prefer-register-over-unsigned %t
+
+namespace llvm { };
+
+// This class shouldn't trigger it despite the similarity as it's not inside the llvm namespace
+class Register {
+public:
+  operator unsigned();
+};
+
+Register getReg();
+
+void do_nothing_1() {
+  unsigned Reg1 = getReg();
+  // CHECK-FIXES: do_nothing_1()
+  // CHECK-FIXES-NEXT: unsigned Reg1 = getReg();
+}
+
+void do_nothing_2() {
+  using namespace llvm;
+  unsigned Reg2 = getReg();
+  // CHECK-FIXES: do_nothing_2()
+  // CHECK-FIXES-NEXT: using namespace llvm;
+  // CHECK-FIXES-NEXT: unsigned Reg2 = getReg();
+}
+
+namespace llvm {
+void do_nothing_3() {
+  unsigned Reg3 = getReg();
+  // CHECK-FIXES: do_nothing_3()
+  // CHECK-FIXES-NEXT: unsigned Reg3 = getReg();
+}
+} // end namespace llvm
Index: clang-tools-extra/test/clang-tidy/llvm-prefer-register-over-unsigned2.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/llvm-prefer-register-over-unsigned2.cpp
@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s llvm-prefer-register-over-unsigned %t
+
+namespace llvm {
+class Register {
+public:
+  operator unsigned();
+};
+} // end namespace llvm
+
+llvm::Register getReg();
+
+using namespace llvm;
+
+void apply_1() {
+  unsigned Reg = getReg();
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'Reg' declared as 'unsigned int'; use 'Register' instead [llvm-prefer-register-over-unsigned]
+  // CHECK-FIXES: apply_1()
+  // CHECK-FIXES-NEXT: Register Reg = getReg();
+}
+
+void done_1() {
+  llvm::Register Reg = getReg();
+  // CHECK-FIXES: done_1()
+  // CHECK-FIXES-NEXT: llvm::Register Reg = getReg();
+}
Index: clang-tools-extra/test/clang-tidy/llvm-prefer-register-over-unsigned.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/llvm-prefer-register-over-unsigned.cpp
@@ -0,0 +1,143 @@
+// RUN: %check_clang_tidy %s llvm-prefer-register-over-unsigned %t
+
+namespace llvm {
+class Register {
+public:
+  operator unsigned();
+
+  unsigned Reg;
+};
+
+// This class shouldn't trigger it despite the similarity.
+class RegisterLike {
+public:
+  operator unsigned();
+
+  unsigned Reg;
+};
+} // end namespace llvm
+
+llvm::Register getReg();
+llvm::RegisterLike getRegLike();
+
+void apply_1() {
+  unsigned Reg1 = getReg();
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'Reg1' declared as 'unsigned int'; use 'llvm::Register' instead [llvm-prefer-register-over-unsigned]
+  // CHECK-FIXES: apply_1()
+  // CHECK-FIXES-NEXT: llvm::Register Reg1 = getReg();
+}
+
+void apply_2() {
+  using namespace llvm;
+  unsigned Reg2 = getReg();
+  // FIXME: Function-scoped UsingDirectiveDecl's don't appear to be in the
+  //DeclContext for the function so we can't elide the llvm:: in this
+  //case. Fortunately, it doesn't actually occur in the LLVM code base.
+  // CHECK-MESSAGES: :[[@LINE-4]]:12: warning: variable 'Reg2' declared as 'unsigned int'; use 'llvm::Register' instead [llvm-prefer-register-over-unsigned]
+  // CHECK-FIXES: apply_2()
+  // CHECK-FIXES-NEXT: using namespace llvm;
+  // CHECK-FIXES-NEXT: llvm::Register Reg2 = getReg();
+}
+
+namespace llvm {
+void apply_3() {
+  unsigned Reg3 = getReg();
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'Reg3' declared as 'unsigned int'; use 'Register' instead [llvm-prefer-register-over-unsigned]
+  // CHECK-FIXES: apply_3()
+  // CHECK-FIXES-NEXT: Register Reg3 = getReg();
+}
+} // end namespace llvm
+
+void done_1() {
+  llvm::Register Reg1 = getReg();
+  // CHECK-FIXES: done_1()
+  // CHECK-FIXES-NEXT: llvm::Register Reg1 = getReg();
+}
+
+void done_2() {
+  using namespace llvm;
+  Register Reg2 = getReg();
+  // 

r369474 - Add triple to new test to try to pacify bots

2019-08-20 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Aug 20 16:32:51 2019
New Revision: 369474

URL: http://llvm.org/viewvc/llvm-project?rev=369474=rev
Log:
Add triple to new test to try to pacify bots

Modified:
cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp?rev=369474=369473=369474=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp Tue Aug 20 16:32:51 
2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -gcodeview -debug-info-kind=limited -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm %s -gcodeview 
-debug-info-kind=limited -o - | FileCheck %s
 
 struct a {
   ~a();


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


[PATCH] D66505: Make add_new_check.py's insertion of registerCheck<> more closely match the sort order

2019-08-20 Thread Daniel Sanders via Phabricator via cfe-commits
dsanders created this revision.
dsanders added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Following on from review comments in D65919  
about the ordering
of the registerCheck<> calls. Ignore namespaces when finding the correct
insertion point to make the heuristic more accurate. The actual sort order
is based on the check name in the string but that isn't always on the same
line so the class name is used as a proxy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66505

Files:
  clang-tools-extra/clang-tidy/add_new_check.py


Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -185,7 +185,7 @@
   check_added = True
   f.write(check_decl)
 else:
-  match = re.search('registerCheck<(.*)>', line)
+  match = re.search('registerCheck<((.*::).*)>', line)
   if match and match.group(1) > check_name_camel:
 check_added = True
 f.write(check_decl)


Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -185,7 +185,7 @@
   check_added = True
   f.write(check_decl)
 else:
-  match = re.search('registerCheck<(.*)>', line)
+  match = re.search('registerCheck<((.*::).*)>', line)
   if match and match.group(1) > check_name_camel:
 check_added = True
 f.write(check_decl)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65724: [analyzer] Don't make ConditionBRVisitor events prunable when the condition is an interesting field

2019-08-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 216283.
Szelethus added a comment.

- Add the `FIXME`
- Cascade test changes from D65575 


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

https://reviews.llvm.org/D65724

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/track-control-dependency-conditions.cpp

Index: clang/test/Analysis/track-control-dependency-conditions.cpp
===
--- clang/test/Analysis/track-control-dependency-conditions.cpp
+++ clang/test/Analysis/track-control-dependency-conditions.cpp
@@ -407,6 +407,91 @@
 }
 } // end of namespace condition_written_in_nested_stackframe_before_assignment
 
+namespace condition_lambda_capture_by_reference_last_write {
+int getInt();
+
+[[noreturn]] void halt();
+
+void f(int flag) {
+  int *x = 0; // expected-note-re^}}'x' initialized to a null pointer value{{$
+
+  auto lambda = []() {
+flag = getInt(); // tracking-note-re^}}Value assigned to 'flag', which participates in a condition later{{$
+  };
+
+  lambda(); // tracking-note-re^}}Calling 'operator()'{{$
+// tracking-note-re@-1^}}Returning from 'operator()'{{$
+
+  if (flag) // expected-note-re^}}Assuming 'flag' is not equal to 0{{$
+// expected-note-re@-1^}}Taking true branch{{$
+// debug-note-re@-2^}}Tracking condition 'flag'{{$
+*x = 5; // expected-warning{{Dereference of null pointer}}
+// expected-note@-1{{Dereference of null pointer}}
+}
+} // end of namespace condition_lambda_capture_by_reference_last_write
+
+namespace condition_lambda_capture_by_value_assumption {
+int getInt();
+
+[[noreturn]] void halt();
+
+void bar(int ) {
+  flag = getInt(); // tracking-note-re^}}Value assigned to 'flag', which participates in a condition later{{$
+}
+
+void f(int flag) {
+  int *x = 0; // expected-note-re^}}'x' initialized to a null pointer value{{$
+
+  auto lambda = [flag]() {
+if (!flag) // tracking-note-re^}}Assuming 'flag' is not equal to 0{{$
+   // tracking-note-re@-1^}}Taking false branch{{$
+  halt();
+  };
+
+  bar(flag); // tracking-note-re^}}Calling 'bar'{{$
+ // tracking-note-re@-1^}}Returning from 'bar'{{$
+  lambda();  // tracking-note-re^}}Calling 'operator()'{{$
+ // tracking-note-re@-1^}}Returning from 'operator()'{{$
+
+  if (flag) // expected-note-re^}}Assuming 'flag' is not equal to 0{{$
+// expected-note-re@-1^}}Taking true branch{{$
+// debug-note-re@-2^}}Tracking condition 'flag'{{$
+*x = 5; // expected-warning{{Dereference of null pointer}}
+// expected-note@-1{{Dereference of null pointer}}
+}
+} // end of namespace condition_lambda_capture_by_value_assumption
+
+namespace condition_lambda_capture_by_reference_assumption {
+int getInt();
+
+[[noreturn]] void halt();
+
+void bar(int ) {
+  flag = getInt(); // tracking-note-re^}}Value assigned to 'flag', which participates in a condition later{{$
+}
+
+void f(int flag) {
+  int *x = 0; // expected-note-re^}}'x' initialized to a null pointer value{{$
+
+  auto lambda = []() {
+if (!flag) // tracking-note-re^}}Assuming 'flag' is not equal to 0{{$
+   // tracking-note-re@-1^}}Taking false branch{{$
+  halt();
+  };
+
+  bar(flag); // tracking-note-re^}}Calling 'bar'{{$
+ // tracking-note-re@-1^}}Returning from 'bar'{{$
+  lambda();  // tracking-note-re^}}Calling 'operator()'{{$
+ // tracking-note-re@-1^}}Returning from 'operator()'{{$
+
+  if (flag) // expected-note-re^}}'flag' is not equal to 0{{$
+// expected-note-re@-1^}}Taking true branch{{$
+// debug-note-re@-2^}}Tracking condition 'flag'}}
+*x = 5; // expected-warning{{Dereference of null pointer}}
+// expected-note@-1{{Dereference of null pointer}}
+}
+} // end of namespace condition_lambda_capture_by_reference_assumption
+
 namespace collapse_point_not_in_condition {
 
 [[noreturn]] void halt();
@@ -459,6 +544,35 @@
 
 } // end of namespace unimportant_write_before_collapse_point
 
+namespace collapse_point_not_in_condition_as_field {
+
+[[noreturn]] void halt();
+struct IntWrapper {
+  int b;
+  IntWrapper();
+
+  void check() {
+if (!b) // tracking-note-re^}}Assuming field 'b' is not equal to 0{{$
+// tracking-note-re@-1^}}Taking false branch{{$
+  halt();
+return;
+  }
+};
+
+void f(IntWrapper i) {
+  int *x = 0; // expected-note-re^}}'x' initialized to a null pointer value{{$
+
+  i.check(); // tracking-note-re^}}Calling 'IntWrapper::check'{{$
+

[PATCH] D65575: [analyzer] Mention whether an event is about a condition in a bug report part 1

2019-08-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D65575#1638430 , @xazax.hun wrote:

> LGTM! I think the UIs could do better displaying this info in the future but 
> this is not your job :)


https://github.com/Ericsson/codechecker/pull/2279

CodeChecker now indents function calls! Woohoo!


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

https://reviews.llvm.org/D65575



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


[PATCH] D65575: [analyzer] Mention whether an event is about a condition in a bug report part 1

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

LGTM! I think the UIs could do better displaying this info in the future but 
this is not your job :)


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

https://reviews.llvm.org/D65575



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


[PATCH] D65575: [analyzer] Mention whether an event is about a condition in a bug report part 1

2019-08-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

*actually accepting*


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

https://reviews.llvm.org/D65575



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


[PATCH] D65575: [analyzer] Mention whether an event is about a condition in a bug report part 1

2019-08-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Hmm-hmm, I kinda like the comma, but would happily concede on this. Its been a 
while since my english exam :^)


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

https://reviews.llvm.org/D65575



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


[PATCH] D66122: [CodeGen] Emit dynamic initializers for static TLS vars in outlined scopes

2019-08-20 Thread Princeton Ferro via Phabricator via cfe-commits
Prince781 marked an inline comment as done.
Prince781 added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:479
+return a_deps.find(b) != a_deps.end() 
+|| b->getLocation() < a->getLocation(); // ensure deterministic 
ordering
+  });

efriedma wrote:
> Is the call to a_deps.find() here actually necessary?  It shouldn't be 
> possible for an initializer to directly refer to a variable declared later.
> 
> "<" on SourceLocations isn't source order, in general; you need 
> isBeforeInTranslationUnit.  (This should be documented somewhere, but I'm not 
> finding the documentation, unfortunately.  Any suggestions for where it 
> should be documented?)
> It shouldn't be possible for an initializer to directly refer to a variable 
> declared later.

That's true. I was using `deps.find()` to order the initialization of the 
variables. But since you mention `isBeforeInTranslationUnit`, I can use that 
instead. It appears to be documented [[ 
https://clang.llvm.org/doxygen/classclang_1_1SourceManager.html#af0ffe5c3a34c93204accb74f0f4717c5
 | here ]].


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66122



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


[PATCH] D63638: [clang][NewPM] Add new pass manager RUN lines to avx512f-builtins.c

2019-08-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper abandoned this revision.
craig.topper added a comment.

I don't think so.


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

https://reviews.llvm.org/D63638



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


[PATCH] D65575: [analyzer] Mention whether an event is about a condition in a bug report part 1

2019-08-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thanks!!

I also suspect we don't need the comma.


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

https://reviews.llvm.org/D65575



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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2019-08-20 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 216274.
paulkirth added a comment.
Herald added a subscriber: ormris.

Update LLVM based implementation

Adds LLVM based tests
Cleans up existing tests in clang
Adds new llvm flag -pgo-warn-misexpect
Adds llvm flag when -Wmisexpect enabled in frontend
Adds new debug output 
Fixes error when calculating & scaling branch weights
Improves fidelity of diagnostic outpus from SwithInst
Removes Remark output from MisExpecDiagHandler & uses ORE directly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66324

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
  clang/test/Profile/Inputs/misexpect-branch.proftext
  clang/test/Profile/Inputs/misexpect-switch-default-only.proftext
  clang/test/Profile/Inputs/misexpect-switch-default.proftext
  clang/test/Profile/Inputs/misexpect-switch.proftext
  clang/test/Profile/misexpect-branch-cold.c
  clang/test/Profile/misexpect-branch-nonconst-expected-val.c
  clang/test/Profile/misexpect-branch.c
  clang/test/Profile/misexpect-switch-default.c
  clang/test/Profile/misexpect-switch-nonconst.c
  clang/test/Profile/misexpect-switch-only-default-case.c
  clang/test/Profile/misexpect-switch.c
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/FixedMetadataKinds.def
  llvm/include/llvm/IR/MDBuilder.h
  llvm/include/llvm/Transforms/Utils/MisExpect.h
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/MDBuilder.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/MisExpect.cpp
  llvm/test/ThinLTO/X86/lazyload_metadata.ll
  llvm/test/Transforms/LowerExpectIntrinsic/basic.ll
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/misexpect-branch-correct.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch-default.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch.ll

Index: llvm/test/Transforms/PGOProfile/misexpect-switch.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/misexpect-switch.ll
@@ -0,0 +1,293 @@
+
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch.proftext -o %t.profdata
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch-correct.proftext -o %t.c.profdata
+
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect 2>&1 | FileCheck %s --check-prefix=WARNING
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=BOTH
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED
+
+; New PM
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED
+
+; RUN: opt < %s -lower-expect -pgo-instr-use -pgo-test-profile-file=%t.c.profdata -S -pgo-warn-misexpect -pass-remarks=misexpect 2>&1 | FileCheck %s --check-prefix=CORRECT
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.c.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=CORRECT
+
+; WARNING-DAG: warning: misexpect-switch.c:26:5: 0.00%
+; WARNING-NOT: remark: misexpect-switch.c:26:5: Potential performance regression from use of __builtin_expect(): Annotation was correct on 0.00% of profiled executions.
+
+; REMARK-NOT: warning: misexpect-switch.c:26:5: 0.00%
+; REMARK-DAG: remark: misexpect-switch.c:26:5: Potential performance regression from 

[PATCH] D66068: cmake: Make building clang-shlib optional

2019-08-20 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D66068#1636240 , @jvesely wrote:

> sorry for the delay. I fully understand the need to reduce the number of 
> options. Having always used SHARED_LIBS build I remember weekly shared build 
> breakages.


This is exactly what we want to avoid in the future by simplifying build 
configurations.

> That said, forcing everyone to build one huge library effectively makes debug 
> builds unusable in any practical way.

Nobody is forced to build this. You can run the `check` targets which don't 
include this library in their dependency chain, and you can use the 
`LLVM_DISTRIBUITON_COMPONENTS` option I mentioned earlier to create build and 
install targets that exclude it. We are just including it as part of the `all` 
target, because it is part of building everything. Where I think you and I are 
really disagreeing is that you seem resistant to altering your workflow.

> What is the use-case of one big shared lib that split libraries can't do?

clang-cpp is an installable and shippable library, which is not the use case 
that the split libraries were designed for. Also, since it is a shared library, 
tools can be linked against it to reduce binary distribution sizes (at the cost 
of some runtime performance). It is worth noting that the `BUILD_SHARED_LIBS` 
option is explicitly documented in several places as being for developer use 
only, not for shipping. Which means this is the only supported mechanism for 
shipping clang's logic in a shared library.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66068



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


[PATCH] D66122: [CodeGen] Emit dynamic initializers for static TLS vars in outlined scopes

2019-08-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:479
+return a_deps.find(b) != a_deps.end() 
+|| b->getLocation() < a->getLocation(); // ensure deterministic 
ordering
+  });

Is the call to a_deps.find() here actually necessary?  It shouldn't be possible 
for an initializer to directly refer to a variable declared later.

"<" on SourceLocations isn't source order, in general; you need 
isBeforeInTranslationUnit.  (This should be documented somewhere, but I'm not 
finding the documentation, unfortunately.  Any suggestions for where it should 
be documented?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66122



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


[PATCH] D65575: [analyzer] Mention whether an event is about a condition in a bug report part 1

2019-08-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 216273.
Szelethus added a comment.

- Change the condition postfix as discussed
- `expected-note{{...}}` -> `expected-note-re^}}...{{$`


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

https://reviews.llvm.org/D65575

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/track-control-dependency-conditions.cpp

Index: clang/test/Analysis/track-control-dependency-conditions.cpp
===
--- clang/test/Analysis/track-control-dependency-conditions.cpp
+++ clang/test/Analysis/track-control-dependency-conditions.cpp
@@ -29,24 +29,24 @@
 bool coin();
 
 void foo() {
-  flag = coin(); // tracking-note{{Value assigned to 'flag'}}
+  flag = coin(); // tracking-note-re^}}Value assigned to 'flag', which participates in a condition later{{$
 }
 
 void test() {
-  int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
+  int *x = 0; // expected-note-re^}}'x' initialized to a null pointer value{{$
   flag = 1;
 
   foo(); // TODO: Add nodes here about flag's value being invalidated.
-  if (flag) // expected-note   {{Assuming 'flag' is 0}}
-// expected-note@-1{{Taking false branch}}
+  if (flag) // expected-note-re   ^}}Assuming 'flag' is 0{{$
+// expected-note-re@-1^}}Taking false branch{{$
 x = new int;
 
-  foo(); // tracking-note{{Calling 'foo'}}
- // tracking-note@-1{{Returning from 'foo'}}
+  foo(); // tracking-note-re^}}Calling 'foo'{{$
+ // tracking-note-re@-1^}}Returning from 'foo'{{$
 
-  if (flag) // expected-note   {{Assuming 'flag' is not equal to 0}}
-// expected-note@-1{{Taking true branch}}
-// debug-note@-2{{Tracking condition 'flag'}}
+  if (flag) // expected-note-re   ^}}Assuming 'flag' is not equal to 0{{$
+// expected-note-re@-1^}}Taking true branch{{$
+// debug-note-re@-2^}}Tracking condition 'flag'{{$
 
 *x = 5; // expected-warning{{Dereference of null pointer}}
 // expected-note@-1{{Dereference of null pointer}}
@@ -58,7 +58,7 @@
 bool coin();
 
 void foo() {
-  flag = coin(); // tracking-note{{Value assigned to 'flag'}}
+  flag = coin(); // tracking-note-re^}}Value assigned to 'flag', which participates in a condition later{{$
 }
 
 void test() {
@@ -66,18 +66,18 @@
   flag = 1;
 
   foo();
-  if (flag) // expected-note   {{Assuming 'flag' is 0}}
-// expected-note@-1{{Taking false branch}}
+  if (flag) // expected-note-re   ^}}Assuming 'flag' is 0{{$
+// expected-note-re@-1^}}Taking false branch{{$
 x = new int;
 
-  x = 0; // expected-note{{Null pointer value stored to 'x'}}
+  x = 0; // expected-note-re^}}Null pointer value stored to 'x'{{$
 
-  foo(); // tracking-note{{Calling 'foo'}}
- // tracking-note@-1{{Returning from 'foo'}}
+  foo(); // tracking-note-re^}}Calling 'foo'{{$
+ // tracking-note-re@-1^}}Returning from 'foo'{{$
 
-  if (flag) // expected-note   {{Assuming 'flag' is not equal to 0}}
-// expected-note@-1{{Taking true branch}}
-// debug-note@-2{{Tracking condition 'flag'}}
+  if (flag) // expected-note-re   ^}}Assuming 'flag' is not equal to 0{{$
+// expected-note-re@-1^}}Taking true branch{{$
+// debug-note-re@-2^}}Tracking condition 'flag'{{$
 
 *x = 5; // expected-warning{{Dereference of null pointer}}
 // expected-note@-1{{Dereference of null pointer}}
@@ -90,25 +90,25 @@
 
 void foo() {
   // coin() could write bar, do it's invalidated.
-  flag = coin(); // tracking-note{{Value assigned to 'flag'}}
- // tracking-note@-1{{Value assigned to 'bar'}}
+  flag = coin(); // tracking-note-re^}}Value assigned to 'flag', which participates in a condition later{{$
+ // tracking-note-re@-1^}}Value assigned to 'bar', which participates in a condition later{{$
 }
 
 int bar;
 
 void test() {
-  int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
+  int *x = 0; // expected-note-re^}}'x' initialized to a null pointer value{{$
   flag = 1;
 
-  foo(); // tracking-note{{Calling 'foo'}}
- // tracking-note@-1{{Returning from 'foo'}}
+  foo(); // tracking-note-re^}}Calling 'foo'{{$
+ // tracking-note-re@-1^}}Returning from 'foo'{{$
 
-  if (bar) // expected-note   {{Assuming 'bar' is not equal to 0}}
-   // expected-note@-1{{Taking true branch}}
-   // debug-note@-2{{Tracking condition 'bar'}}
-if (flag) // expected-note   {{Assuming 'flag' is not equal to 0}}
-  // expected-note@-1{{Taking true branch}}
-  // debug-note@-2{{Tracking condition 'flag'}}
+  if (bar) // expected-note-re   ^}}Assuming 'bar' is not equal 

[PATCH] D66502: [clang-doc] Switch Generator::CreateResources to use llvm::Error

2019-08-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
juliehockett added reviewers: DiegoAstiazaran, jakehehrlich.
juliehockett added a project: clang-tools-extra.
Herald added subscribers: kadircet, arphaman.

https://reviews.llvm.org/D66502

Files:
  clang-tools-extra/clang-doc/Generators.cpp
  clang-tools-extra/clang-doc/Generators.h
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -326,8 +326,11 @@
 return 1;
 
   llvm::outs() << "Generating assets for docs...\n";
-  if (!G->get()->createResources(CDCtx))
+  Err = G->get()->createResources(CDCtx);
+  if (Err) {
+llvm::errs() << toString(std::move(Err)) << "\n";
 return 1;
+  }
 
   return 0;
 }
Index: clang-tools-extra/clang-doc/HTMLGenerator.cpp
===
--- clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -829,7 +829,7 @@
 
   llvm::Error generateDocForInfo(Info *I, llvm::raw_ostream ,
  const ClangDocContext ) override;
-  bool createResources(ClangDocContext ) override;
+  llvm::Error createResources(ClangDocContext ) override;
 };
 
 const char *HTMLGenerator::Format = "html";
@@ -883,7 +883,7 @@
   llvm_unreachable("Unknown InfoType");
 }
 
-static bool SerializeIndex(ClangDocContext ) {
+static llvm::Error SerializeIndex(ClangDocContext ) {
   std::error_code OK;
   std::error_code FileErr;
   llvm::SmallString<128> FilePath;
@@ -891,8 +891,9 @@
   llvm::sys::path::append(FilePath, "index_json.js");
   llvm::raw_fd_ostream OS(FilePath, FileErr, llvm::sys::fs::F_None);
   if (FileErr != OK) {
-llvm::errs() << "Error creating index file: " << FileErr.message() << "\n";
-return false;
+return llvm::make_error(
+"Error creating index file: " + FileErr.message() + "\n",
+llvm::inconvertibleErrorCode());
   }
   CDCtx.Idx.sort();
   llvm::json::OStream J(OS, 2);
@@ -911,7 +912,7 @@
   OS << "var JsonIndex = `\n";
   IndexToJSON(CDCtx.Idx);
   OS << "`;\n";
-  return true;
+  return llvm::Error::success();
 }
 
 // Generates a main HTML node that has the main content of the file that shows
@@ -932,15 +933,16 @@
   return MainNode;
 }
 
-static bool GenIndex(const ClangDocContext ) {
+static llvm::Error GenIndex(const ClangDocContext ) {
   std::error_code FileErr, OK;
   llvm::SmallString<128> IndexPath;
   llvm::sys::path::native(CDCtx.OutDirectory, IndexPath);
   llvm::sys::path::append(IndexPath, "index.html");
   llvm::raw_fd_ostream IndexOS(IndexPath, FileErr, llvm::sys::fs::F_None);
   if (FileErr != OK) {
-llvm::errs() << "Error creating main index: " << FileErr.message() << "\n";
-return false;
+return llvm::make_error(
+"Error creating main index: " + FileErr.message() + "\n",
+llvm::inconvertibleErrorCode());
   }
 
   HTMLFile F;
@@ -958,10 +960,10 @@
 
   F.Render(IndexOS);
 
-  return true;
+  return llvm::Error::success();
 }
 
-static bool CopyFile(StringRef FilePath, StringRef OutDirectory) {
+static llvm::Error CopyFile(StringRef FilePath, StringRef OutDirectory) {
   llvm::SmallString<128> PathWrite;
   llvm::sys::path::native(OutDirectory, PathWrite);
   llvm::sys::path::append(PathWrite, llvm::sys::path::filename(FilePath));
@@ -970,24 +972,33 @@
   std::error_code OK;
   std::error_code FileErr = llvm::sys::fs::copy_file(PathRead, PathWrite);
   if (FileErr != OK) {
-llvm::errs() << "Error creating file "
- << llvm::sys::path::filename(FilePath) << ": "
- << FileErr.message() << "\n";
-return false;
+return llvm::make_error(
+"Error creating file " + llvm::sys::path::filename(FilePath) + ": " +
+FileErr.message() + "\n",
+llvm::inconvertibleErrorCode());
   }
-  return true;
+  return llvm::Error::success();
 }
 
-bool HTMLGenerator::createResources(ClangDocContext ) {
-  if (!SerializeIndex(CDCtx) || !GenIndex(CDCtx))
-return false;
-  for (const auto  : CDCtx.UserStylesheets)
-if (!CopyFile(FilePath, CDCtx.OutDirectory))
-  return false;
-  for (const auto  : CDCtx.FilesToCopy)
-if (!CopyFile(FilePath, CDCtx.OutDirectory))
-  return false;
-  return true;
+llvm::Error HTMLGenerator::createResources(ClangDocContext ) {
+  auto Err = SerializeIndex(CDCtx);
+  if (Err)
+return Err;
+  Err = GenIndex(CDCtx);
+  if (Err)
+return Err;
+
+  for (const auto  : CDCtx.UserStylesheets) {
+Err = CopyFile(FilePath, CDCtx.OutDirectory);
+if (Err)
+  return Err;
+  }
+  for (const auto  : CDCtx.FilesToCopy) {
+Err = CopyFile(FilePath, CDCtx.OutDirectory);
+if (Err)
+  return Err;
+  }
+  return llvm::Error::success();
 }
 
 static 

[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-20 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369458: [DebugInfo] Add debug location to dynamic atexit 
destructor (authored by aganea, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66328?vs=216233=216263#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66328

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp


Index: cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
@@ -30,24 +30,24 @@
 template A FooTpl::sdm_tpl;
 
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init",{{.*}} line: 
15,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}} line: 15,{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}}: DISPFlagLocalToUnit 
| DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init.1",{{.*}} line: 
16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 
16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}} line: 16,{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} line: 
19,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}}: 
DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-KEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'glob'",{{.*}} 
line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'glob'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} 
line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 
16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'stat'",{{.*}} line: 19,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'array'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'stat'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 
 // MSVC does weird stuff when templates are involved, so we don't match 
exactly,
 // but these names are reasonable.
 // FIXME: These should not be marked DISPFlagLocalToUnit.
 // CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic initializer for 
'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor 
for 'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | 
DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor 
for 'sdm_tpl'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
Index: cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm %s -gcodeview -debug-info-kind=limited -o - | 
FileCheck %s
+
+struct a {
+  ~a();
+};
+template  struct c : a {
+  c(void (b::*)());
+};
+struct B {
+  virtual void e();
+};
+c *d() { static c f(::e); return  }
+
+// CHECK: define internal void @"??__Ff@?1??d@@YAPEAU?$c@UBXZ@YAXXZ"()
+// CHECK-SAME: !dbg ![[SUBPROGRAM:[0-9]+]] {
+// CHECK: call void @"??1?$c@UBQEAA@XZ"(%struct.c* 
@"?f@?1??d@@YAPEAU?$c@UBXZ@4U2@A"), !dbg ![[LOCATION:[0-9]+]]
+// CHECK-NEXT: ret void, !dbg ![[LOCATION]]
+// CHECK: ![[SUBPROGRAM]] = distinct !DISubprogram(name: "`dynamic atexit 
destructor for 'f'"
+// CHECK-SAME: flags: DIFlagArtificial
+// CHECK: ![[LOCATION]] = 

r369458 - [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-20 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Tue Aug 20 15:09:49 2019
New Revision: 369458

URL: http://llvm.org/viewvc/llvm-project?rev=369458=rev
Log:
[DebugInfo] Add debug location to dynamic atexit destructor

Fixes PR43012

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

Added:
cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=369458=369457=369458=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Aug 20 15:09:49 2019
@@ -3564,7 +3564,8 @@ void CGDebugInfo::EmitFunctionStart(Glob
   if (Name.startswith("\01"))
 Name = Name.substr(1);
 
-  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
+  if (!HasDecl || D->isImplicit() || D->hasAttr() ||
+  (isa(D) && GD.getDynamicInitKind() == DynamicInitKind::AtExit)) 
{
 Flags |= llvm::DINode::FlagArtificial;
 // Artificial functions should not silently reuse CurLoc.
 CurLoc = SourceLocation();

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=369458=369457=369458=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Tue Aug 20 15:09:49 2019
@@ -247,6 +247,8 @@ llvm::Function *CodeGenFunction::createA
 
   CGF.StartFunction(GlobalDecl(, DynamicInitKind::AtExit),
 CGM.getContext().VoidTy, fn, FI, FunctionArgList());
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(CGF);
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
 

Added: cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp?rev=369458=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-atexit-stub.cpp Tue Aug 20 15:09:49 
2019
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm %s -gcodeview -debug-info-kind=limited -o - | 
FileCheck %s
+
+struct a {
+  ~a();
+};
+template  struct c : a {
+  c(void (b::*)());
+};
+struct B {
+  virtual void e();
+};
+c *d() { static c f(::e); return  }
+
+// CHECK: define internal void @"??__Ff@?1??d@@YAPEAU?$c@UBXZ@YAXXZ"()
+// CHECK-SAME: !dbg ![[SUBPROGRAM:[0-9]+]] {
+// CHECK: call void @"??1?$c@UBQEAA@XZ"(%struct.c* 
@"?f@?1??d@@YAPEAU?$c@UBXZ@4U2@A"), !dbg ![[LOCATION:[0-9]+]]
+// CHECK-NEXT: ret void, !dbg ![[LOCATION]]
+// CHECK: ![[SUBPROGRAM]] = distinct !DISubprogram(name: "`dynamic atexit 
destructor for 'f'"
+// CHECK-SAME: flags: DIFlagArtificial
+// CHECK: ![[LOCATION]] = !DILocation(line: 0, scope: ![[SUBPROGRAM]])

Modified: cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp?rev=369458=369457=369458=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp Tue Aug 20 
15:09:49 2019
@@ -30,24 +30,24 @@ A FooTpl::sdm_tpl(sizeof(U) + sizeof(
 template A FooTpl::sdm_tpl;
 
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init",{{.*}} line: 
15,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}} line: 15,{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}}: DISPFlagLocalToUnit 
| DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init.1",{{.*}} line: 
16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 
16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}} line: 16,{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} line: 
19,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}}: 
DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-KEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'glob'",{{.*}} 

[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thank you!


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

https://reviews.llvm.org/D66328



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


[PATCH] D66486: [LifetimeAnalysis] Detect more cases when the address of a local variable escapes

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

Ok, I think I know what is going on.

Basically, we have a `MutableArrayRef` which is NOT a pointer as it is NOT 
annotated as `gsl::Pointer`. So in the AST we see a local non-pointer object, 
and we derive a pointer from this local object. This is why the warnings thinks 
that we return the address of a local variable. In case we do annotate 
`MutableArrayRef` to be a Pointer we will no longer see the warning.

Do you think we should stop the tracking after seeing a `DerivedToBase` cast? 
Or should we continue to report those errors so the users can add the missing 
annotation? I feel like this is something that is potentially up for a debate.,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66486



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


[PATCH] D63638: [clang][NewPM] Add new pass manager RUN lines to avx512f-builtins.c

2019-08-20 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D63638#1596313 , @leonardchan wrote:

> I created D65110  if we're ok with just 
> using the new PM.


@craig.topper Is this patch still relevant?


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

https://reviews.llvm.org/D63638



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


[PATCH] D65349: [analyzer] Be more careful with destructors of non-regions.

2019-08-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369450: [analyzer] Fix a crash when destroying a non-region. 
(authored by dergachev, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65349?vs=214972=216256#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D65349

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/test/Analysis/dtor.cpp

Index: cfe/trunk/test/Analysis/dtor.cpp
===
--- cfe/trunk/test/Analysis/dtor.cpp
+++ cfe/trunk/test/Analysis/dtor.cpp
@@ -540,3 +540,33 @@
   clang_analyzer_eval(__alignof(NonTrivial) > 0); // expected-warning{{TRUE}}
 }
 }
+
+namespace dtor_over_loc_concrete_int {
+struct A {
+  ~A() {}
+};
+
+struct B {
+  A a;
+  ~B() {}
+};
+
+struct C : A {
+  ~C() {}
+};
+
+void testB() {
+  B *b = (B *)-1;
+  b->~B(); // no-crash
+}
+
+void testC() {
+  C *c = (C *)-1;
+  c->~C(); // no-crash
+}
+
+void testAutoDtor() {
+  const A  = *(A *)-1;
+  // no-crash
+}
+} // namespace dtor_over_loc_concrete_int
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -604,7 +604,7 @@
 bool IsBaseDtor,
 ExplodedNode *Pred,
 ExplodedNodeSet ,
-const EvalCallOptions ) {
+EvalCallOptions ) {
   assert(S && "A destructor without a trigger!");
   const LocationContext *LCtx = Pred->getLocationContext();
   ProgramStateRef State = Pred->getState();
@@ -612,7 +612,6 @@
   const CXXRecordDecl *RecordDecl = ObjectType->getAsCXXRecordDecl();
   assert(RecordDecl && "Only CXXRecordDecls should have destructors");
   const CXXDestructorDecl *DtorDecl = RecordDecl->getDestructor();
-
   // FIXME: There should always be a Decl, otherwise the destructor call
   // shouldn't have been added to the CFG in the first place.
   if (!DtorDecl) {
@@ -626,9 +625,27 @@
 return;
   }
 
+  if (!Dest) {
+// We're trying to destroy something that is not a region. This may happen
+// for a variety of reasons (unknown target region, concrete integer instead
+// of target region, etc.). The current code makes an attempt to recover.
+// FIXME: We probably don't really need to recover when we're dealing
+// with concrete integers specifically.
+CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion = true;
+if (const Expr *E = dyn_cast_or_null(S)) {
+  Dest = MRMgr.getCXXTempObjectRegion(E, Pred->getLocationContext());
+} else {
+  static SimpleProgramPointTag T("ExprEngine", "SkipInvalidDestructor");
+  NodeBuilder Bldr(Pred, Dst, *currBldrCtx);
+  Bldr.generateSink(Pred->getLocation().withTag(),
+Pred->getState(), Pred);
+  return;
+}
+  }
+
   CallEventManager  = getStateManager().getCallEventManager();
   CallEventRef Call =
-CEMgr.getCXXDestructorCall(DtorDecl, S, Dest, IsBaseDtor, State, LCtx);
+  CEMgr.getCXXDestructorCall(DtorDecl, S, Dest, IsBaseDtor, State, LCtx);
 
   PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
 Call->getSourceRange().getBegin(),
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -977,8 +977,8 @@
   Region = makeZeroElementRegion(state, loc::MemRegionVal(Region), varType,
  CallOpts.IsArrayCtorOrDtor).getAsRegion();
 
-  VisitCXXDestructor(varType, Region, Dtor.getTriggerStmt(), /*IsBase=*/ false,
- Pred, Dst, CallOpts);
+  VisitCXXDestructor(varType, Region, Dtor.getTriggerStmt(),
+ /*IsBase=*/false, Pred, Dst, CallOpts);
 }
 
 void ExprEngine::ProcessDeleteDtor(const CFGDeleteDtor Dtor,
@@ -1036,8 +1036,9 @@
   SVal BaseVal = getStoreManager().evalDerivedToBase(ThisVal, BaseTy,
  Base->isVirtual());
 
-  VisitCXXDestructor(BaseTy, BaseVal.castAs().getRegion(),
- CurDtor->getBody(), /*IsBase=*/ true, Pred, Dst, {});
+  EvalCallOptions CallOpts;
+  VisitCXXDestructor(BaseTy, BaseVal.getAsRegion(), CurDtor->getBody(),
+ /*IsBase=*/true, Pred, Dst, CallOpts);
 }
 
 void ExprEngine::ProcessMemberDtor(const CFGMemberDtor D,
@@ -1048,10 +1049,10 @@
   

[PATCH] D64274: [analyzer] VirtualCallChecker overhaul.

2019-08-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369449: [analyzer] Improve VirtualCallChecker and enable 
parts of it by default. (authored by dergachev, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64274?vs=215007=216255#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64274

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
  cfe/trunk/test/Analysis/virtualcall-plist.cpp
  cfe/trunk/test/Analysis/virtualcall.cpp
  cfe/trunk/test/Analysis/virtualcall.h

Index: cfe/trunk/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
@@ -17,4 +17,5 @@
   "Memory (Core Foundation/Objective-C/OSObject)";
 const char * const MemoryError = "Memory error";
 const char * const UnixAPI = "Unix API";
+const char * const CXXObjectLifecycle = "C++ object lifecycle";
 }}}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
@@ -6,7 +6,7 @@
 //
 //===--===//
 //
-//  This file defines a checker that checks virtual function calls during
+//  This file defines a checker that checks virtual method calls during
 //  construction or destruction of C++ objects.
 //
 //===--===//
@@ -40,11 +40,9 @@
 namespace {
 class VirtualCallChecker
 : public Checker {
-  mutable std::unique_ptr BT;
-
 public:
-  // The flag to determine if pure virtual functions should be issued only.
-  DefaultBool IsPureOnly;
+  // These are going to be null if the respective check is disabled.
+  mutable std::unique_ptr BT_Pure, BT_Impure;
 
   void checkBeginFunction(CheckerContext ) const;
   void checkEndFunction(const ReturnStmt *RS, CheckerContext ) const;
@@ -53,85 +51,13 @@
 private:
   void registerCtorDtorCallInState(bool IsBeginFunction,
CheckerContext ) const;
-  void reportBug(StringRef Msg, bool PureError, const MemRegion *Reg,
- CheckerContext ) const;
-
-  class VirtualBugVisitor : public BugReporterVisitor {
-  private:
-const MemRegion *ObjectRegion;
-bool Found;
-
-  public:
-VirtualBugVisitor(const MemRegion *R) : ObjectRegion(R), Found(false) {}
-
-void Profile(llvm::FoldingSetNodeID ) const override {
-  static int X = 0;
-  ID.AddPointer();
-  ID.AddPointer(ObjectRegion);
-}
-
-PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
- BugReporterContext ,
- BugReport ) override;
-  };
 };
 } // end namespace
 
 // GDM (generic data map) to the memregion of this for the ctor and dtor.
 REGISTER_MAP_WITH_PROGRAMSTATE(CtorDtorMap, const MemRegion *, ObjectState)
 
-PathDiagnosticPieceRef VirtualCallChecker::VirtualBugVisitor::VisitNode(
-const ExplodedNode *N, BugReporterContext , BugReport &) {
-  // We need the last ctor/dtor which call the virtual function.
-  // The visitor walks the ExplodedGraph backwards.
-  if (Found)
-return nullptr;
-
-  ProgramStateRef State = N->getState();
-  const LocationContext *LCtx = N->getLocationContext();
-  const CXXConstructorDecl *CD =
-  dyn_cast_or_null(LCtx->getDecl());
-  const CXXDestructorDecl *DD =
-  dyn_cast_or_null(LCtx->getDecl());
-
-  if (!CD && !DD)
-return nullptr;
-
-  ProgramStateManager  = State->getStateManager();
-  auto  = PSM.getSValBuilder();
-  const auto *MD = dyn_cast(LCtx->getDecl());
-  if (!MD)
-return nullptr;
-  auto ThiSVal =
-  State->getSVal(SVB.getCXXThis(MD, LCtx->getStackFrame()));
-  const MemRegion *Reg = ThiSVal.castAs().getRegion();
-  if (!Reg)
-return nullptr;
-  if (Reg != ObjectRegion)
-return nullptr;
-
-  const Stmt *S = PathDiagnosticLocation::getStmt(N);
-  if (!S)
-return nullptr;
-  Found = true;
-
-  std::string InfoText;
-  if (CD)
-InfoText = "This constructor of an object of type '" +
-   CD->getNameAsString() +
-   "' has not returned when the virtual method was called";
-  else
-InfoText = "This destructor of an object of type '" +
-   DD->getNameAsString() +
-   "' has not 

r369450 - [analyzer] Fix a crash when destroying a non-region.

2019-08-20 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Aug 20 14:41:17 2019
New Revision: 369450

URL: http://llvm.org/viewvc/llvm-project?rev=369450=rev
Log:
[analyzer] Fix a crash when destroying a non-region.

Add defensive check that prevents a crash when we try to evaluate a destructor
whose this-value is a concrete integer that isn't a null.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/test/Analysis/dtor.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=369450=369449=369450=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Tue 
Aug 20 14:41:17 2019
@@ -530,7 +530,7 @@ public:
   void VisitCXXDestructor(QualType ObjectType, const MemRegion *Dest,
   const Stmt *S, bool IsBaseDtor,
   ExplodedNode *Pred, ExplodedNodeSet ,
-  const EvalCallOptions );
+  EvalCallOptions );
 
   void VisitCXXNewAllocatorCall(const CXXNewExpr *CNE,
 ExplodedNode *Pred,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=369450=369449=369450=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Tue Aug 20 14:41:17 2019
@@ -977,8 +977,8 @@ void ExprEngine::ProcessAutomaticObjDtor
   Region = makeZeroElementRegion(state, loc::MemRegionVal(Region), varType,
  CallOpts.IsArrayCtorOrDtor).getAsRegion();
 
-  VisitCXXDestructor(varType, Region, Dtor.getTriggerStmt(), /*IsBase=*/ false,
- Pred, Dst, CallOpts);
+  VisitCXXDestructor(varType, Region, Dtor.getTriggerStmt(),
+ /*IsBase=*/false, Pred, Dst, CallOpts);
 }
 
 void ExprEngine::ProcessDeleteDtor(const CFGDeleteDtor Dtor,
@@ -1036,8 +1036,9 @@ void ExprEngine::ProcessBaseDtor(const C
   SVal BaseVal = getStoreManager().evalDerivedToBase(ThisVal, BaseTy,
  Base->isVirtual());
 
-  VisitCXXDestructor(BaseTy, BaseVal.castAs().getRegion(),
- CurDtor->getBody(), /*IsBase=*/ true, Pred, Dst, {});
+  EvalCallOptions CallOpts;
+  VisitCXXDestructor(BaseTy, BaseVal.getAsRegion(), CurDtor->getBody(),
+ /*IsBase=*/true, Pred, Dst, CallOpts);
 }
 
 void ExprEngine::ProcessMemberDtor(const CFGMemberDtor D,
@@ -1048,10 +1049,10 @@ void ExprEngine::ProcessMemberDtor(const
   const LocationContext *LCtx = Pred->getLocationContext();
 
   const auto *CurDtor = cast(LCtx->getDecl());
-  Loc ThisVal = getSValBuilder().getCXXThis(CurDtor,
-LCtx->getStackFrame());
-  SVal FieldVal =
-  State->getLValue(Member, State->getSVal(ThisVal).castAs());
+  Loc ThisStorageLoc =
+  getSValBuilder().getCXXThis(CurDtor, LCtx->getStackFrame());
+  Loc ThisLoc = State->getSVal(ThisStorageLoc).castAs();
+  SVal FieldVal = State->getLValue(Member, ThisLoc);
 
   // FIXME: We need to run the same destructor on every element of the array.
   // This workaround will just run the first destructor (which will still
@@ -1060,8 +1061,8 @@ void ExprEngine::ProcessMemberDtor(const
   FieldVal = makeZeroElementRegion(State, FieldVal, T,
CallOpts.IsArrayCtorOrDtor);
 
-  VisitCXXDestructor(T, FieldVal.castAs().getRegion(),
- CurDtor->getBody(), /*IsBase=*/false, Pred, Dst, 
CallOpts);
+  VisitCXXDestructor(T, FieldVal.getAsRegion(), CurDtor->getBody(),
+ /*IsBase=*/false, Pred, Dst, CallOpts);
 }
 
 void ExprEngine::ProcessTemporaryDtor(const CFGTemporaryDtor D,
@@ -1109,8 +1110,6 @@ void ExprEngine::ProcessTemporaryDtor(co
   EvalCallOptions CallOpts;
   CallOpts.IsTemporaryCtorOrDtor = true;
   if (!MR) {
-CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion = true;
-
 // If we have no MR, we still need to unwrap the array to avoid destroying
 // the whole array at once. Regardless, we'd eventually need to model array
 // destructors properly, element-by-element.

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp?rev=369450=369449=369450=diff

r369451 - [analyzer] NFC: Remove the BugTypes set from BugReporter.

2019-08-20 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Aug 20 14:41:20 2019
New Revision: 369451

URL: http://llvm.org/viewvc/llvm-project?rev=369451=rev
Log:
[analyzer] NFC: Remove the BugTypes set from BugReporter.

Its only purpose was to avoid a bug that's caused by
making a virtual call in BugReporter's destructor.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=369451=369450=369451=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Tue 
Aug 20 14:41:20 2019
@@ -408,11 +408,6 @@ public:
   enum Kind { BasicBRKind, PathSensitiveBRKind };
 
 private:
-  using BugTypesTy = llvm::ImmutableSet;
-
-  BugTypesTy::Factory F;
-  BugTypesTy BugTypes;
-
   const Kind kind;
   BugReporterData& D;
 
@@ -433,11 +428,10 @@ private:
 
 protected:
   BugReporter(BugReporterData& d, Kind k)
-  : BugTypes(F.getEmptySet()), kind(k), D(d) {}
+  : kind(k), D(d) {}
 
 public:
-  BugReporter(BugReporterData& d)
-  : BugTypes(F.getEmptySet()), kind(BasicBRKind), D(d) {}
+  BugReporter(BugReporterData ) : kind(BasicBRKind), D(d) {}
   virtual ~BugReporter();
 
   /// Generate and flush diagnostics for all bug reports.
@@ -453,11 +447,6 @@ public:
 return D.getPathDiagnosticConsumers();
   }
 
-  /// Iterator over the set of BugTypes tracked by the BugReporter.
-  using iterator = BugTypesTy::iterator;
-  iterator begin() { return BugTypes.begin(); }
-  iterator end() { return BugTypes.end(); }
-
   /// Iterator over the set of BugReports tracked by the BugReporter.
   using EQClasses_iterator = llvm::FoldingSet::iterator;
   EQClasses_iterator EQClasses_begin() { return EQClasses.begin(); }
@@ -475,8 +464,6 @@ public:
 return {};
   }
 
-  void Register(const BugType *BT);
-
   /// Add the given report to the set of reports tracked by BugReporter.
   ///
   /// The reports are usually generated by the checkers. Further, they are
@@ -511,8 +498,6 @@ public:
   PathSensitiveBugReporter(BugReporterData& d, ExprEngine& eng)
   : BugReporter(d, PathSensitiveBRKind), Eng(eng) {}
 
-  ~PathSensitiveBugReporter() override = default;
-
   /// getGraph - Get the exploded graph created by the analysis engine
   ///  for the analyzed method or function.
   const ExplodedGraph () const;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=369451=369450=369451=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Tue Aug 20 14:41:20 2019
@@ -2227,7 +2227,9 @@ ProgramStateManager 
 }
 
 BugReporter::~BugReporter() {
-  FlushReports();
+  // Make sure reports are flushed.
+  assert(StrBugTypes.empty() &&
+ "Destroying BugReporter before diagnostics are emitted!");
 
   // Free the bug reports we are tracking.
   for (const auto I : EQClassesVector)
@@ -2235,9 +2237,6 @@ BugReporter::~BugReporter() {
 }
 
 void BugReporter::FlushReports() {
-  if (BugTypes.isEmpty())
-return;
-
   // We need to flush reports in deterministic order to ensure the order
   // of the reports is consistent between runs.
   for (const auto EQ : EQClassesVector)
@@ -2248,9 +2247,6 @@ void BugReporter::FlushReports() {
   // FIXME: There are leaks from checkers that assume that the BugTypes they
   // create will be destroyed by the BugReporter.
   llvm::DeleteContainerSeconds(StrBugTypes);
-
-  // Remove all references to the BugType objects.
-  BugTypes = F.getEmptySet();
 }
 
 
//===--===//
@@ -2668,10 +2664,6 @@ PathSensitiveBugReporter::generatePathDi
   return Out;
 }
 
-void BugReporter::Register(const BugType *BT) {
-  BugTypes = F.add(BugTypes, BT);
-}
-
 void BugReporter::emitReport(std::unique_ptr R) {
   if (const ExplodedNode *E = R->getErrorNode()) {
 // An error node must either be a sink or have a tag, otherwise
@@ -2702,8 +2694,6 @@ void BugReporter::emitReport(std::unique
   R->Profile(ID);
 
   // Lookup the equivance class.  If there isn't one, create it.
-  const BugType& BT = R->getBugType();
-  Register();
   void *InsertPos;
   BugReportEquivClass* EQ = EQClasses.FindNodeOrInsertPos(ID, InsertPos);
 

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: 

r369449 - [analyzer] Improve VirtualCallChecker and enable parts of it by default.

2019-08-20 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Aug 20 14:41:14 2019
New Revision: 369449

URL: http://llvm.org/viewvc/llvm-project?rev=369449=rev
Log:
[analyzer] Improve VirtualCallChecker and enable parts of it by default.

Calling a pure virtual method during construction or destruction
is undefined behavior. It's worth it to warn about it by default.
That part is now known as the cplusplus.PureVirtualCall checker.

Calling a normal virtual method during construction or destruction
may be fine, but does behave unexpectedly, as it skips virtual dispatch.
Do not warn about this by default, but let projects opt in into it
by enabling the optin.cplusplus.VirtualCall checker manually.

Give the two parts differentiated warning text:

  Before:

Call to virtual function during construction or destruction:
Call to pure virtual function during construction

Call to virtual function during construction or destruction:
Call to virtual function during destruction

  After:

Pure virtual method call:
Call to pure virtual method 'X::foo' during construction
has undefined behavior

Unexpected loss of virtual dispatch:
Call to virtual method 'Y::bar' during construction
bypasses virtual dispatch

Also fix checker names in consumers that support them (eg., clang-tidy)
because we now have different checker names for pure virtual calls and
regular virtual calls.

Also fix capitalization in the bug category.

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

Added:
cfe/trunk/test/Analysis/virtualcall-plist.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td

cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
cfe/trunk/test/Analysis/virtualcall.cpp
cfe/trunk/test/Analysis/virtualcall.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=369449=369448=369449=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Tue Aug 20 
14:41:14 2019
@@ -504,6 +504,15 @@ def MoveChecker: Checker<"Move">,
   ]>,
   Documentation;
 
+def VirtualCallModeling : Checker<"VirtualCallModeling">,
+  HelpText<"Auxiliary modeling for the virtual method call checkers">,
+  Documentation,
+  Hidden;
+
+def PureVirtualCallChecker : Checker<"PureVirtualCall">,
+  HelpText<"Check pure virtual function calls during 
construction/destruction">,
+  Dependencies<[VirtualCallModeling]>,
+  Documentation;
 } // end: "cplusplus"
 
 let ParentPackage = CplusplusOptIn in {
@@ -552,14 +561,17 @@ def UninitializedObjectChecker: Checker<
   Documentation;
 
 def VirtualCallChecker : Checker<"VirtualCall">,
-  HelpText<"Check virtual function calls during construction or destruction">,
+  HelpText<"Check virtual function calls during construction/destruction">,
   CheckerOptions<[
 CmdLineOption
+  InAlpha>
   ]>,
+  Dependencies<[VirtualCallModeling]>,
   Documentation;
 
 } // end: "optin.cplusplus"

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h?rev=369449=369448=369449=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h 
Tue Aug 20 14:41:14 2019
@@ -18,6 +18,7 @@ namespace clang {
   extern const char * const MemoryRefCount;
   extern const char * const MemoryError;
   extern const char * const UnixAPI;
+  extern const char * const CXXObjectLifecycle;
 }
   }
 }

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h?rev=369449=369448=369449=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h Tue Aug 20 
14:41:14 2019
@@ -105,6 +105,7 @@ public:
   CheckName() = default;
 
   StringRef getName() const { return Name; }
+  operator StringRef() const { return Name; }
 };
 
 enum class ObjCMessageVisitKind {

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
URL: 

[PATCH] D66486: [LifetimeAnalysis] Detect more cases when the address of a local variable escapes

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

In D66486#1638213 , @mgehre wrote:

> This change might be the cause for the false-positive in 
> https://github.com/mgehre/llvm-project/issues/45. Could you check?


Sure, looking into it! Thanks for pointing this out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66486



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


[PATCH] D66486: [LifetimeAnalysis] Detect more cases when the address of a local variable escapes

2019-08-20 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added a comment.

This change might be the cause for the false-positive in 
https://github.com/mgehre/llvm-project/issues/45. Could you check?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66486



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


[PATCH] D66325: [analyzer] CastValueChecker: Store the dynamic types and casts

2019-08-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 216250.
Charusso added a comment.

- Added a new test case and refactored that test file.


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

https://reviews.llvm.org/D66325

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicCastInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/DynamicType.cpp
  clang/lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/test/Analysis/Inputs/llvm.h
  clang/test/Analysis/cast-value-logic.cpp
  clang/test/Analysis/cast-value-notes.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cast-value.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Analysis/expr-inspection.c

Index: clang/test/Analysis/expr-inspection.c
===
--- clang/test/Analysis/expr-inspection.c
+++ clang/test/Analysis/expr-inspection.c
@@ -38,6 +38,7 @@
 // CHECK-NEXT: { "symbol": "reg_$0", "range": "{ [-2147483648, 13] }" }
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "dynamic_types": null,
+// CHECK-NEXT:   "dynamic_casts": null,
 // CHECK-NEXT:   "constructing_objects": null,
 // CHECK-NEXT:   "checker_messages": null
 // CHECK-NEXT: }
Index: clang/test/Analysis/dump_egraph.cpp
===
--- clang/test/Analysis/dump_egraph.cpp
+++ clang/test/Analysis/dump_egraph.cpp
@@ -24,4 +24,5 @@
 
 // CHECK: \"cluster\": \"t\", \"pointer\": \"{{0x[0-9a-f]+}}\", \"items\": [\l\{ \"kind\": \"Default\", \"offset\": 0, \"value\": \"conj_$2\{int, LC5, no stmt, #1\}\"
 
-// CHECK: \"dynamic_types\": [\l\{ \"region\": \"HeapSymRegion\{conj_$1\{struct S *, LC1, S{{[0-9]+}}, #1\}\}\", \"dyn_type\": \"struct S\", \"sub_classable\": false\}\l
+// CHECK: \"dynamic_types\": [\l\{ \"region\": \"HeapSymRegion\{conj_$1\{struct S *, LC1, S{{[0-9]+}}, #1\}\}\", \"dyn_type\": \"struct S\", \"sub_classable\": false \}\l
+
Index: clang/test/Analysis/cast-value.cpp
===
--- clang/test/Analysis/cast-value.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-// RUN: %clang_analyze_cc1 \
-// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
-// RUN:  -verify=logic %s
-// RUN: %clang_analyze_cc1 \
-// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue \
-// RUN:  -analyzer-output=text -verify %s
-
-void clang_analyzer_numTimesReached();
-void clang_analyzer_warnIfReached();
-void clang_analyzer_eval(bool);
-
-namespace llvm {
-template 
-const X *cast(Y Value);
-
-template 
-const X *dyn_cast(Y *Value);
-template 
-const X _cast(Y );
-
-template 
-const X *cast_or_null(Y Value);
-
-template 
-const X *dyn_cast_or_null(Y *Value);
-template 
-const X *dyn_cast_or_null(Y );
-} // namespace llvm
-
-namespace clang {
-struct Shape {
-  template 
-  const T *castAs() const;
-
-  template 
-  const T *getAs() const;
-};
-class Triangle : public Shape {};
-class Circle : public Shape {};
-} // namespace clang
-
-using namespace llvm;
-using namespace clang;
-
-namespace test_cast {
-void evalLogic(const Shape *S) {
-  const Circle *C = cast(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{1}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // no-warning
-
-  if (!S)
-clang_analyzer_warnIfReached(); // no-warning
-}
-} // namespace test_cast
-
-namespace test_dyn_cast {
-void evalLogic(const Shape *S) {
-  const Circle *C = dyn_cast(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{2}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // logic-warning {{REACHABLE}}
-
-  if (!S)
-clang_analyzer_warnIfReached(); // no-warning
-}
-} // namespace test_dyn_cast
-
-namespace test_cast_or_null {
-void evalLogic(const Shape *S) {
-  const Circle *C = cast_or_null(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{2}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // no-warning
-
-  if (!S)
-clang_analyzer_eval(!C); // logic-warning {{TRUE}}
-}
-} // namespace test_cast_or_null
-
-namespace test_dyn_cast_or_null {
-void evalLogic(const Shape *S) {
-  const Circle *C = dyn_cast_or_null(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{3}}
-
-  if (S && C)

[PATCH] D66325: [analyzer] CastValueChecker: Store the dynamic types and casts

2019-08-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Something went wrong with message generation, can you take a look?




Comment at: clang/test/Analysis/cast-value-notes.cpp:24
+  const auto  = dyn_cast(S);
+  // expected-note@-1 {{Assuming 'S' is a 'Circle', not a 'Shape'}}
+  // expected-note@-2 {{Dereference of null pointer}}

A circle is always a shape.

`Assuming 'S' is a 'Shape' that is not a 'Circle'` sounds about right.

Or just `Assuming 'S' is not a 'Circle'`.



Comment at: clang/test/Analysis/cast-value-notes.cpp:34
+  if (dyn_cast_or_null(C)) {
+// no-note: 'Assuming 'C' is a 'Circle', not a 'Circle''
+return;

A circle is always a circle.



Comment at: clang/test/Analysis/cast-value-notes.cpp:55
+  if (dyn_cast_or_null(C)) {
+// expected-note@-1 {{Assuming 'C' is a 'Triangle', not a 'Circle'}}
+// expected-note@-2 {{Taking false branch}}

The `not a 'Circle'` part is suspiciously specific.


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

https://reviews.llvm.org/D66325



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


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-08-20 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a comment.

In D64943#1633164 , @ABataev wrote:

> In D64943#1619958 , @sdmitriev wrote:
>
> > As I understand ‘atexit’ solution would be target dependent (‘__cxa_atexit’ 
> > on Linux and ‘atexit’ on Windows) whereas @llvm.global_ctors/dtors 
> > variables offer similar and platform neutral functionality 
> > (http://llvm.org/docs/LangRef.html#the-llvm-global-ctors-global-variable). 
> > Why do you think that ‘atexit’ is a better choice?
>
>
> Because it does not work on Windows, better to have portable solution, if 
> possible.


@vzakhari has already committed his fix for llvm.global_dtors 
(https://reviews.llvm.org/D66373), so I assume use of llvm.global_dtors in this 
patch would no longer cause problems on Windows.


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

https://reviews.llvm.org/D64943



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


[PATCH] D66179: [LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)

2019-08-20 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 216247.
mgehre marked 6 inline comments as done.
mgehre added a comment.
Herald added a subscriber: mgorny.

- Put OwnerAttr/PointerAttr on all redeclarations
- clang/lib/Sema/SemaAttr.cpp: Use Attribute::CreateImplicit as requested in 
review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66179

Files:
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
  clang/test/SemaCXX/attr-gsl-owner-pointer.cpp
  clang/unittests/Sema/CMakeLists.txt
  clang/unittests/Sema/GslOwnerPointerInference.cpp

Index: clang/unittests/Sema/GslOwnerPointerInference.cpp
===
--- /dev/null
+++ clang/unittests/Sema/GslOwnerPointerInference.cpp
@@ -0,0 +1,61 @@
+//== unittests/Sema/GslOwnerPointerInference.cpp - gsl::Owner/Pointer //
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "../ASTMatchers/ASTMatchersTest.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+using namespace ast_matchers;
+
+TEST(OwnerPointer, BothHaveAttributes) {
+  EXPECT_TRUE(matches(
+R"cpp(
+  template
+  class [[gsl::Owner]] C;
+
+  template
+  class [[gsl::Owner]] C {};
+
+  C c;
+  )cpp",
+classTemplateSpecializationDecl(hasName("C"), hasAttr(clang::attr::Owner;
+}
+
+TEST(OwnerPointer, ForwardDeclOnly) {
+  EXPECT_TRUE(matches(
+R"cpp(
+  template
+  class [[gsl::Owner]] C;
+
+  template
+  class C {};
+
+  C c;
+  )cpp",
+classTemplateSpecializationDecl(hasName("C"), hasAttr(clang::attr::Owner;
+}
+
+TEST(OwnerPointer, LateForwardDeclOnly) {
+  EXPECT_TRUE(matches(
+R"cpp(
+  template
+  class C;
+
+  template
+  class C {};
+
+  template
+  class [[gsl::Owner]] C;
+
+  C c;
+  )cpp",
+classTemplateSpecializationDecl(hasName("C"), hasAttr(clang::attr::Owner;
+}
+
+} // namespace clang
Index: clang/unittests/Sema/CMakeLists.txt
===
--- clang/unittests/Sema/CMakeLists.txt
+++ clang/unittests/Sema/CMakeLists.txt
@@ -5,11 +5,13 @@
 add_clang_unittest(SemaTests
   ExternalSemaSourceTest.cpp
   CodeCompleteTest.cpp
+  GslOwnerPointerInference.cpp
   )
 
 clang_target_link_libraries(SemaTests
   PRIVATE
   clangAST
+  clangASTMatchers
   clangBasic
   clangFrontend
   clangParse
Index: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp
===
--- clang/test/SemaCXX/attr-gsl-owner-pointer.cpp
+++ clang/test/SemaCXX/attr-gsl-owner-pointer.cpp
@@ -105,3 +105,20 @@
 class [[gsl::Owner(int)]] AddTheSameLater;
 // CHECK: CXXRecordDecl {{.*}} prev {{.*}} AddTheSameLater
 // CHECK: OwnerAttr {{.*}} int
+
+template 
+class [[gsl::Owner]] ForwardDeclared;
+// CHECK: ClassTemplateDecl {{.*}} ForwardDeclared
+// CHECK: OwnerAttr {{.*}}
+// CHECK: ClassTemplateSpecializationDecl {{.*}} ForwardDeclared
+// CHECK: TemplateArgument type 'int'
+// CHECK: OwnerAttr {{.*}}
+
+template 
+class [[gsl::Owner]] ForwardDeclared {
+// CHECK: ClassTemplateDecl {{.*}} ForwardDeclared
+// CHECK: CXXRecordDecl {{.*}} ForwardDeclared definition
+// CHECK: OwnerAttr {{.*}}
+};
+
+static_assert(sizeof(ForwardDeclared), ""); // Force instantiation.
Index: clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
===
--- clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
+++ clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp
@@ -92,6 +92,59 @@
 static_assert(sizeof(unordered_map::iterator), ""); // Force instantiation.
 } // namespace inlinens
 
+// The iterator typedef is a DependentNameType.
+template 
+class __unordered_multimap_iterator {};
+// CHECK: ClassTemplateDecl {{.*}} __unordered_multimap_iterator
+// CHECK: ClassTemplateSpecializationDecl {{.*}} __unordered_multimap_iterator
+// CHECK: TemplateArgument type 'int'
+// CHECK: PointerAttr
+
+template 
+class __unordered_multimap_base {
+public:
+  using iterator = __unordered_multimap_iterator;
+};
+
+template 
+class unordered_multimap {
+  // CHECK: ClassTemplateDecl {{.*}} unordered_multimap
+  // CHECK: OwnerAttr {{.*}}
+  // CHECK: ClassTemplateSpecializationDecl {{.*}} unordered_multimap
+  // CHECK: OwnerAttr {{.*}}
+public:
+  using _Mybase = __unordered_multimap_base;
+  using iterator = typename _Mybase::iterator;
+};
+static_assert(sizeof(unordered_multimap::iterator), ""); // Force instantiation.
+
+// The canonical 

[PATCH] D66179: [LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)

2019-08-20 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added a comment.

I now add the attributes to all redeclarations to make the logic a bit easier 
to follow.




Comment at: clang/lib/Sema/SemaAttr.cpp:94
 
-  Canonical->addAttr(::new (Context) Attribute(SourceRange{}, Context,
-   /*DerefType*/ nullptr,
-   /*Spelling=*/0));
+  Record->addAttr(::new (Context) Attribute(SourceRange{}, Context,
+/*DerefType*/ nullptr,

xazax.hun wrote:
> Doesn't the attribute have a `CreateImplicit` static method? If so, we could 
> use that :)
Nice, didn't know that!



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer-std.cpp:95
 
+// The iterator typedef is a DependentNameType.
+template 

gribozavr wrote:
> mgehre wrote:
> > gribozavr wrote:
> > > This test file is getting pretty long and subtle, with lots of things are 
> > > being mixed into one file without isolation.
> > > 
> > > WDYT about refactoring it into a unit test that uses AST matchers to 
> > > verify attribute presence?
> > > 
> > > See clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp for examples.
> > > 
> > > Each test case would look approximately like this:
> > > 
> > > ```
> > > EXPECT_TRUE(matches(
> > >   "template class ...",
> > >   classTemplateDecl(hasName("foo"), hasAttr(clang::attr::GslPointer)));
> > > ```
> > > 
> > > Each test case would be isolated from other tests, each test would have a 
> > > name (and optionally a comment) that will make it obvious what exactly is 
> > > being tested.
> > > 
> > > It would be also possible to verify things like "The iterator typedef is 
> > > a DependentNameType" to ensure that we're testing exactly what we want to 
> > > test.
> > I like the AST matcher approach! This test file is really hard to debug - I 
> > usually copy a test to its own file for debugging. 
> > Would you be okay with deferring the testing change to the next PR?
> Of course! Thanks!
I added the some tests for this particular change to a new unittest and will 
migrate the rest of the tests later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66179



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


[PATCH] D66325: [analyzer] CastValueChecker: Store the dynamic types and casts

2019-08-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 216246.
Charusso marked 15 inline comments as done.
Charusso added a comment.
Herald added a subscriber: mgorny.

- Fix.


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

https://reviews.llvm.org/D66325

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicCastInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/DynamicType.cpp
  clang/lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/test/Analysis/Inputs/llvm.h
  clang/test/Analysis/cast-value-logic.cpp
  clang/test/Analysis/cast-value-notes.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cast-value.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Analysis/expr-inspection.c

Index: clang/test/Analysis/expr-inspection.c
===
--- clang/test/Analysis/expr-inspection.c
+++ clang/test/Analysis/expr-inspection.c
@@ -38,6 +38,7 @@
 // CHECK-NEXT: { "symbol": "reg_$0", "range": "{ [-2147483648, 13] }" }
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "dynamic_types": null,
+// CHECK-NEXT:   "dynamic_casts": null,
 // CHECK-NEXT:   "constructing_objects": null,
 // CHECK-NEXT:   "checker_messages": null
 // CHECK-NEXT: }
Index: clang/test/Analysis/dump_egraph.cpp
===
--- clang/test/Analysis/dump_egraph.cpp
+++ clang/test/Analysis/dump_egraph.cpp
@@ -24,4 +24,5 @@
 
 // CHECK: \"cluster\": \"t\", \"pointer\": \"{{0x[0-9a-f]+}}\", \"items\": [\l\{ \"kind\": \"Default\", \"offset\": 0, \"value\": \"conj_$2\{int, LC5, no stmt, #1\}\"
 
-// CHECK: \"dynamic_types\": [\l\{ \"region\": \"HeapSymRegion\{conj_$1\{struct S *, LC1, S{{[0-9]+}}, #1\}\}\", \"dyn_type\": \"struct S\", \"sub_classable\": false\}\l
+// CHECK: \"dynamic_types\": [\l\{ \"region\": \"HeapSymRegion\{conj_$1\{struct S *, LC1, S{{[0-9]+}}, #1\}\}\", \"dyn_type\": \"struct S\", \"sub_classable\": false \}\l
+
Index: clang/test/Analysis/cast-value.cpp
===
--- clang/test/Analysis/cast-value.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-// RUN: %clang_analyze_cc1 \
-// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
-// RUN:  -verify=logic %s
-// RUN: %clang_analyze_cc1 \
-// RUN:  -analyzer-checker=core,apiModeling.llvm.CastValue \
-// RUN:  -analyzer-output=text -verify %s
-
-void clang_analyzer_numTimesReached();
-void clang_analyzer_warnIfReached();
-void clang_analyzer_eval(bool);
-
-namespace llvm {
-template 
-const X *cast(Y Value);
-
-template 
-const X *dyn_cast(Y *Value);
-template 
-const X _cast(Y );
-
-template 
-const X *cast_or_null(Y Value);
-
-template 
-const X *dyn_cast_or_null(Y *Value);
-template 
-const X *dyn_cast_or_null(Y );
-} // namespace llvm
-
-namespace clang {
-struct Shape {
-  template 
-  const T *castAs() const;
-
-  template 
-  const T *getAs() const;
-};
-class Triangle : public Shape {};
-class Circle : public Shape {};
-} // namespace clang
-
-using namespace llvm;
-using namespace clang;
-
-namespace test_cast {
-void evalLogic(const Shape *S) {
-  const Circle *C = cast(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{1}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // no-warning
-
-  if (!S)
-clang_analyzer_warnIfReached(); // no-warning
-}
-} // namespace test_cast
-
-namespace test_dyn_cast {
-void evalLogic(const Shape *S) {
-  const Circle *C = dyn_cast(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{2}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // logic-warning {{REACHABLE}}
-
-  if (!S)
-clang_analyzer_warnIfReached(); // no-warning
-}
-} // namespace test_dyn_cast
-
-namespace test_cast_or_null {
-void evalLogic(const Shape *S) {
-  const Circle *C = cast_or_null(S);
-  clang_analyzer_numTimesReached(); // logic-warning {{2}}
-
-  if (S && C)
-clang_analyzer_eval(C == S); // logic-warning {{TRUE}}
-
-  if (S && !C)
-clang_analyzer_warnIfReached(); // no-warning
-
-  if (!S)
-clang_analyzer_eval(!C); // logic-warning {{TRUE}}
-}
-} // namespace test_cast_or_null
-
-namespace test_dyn_cast_or_null {
-void evalLogic(const Shape *S) {
-  const Circle *C = dyn_cast_or_null(S);
-  clang_analyzer_numTimesReached(); // 

[PATCH] D66423: [analyzer] CastValueChecker: Model isa(), isa_and_nonnull()

2019-08-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked 9 inline comments as done.
Charusso added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp:216
+  const NoteTag *Tag = C.getNoteTag(
+  [=](BugReport &) -> std::string {
+SmallString<128> Msg;

NoQ wrote:
> Can you use the overload without the bug report parameter? Cause you don't 
> seem to be using it anyway.
I think you have forgotten to implement that scenario, but now we have that as 
well since D66325.



Comment at: clang/test/Analysis/cast-value-notes.cpp:5-27
 namespace llvm {
 template 
 const X *cast(Y Value);
 
 template 
 const X *dyn_cast(Y *Value);
 template 

NoQ wrote:
> Szelethus wrote:
> > Hmm, we may want to move these eventually to `clang/test/Inputs/`, since 
> > this isn't the only LLVM checker. Thought that said, I want to see the 
> > other LLVM checker gone, like, purged from the codebase for being the 
> > abomination that it is.
> > 
> > Feel free to leave these here for know, just thinking aloud :)
> I agree, extracting common definitions into a system header simulator usually 
> ends up being worth it pretty quickly.
Thanks for the idea! Moved in D66325.



Comment at: clang/test/Analysis/cast-value-notes.cpp:111
+  if (isa(C)) {
+// expected-note@-1 {{Assuming 'C' with type 'Circle' is not the instance 
of 'Triangle'}}
+// expected-note@-2 {{Taking false branch}}

NoQ wrote:
> This test looks incorrect. We shouldn't be assuming this, we already know 
> that it's not a triangle because we know that it's a circle.
Let us discuss in D66325.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66423



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


[PATCH] D66490: [NewPM] Enable the New Pass Manager by Default in Clang

2019-08-20 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

We already know that we don't want this enabled for tsan builds due to 
https://bugs.llvm.org/show_bug.cgi?id=42877, but I don't even know if anyone 
else will hit it (it's only when building one particular library).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66490



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


[PATCH] D66460: [analyzer] Remove BugReporter.BugTypes.

2019-08-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

LG!


Repository:
  rC Clang

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

https://reviews.llvm.org/D66460



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


[PATCH] D63648: [Preprocessor] Honor absolute paths in diagnostics

2019-08-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D63648#1593619 , @thakis wrote:

> - Does fastbuild have something like distcc-pump?


Fastbuild works like plain distcc and unfortunately it does not have pump mode.

> - IIRC we used to use fdiagnostics-absolute-paths in Chromium but eventually 
> stopped because someone figured out how to make MSVC's jump-to-diag work even 
> with relative paths (?)

Let me know if you find out what was your solution ;) Otherwise we could 
absolutize paths in Fastbuild.

While I think we will go the relative paths route -  do you think the changes 
in this patch related to `--show-includes` and `note:` make sense? Could 
`-fdiagnostics-absolute-paths` affect `--show-includes` as well? I am just 
wondering. Otherwise I'll drop the patch.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63648



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


[PATCH] D66473: [analyzer] Removed some dead code in BugReporter and related files

2019-08-20 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr marked an inline comment as done.
gribozavr added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:408
-public:
-  enum Kind { BasicBRKind, PathSensitiveBRKind };
-

NoQ wrote:
> gribozavr wrote:
> > NoQ wrote:
> > > Hey, i just added that! :D (well, renamed) (rC369320)
> > > 
> > > I believe we do want a separation between a {bug report, bug reporter} 
> > > classes that's only suitable for path-insensitive reports (which would 
> > > live in libAnalysis and we could handle them to clang-tidy while still 
> > > being able to compile it without CLANG_ENABLE_STATIC_ANALYZER) and all 
> > > the path-sensitive report logic that is pretty huge but only Static 
> > > Analyzer needs it. For that purpose we'd better leave this in. WDYT? See 
> > > also D66460.
> > > 
> > > Should i ask on the mailing list whether you're willing to sacrifice 
> > > building clang-tidy without CLANG_ENABLE_STATIC_ANALYZER in order to 
> > > transition to BugReporter? Cause i thought it was obvious that it's not a 
> > > great idea, even if it causes me to do a bit of cleanup work on my end.
> > > 
> > > That said, i'm surprised that it's deadcode, i.e. that nobody ever 
> > > dyn_casts bug reporters, even though we already have two bug reporter 
> > > classes. Maybe we can indeed remove this facility.
> > > I believe we do want a separation between a {bug report, bug reporter} 
> > > classes [...]
> > 
> > Yes, the separation is nice.
> > 
> > > For that purpose we'd better leave this in.
> > 
> > `Kind` is only needed for dynamic casting between different bug reporters. 
> > I'm not sure that is useful in practice (case in point -- the `classof` is 
> > not used today), specifically because the client that produces diagnostics 
> > will need to work with a bug reporter of the correct kind. If a 
> > path-sensitive client is handed a pointer to the base class, `BugReporter`, 
> > would it try to `dyn_cast` it to the derived class?.. what if it fails?..
> > 
> > Basically, I don't understand why one would want dynamic casting for these 
> > classes. I totally agree with the separation though.
> > 
> > > Should i ask on the mailing list whether you're willing to sacrifice 
> > > building clang-tidy without CLANG_ENABLE_STATIC_ANALYZER in order to 
> > > transition to BugReporter?
> > 
> > I personally don't mind CLANG_ENABLE_STATIC_ANALYZER going away completely 
> > (I have a fast machine and use a build system with strong caching), 
> > however, there are other people who are a lot more sensitive to build time, 
> > and for whom it might be important.
> > I personally don't mind CLANG_ENABLE_STATIC_ANALYZER going away completely 
> > (I have a fast machine and use a build system with strong caching), 
> > however, there are other people who are a lot more sensitive to build time, 
> > and for whom it might be important.
> 
> I think for clang it's mostly about binary size; people occasionally want 
> compact clangs.
> 
> > I'm not sure that is useful in practice (case in point -- the classof is 
> > not used today), specifically because the client that produces diagnostics 
> > will need to work with a bug reporter of the correct kind.
> 
> Yeah, i agree. I'll add it back if i ever need it.
> 
> I think for clang it's mostly about binary size; people occasionally want 
> compact clangs.

That's true -- some people also want to have a small clang binary; however you 
asked about clang-tidy without CLANG_ENABLE_STATIC_ANALYZER :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66473



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


[PATCH] D66493: [NewPM] Run ubsan-coroutines test under the legacy pass manager only

2019-08-20 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369442: [NewPM] Run ubsan-coroutines test under the legacy 
pass manager only (authored by leonardchan, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66493?vs=216230=216242#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66493

Files:
  cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp


Index: cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp
===
--- cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp
+++ cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp
@@ -1,6 +1,8 @@
 // This test merely verifies that emitting the object file does not cause a
 // crash when the LLVM coroutines passes are run.
-// RUN: %clang_cc1 -emit-obj -std=c++2a -fsanitize=null %s -o %t.o
+// PR42867: Disable this test for the new PM since the passes that lower the
+// llvm.coro.* intrinsics have not yet been ported.
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -emit-obj -std=c++2a 
-fsanitize=null %s -o %t.o
 
 namespace std::experimental {
 template  struct coroutine_traits {


Index: cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp
===
--- cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp
+++ cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp
@@ -1,6 +1,8 @@
 // This test merely verifies that emitting the object file does not cause a
 // crash when the LLVM coroutines passes are run.
-// RUN: %clang_cc1 -emit-obj -std=c++2a -fsanitize=null %s -o %t.o
+// PR42867: Disable this test for the new PM since the passes that lower the
+// llvm.coro.* intrinsics have not yet been ported.
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -emit-obj -std=c++2a -fsanitize=null %s -o %t.o
 
 namespace std::experimental {
 template  struct coroutine_traits {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369442 - [NewPM] Run ubsan-coroutines test under the legacy pass manager only

2019-08-20 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Tue Aug 20 13:55:36 2019
New Revision: 369442

URL: http://llvm.org/viewvc/llvm-project?rev=369442=rev
Log:
[NewPM] Run ubsan-coroutines test under the legacy pass manager only

The passes that lower the llvm.coro.* instrinsics have not yet been ported,
so only run under the legacy PM for now.

See https://bugs.llvm.org/show_bug.cgi?id=42867

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

Modified:
cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp

Modified: cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp?rev=369442=369441=369442=diff
==
--- cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp Tue Aug 20 13:55:36 2019
@@ -1,6 +1,8 @@
 // This test merely verifies that emitting the object file does not cause a
 // crash when the LLVM coroutines passes are run.
-// RUN: %clang_cc1 -emit-obj -std=c++2a -fsanitize=null %s -o %t.o
+// PR42867: Disable this test for the new PM since the passes that lower the
+// llvm.coro.* intrinsics have not yet been ported.
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -emit-obj -std=c++2a 
-fsanitize=null %s -o %t.o
 
 namespace std::experimental {
 template  struct coroutine_traits {


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


[PATCH] D66493: [NewPM] Run ubsan-coroutines test under the legacy pass manager only

2019-08-20 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks, lgtm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66493



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


[PATCH] D66473: [analyzer] Removed some dead code in BugReporter and related files

2019-08-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:408
-public:
-  enum Kind { BasicBRKind, PathSensitiveBRKind };
-

gribozavr wrote:
> NoQ wrote:
> > Hey, i just added that! :D (well, renamed) (rC369320)
> > 
> > I believe we do want a separation between a {bug report, bug reporter} 
> > classes that's only suitable for path-insensitive reports (which would live 
> > in libAnalysis and we could handle them to clang-tidy while still being 
> > able to compile it without CLANG_ENABLE_STATIC_ANALYZER) and all the 
> > path-sensitive report logic that is pretty huge but only Static Analyzer 
> > needs it. For that purpose we'd better leave this in. WDYT? See also D66460.
> > 
> > Should i ask on the mailing list whether you're willing to sacrifice 
> > building clang-tidy without CLANG_ENABLE_STATIC_ANALYZER in order to 
> > transition to BugReporter? Cause i thought it was obvious that it's not a 
> > great idea, even if it causes me to do a bit of cleanup work on my end.
> > 
> > That said, i'm surprised that it's deadcode, i.e. that nobody ever 
> > dyn_casts bug reporters, even though we already have two bug reporter 
> > classes. Maybe we can indeed remove this facility.
> > I believe we do want a separation between a {bug report, bug reporter} 
> > classes [...]
> 
> Yes, the separation is nice.
> 
> > For that purpose we'd better leave this in.
> 
> `Kind` is only needed for dynamic casting between different bug reporters. 
> I'm not sure that is useful in practice (case in point -- the `classof` is 
> not used today), specifically because the client that produces diagnostics 
> will need to work with a bug reporter of the correct kind. If a 
> path-sensitive client is handed a pointer to the base class, `BugReporter`, 
> would it try to `dyn_cast` it to the derived class?.. what if it fails?..
> 
> Basically, I don't understand why one would want dynamic casting for these 
> classes. I totally agree with the separation though.
> 
> > Should i ask on the mailing list whether you're willing to sacrifice 
> > building clang-tidy without CLANG_ENABLE_STATIC_ANALYZER in order to 
> > transition to BugReporter?
> 
> I personally don't mind CLANG_ENABLE_STATIC_ANALYZER going away completely (I 
> have a fast machine and use a build system with strong caching), however, 
> there are other people who are a lot more sensitive to build time, and for 
> whom it might be important.
> I personally don't mind CLANG_ENABLE_STATIC_ANALYZER going away completely (I 
> have a fast machine and use a build system with strong caching), however, 
> there are other people who are a lot more sensitive to build time, and for 
> whom it might be important.

I think for clang it's mostly about binary size; people occasionally want 
compact clangs.

> I'm not sure that is useful in practice (case in point -- the classof is not 
> used today), specifically because the client that produces diagnostics will 
> need to work with a bug reporter of the correct kind.

Yeah, i agree. I'll add it back if i ever need it.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66473



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


[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 216233.
aganea marked 2 inline comments as done.

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

https://reviews.llvm.org/D66328

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGenCXX/debug-info-atexit-stub.cpp
  test/CodeGenCXX/debug-info-global-ctor-dtor.cpp


Index: test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
===
--- test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
+++ test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
@@ -30,24 +30,24 @@
 template A FooTpl::sdm_tpl;
 
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init",{{.*}} line: 
15,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}} line: 15,{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}}: DISPFlagLocalToUnit 
| DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init.1",{{.*}} line: 
16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 
16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}} line: 16,{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} line: 
19,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}}: 
DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-KEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'glob'",{{.*}} 
line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'glob'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} 
line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 
16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'stat'",{{.*}} line: 19,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'array'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'stat'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 
 // MSVC does weird stuff when templates are involved, so we don't match 
exactly,
 // but these names are reasonable.
 // FIXME: These should not be marked DISPFlagLocalToUnit.
 // CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic initializer for 
'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor 
for 'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | 
DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor 
for 'sdm_tpl'",{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
Index: test/CodeGenCXX/debug-info-atexit-stub.cpp
===
--- test/CodeGenCXX/debug-info-atexit-stub.cpp
+++ test/CodeGenCXX/debug-info-atexit-stub.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-windows-msvc -gcodeview 
-debug-info-kind=limited -o - | FileCheck %s
+
+struct a {
+  ~a();
+};
+template  struct c : a {
+  c(void (b::*)());
+};
+struct B {
+  virtual void e();
+};
+c *d() { static c f(::e); return  }
+
+// CHECK: define internal void @"??__Ff@?1??d@@YAPEAU?$c@UBXZ@YAXXZ"()
+// CHECK-SAME: !dbg ![[SUBPROGRAM:[0-9]+]] {
+// CHECK: call void @"??1?$c@UBQEAA@XZ"(%struct.c* 
@"?f@?1??d@@YAPEAU?$c@UBXZ@4U2@A"), !dbg ![[LOCATION:[0-9]+]]
+// CHECK-NEXT: ret void, !dbg ![[LOCATION]]
+// CHECK: ![[SUBPROGRAM]] = distinct !DISubprogram(name: "`dynamic atexit 
destructor for 'f'"
+// CHECK-SAME: flags: DIFlagArtificial
+// CHECK: ![[LOCATION]] = !DILocation(line: 0, scope: ![[SUBPROGRAM]])
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -247,6 +247,8 @@
 
   CGF.StartFunction(GlobalDecl(, DynamicInitKind::AtExit),
 CGM.getContext().VoidTy, fn, FI, FunctionArgList());
+  // 

[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

2019-08-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: test/CodeGenCXX/debug-info-atexit-stub.cpp:14
+
+// CHECK: define internal void @"??__Ff@?1??d@@YAPEAU?$c@UBXZ@YAXXZ"()
+// CHECK-SAME: !dbg ![[SUBPROGRAM:[0-9]+]] {

probinson wrote:
> Do these Windows-mangled names work on Linux?
Ensure Microsoft mangling is always used.


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

https://reviews.llvm.org/D66328



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


[PATCH] D62899: [analyzer][UninitializedObjectChecker] Mark uninitialized regions as interesting.

2019-08-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D62899#1634657 , @Szelethus wrote:

> In D62899#1551312 , @NoQ wrote:
>
> > In D62899#1549715 , @Szelethus 
> > wrote:
> >
> > > Added a proper testfile. The only downside of it is that it doesn't test 
> > > anything.
> >
> >
> > Use creduce!
>
>
> I would, but I'm not even sure what to look for, really.


When you already have code and have a real-world example that it works but you 
don't have a reduced test case, just use "anything changes" as the reduce 
condition, because you're basically interested in the answer to "why does this 
patch change anything at all?".


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

https://reviews.llvm.org/D62899



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


[PATCH] D64274: [analyzer] VirtualCallChecker overhaul.

2019-08-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp:14-20
 const char * const CoreFoundationObjectiveC = "Core Foundation/Objective-C";
 const char * const LogicError = "Logic error";
 const char * const MemoryRefCount =
   "Memory (Core Foundation/Objective-C/OSObject)";
 const char * const MemoryError = "Memory error";
 const char * const UnixAPI = "Unix API";
+const char * const CXXObjectLifecycle = "C++ object lifecycle";

Szelethus wrote:
> `static constexpr StringLiteral`? Why is there a need to have a header and a 
> cpp file for this? Not that it matters much (definitely not in the context of 
> this patch), but compile-time stuff is cool.
Ancient stuff, i guess. We only have C++11 for like 3 years i think.


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

https://reviews.llvm.org/D64274



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


[PATCH] D44672: [CodeGen] Disable UBSan for coroutine functions

2019-08-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D44672#1637984 , @vsk wrote:

> In D44672#1637891 , @leonardchan 
> wrote:
>
> > It seems that this test leads to an `UNREACHABLE` under the new pass 
> > manager (can check this by adding `-fexperimental-new-pass-manager` to the 
> > test. I think this is because the passes for lowering the `llvm.coro` 
> > intrinsics are not yet ported to the new PM. Would it be fine to add 
> > `-fno-experimental-new-pass-manager` to the test to indicate it should be 
> > run under the legacy PM only? Thanks.
>
>
> Sounds reasonable to me. It would be great to include a link to some master 
> PR for the new PM porting effort with the test change.


Thanks. I added you as a reviewer to D66493  
and linked in https://bugs.llvm.org/show_bug.cgi?id=42867 which I filed a while 
back and has the same root problem.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D44672



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


[PATCH] D66493: [NewPM] Run ubsan-coroutines test under the legacy pass manager only

2019-08-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: vsk, modocache.
leonardchan added a project: clang.
Herald added a subscriber: EricWF.

The passes that lower the `llvm.coro.*` instrinsics have not yet been ported, 
so only run under the legacy PM for now.

See https://bugs.llvm.org/show_bug.cgi?id=42867


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66493

Files:
  clang/test/CodeGenCXX/ubsan-coroutines.cpp


Index: clang/test/CodeGenCXX/ubsan-coroutines.cpp
===
--- clang/test/CodeGenCXX/ubsan-coroutines.cpp
+++ clang/test/CodeGenCXX/ubsan-coroutines.cpp
@@ -1,6 +1,8 @@
 // This test merely verifies that emitting the object file does not cause a
 // crash when the LLVM coroutines passes are run.
-// RUN: %clang_cc1 -emit-obj -std=c++2a -fsanitize=null %s -o %t.o
+// PR42867: Disable this test for the new PM since the passes that lower the
+// llvm.coro.* intrinsics have not yet been ported.
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -emit-obj -std=c++2a 
-fsanitize=null %s -o %t.o
 
 namespace std::experimental {
 template  struct coroutine_traits {


Index: clang/test/CodeGenCXX/ubsan-coroutines.cpp
===
--- clang/test/CodeGenCXX/ubsan-coroutines.cpp
+++ clang/test/CodeGenCXX/ubsan-coroutines.cpp
@@ -1,6 +1,8 @@
 // This test merely verifies that emitting the object file does not cause a
 // crash when the LLVM coroutines passes are run.
-// RUN: %clang_cc1 -emit-obj -std=c++2a -fsanitize=null %s -o %t.o
+// PR42867: Disable this test for the new PM since the passes that lower the
+// llvm.coro.* intrinsics have not yet been ported.
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -emit-obj -std=c++2a -fsanitize=null %s -o %t.o
 
 namespace std::experimental {
 template  struct coroutine_traits {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66364: Diagnose use of _Thread_local as an extension when appropriate

2019-08-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

@rsmith are you fine with implementing the diagnostic for these keywords 
piecemeal based on the pattern from this patch, or do you want to see an 
omnibus patch that adds all of them at once?

In D66364#1637635 , @ldionne wrote:

> Please ping me directly if you expect libc++ maintainers to do something 
> following this patch.


Will do, thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D66364



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


r369432 - [OPENMP]Fix delayed diagnostics for standalone declare target directive.

2019-08-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug 20 12:50:13 2019
New Revision: 369432

URL: http://llvm.org/viewvc/llvm-project?rev=369432=rev
Log:
[OPENMP]Fix delayed diagnostics for standalone declare target directive.

If the function is marked as declare target in a standalone directive,
the delayed diagnostics is not emitted. Patch fixes this problem.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
cfe/trunk/test/OpenMP/nvptx_va_arg_delayed_diags.c

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=369432=369431=369432=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug 20 12:50:13 2019
@@ -8997,7 +8997,8 @@ private:
   void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI);
 
   /// Check whether we're allowed to call Callee from the current function.
-  void checkOpenMPDeviceFunction(SourceLocation Loc, FunctionDecl *Callee);
+  void checkOpenMPDeviceFunction(SourceLocation Loc, FunctionDecl *Callee,
+ bool CheckForDelayedContext = true);
 
   /// Check if the expression is allowed to be used in expressions for the
   /// OpenMP devices.

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=369432=369431=369432=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Aug 20 12:50:13 2019
@@ -1383,7 +1383,7 @@ static void emitCallStackNotes(Sema ,
 
 // Emit any deferred diagnostics for FD and erase them from the map in which
 // they're stored.
-static void emitDeferredDiags(Sema , FunctionDecl *FD) {
+static void emitDeferredDiags(Sema , FunctionDecl *FD, bool ShowCallStack) {
   auto It = S.DeviceDeferredDiags.find(FD);
   if (It == S.DeviceDeferredDiags.end())
 return;
@@ -1402,7 +1402,7 @@ static void emitDeferredDiags(Sema , F
   // FIXME: Should this be called after every warning/error emitted in the loop
   // above, instead of just once per function?  That would be consistent with
   // how we handle immediate errors, but it also seems like a bit much.
-  if (HasWarningOrError)
+  if (HasWarningOrError && ShowCallStack)
 emitCallStackNotes(S, FD);
 }
 
@@ -1505,7 +1505,7 @@ void Sema::markKnownEmitted(
 assert(!IsKnownEmitted(S, C.Callee) &&
"Worklist should not contain known-emitted functions.");
 S.DeviceKnownEmittedFns[C.Callee] = {C.Caller, C.Loc};
-emitDeferredDiags(S, C.Callee);
+emitDeferredDiags(S, C.Callee, C.Caller);
 
 // If this is a template instantiation, explore its callgraph as well:
 // Non-dependent calls are part of the template's callgraph, while 
dependent

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=369432=369431=369432=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Aug 20 12:50:13 2019
@@ -1576,7 +1576,8 @@ Sema::DeviceDiagBuilder Sema::diagIfOpen
Loc, DiagID, getCurFunctionDecl(), *this);
 }
 
-void Sema::checkOpenMPDeviceFunction(SourceLocation Loc, FunctionDecl *Callee) 
{
+void Sema::checkOpenMPDeviceFunction(SourceLocation Loc, FunctionDecl *Callee,
+ bool CheckForDelayedContext) {
   assert(LangOpts.OpenMP && LangOpts.OpenMPIsDevice &&
  "Expected OpenMP device compilation.");
   assert(Callee && "Callee may not be null.");
@@ -1584,9 +1585,13 @@ void Sema::checkOpenMPDeviceFunction(Sou
 
   // If the caller is known-emitted, mark the callee as known-emitted.
   // Otherwise, mark the call in our call graph so we can traverse it later.
-  if (!isOpenMPDeviceDelayedContext(*this) ||
+  if ((CheckForDelayedContext && !isOpenMPDeviceDelayedContext(*this)) ||
+  (!Caller && !CheckForDelayedContext) ||
   (Caller && isKnownEmitted(*this, Caller)))
-markKnownEmitted(*this, Caller, Callee, Loc, isKnownEmitted);
+markKnownEmitted(*this, Caller, Callee, Loc,
+ [CheckForDelayedContext](Sema , FunctionDecl *FD) {
+   return CheckForDelayedContext && isKnownEmitted(S, FD);
+ });
   else if (Caller)
 DeviceCallGraph[Caller].insert({Callee, Loc});
 }
@@ -15406,15 +15411,17 @@ void Sema::checkDeclIsAllowedInOpenMPTar
   }
   if (const auto *FTD = dyn_cast(D))
 D = FTD->getTemplatedDecl();
-  if (const auto *FD = dyn_cast(D)) {
+  if (auto *FD = dyn_cast(D)) {
 llvm::Optional Res =
 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(FD);
-

[PATCH] D66492: [Clang][CodeGen] set alias linkage on QualType

2019-08-20 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added a reviewer: rsmith.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

It seems that CodeGen was always using ExternalLinkage when emitting a
GlobalDecl with __attribute__((alias)). This leads to symbol
redefinitions (ODR) that cause failures at link time for static aliases.
This is readily attempting to link an ARM (32b) allyesconfig Linux
kernel built with Clang.

Reported-by: nathanchance
Suggested-by: ihalip
Link: https://github.com/ClangBuiltLinux/linux/issues/631


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66492

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/alias.c


Index: clang/test/CodeGen/alias.c
===
--- clang/test/CodeGen/alias.c
+++ clang/test/CodeGen/alias.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECKBASIC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECKCC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck 
-check-prefix=CHECKASM %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
 
 int g0;
 // CHECKBASIC-DAG: @g0 = common global i32 0
@@ -88,3 +89,9 @@
 void test9_bar(void) { }
 void test9_zed(void) __attribute__((section("test")));
 void test9_zed(void) __attribute__((alias("test9_bar")));
+
+// Test that the alias gets its linkage from its declared qual type.
+// CHECKGLOBALS: @test10_foo = internal
+// CHECKGLOBALS-NOT: @test10_foo = dso_local
+int test10;
+static int test10_foo __attribute__((alias("test10")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4363,17 +4363,22 @@
   // Create a reference to the named value.  This ensures that it is emitted
   // if a deferred decl.
   llvm::Constant *Aliasee;
-  if (isa(DeclTy))
+  llvm::GlobalValue::LinkageTypes LT;
+  if (isa(DeclTy)) {
 Aliasee = GetOrCreateLLVMFunction(AA->getAliasee(), DeclTy, GD,
   /*ForVTable=*/false);
-  else
+LT = getFunctionLinkage(GD);
+  } else {
 Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
 llvm::PointerType::getUnqual(DeclTy),
 /*D=*/nullptr);
+LT = getLLVMLinkageVarDefinition(cast(GD.getDecl()),
+ D->getType().isConstQualified());
+  }
 
   // Create the new alias itself, but don't set a name yet.
-  auto *GA = llvm::GlobalAlias::create(
-  DeclTy, 0, llvm::Function::ExternalLinkage, "", Aliasee, ());
+  auto *GA =
+  llvm::GlobalAlias::create(DeclTy, 0, LT, "", Aliasee, ());
 
   if (Entry) {
 if (GA->getAliasee() == Entry) {


Index: clang/test/CodeGen/alias.c
===
--- clang/test/CodeGen/alias.c
+++ clang/test/CodeGen/alias.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKBASIC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s
 // RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck -check-prefix=CHECKASM %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
 
 int g0;
 // CHECKBASIC-DAG: @g0 = common global i32 0
@@ -88,3 +89,9 @@
 void test9_bar(void) { }
 void test9_zed(void) __attribute__((section("test")));
 void test9_zed(void) __attribute__((alias("test9_bar")));
+
+// Test that the alias gets its linkage from its declared qual type.
+// CHECKGLOBALS: @test10_foo = internal
+// CHECKGLOBALS-NOT: @test10_foo = dso_local
+int test10;
+static int test10_foo __attribute__((alias("test10")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4363,17 +4363,22 @@
   // Create a reference to the named value.  This ensures that it is emitted
   // if a deferred decl.
   llvm::Constant *Aliasee;
-  if (isa(DeclTy))
+  llvm::GlobalValue::LinkageTypes LT;
+  if (isa(DeclTy)) {
 Aliasee = GetOrCreateLLVMFunction(AA->getAliasee(), DeclTy, GD,
   /*ForVTable=*/false);
-  else
+LT = getFunctionLinkage(GD);
+  } else {
 Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
 llvm::PointerType::getUnqual(DeclTy),
 /*D=*/nullptr);
+LT = getLLVMLinkageVarDefinition(cast(GD.getDecl()),
+ D->getType().isConstQualified());
+  }
 
   // Create the new alias 

[PATCH] D65211: [analyzer] Update the SARIF exporter to SARIF 2.1

2019-08-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D65211#1606089 , @aaron.ballman 
wrote:

> This LGTM, but I'd appreciate a second reviewer chiming in only because Joe 
> is a coworker.


Sufficient time has passed that any concerns other reviewers have can be 
addressed post-commit. Continues to LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65211



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


[PATCH] D65206: [analyzer] Fix text range end columns in SARIF to be exclusive

2019-08-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D65206#1606072 , @aaron.ballman 
wrote:

> This LGTM, but I'd appreciate a second reviewer chiming in only because Joe 
> is a coworker.


Sufficient time has passed that any concerns other reviewers have can be 
addressed post-commit. Continues to LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65206



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


[PATCH] D65209: [analyzer] Fix a SARIF exporter crash with macro expansions

2019-08-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D65209#1606075 , @aaron.ballman 
wrote:

> This LGTM, but I'd appreciate a second reviewer chiming in only because Joe 
> is a coworker.


Sufficient time has passed that any concerns other reviewers have can be 
addressed post-commit. Continues to LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65209



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


[PATCH] D44672: [CodeGen] Disable UBSan for coroutine functions

2019-08-20 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In D44672#1637891 , @leonardchan wrote:

> It seems that this test leads to an `UNREACHABLE` under the new pass manager 
> (can check this by adding `-fexperimental-new-pass-manager` to the test. I 
> think this is because the passes for lowering the `llvm.coro` intrinsics are 
> not yet ported to the new PM. Would it be fine to add 
> `-fno-experimental-new-pass-manager` to the test to indicate it should be run 
> under the legacy PM only? Thanks.


Sounds reasonable to me. It would be great to include a link to some master PR 
for the new PM porting effort with the test change.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D44672



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


[PATCH] D65575: [analyzer] Mention whether an event is about a condition in a bug report part 1

2019-08-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D65575#1621425 , @Szelethus wrote:

> I think it isn't crucial of getting rid of the "The" prefix, if we append ", 
> which participates in a condition later" (which sounds so much better than 
> what I added in this patch), so maybe changing `WillBeUsedForACondition` to 
> that would be good enough.


I guess let's just land that variant! I'm also not super worried about "The" 
here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65575



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


[PATCH] D65481: NFCI: Simplify SourceManager::translateFile by removing code path that should never be taken

2019-08-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ping. I will commit it this week if there are no objections.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65481



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


[PATCH] D66490: [NewPM] Enable the New Pass Manager by Default in Clang

2019-08-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

As of now, from running `check-llvm` and `check-clang` there's 2 failing tests, 
but I'm trying to get those addressed.

- `Clang :: CodeGen/split-lto-unit.c` which should be resolved by D66488 

- `Clang :: CodeGenCXX/ubsan-coroutines.cpp` which was introduced by D44672 
 but I think should be fixed by just disabling 
the test under the new PM since coroutines haven't been ported yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66490



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


[PATCH] D66490: [NewPM] Enable the New Pass Manager by Default in Clang

2019-08-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: chandlerc, echristo, hfinkel, lattner, rupprecht.
leonardchan added a project: clang.
Herald added subscribers: dexonsmith, mehdi_amini, mgorny.

The new PM serves as a replacement for the legacy PM, and promises better 
codegen, better inlining, faster build times, and better PGO and LTO.  Now that 
LLVM 9.0.0 has branched, we have some time before the next release to work out 
any kinks that may arise from the switch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66490

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -233,7 +233,7 @@
 set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 "enable x86 relax relocations by default")
 
-set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
+set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER TRUE CACHE BOOL
   "Enable the experimental new pass manager by default.")
 
 # TODO: verify the values against LangStandards.def?


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -233,7 +233,7 @@
 set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 "enable x86 relax relocations by default")
 
-set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
+set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER TRUE CACHE BOOL
   "Enable the experimental new pass manager by default.")
 
 # TODO: verify the values against LangStandards.def?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62648: [Sema][Typo] Fix assertion failure for expressions with multiple typos

2019-08-20 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369427: [Sema][Typo] Fix assertion failure for expressions 
with multiple typos (authored by dgoldman, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62648

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/lib/Sema/SemaLookup.cpp
  cfe/trunk/test/Sema/typo-correction-recursive.cpp

Index: cfe/trunk/test/Sema/typo-correction-recursive.cpp
===
--- cfe/trunk/test/Sema/typo-correction-recursive.cpp
+++ cfe/trunk/test/Sema/typo-correction-recursive.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior:
+// - multiple typos in a single member call chain are all diagnosed
+// - no typos are diagnosed for multiple typos in an expression when not all
+//   typos can be corrected
+
+class DeepClass
+{
+public:
+  void trigger() const;  // expected-note {{'trigger' declared here}}
+};
+
+class Y
+{
+public:
+  const DeepClass& getX() const { return m_deepInstance; }  // expected-note {{'getX' declared here}}
+private:
+  DeepClass m_deepInstance;
+  int m_n;
+};
+
+class Z
+{
+public:
+  const Y& getY0() const { return m_y0; }  // expected-note {{'getY0' declared here}}
+  const Y& getActiveY() const { return m_y0; }
+
+private:
+  Y m_y0;
+  Y m_y1;
+};
+
+Z z_obj;
+
+void testMultipleCorrections()
+{
+  z_obj.getY2().  // expected-error {{no member named 'getY2' in 'Z'; did you mean 'getY0'}}
+  getM(). // expected-error {{no member named 'getM' in 'Y'; did you mean 'getX'}}
+  triggee();  // expected-error {{no member named 'triggee' in 'DeepClass'; did you mean 'trigger'}}
+}
+
+void testNoCorrections()
+{
+  z_obj.getY2().  // expected-error {{no member named 'getY2' in 'Z'}}
+  getM().
+  thisDoesntSeemToMakeSense();
+}
+
+struct C {};
+struct D { int value; };
+struct A {
+  C get_me_a_C();
+};
+struct B {
+  D get_me_a_D();  // expected-note {{'get_me_a_D' declared here}}
+};
+class Scope {
+public:
+  A make_an_A();
+  B make_a_B();  // expected-note {{'make_a_B' declared here}}
+};
+
+Scope scope_obj;
+
+int testDiscardedCorrections() {
+  return scope_obj.make_an_E().  // expected-error {{no member named 'make_an_E' in 'Scope'; did you mean 'make_a_B'}}
+  get_me_a_Z().value;// expected-error {{no member named 'get_me_a_Z' in 'B'; did you mean 'get_me_a_D'}}
+}
+
+class AmbiguousHelper {
+public:
+  int helpMe();
+  int helpBe();
+};
+class Ambiguous {
+public:
+  int calculateA();
+  int calculateB();
+
+  AmbiguousHelper getHelp1();
+  AmbiguousHelper getHelp2();
+};
+
+Ambiguous ambiguous_obj;
+
+int testDirectAmbiguousCorrection() {
+  return ambiguous_obj.calculateZ();  // expected-error {{no member named 'calculateZ' in 'Ambiguous'}}
+}
+
+int testRecursiveAmbiguousCorrection() {
+  return ambiguous_obj.getHelp3().// expected-error {{no member named 'getHelp3' in 'Ambiguous'}}
+  helpCe();
+}
+
+
+class DeepAmbiguityHelper {
+public:
+  DeepAmbiguityHelper& help1();
+  DeepAmbiguityHelper& help2();
+
+  DeepAmbiguityHelper& methodA();
+  DeepAmbiguityHelper& somethingMethodB();
+  DeepAmbiguityHelper& functionC();
+  DeepAmbiguityHelper& deepMethodD();
+  DeepAmbiguityHelper& asDeepAsItGets();
+};
+
+DeepAmbiguityHelper deep_obj;
+
+int testDeepAmbiguity() {
+  deep_obj.
+  methodB(). // expected-error {{no member named 'methodB' in 'DeepAmbiguityHelper'}}
+  somethingMethodC().
+  functionD().
+  deepMethodD().
+  help3().
+  asDeepASItGet().
+  functionE();
+}
Index: cfe/trunk/lib/Sema/SemaLookup.cpp
===
--- cfe/trunk/lib/Sema/SemaLookup.cpp
+++ cfe/trunk/lib/Sema/SemaLookup.cpp
@@ -5434,6 +5434,8 @@
   State.Consumer = std::move(TCC);
   State.DiagHandler = std::move(TDG);
   State.RecoveryHandler = std::move(TRC);
+  if (TE)
+TypoExprs.push_back(TE);
   return TE;
 }
 
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -7580,15 +7580,22 @@
   llvm::SmallDenseMap OverloadResolution;
 
   /// Emit diagnostics for all of the TypoExprs encountered.
+  ///
   /// If the TypoExprs were successfully corrected, then the diagnostics should
   /// suggest the corrections. Otherwise the diagnostics will not suggest
   /// anything (having been passed an empty TypoCorrection).
-  void EmitAllDiagnostics() {
+  ///
+  /// If we've failed to correct due to ambiguous corrections, we need to
+  /// be sure to pass empty corrections and replacements. Otherwise it's
+  /// possible that the Consumer has a TypoCorrection that 

[PATCH] D44672: [CodeGen] Disable UBSan for coroutine functions

2019-08-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

It seems that this test leads to an `UNREACHABLE` under the new pass manager 
(can check this by adding `-fexperimental-new-pass-manager` to the test. I 
think this is because the passes for lowering the `llvm.coro` intrinsics are 
not yet ported to the new PM. Would it be fine to add 
`-fno-experimental-new-pass-manager` to the test to indicate it should be run 
under the legacy PM only? Thanks.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D44672



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


r369427 - [Sema][Typo] Fix assertion failure for expressions with multiple typos

2019-08-20 Thread David Goldman via cfe-commits
Author: dgoldman
Date: Tue Aug 20 12:03:15 2019
New Revision: 369427

URL: http://llvm.org/viewvc/llvm-project?rev=369427=rev
Log:
[Sema][Typo] Fix assertion failure for expressions with multiple typos

Summary:
As Typo Resolution can create new TypoExprs while resolving typos,
it is necessary to recurse through the expression to search for more
typos.

This should fix the assertion failure in `clang::Sema::~Sema()`:
  `DelayedTypos.empty() && "Uncorrected typos!"`

Notes:
- In case some TypoExprs are created but thrown away, Sema
  now has a Vector that is used to keep track of newly created
  typos.
- For expressions with multiple typos, we only give suggestions
  if we are able to resolve all typos in the expression
- This patch is similar to D37521 except that it does not eagerly
  commit to a correction for the first typo in the expression.
  Instead, it will search for corrections which fix all of the
  typos in the expression.

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Sema/typo-correction-recursive.cpp
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=369427=369426=369427=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug 20 12:03:15 2019
@@ -405,6 +405,12 @@ public:
   /// Source location for newly created implicit MSInheritanceAttrs
   SourceLocation ImplicitMSInheritanceAttrLoc;
 
+  /// Holds TypoExprs that are created from `createDelayedTypo`. This is used 
by
+  /// `TransformTypos` in order to keep track of any TypoExprs that are created
+  /// recursively during typo correction and wipe them away if the correction
+  /// fails.
+  llvm::SmallVector TypoExprs;
+
   /// pragma clang section kind
   enum PragmaClangSectionKind {
 PCSK_Invalid  = 0,

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=369427=369426=369427=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Aug 20 12:03:15 2019
@@ -7580,15 +7580,22 @@ class TransformTypos : public TreeTransf
   llvm::SmallDenseMap OverloadResolution;
 
   /// Emit diagnostics for all of the TypoExprs encountered.
+  ///
   /// If the TypoExprs were successfully corrected, then the diagnostics should
   /// suggest the corrections. Otherwise the diagnostics will not suggest
   /// anything (having been passed an empty TypoCorrection).
-  void EmitAllDiagnostics() {
+  ///
+  /// If we've failed to correct due to ambiguous corrections, we need to
+  /// be sure to pass empty corrections and replacements. Otherwise it's
+  /// possible that the Consumer has a TypoCorrection that failed to ambiguity
+  /// and we don't want to report those diagnostics.
+  void EmitAllDiagnostics(bool IsAmbiguous) {
 for (TypoExpr *TE : TypoExprs) {
   auto  = SemaRef.getTypoExprState(TE);
   if (State.DiagHandler) {
-TypoCorrection TC = State.Consumer->getCurrentCorrection();
-ExprResult Replacement = TransformCache[TE];
+TypoCorrection TC = IsAmbiguous
+? TypoCorrection() : State.Consumer->getCurrentCorrection();
+ExprResult Replacement = IsAmbiguous ? ExprError() : 
TransformCache[TE];
 
 // Extract the NamedDecl from the transformed TypoExpr and add it to 
the
 // TypoCorrection, replacing the existing decls. This ensures the right
@@ -7650,6 +7657,145 @@ class TransformTypos : public TreeTransf
 return ExprFilter(Res.get());
   }
 
+  // Since correcting typos may intoduce new TypoExprs, this function
+  // checks for new TypoExprs and recurses if it finds any. Note that it will
+  // only succeed if it is able to correct all typos in the given expression.
+  ExprResult CheckForRecursiveTypos(ExprResult Res, bool ) {
+if (Res.isInvalid()) {
+  return Res;
+}
+// Check to see if any new TypoExprs were created. If so, we need to 
recurse
+// to check their validity.
+Expr *FixedExpr = Res.get();
+
+auto SavedTypoExprs = std::move(TypoExprs);
+auto SavedAmbiguousTypoExprs = std::move(AmbiguousTypoExprs);
+TypoExprs.clear();
+AmbiguousTypoExprs.clear();
+
+FindTypoExprs(TypoExprs).TraverseStmt(FixedExpr);
+if (!TypoExprs.empty()) {
+  // Recurse to handle newly created TypoExprs. If we're not able to
+  // handle them, discard these TypoExprs.
+  ExprResult RecurResult =
+  RecursiveTransformLoop(FixedExpr, IsAmbiguous);
+  if (RecurResult.isInvalid()) {
+Res = ExprError();
+// Recursive 

[PATCH] D66473: [analyzer] Removed some dead code in BugReporter and related files

2019-08-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2343
   InterExplodedGraphMap ForwardMap;
-  TrimmedGraph = OriginalGraph->trim(Nodes, , );
 

gribozavr wrote:
> NoQ wrote:
> > Btw these days we strongly suspect that the whole graph trimming thing is 
> > useless and should be removed.
> TBH, I don't understand what this code is doing, I was just following the 
> leads from dead code analysis :)
TL;DR: When creating a linear path from the root of the `ExplodedGraph` to a 
given error node (a point at which a bug was emitted), we first trim be graph 
of all nodes that do not lead to an error node, and then create the path from 
that, instead of skipping the entire trimming process.

This isn't that simple (though probably not that difficult either), so feel 
free to leave it as it, the code is already much easier to read!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66473



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


[PATCH] D66473: [analyzer] Removed some dead code in BugReporter and related files

2019-08-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

No way the entire `NodeResolver` is dead code! I spent so much time trying to 
understand it! I mean, now that I think about it, we literally deep copy every 
`ExplodedNode`, so why would we need the mapping to the original, right?

Wow. Thank you so much for clearing this out.




Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2263-2264
 /// A wrapper around an ExplodedGraph that contains a single path from the root
 /// to the error node, and a map that maps the nodes in this path to the ones 
in
 /// the original ExplodedGraph.
 class BugPathInfo {

Let's keep the comment up to date as well :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66473



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


[PATCH] D66473: Removed some dead code in BugReporter and related files

2019-08-20 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr marked 3 inline comments as done.
gribozavr added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:408
-public:
-  enum Kind { BasicBRKind, PathSensitiveBRKind };
-

NoQ wrote:
> Hey, i just added that! :D (well, renamed) (rC369320)
> 
> I believe we do want a separation between a {bug report, bug reporter} 
> classes that's only suitable for path-insensitive reports (which would live 
> in libAnalysis and we could handle them to clang-tidy while still being able 
> to compile it without CLANG_ENABLE_STATIC_ANALYZER) and all the 
> path-sensitive report logic that is pretty huge but only Static Analyzer 
> needs it. For that purpose we'd better leave this in. WDYT? See also D66460.
> 
> Should i ask on the mailing list whether you're willing to sacrifice building 
> clang-tidy without CLANG_ENABLE_STATIC_ANALYZER in order to transition to 
> BugReporter? Cause i thought it was obvious that it's not a great idea, even 
> if it causes me to do a bit of cleanup work on my end.
> 
> That said, i'm surprised that it's deadcode, i.e. that nobody ever dyn_casts 
> bug reporters, even though we already have two bug reporter classes. Maybe we 
> can indeed remove this facility.
> I believe we do want a separation between a {bug report, bug reporter} 
> classes [...]

Yes, the separation is nice.

> For that purpose we'd better leave this in.

`Kind` is only needed for dynamic casting between different bug reporters. I'm 
not sure that is useful in practice (case in point -- the `classof` is not used 
today), specifically because the client that produces diagnostics will need to 
work with a bug reporter of the correct kind. If a path-sensitive client is 
handed a pointer to the base class, `BugReporter`, would it try to `dyn_cast` 
it to the derived class?.. what if it fails?..

Basically, I don't understand why one would want dynamic casting for these 
classes. I totally agree with the separation though.

> Should i ask on the mailing list whether you're willing to sacrifice building 
> clang-tidy without CLANG_ENABLE_STATIC_ANALYZER in order to transition to 
> BugReporter?

I personally don't mind CLANG_ENABLE_STATIC_ANALYZER going away completely (I 
have a fast machine and use a build system with strong caching), however, there 
are other people who are a lot more sensitive to build time, and for whom it 
might be important.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2343
   InterExplodedGraphMap ForwardMap;
-  TrimmedGraph = OriginalGraph->trim(Nodes, , );
 

NoQ wrote:
> Btw these days we strongly suspect that the whole graph trimming thing is 
> useless and should be removed.
TBH, I don't understand what this code is doing, I was just following the leads 
from dead code analysis :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66473



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


[PATCH] D66488: [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1 under the new pass manager

2019-08-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: pcc, tejohnson.
leonardchan added a project: clang.
Herald added subscribers: dexonsmith, steven_wu, inglorion, mehdi_amini.

Match the behavior of D65009  under the new 
pass manager also.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66488

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/split-lto-unit.c


Index: clang/test/CodeGen/split-lto-unit.c
===
--- clang/test/CodeGen/split-lto-unit.c
+++ clang/test/CodeGen/split-lto-unit.c
@@ -7,6 +7,7 @@
 // SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
 //
 // ; Check that regular LTO has EnableSplitLTOUnit = 1
-// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | 
llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" 
--check-prefix=SPLIT
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -flto -triple 
x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s 
--implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -flto -triple 
x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s 
--implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
 
 int main() {}
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1291,7 +1291,7 @@
 if (!TheModule->getModuleFlag("ThinLTO"))
   TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
 TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
- CodeGenOpts.EnableSplitLTOUnit);
+ uint32_t(1));
   }
   MPM.addPass(
   BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, 
EmitLTOSummary));


Index: clang/test/CodeGen/split-lto-unit.c
===
--- clang/test/CodeGen/split-lto-unit.c
+++ clang/test/CodeGen/split-lto-unit.c
@@ -7,6 +7,7 @@
 // SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
 //
 // ; Check that regular LTO has EnableSplitLTOUnit = 1
-// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
 
 int main() {}
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1291,7 +1291,7 @@
 if (!TheModule->getModuleFlag("ThinLTO"))
   TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
 TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
- CodeGenOpts.EnableSplitLTOUnit);
+ uint32_t(1));
   }
   MPM.addPass(
   BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, EmitLTOSummary));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66179: [LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)

2019-08-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/Sema/SemaAttr.cpp:94
 
-  Canonical->addAttr(::new (Context) Attribute(SourceRange{}, Context,
-   /*DerefType*/ nullptr,
-   /*Spelling=*/0));
+  Record->addAttr(::new (Context) Attribute(SourceRange{}, Context,
+/*DerefType*/ nullptr,

Doesn't the attribute have a `CreateImplicit` static method? If so, we could 
use that :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66179



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


r369418 - Fix name of the error message, NFC.

2019-08-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug 20 10:50:13 2019
New Revision: 369418

URL: http://llvm.org/viewvc/llvm-project?rev=369418=rev
Log:
Fix name of the error message, NFC.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=369418=369417=369418=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug 20 10:50:13 
2019
@@ -9329,7 +9329,7 @@ def err_omp_wrong_dependency_iterator_ty
   "expected an integer or a pointer type of the outer loop counter '%0' for 
non-rectangular nests">;
 def err_omp_unsupported_type : Error <
   "host requires %0 bit size %1 type support, but device '%2' does not support 
it">;
-def omp_lambda_capture_in_declare_target_not_to : Error<
+def err_omp_lambda_capture_in_declare_target_not_to : Error<
   "variable captured in declare target region must appear in a to clause">;
 } // end of OpenMP category
 

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=369418=369417=369418=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Aug 20 10:50:13 2019
@@ -15365,7 +15365,7 @@ static void checkDeclInTargetContext(Sou
   // directive, all variables that are captured by the lambda
   // expression must also appear in a to clause.
   SemaRef.Diag(VD->getLocation(),
-   diag::omp_lambda_capture_in_declare_target_not_to);
+   diag::err_omp_lambda_capture_in_declare_target_not_to);
   SemaRef.Diag(SL, diag::note_var_explicitly_captured_here)
   << VD << 0 << SR;
   return;


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


LLVM buildmaster will be updated and restarted tonight

2019-08-20 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 5PM Pacific time today.

Thanks

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


[PATCH] D66303: [LifetimeAnalysis] Add support for free functions

2019-08-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked 2 inline comments as done.
xazax.hun added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:6622
+return false;
+  const auto *RD = FD->getParamDecl(0)->getType()->getPointeeCXXRecordDecl();
+  if (!FD->isInStdNamespace() || !RD || !RD->isInStdNamespace())

mgehre wrote:
> Maybe move the `Callee->getNumParams() == 1` check from the caller into this 
> function so it's obvious that `getParamDecl(0)` is allowed?
Thanks, I addressed this one before committing.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66303



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


[PATCH] D66486: [LifetimeAnalysis] Detect more cases when the address of a local variable escapes

2019-08-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: gribozavr, mgehre.
xazax.hun added a project: clang.
Herald added subscribers: Szelethus, Charusso, gamesh411, dkrupp, rnkovacs.

This patch relaxes some of the checks so we can detect more cases where local 
variable escapes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66486

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Index: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
===
--- clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
+++ clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
@@ -141,6 +141,9 @@
 template 
 auto data(const C ) -> decltype(c.data());
 
+template
+T *begin(T ()[N]);
+
 template 
 struct vector {
   typedef __gnu_cxx::basic_iterator iterator;
@@ -188,6 +191,14 @@
 
 template
 T any_cast(const any& operand);
+
+template
+struct reference_wrapper {
+  reference_wrapper(T &&);
+};
+
+template
+reference_wrapper ref(T& t) noexcept;
 }
 
 void modelIterators() {
@@ -298,3 +309,45 @@
   const std::vector  = getVec();
   const int *val = v.data(); // Ok, it is lifetime extended.
 }
+
+std::reference_wrapper danglingPtrFromNonOwnerLocal() {
+  int i = 5;
+  return i; // expected-warning {{address of stack memory associated with local variable 'i' returned}}
+}
+
+std::reference_wrapper danglingPtrFromNonOwnerLocal2() {
+  int i = 5;
+  return std::ref(i); // expected-warning {{address of stack memory associated with local variable 'i' returned}}
+}
+
+int *returnPtrToLocalArray() {
+  int a[5];
+  return std::begin(a); // expected-warning {{address of stack memory associated with local variable 'a' returned}}
+}
+
+struct ptr_wrapper {
+  std::vector::iterator member;
+};
+
+ptr_wrapper getPtrWrapper();
+
+std::vector::iterator returnPtrFromWrapper() {
+  ptr_wrapper local = getPtrWrapper();
+  return local.member; // OK.
+}
+
+std::vector::iterator returnPtrFromWrapperThroughRef() {
+  ptr_wrapper local = getPtrWrapper();
+  ptr_wrapper  = local;
+  return local2.member; // OK.
+}
+
+std::vector::iterator returnPtrFromWrapperThroughRef2() {
+  ptr_wrapper local = getPtrWrapper();
+  std::vector::iterator  = local.member;
+  return local2; // OK.
+}
+
+void checkPtrMemberFromAggregate() {
+  std::vector::iterator local = getPtrWrapper().member; // OK.
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -6551,6 +6551,15 @@
   });
 }
 
+static bool pathOnlyInitializesGslPointer(IndirectLocalPath ) {
+  for (auto It = Path.rbegin(), End = Path.rend(); It != End; ++It) {
+if (It->Kind == IndirectLocalPathEntry::VarInit)
+  continue;
+return It->Kind == IndirectLocalPathEntry::GslPointerInit;
+  }
+  return false;
+}
+
 static void visitLocalsRetainedByInitializer(IndirectLocalPath ,
  Expr *Init, LocalVisitor Visit,
  bool RevisitSubinits);
@@ -6619,17 +6628,14 @@
 static bool shouldTrackFirstArgument(const FunctionDecl *FD) {
   if (!FD->getIdentifier() || FD->getNumParams() != 1)
 return false;
-  const auto *RD = FD->getParamDecl(0)->getType()->getPointeeCXXRecordDecl();
-  if (!FD->isInStdNamespace() || !RD || !RD->isInStdNamespace())
-return false;
-  if (!isRecordWithAttr(QualType(RD->getTypeForDecl(), 0)) &&
-  !isRecordWithAttr(QualType(RD->getTypeForDecl(), 0)))
+  if (!FD->isInStdNamespace())
 return false;
   if (FD->getReturnType()->isPointerType() ||
   isRecordWithAttr(FD->getReturnType())) {
 return llvm::StringSwitch(FD->getName())
 .Cases("begin", "rbegin", "cbegin", "crbegin", true)
 .Cases("end", "rend", "cend", "crend", true)
+.Cases("cref", "ref", true)
 .Case("data", true)
 .Default(false);
   } else if (FD->getReturnType()->isReferenceType()) {
@@ -6763,7 +6769,10 @@
 
 // Step over any subobject adjustments; we may have a materialized
 // temporary inside them.
-Init = const_cast(Init->skipRValueSubobjectAdjustments());
+// We are not interested in the temporary base objects of gsl::Pointers:
+//   Temp().ptr; // Here ptr might not dangle.
+if (!pathOnlyInitializesGslPointer(Path))
+  Init = const_cast(Init->skipRValueSubobjectAdjustments());
 
 // Per current approach for DR1376, look through casts to reference type
 // when performing lifetime extension.
@@ -6882,7 +6891,10 @@
   Init = FE->getSubExpr();
 
 // Dig out the expression which constructs the extended temporary.
-Init = const_cast(Init->skipRValueSubobjectAdjustments());
+// We are not interested in the temporary base objects of gsl::Pointers:
+//   Temp().ptr; // Here ptr might not dangle.
+if (!pathOnlyInitializesGslPointer(Path))
+  Init = 

[PATCH] D64838: [Attr] Support _attribute__ ((fallthrough))

2019-08-20 Thread Nathan Huckleberry via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369414: [Attr] Support _attribute__ ((fallthrough)) 
(authored by Nathan-Huckleberry, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64838?vs=213435=216191#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64838

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseStmt.cpp
  cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
  cfe/trunk/test/Sema/fallthrough-attr.c
  cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp
  cfe/trunk/test/SemaCXX/warn-unused-label-error.cpp

Index: cfe/trunk/test/SemaCXX/warn-unused-label-error.cpp
===
--- cfe/trunk/test/SemaCXX/warn-unused-label-error.cpp
+++ cfe/trunk/test/SemaCXX/warn-unused-label-error.cpp
@@ -18,9 +18,9 @@
   }
 
   void h() {
-D: // expected-warning {{unused label 'D'}}
-  #pragma weak unused_local_static
-  __attribute__((unused))  // expected-warning {{declaration does not declare anything}}
-  ;
+  D:
+#pragma weak unused_local_static
+__attribute__((unused)) // expected-error {{'unused' attribute cannot be applied to a statement}}
+;
   }
 }
Index: cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp
===
--- cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp
+++ cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp
@@ -329,3 +329,15 @@
   }
   return n;
 }
+
+int fallthrough_attribute_spelling(int n) {
+  switch (n) {
+  case 0:
+n++;
+__attribute__((fallthrough));
+  case 1:
+n++;
+break;
+  }
+  return n;
+}
Index: cfe/trunk/test/Sema/fallthrough-attr.c
===
--- cfe/trunk/test/Sema/fallthrough-attr.c
+++ cfe/trunk/test/Sema/fallthrough-attr.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -std=gnu89 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough %s
+
+int fallthrough_attribute_spelling(int n) {
+  switch (n) {
+  case 0:
+n++;
+  case 1:
+#if defined(C2X)
+// expected-warning@-2{{unannotated fall-through between switch labels}} expected-note@-2{{insert '[[fallthrough]];' to silence this warning}} expected-note@-2{{insert 'break;' to avoid fall-through}}
+#else
+// expected-warning@-4{{unannotated fall-through between switch labels}} expected-note@-4{{insert '__attribute__((fallthrough));' to silence this warning}} expected-note@-4{{insert 'break;' to avoid fall-through}}
+#endif
+n++;
+__attribute__((fallthrough));
+  case 2:
+n++;
+break;
+  }
+  return n;
+}
Index: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
===
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
@@ -1215,7 +1215,7 @@
 tok::r_square, tok::r_square
   };
 
-  bool PreferClangAttr = !PP.getLangOpts().CPlusPlus17;
+  bool PreferClangAttr = !PP.getLangOpts().CPlusPlus17 && !PP.getLangOpts().C2x;
 
   StringRef MacroName;
   if (PreferClangAttr)
@@ -1224,24 +1224,19 @@
 MacroName = PP.getLastMacroWithSpelling(Loc, FallthroughTokens);
   if (MacroName.empty() && !PreferClangAttr)
 MacroName = PP.getLastMacroWithSpelling(Loc, ClangFallthroughTokens);
-  if (MacroName.empty())
-MacroName = PreferClangAttr ? "[[clang::fallthrough]]" : "[[fallthrough]]";
+  if (MacroName.empty()) {
+if (!PreferClangAttr)
+  MacroName = "[[fallthrough]]";
+else if (PP.getLangOpts().CPlusPlus)
+  MacroName = "[[clang::fallthrough]]";
+else
+  MacroName = "__attribute__((fallthrough))";
+  }
   return MacroName;
 }
 
 static void DiagnoseSwitchLabelsFallthrough(Sema , AnalysisDeclContext ,
 bool PerFunction) {
-  // Only perform this analysis when using [[]] attributes. There is no good
-  // workflow for this warning when not using C++11. There is no good way to
-  // silence the warning (no attribute is available) unless we are using
-  // [[]] attributes. One could use pragmas to silence the warning, but as a
-  // general solution that is gross and not in the spirit of this warning.
-  //
-  // NOTE: This an intermediate solution. There are on-going discussions on
-  // how to properly support this warning outside of C++11 with an annotation.
-  if (!AC.getASTContext().getLangOpts().DoubleSquareBracketAttributes)
-  

[PATCH] D66485: [Clang][Bundler] Use llvm-objcopy for creating fat object files

2019-08-20 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev created this revision.
sdmitriev added a reviewer: ABataev.
Herald added subscribers: cfe-commits, abrachet, mgorny.
Herald added a reviewer: alexshap.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

clang-offload-bundler currently uses partial linking for creating fat object 
files, but such technique cannot be used on Windows due to the absence of 
partial linking support in the linker. This patch changes implementation to use 
llvm-objcopy for merging device and host objects instead of doing partial 
linking. This is one step forward towards enabling OpenMP offload on Windows.


Repository:
  rC Clang

https://reviews.llvm.org/D66485

Files:
  clang/test/CMakeLists.txt
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -21,12 +21,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
-#include "llvm/Bitcode/BitcodeWriter.h"
-#include "llvm/IR/Constant.h"
-#include "llvm/IR/Constants.h"
-#include "llvm/IR/GlobalVariable.h"
-#include "llvm/IR/LLVMContext.h"
-#include "llvm/IR/Module.h"
 #include "llvm/Object/Binary.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/Casting.h"
@@ -39,6 +33,7 @@
 #include "llvm/Support/Program.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
 #include 
 #include 
 #include 
@@ -94,11 +89,6 @@
  "instead of actually executing them - for testing purposes.\n"),
 cl::init(false), cl::cat(ClangOffloadBundlerCategory));
 
-static cl::opt DumpTemporaryFiles(
-"dump-temporary-files",
-cl::desc("Dumps any temporary files created - for testing purposes.\n"),
-cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
 /// Magic string that marks the existence of offloading data.
 #define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
 
@@ -116,12 +106,6 @@
   OffloadKind = KindTriplePair.first;
   Triple = KindTriplePair.second;
 }
-static StringRef getTriple(StringRef Target) {
-  StringRef OffloadKind;
-  StringRef Triple;
-  getOffloadKindAndTriple(Target, OffloadKind, Triple);
-  return Triple;
-}
 static bool hasHostKind(StringRef Target) {
   StringRef OffloadKind;
   StringRef Triple;
@@ -410,19 +394,6 @@
   /// read from the buffers.
   unsigned NumberOfProcessedInputs = 0;
 
-  /// LLVM context used to create the auxiliary modules.
-  LLVMContext VMContext;
-
-  /// LLVM module used to create an object with all the bundle
-  /// components.
-  std::unique_ptr AuxModule;
-
-  /// The current triple we are working with.
-  StringRef CurrentTriple;
-
-  /// The name of the main input file.
-  StringRef MainInputFileName;
-
   /// Iterator of the current and next section.
   section_iterator CurrentSection;
   section_iterator NextSection;
@@ -476,19 +447,10 @@
 
 // Record number of inputs.
 NumberOfInputs = Inputs.size();
-
-// Create an LLVM module to have the content we need to bundle.
-auto *M = new Module("clang-offload-bundle", VMContext);
-M->setTargetTriple(getTriple(TargetNames[HostInputIndex]));
-AuxModule.reset(M);
   }
 
   void WriteBundleStart(raw_fd_ostream , StringRef TargetTriple) final {
 ++NumberOfProcessedInputs;
-
-// Record the triple we are using, that will be used to name the section we
-// will create.
-CurrentTriple = TargetTriple;
   }
 
   bool WriteBundleEnd(raw_fd_ostream , StringRef TargetTriple) final {
@@ -500,76 +462,39 @@
 if (NumberOfProcessedInputs != NumberOfInputs)
   return false;
 
-// Create the bitcode file name to write the resulting code to. Keep it if
-// save-temps is active.
-SmallString<128> BitcodeFileName;
-if (sys::fs::createTemporaryFile("clang-offload-bundler", "bc",
- BitcodeFileName)) {
-  errs() << "error: unable to create temporary file.\n";
+// Find llvm-objcopy in order to create the bundle binary.
+ErrorOr Objcopy = sys::findProgramByName(
+"llvm-objcopy", sys::path::parent_path(BundlerExecutable));
+if (!Objcopy) {
+  errs() << "error: unable to find 'llvm-objcopy' in path.\n";
   return true;
 }
 
-// Dump the contents of the temporary file if that was requested.
-if (DumpTemporaryFiles) {
-  errs() << ";\n; Object file bundler IR file.\n;\n";
-  AuxModule.get()->print(errs(), nullptr,
- /*ShouldPreserveUseListOrder=*/false,
- /*IsForDebug=*/true);
-  errs() << '\n';
-}
-
-// Find clang in order to create the bundle binary.
-StringRef Dir = 

r369414 - [Attr] Support _attribute__ ((fallthrough))

2019-08-20 Thread Nathan Huckleberry via cfe-commits
Author: nathan-huckleberry
Date: Tue Aug 20 10:16:49 2019
New Revision: 369414

URL: http://llvm.org/viewvc/llvm-project?rev=369414=rev
Log:
[Attr] Support _attribute__ ((fallthrough))

Summary: Fixed extraneous matches of non-NullStmt

Reviewers: aaron.ballman, rsmith, efriedma, xbolva00

Reviewed By: aaron.ballman, rsmith, xbolva00

Subscribers: riccibruno, arphaman, ziangwan, ojeda, xbolva00, nickdesaulniers, 
cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Sema/fallthrough-attr.c
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp
cfe/trunk/test/SemaCXX/warn-unused-label-error.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=369414=369413=369414=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Aug 20 10:16:49 2019
@@ -1170,7 +1170,7 @@ def ExtVectorType : Attr {
 
 def FallThrough : StmtAttr {
   let Spellings = [CXX11<"", "fallthrough", 201603>, C2x<"", "fallthrough">,
-   CXX11<"clang", "fallthrough">];
+   CXX11<"clang", "fallthrough">, GCC<"fallthrough">];
 //  let Subjects = [NullStmt];
   let Documentation = [FallthroughDocs];
 }

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=369414=369413=369414=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Aug 20 10:16:49 2019
@@ -2107,12 +2107,13 @@ private:
 
   DeclGroupPtrTy ParseDeclaration(DeclaratorContext Context,
   SourceLocation ,
-  ParsedAttributesWithRange );
-  DeclGroupPtrTy ParseSimpleDeclaration(DeclaratorContext Context,
-SourceLocation ,
-ParsedAttributesWithRange ,
-bool RequireSemi,
-ForRangeInit *FRI = nullptr);
+  ParsedAttributesWithRange ,
+  SourceLocation *DeclSpecStart = nullptr);
+  DeclGroupPtrTy
+  ParseSimpleDeclaration(DeclaratorContext Context, SourceLocation ,
+ ParsedAttributesWithRange , bool RequireSemi,
+ ForRangeInit *FRI = nullptr,
+ SourceLocation *DeclSpecStart = nullptr);
   bool MightBeDeclarator(DeclaratorContext Context);
   DeclGroupPtrTy ParseDeclGroup(ParsingDeclSpec , DeclaratorContext Context,
 SourceLocation *DeclEnd = nullptr,

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=369414=369413=369414=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Aug 20 10:16:49 2019
@@ -1741,9 +1741,10 @@ void Parser::stripTypeAttributesOffDeclS
 /// [C++11/C11] static_assert-declaration
 /// others... [FIXME]
 ///
-Parser::DeclGroupPtrTy Parser::ParseDeclaration(DeclaratorContext Context,
-SourceLocation ,
-  ParsedAttributesWithRange ) {
+Parser::DeclGroupPtrTy
+Parser::ParseDeclaration(DeclaratorContext Context, SourceLocation ,
+ ParsedAttributesWithRange ,
+ SourceLocation *DeclSpecStart) {
   ParenBraceBracketBalancer BalancerRAIIObj(*this);
   // Must temporarily exit the objective-c container scope for
   // parsing c none objective-c decls.
@@ -1763,8 +1764,8 @@ Parser::DeclGroupPtrTy Parser::ParseDecl
   SourceLocation InlineLoc = ConsumeToken();
   return ParseNamespace(Context, DeclEnd, InlineLoc);
 }
-return ParseSimpleDeclaration(Context, DeclEnd, attrs,
-  true);
+return ParseSimpleDeclaration(Context, DeclEnd, attrs, true, nullptr,
+  DeclSpecStart);
   case tok::kw_namespace:
 ProhibitAttributes(attrs);
 return ParseNamespace(Context, DeclEnd);
@@ -1777,7 +1778,8 @@ Parser::DeclGroupPtrTy Parser::ParseDecl
 SingleDecl = ParseStaticAssertDeclaration(DeclEnd);
 break;
   default:
-return ParseSimpleDeclaration(Context, DeclEnd, attrs, true);
+return ParseSimpleDeclaration(Context, DeclEnd, attrs, true, nullptr,
+   

[PATCH] D66303: [LifetimeAnalysis] Add support for free functions

2019-08-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369408: [LifetimeAnalysis] Add support for free functions 
(authored by xazax, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66303?vs=215413=216188#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66303

Files:
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp

Index: cfe/trunk/lib/Sema/SemaInit.cpp
===
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -6616,6 +6616,30 @@
   return false;
 }
 
+static bool shouldTrackFirstArgument(const FunctionDecl *FD) {
+  if (!FD->getIdentifier() || FD->getNumParams() != 1)
+return false;
+  const auto *RD = FD->getParamDecl(0)->getType()->getPointeeCXXRecordDecl();
+  if (!FD->isInStdNamespace() || !RD || !RD->isInStdNamespace())
+return false;
+  if (!isRecordWithAttr(QualType(RD->getTypeForDecl(), 0)) &&
+  !isRecordWithAttr(QualType(RD->getTypeForDecl(), 0)))
+return false;
+  if (FD->getReturnType()->isPointerType() ||
+  isRecordWithAttr(FD->getReturnType())) {
+return llvm::StringSwitch(FD->getName())
+.Cases("begin", "rbegin", "cbegin", "crbegin", true)
+.Cases("end", "rend", "cend", "crend", true)
+.Case("data", true)
+.Default(false);
+  } else if (FD->getReturnType()->isReferenceType()) {
+return llvm::StringSwitch(FD->getName())
+.Cases("get", "any_cast", true)
+.Default(false);
+  }
+  return false;
+}
+
 static void handleGslAnnotatedTypes(IndirectLocalPath , Expr *Call,
 LocalVisitor Visit) {
   auto VisitPointerArg = [&](const Decl *D, Expr *Arg) {
@@ -6639,6 +6663,11 @@
 shouldTrackImplicitObjectArg(cast(Callee)))
   VisitPointerArg(Callee, OCE->getArg(0));
 return;
+  } else if (auto *CE = dyn_cast(Call)) {
+FunctionDecl *Callee = CE->getDirectCallee();
+if (Callee && shouldTrackFirstArgument(Callee))
+  VisitPointerArg(Callee, CE->getArg(0));
+return;
   }
 
   if (auto *CCE = dyn_cast(Call)) {
Index: cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp
===
--- cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp
+++ cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp
@@ -131,13 +131,16 @@
 }
 
 namespace std {
-template struct remove_reference   { typedef T type; };
-template struct remove_reference  { typedef T type; };
-template struct remove_reference { typedef T type; };
+template struct remove_reference   { typedef T type; };
+template struct remove_reference  { typedef T type; };
+template struct remove_reference { typedef T type; };
 
-template
+template
 typename remove_reference::type &(T &) noexcept;
 
+template 
+auto data(const C ) -> decltype(c.data());
+
 template 
 struct vector {
   typedef __gnu_cxx::basic_iterator iterator;
@@ -180,6 +183,11 @@
 struct stack {
   T ();
 };
+
+struct any {};
+
+template
+T any_cast(const any& operand);
 }
 
 void modelIterators() {
@@ -191,6 +199,22 @@
   return std::vector().begin(); // expected-warning {{returning address of local temporary object}}
 }
 
+const int *modelFreeFunctions() {
+  return std::data(std::vector()); // expected-warning {{returning address of local temporary object}}
+}
+
+int () {
+  return std::any_cast(std::any{}); // expected-warning {{returning reference to local temporary object}}
+}
+
+int modelAnyCast2() {
+  return std::any_cast(std::any{}); // ok
+}
+
+int modelAnyCast3() {
+  return std::any_cast(std::any{}); // ok
+}
+
 const char *danglingRawPtrFromLocal() {
   std::basic_string s;
   return s.c_str(); // expected-warning {{address of stack memory associated with local variable 's' returned}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369408 - [LifetimeAnalysis] Add support for free functions

2019-08-20 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Aug 20 09:45:06 2019
New Revision: 369408

URL: http://llvm.org/viewvc/llvm-project?rev=369408=rev
Log:
[LifetimeAnalysis] Add support for free functions

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

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=369408=369407=369408=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Aug 20 09:45:06 2019
@@ -6616,6 +6616,30 @@ static bool shouldTrackImplicitObjectArg
   return false;
 }
 
+static bool shouldTrackFirstArgument(const FunctionDecl *FD) {
+  if (!FD->getIdentifier() || FD->getNumParams() != 1)
+return false;
+  const auto *RD = FD->getParamDecl(0)->getType()->getPointeeCXXRecordDecl();
+  if (!FD->isInStdNamespace() || !RD || !RD->isInStdNamespace())
+return false;
+  if (!isRecordWithAttr(QualType(RD->getTypeForDecl(), 0)) &&
+  !isRecordWithAttr(QualType(RD->getTypeForDecl(), 0)))
+return false;
+  if (FD->getReturnType()->isPointerType() ||
+  isRecordWithAttr(FD->getReturnType())) {
+return llvm::StringSwitch(FD->getName())
+.Cases("begin", "rbegin", "cbegin", "crbegin", true)
+.Cases("end", "rend", "cend", "crend", true)
+.Case("data", true)
+.Default(false);
+  } else if (FD->getReturnType()->isReferenceType()) {
+return llvm::StringSwitch(FD->getName())
+.Cases("get", "any_cast", true)
+.Default(false);
+  }
+  return false;
+}
+
 static void handleGslAnnotatedTypes(IndirectLocalPath , Expr *Call,
 LocalVisitor Visit) {
   auto VisitPointerArg = [&](const Decl *D, Expr *Arg) {
@@ -6639,6 +6663,11 @@ static void handleGslAnnotatedTypes(Indi
 shouldTrackImplicitObjectArg(cast(Callee)))
   VisitPointerArg(Callee, OCE->getArg(0));
 return;
+  } else if (auto *CE = dyn_cast(Call)) {
+FunctionDecl *Callee = CE->getDirectCallee();
+if (Callee && shouldTrackFirstArgument(Callee))
+  VisitPointerArg(Callee, CE->getArg(0));
+return;
   }
 
   if (auto *CCE = dyn_cast(Call)) {

Modified: cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp?rev=369408=369407=369408=diff
==
--- cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp (original)
+++ cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp Tue Aug 20 09:45:06 
2019
@@ -131,13 +131,16 @@ bool operator!=(basic_iterator, basic
 }
 
 namespace std {
-template struct remove_reference   { typedef T type; };
-template struct remove_reference  { typedef T type; };
-template struct remove_reference { typedef T type; };
+template struct remove_reference   { typedef T type; };
+template struct remove_reference  { typedef T type; };
+template struct remove_reference { typedef T type; };
 
-template
+template
 typename remove_reference::type &(T &) noexcept;
 
+template 
+auto data(const C ) -> decltype(c.data());
+
 template 
 struct vector {
   typedef __gnu_cxx::basic_iterator iterator;
@@ -180,6 +183,11 @@ template
 struct stack {
   T ();
 };
+
+struct any {};
+
+template
+T any_cast(const any& operand);
 }
 
 void modelIterators() {
@@ -191,6 +199,22 @@ std::vector::iterator modelIterator
   return std::vector().begin(); // expected-warning {{returning address 
of local temporary object}}
 }
 
+const int *modelFreeFunctions() {
+  return std::data(std::vector()); // expected-warning {{returning 
address of local temporary object}}
+}
+
+int () {
+  return std::any_cast(std::any{}); // expected-warning {{returning 
reference to local temporary object}}
+}
+
+int modelAnyCast2() {
+  return std::any_cast(std::any{}); // ok
+}
+
+int modelAnyCast3() {
+  return std::any_cast(std::any{}); // ok
+}
+
 const char *danglingRawPtrFromLocal() {
   std::basic_string s;
   return s.c_str(); // expected-warning {{address of stack memory associated 
with local variable 's' returned}}


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


[PATCH] D66364: Diagnose use of _Thread_local as an extension when appropriate

2019-08-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D66364#1637570 , @aaron.ballman 
wrote:

> In D66364#1635863 , @ldionne wrote:
>
> > In D66364#1635814 , @aaron.ballman 
> > wrote:
> >
> > > [ ...]
> > >
> > > Adding some libc++ maintainers to see if they have opinions.
> > >
> > > `__extension__` is one option. Could we get away with push/pop disabling 
> > > of the diagnostic? Or perhaps this is a situation where we should not 
> > > diagnose use within a system header in the first place, because that's 
> > > part of the implementation?
> >
> >
> > I just learned about `__extension__`, but from my perspective it makes 
> > sense to mark uses of `_Atomic` with `__extension__` (or disable the 
> > warning with a `#pragma`) inside libc++ if we're using something 
> > non-standard for the current dialect. I don't think Clang should bend its 
> > back for libc++ in this case.
>
>
> Okay, that's good feedback, thank you!


Please ping me directly if you expect libc++ maintainers to do something 
following this patch.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66364



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


[PATCH] D66394: clang-cl: Enable /Zc:twoPhase by default if targeting MSVC 2017 update 3 or newer

2019-08-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL369402: win: Enable /Zc:twoPhase by default if targeting 
MSVC 2017 update 3 or newer (authored by nico, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66394?vs=215785=216181#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66394

Files:
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/include/clang/Driver/CLCompatOptions.td
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/cl-options.c


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4883,12 +4883,14 @@
 !IsWindowsMSVC || IsMSVC2015Compatible))
 CmdArgs.push_back("-fno-threadsafe-statics");
 
-  // -fno-delayed-template-parsing is default, except when targeting MSVC.
-  // Many old Windows SDK versions require this to parse.
-  // FIXME: MSVC introduced /Zc:twoPhase- to disable this behavior in their
-  // compiler. We should be able to disable this by default at some point.
+  // -fno-delayed-template-parsing is default, except when targeting MSVC
+  // earlier than MSVC 2017 15.3 (_MSC_VER 1911).  Windows SDK versions
+  // 10.0.15063.0 (Creators Update or Redstone 2) and earlier require this to
+  // parse.
+  bool IsMSVCBefore2017Update3 = !MSVT.empty() && MSVT < VersionTuple(19, 11);
   if (Args.hasFlag(options::OPT_fdelayed_template_parsing,
-   options::OPT_fno_delayed_template_parsing, IsWindowsMSVC))
+   options::OPT_fno_delayed_template_parsing,
+   IsMSVCBefore2017Update3))
 CmdArgs.push_back("-fdelayed-template-parsing");
 
   // -fgnu-keywords default varies depending on language; only pass if
Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -90,6 +90,9 @@
 Windows Support
 ---
 
+- clang-cl now defaults to ``/Zc:twoPhase`` if targeting MSVC2017 update 3 or
+  later (``_MSC_VER`` >= 1911). This matches MSVC's behavior. Explicitly pass
+  ``/Zc:twoPhase-`` to restore the old behavior.
 - ...
 
 C Language Changes in Clang
Index: cfe/trunk/include/clang/Driver/CLCompatOptions.td
===
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td
@@ -235,10 +235,10 @@
 def _SLASH_Zc_trigraphs_off : CLFlag<"Zc:trigraphs-">,
   HelpText<"Disable trigraphs (default)">, Alias;
 def _SLASH_Zc_twoPhase : CLFlag<"Zc:twoPhase">,
-  HelpText<"Enable two-phase name lookup in templates">,
+  HelpText<"Enable two-phase name lookup in templates (default)">,
   Alias;
 def _SLASH_Zc_twoPhase_ : CLFlag<"Zc:twoPhase-">,
-  HelpText<"Disable two-phase name lookup in templates (default)">,
+  HelpText<"Disable two-phase name lookup in templates">,
   Alias;
 def _SLASH_Z7 : CLFlag<"Z7">,
   HelpText<"Enable CodeView debug information in object files">;
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -316,13 +316,19 @@
 
 // We recognize -f[no-]delayed-template-parsing.
 // /Zc:twoPhase[-] has the opposite meaning.
-// RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDDEFAULT 
%s
-// DELAYEDDEFAULT: "-fdelayed-template-parsing"
-// RUN: %clang_cl -c -fdelayed-template-parsing -### -- %s 2>&1 | FileCheck 
-check-prefix=DELAYEDON %s
-// RUN: %clang_cl -c /Zc:twoPhase- -### -- %s 2>&1 | FileCheck 
-check-prefix=DELAYEDON %s
+// RUN: %clang_cl -c -fmsc-version=1910 -### -- %s 2>&1 | FileCheck 
-check-prefix=OLDDELAYEDDEFAULT %s
+// OLDDELAYEDDEFAULT: "-fdelayed-template-parsing"
+// RUN: %clang_cl -fmsc-version=1911 -c -### -- %s 2>&1 | FileCheck 
-check-prefix=NEWDELAYEDDEFAULT %s
+// NEWDELAYEDDEFAULT-NOT: "-fdelayed-template-parsing"
+// RUN: %clang_cl -c -fmsc-version=1910 -fdelayed-template-parsing -### -- %s 
2>&1 | FileCheck -check-prefix=DELAYEDON %s
+// RUN: %clang_cl -c -fmsc-version=1911 -fdelayed-template-parsing -### -- %s 
2>&1 | FileCheck -check-prefix=DELAYEDON %s
+// RUN: %clang_cl -c -fmsc-version=1910 /Zc:twoPhase- -### -- %s 2>&1 | 
FileCheck -check-prefix=DELAYEDON %s
+// RUN: %clang_cl -c -fmsc-version=1911 /Zc:twoPhase- -### -- %s 2>&1 | 
FileCheck -check-prefix=DELAYEDON %s
 // DELAYEDON: "-fdelayed-template-parsing"
-// RUN: %clang_cl -c -fno-delayed-template-parsing -### -- %s 2>&1 | FileCheck 
-check-prefix=DELAYEDOFF %s
-// RUN: %clang_cl -c /Zc:twoPhase -### -- %s 2>&1 | FileCheck 
-check-prefix=DELAYEDOFF %s
+// RUN: %clang_cl 

r369402 - win: Enable /Zc:twoPhase by default if targeting MSVC 2017 update 3 or newer

2019-08-20 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Aug 20 09:28:11 2019
New Revision: 369402

URL: http://llvm.org/viewvc/llvm-project?rev=369402=rev
Log:
win: Enable /Zc:twoPhase by default if targeting MSVC 2017 update 3 or newer

MSVC 2017 update 3 (_MSC_VER 1911) enables /Zc:twoPhase by default, and
so should clang-cl:
https://docs.microsoft.com/en-us/cpp/build/reference/zc-twophase

clang-cl takes the MSVC version it emulates from the -fmsc-version flag,
or if that's not passed it tries to check what the installed version of
MSVC is and uses that, and failing that it uses a default version that's
currently 1911. So this changes the default if no -fmsc-version flag is
passed and no installed MSVC is detected. (It also changes the default
if -fmsc-version is passed or MSVC is detected, and either indicates
_MSC_VER >= 1911.)

As mentioned in the MSDN article, the Windows SDK header files in
version 10.0.15063.0 (Creators Update or Redstone 2) and earlier
versions do not work correctly with /Zc:twoPhase. If you need to use
these old SDKs with a new clang-cl, explicitly pass /Zc:twoPhase- to get
the old behavior.

Fixes PR43032.

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

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=369402=369401=369402=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Aug 20 09:28:11 2019
@@ -90,6 +90,9 @@ Attribute Changes in Clang
 Windows Support
 ---
 
+- clang-cl now defaults to ``/Zc:twoPhase`` if targeting MSVC2017 update 3 or
+  later (``_MSC_VER`` >= 1911). This matches MSVC's behavior. Explicitly pass
+  ``/Zc:twoPhase-`` to restore the old behavior.
 - ...
 
 C Language Changes in Clang

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=369402=369401=369402=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Tue Aug 20 09:28:11 2019
@@ -235,10 +235,10 @@ def _SLASH_Zc_trigraphs : CLFlag<"Zc:tri
 def _SLASH_Zc_trigraphs_off : CLFlag<"Zc:trigraphs-">,
   HelpText<"Disable trigraphs (default)">, Alias;
 def _SLASH_Zc_twoPhase : CLFlag<"Zc:twoPhase">,
-  HelpText<"Enable two-phase name lookup in templates">,
+  HelpText<"Enable two-phase name lookup in templates (default)">,
   Alias;
 def _SLASH_Zc_twoPhase_ : CLFlag<"Zc:twoPhase-">,
-  HelpText<"Disable two-phase name lookup in templates (default)">,
+  HelpText<"Disable two-phase name lookup in templates">,
   Alias;
 def _SLASH_Z7 : CLFlag<"Z7">,
   HelpText<"Enable CodeView debug information in object files">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=369402=369401=369402=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Aug 20 09:28:11 2019
@@ -4883,12 +4883,14 @@ void Clang::ConstructJob(Compilation ,
 !IsWindowsMSVC || IsMSVC2015Compatible))
 CmdArgs.push_back("-fno-threadsafe-statics");
 
-  // -fno-delayed-template-parsing is default, except when targeting MSVC.
-  // Many old Windows SDK versions require this to parse.
-  // FIXME: MSVC introduced /Zc:twoPhase- to disable this behavior in their
-  // compiler. We should be able to disable this by default at some point.
+  // -fno-delayed-template-parsing is default, except when targeting MSVC
+  // earlier than MSVC 2017 15.3 (_MSC_VER 1911).  Windows SDK versions
+  // 10.0.15063.0 (Creators Update or Redstone 2) and earlier require this to
+  // parse.
+  bool IsMSVCBefore2017Update3 = !MSVT.empty() && MSVT < VersionTuple(19, 11);
   if (Args.hasFlag(options::OPT_fdelayed_template_parsing,
-   options::OPT_fno_delayed_template_parsing, IsWindowsMSVC))
+   options::OPT_fno_delayed_template_parsing,
+   IsMSVCBefore2017Update3))
 CmdArgs.push_back("-fdelayed-template-parsing");
 
   // -fgnu-keywords default varies depending on language; only pass if

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=369402=369401=369402=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Tue Aug 20 09:28:11 2019
@@ -316,13 +316,19 @@
 
 // We recognize 

[PATCH] D66302: [SVE][Inline-Asm] Support for SVE asm operands

2019-08-20 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 216178.
kmclaughlin added a comment.

- Added a new test file, aarch64-sve-asm-negative.ll
- Updated description of the 'y' constraint in LangRef.rst




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

https://reviews.llvm.org/D66302

Files:
  docs/LangRef.rst
  lib/Target/AArch64/AArch64AsmPrinter.cpp
  lib/Target/AArch64/AArch64ISelLowering.cpp
  lib/Target/AArch64/AArch64InstrInfo.cpp
  lib/Target/AArch64/AArch64SVEInstrInfo.td
  test/CodeGen/AArch64/aarch64-sve-asm-negative.ll
  test/CodeGen/AArch64/aarch64-sve-asm.ll
  test/CodeGen/AArch64/arm64-inline-asm.ll

Index: test/CodeGen/AArch64/arm64-inline-asm.ll
===
--- test/CodeGen/AArch64/arm64-inline-asm.ll
+++ test/CodeGen/AArch64/arm64-inline-asm.ll
@@ -138,6 +138,8 @@
   %a = alloca [2 x float], align 4
   %arraydecay = getelementptr inbounds [2 x float], [2 x float]* %a, i32 0, i32 0
   %0 = load <2 x float>, <2 x float>* %data, align 8
+  call void asm sideeffect "ldr ${1:z}, [$0]\0A", "r,w"(float* %arraydecay, <2 x float> %0) nounwind
+  ; CHECK: ldr {{z[0-9]+}}, [{{x[0-9]+}}]
   call void asm sideeffect "ldr ${1:q}, [$0]\0A", "r,w"(float* %arraydecay, <2 x float> %0) nounwind
   ; CHECK: ldr {{q[0-9]+}}, [{{x[0-9]+}}]
   call void asm sideeffect "ldr ${1:d}, [$0]\0A", "r,w"(float* %arraydecay, <2 x float> %0) nounwind
Index: test/CodeGen/AArch64/aarch64-sve-asm.ll
===
--- /dev/null
+++ test/CodeGen/AArch64/aarch64-sve-asm.ll
@@ -0,0 +1,46 @@
+; RUN: llc < %s -mtriple aarch64-none-linux-gnu -mattr=+sve -stop-after=finalize-isel | FileCheck %s --check-prefix=CHECK
+
+target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-none-linux-gnu"
+
+; Function Attrs: nounwind readnone
+; CHECK: [[ARG1:%[0-9]+]]:zpr = COPY $z1
+; CHECK: [[ARG2:%[0-9]+]]:zpr = COPY $z0
+; CHECK: [[ARG3:%[0-9]+]]:zpr = COPY [[ARG2]]
+; CHECK: [[ARG4:%[0-9]+]]:zpr_3b = COPY [[ARG1]]
+define  @test_svadd_i8( %Zn,  %Zm) {
+  %1 = tail call  asm "add $0.b, $1.b, $2.b", "=w,w,y"( %Zn,  %Zm)
+  ret  %1
+}
+
+; Function Attrs: nounwind readnone
+; CHECK: [[ARG1:%[0-9]+]]:zpr = COPY $z1
+; CHECK: [[ARG2:%[0-9]+]]:zpr = COPY $z0
+; CHECK: [[ARG3:%[0-9]+]]:zpr = COPY [[ARG2]]
+; CHECK: [[ARG4:%[0-9]+]]:zpr_4b = COPY [[ARG1]]
+define  @test_svsub_i64( %Zn,  %Zm) {
+  %1 = tail call  asm "sub $0.d, $1.d, $2.d", "=w,w,x"( %Zn,  %Zm)
+  ret  %1
+}
+
+; Function Attrs: nounwind readnone
+; CHECK: [[ARG1:%[0-9]+]]:zpr = COPY $z1
+; CHECK: [[ARG2:%[0-9]+]]:zpr = COPY $z0
+; CHECK: [[ARG3:%[0-9]+]]:zpr = COPY [[ARG2]]
+; CHECK: [[ARG4:%[0-9]+]]:zpr_3b = COPY [[ARG1]]
+define  @test_svfmul_f16( %Zn,  %Zm) {
+  %1 = tail call  asm "fmul $0.h, $1.h, $2.h", "=w,w,y"( %Zn,  %Zm)
+  ret  %1
+}
+
+; Function Attrs: nounwind readnone
+; CHECK: [[ARG1:%[0-9]+]]:zpr = COPY $z1
+; CHECK: [[ARG2:%[0-9]+]]:zpr = COPY $z0
+; CHECK: [[ARG3:%[0-9]+]]:zpr = COPY [[ARG2]]
+; CHECK: [[ARG4:%[0-9]+]]:zpr_4b = COPY [[ARG1]]
+define  @test_svfmul_f( %Zn,  %Zm) {
+  %1 = tail call  asm "fmul $0.s, $1.s, $2.s", "=w,w,x"( %Zn,  %Zm)
+  ret  %1
+}
+
+!0 = !{i32 188, i32 210}
Index: test/CodeGen/AArch64/aarch64-sve-asm-negative.ll
===
--- /dev/null
+++ test/CodeGen/AArch64/aarch64-sve-asm-negative.ll
@@ -0,0 +1,8 @@
+; RUN: not llc -mtriple aarch64-none-linux-gnu -mattr=+neon -o %t.s -filetype=asm %s 2>&1 | FileCheck %s
+
+; Function Attrs: nounwind readnone
+; CHECK: error: couldn't allocate input reg for constraint 'y'
+define <4 x i32> @test_neon(<4 x i32> %in1, <4 x i32> %in2) {
+  %1 = tail call <4 x i32> asm "add $0.4s, $1.4s, $2.4s", "=w,w,y"(<4 x i32> %in1, <4 x i32> %in2)
+  ret <4 x i32> %1
+}
Index: lib/Target/AArch64/AArch64SVEInstrInfo.td
===
--- lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -1020,6 +1020,56 @@
   (FCMGT_PPzZZ_S PPR32:$Zd, PPR3bAny:$Pg, ZPR32:$Zn, ZPR32:$Zm), 0>;
   def : InstAlias<"fcmlt $Zd, $Pg/z, $Zm, $Zn",
   (FCMGT_PPzZZ_D PPR64:$Zd, PPR3bAny:$Pg, ZPR64:$Zn, ZPR64:$Zm), 0>;
+
+  def : Pat<(nxv16i8 (bitconvert (nxv8i16 ZPR:$src))), (nxv16i8 ZPR:$src)>;
+  def : Pat<(nxv16i8 (bitconvert (nxv4i32 ZPR:$src))), (nxv16i8 ZPR:$src)>;
+  def : Pat<(nxv16i8 (bitconvert (nxv2i64 ZPR:$src))), (nxv16i8 ZPR:$src)>;
+  def : Pat<(nxv16i8 (bitconvert (nxv8f16 ZPR:$src))), (nxv16i8 ZPR:$src)>;
+  def : Pat<(nxv16i8 (bitconvert (nxv4f32 ZPR:$src))), (nxv16i8 ZPR:$src)>;
+  def : Pat<(nxv16i8 (bitconvert (nxv2f64 ZPR:$src))), (nxv16i8 ZPR:$src)>;
+
+  def : Pat<(nxv8i16 (bitconvert (nxv16i8 ZPR:$src))), (nxv8i16 ZPR:$src)>;
+  def : Pat<(nxv8i16 (bitconvert (nxv4i32 ZPR:$src))), (nxv8i16 ZPR:$src)>;
+  def : Pat<(nxv8i16 (bitconvert (nxv2i64 ZPR:$src))), (nxv8i16 ZPR:$src)>;
+  def : 

[PATCH] D66481: [C++20] Support for lambdas in unevaluated context

2019-08-20 Thread Kris Jusiak via Phabricator via cfe-commits
krzysztof-jusiak added a comment.

In D66481#1637530 , @lebedev.ri wrote:

> Doesn't this inadvertently allow them in every standard? That seems wrong.


Good point, you are right, will fix it and resubmit 


Repository:
  rC Clang

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

https://reviews.llvm.org/D66481



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


[PATCH] D66481: [C++20] Support for lambdas in unevaluated context

2019-08-20 Thread Kris Jusiak via Phabricator via cfe-commits
krzysztof-jusiak added a comment.

In D66481#1637525 , @riccibruno wrote:

> Can you submit the patch with the full context (ie: git diff -U999) ?


Sure, will do it


Repository:
  rC Clang

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

https://reviews.llvm.org/D66481



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


[PATCH] D66364: Diagnose use of _Thread_local as an extension when appropriate

2019-08-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D66364#1635863 , @ldionne wrote:

> In D66364#1635814 , @aaron.ballman 
> wrote:
>
> > [ ...]
> >
> > Adding some libc++ maintainers to see if they have opinions.
> >
> > `__extension__` is one option. Could we get away with push/pop disabling of 
> > the diagnostic? Or perhaps this is a situation where we should not diagnose 
> > use within a system header in the first place, because that's part of the 
> > implementation?
>
>
> I just learned about `__extension__`, but from my perspective it makes sense 
> to mark uses of `_Atomic` with `__extension__` (or disable the warning with a 
> `#pragma`) inside libc++ if we're using something non-standard for the 
> current dialect. I don't think Clang should bend its back for libc++ in this 
> case.


Okay, that's good feedback, thank you!


Repository:
  rC Clang

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

https://reviews.llvm.org/D66364



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


r369397 - [clang] Use the new Regex::isValid() with no parameter

2019-08-20 Thread Jan Kratochvil via cfe-commits
Author: jankratochvil
Date: Tue Aug 20 09:07:31 2019
New Revision: 369397

URL: http://llvm.org/viewvc/llvm-project?rev=369397=rev
Log:
[clang] Use the new Regex::isValid() with no parameter

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

Modified:
cfe/trunk/lib/Analysis/CloneDetection.cpp

Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=369397=369396=369397=diff
==
--- cfe/trunk/lib/Analysis/CloneDetection.cpp (original)
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp Tue Aug 20 09:07:31 2019
@@ -153,9 +153,8 @@ void OnlyLargestCloneConstraint::constra
 
 bool FilenamePatternConstraint::isAutoGenerated(
 const CloneDetector::CloneGroup ) {
-  std::string Error;
   if (IgnoredFilesPattern.empty() || Group.empty() ||
-  !IgnoredFilesRegex->isValid(Error))
+  !IgnoredFilesRegex->isValid())
 return false;
 
   for (const StmtSequence  : Group) {


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


  1   2   >