r369574 - [analyzer] Mention whether an event is about a condition in a bug report part 1

Kristof Umann via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 21 13:43:27 PDT 2019


Author: szelethus
Date: Wed Aug 21 13:43:27 2019
New Revision: 369574

URL: http://llvm.org/viewvc/llvm-project?rev=369574&view=rev
Log:
[analyzer] Mention whether an event is about a condition in a bug report part 1

Can't add much more to the title! This is part 1, the case where the collapse
point isn't in the condition point is the responsibility of ConditionBRVisitor,
which I'm addressing in part 2.

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

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
    cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=369574&r1=369573&r2=369574&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Wed Aug 21 13:43:27 2019
@@ -298,6 +298,7 @@ class NoStoreFuncVisitor final : public
   MemRegionManager &MmrMgr;
   const SourceManager &SM;
   const PrintingPolicy &PP;
+  bugreporter::TrackingKind TKind;
 
   /// Recursion limit for dereferencing fields when looking for the
   /// region of interest.
@@ -318,10 +319,10 @@ class NoStoreFuncVisitor final : public
   using RegionVector = SmallVector<const MemRegion *, 5>;
 
 public:
-  NoStoreFuncVisitor(const SubRegion *R)
+  NoStoreFuncVisitor(const SubRegion *R, bugreporter::TrackingKind TKind)
       : RegionOfInterest(R), MmrMgr(*R->getMemRegionManager()),
         SM(MmrMgr.getContext().getSourceManager()),
-        PP(MmrMgr.getContext().getPrintingPolicy()) {}
+        PP(MmrMgr.getContext().getPrintingPolicy()), TKind(TKind) {}
 
   void Profile(llvm::FoldingSetNodeID &ID) const override {
     static int Tag = 0;
@@ -612,6 +613,9 @@ void NoStoreFuncVisitor::findModifyingFr
   } while (N);
 }
 
+static llvm::StringLiteral WillBeUsedForACondition =
+    ", which participates in a condition later";
+
 PathDiagnosticPieceRef NoStoreFuncVisitor::maybeEmitNote(
     BugReport &R, const CallEvent &Call, const ExplodedNode *N,
     const RegionVector &FieldChain, const MemRegion *MatchedRegion,
@@ -658,6 +662,8 @@ PathDiagnosticPieceRef NoStoreFuncVisito
     return nullptr;
 
   os << "'";
+  if (TKind == bugreporter::TrackingKind::Condition)
+    os << WillBeUsedForACondition;
   return std::make_shared<PathDiagnosticEventPiece>(L, os.str());
 }
 
@@ -1068,6 +1074,9 @@ public:
     if (!L.isValid() || !L.asLocation().isValid())
       return nullptr;
 
+    if (TKind == bugreporter::TrackingKind::Condition)
+      Out << WillBeUsedForACondition;
+
     auto EventPiece = std::make_shared<PathDiagnosticEventPiece>(L, Out.str());
 
     // If we determined that the note is meaningless, make it prunable, and
@@ -1450,6 +1459,9 @@ FindLastStoreBRVisitor::VisitNode(const
   if (os.str().empty())
     showBRDefaultDiagnostics(os, R, V);
 
+  if (TKind == bugreporter::TrackingKind::Condition)
+    os << WillBeUsedForACondition;
+
   // Construct a new PathDiagnosticPiece.
   ProgramPoint P = StoreSite->getLocation();
   PathDiagnosticLocation L;
@@ -1933,7 +1945,7 @@ bool bugreporter::trackExpressionValue(c
       // Mark both the variable region and its contents as interesting.
       SVal V = LVState->getRawSVal(loc::MemRegionVal(R));
       report.addVisitor(
-          std::make_unique<NoStoreFuncVisitor>(cast<SubRegion>(R)));
+          std::make_unique<NoStoreFuncVisitor>(cast<SubRegion>(R), TKind));
 
       MacroNullReturnSuppressionVisitor::addMacroVisitorIfNecessary(
           LVNode, R, EnableNullFPSuppression, report, V);

Modified: cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp?rev=369574&r1=369573&r2=369574&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp (original)
+++ cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp Wed Aug 21 13:43:27 2019
@@ -29,24 +29,24 @@ int flag;
 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 at -1{{Taking false branch}}
+  if (flag) // expected-note-re   {{{{^}}Assuming 'flag' is 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking false branch{{$}}}}
     x = new int;
 
-  foo(); // tracking-note{{Calling 'foo'}}
-         // tracking-note at -1{{Returning from 'foo'}}
+  foo(); // tracking-note-re{{{{^}}Calling 'foo'{{$}}}}
+         // tracking-note-re at -1{{{{^}}Returning from 'foo'{{$}}}}
 
-  if (flag) // expected-note   {{Assuming 'flag' is not equal to 0}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  if (flag) // expected-note-re   {{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
 
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
@@ -58,7 +58,7 @@ int flag;
 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 @@ void test() {
   flag = 1;
 
   foo();
-  if (flag) // expected-note   {{Assuming 'flag' is 0}}
-            // expected-note at -1{{Taking false branch}}
+  if (flag) // expected-note-re   {{{{^}}Assuming 'flag' is 0{{$}}}}
+            // expected-note-re at -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 at -1{{Returning from 'foo'}}
+  foo(); // tracking-note-re{{{{^}}Calling 'foo'{{$}}}}
+         // tracking-note-re at -1{{{{^}}Returning from 'foo'{{$}}}}
 
-  if (flag) // expected-note   {{Assuming 'flag' is not equal to 0}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  if (flag) // expected-note-re   {{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
 
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
@@ -90,25 +90,25 @@ bool coin();
 
 void foo() {
   // coin() could write bar, do it's invalidated.
-  flag = coin(); // tracking-note{{Value assigned to 'flag'}}
-                 // tracking-note at -1{{Value assigned to 'bar'}}
+  flag = coin(); // tracking-note-re{{{{^}}Value assigned to 'flag', which participates in a condition later{{$}}}}
+                 // tracking-note-re at -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 at -1{{Returning from 'foo'}}
+  foo(); // tracking-note-re{{{{^}}Calling 'foo'{{$}}}}
+         // tracking-note-re at -1{{{{^}}Returning from 'foo'{{$}}}}
 
-  if (bar) // expected-note   {{Assuming 'bar' is not equal to 0}}
-           // expected-note at -1{{Taking true branch}}
-           // debug-note at -2{{Tracking condition 'bar'}}
-    if (flag) // expected-note   {{Assuming 'flag' is not equal to 0}}
-              // expected-note at -1{{Taking true branch}}
-              // debug-note at -2{{Tracking condition 'flag'}}
+  if (bar) // expected-note-re   {{{{^}}Assuming 'bar' is not equal to 0{{$}}}}
+           // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+           // debug-note-re at -2{{{{^}}Tracking condition 'bar'{{$}}}}
+    if (flag) // expected-note-re   {{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
+              // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+              // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
 
       *x = 5; // expected-warning{{Dereference of null pointer}}
               // expected-note at -1{{Dereference of null pointer}}
@@ -125,11 +125,11 @@ bool foo() {
 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{{$}}}}
 
-  if (int flag = foo()) // debug-note{{Tracking condition 'flag'}}
-                        // expected-note at -1{{Assuming 'flag' is not equal to 0}}
-                        // expected-note at -2{{Taking true branch}}
+  if (int flag = foo()) // debug-note-re{{{{^}}Tracking condition 'flag'{{$}}}}
+                        // expected-note-re at -1{{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
+                        // expected-note-re at -2{{{{^}}Taking true branch{{$}}}}
 
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
@@ -144,12 +144,12 @@ struct ConvertsToBool {
 };
 
 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{{$}}}}
 
   if (ConvertsToBool())
-    // debug-note at -1{{Tracking condition 'ConvertsToBool()'}}
-    // expected-note at -2{{Assuming the condition is true}}
-    // expected-note at -3{{Taking true branch}}
+    // debug-note-re at -1{{{{^}}Tracking condition 'ConvertsToBool()'{{$}}}}
+    // expected-note-re at -2{{{{^}}Assuming the condition is true{{$}}}}
+    // expected-note-re at -3{{{{^}}Taking true branch{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -159,9 +159,9 @@ void test() {
 namespace note_from_different_but_not_nested_stackframe {
 
 void nullptrDeref(int *ptr, bool True) {
-  if (True) // expected-note{{'True' is true}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'True}}
+  if (True) // expected-note-re{{{{^}}'True' is true{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'True'{{$}}}}
     *ptr = 5;
   // expected-note at -1{{Dereference of null pointer (loaded from variable 'ptr')}}
   // expected-warning at -2{{Dereference of null pointer (loaded from variable 'ptr')}}
@@ -169,11 +169,11 @@ void nullptrDeref(int *ptr, bool True) {
 
 void f() {
   int *ptr = nullptr;
-  // expected-note at -1{{'ptr' initialized to a null pointer value}}
+  // expected-note-re at -1{{{{^}}'ptr' initialized to a null pointer value{{$}}}}
   bool True = true;
   nullptrDeref(ptr, True);
-  // expected-note at -1{{Passing null pointer value via 1st parameter 'ptr'}}
-  // expected-note at -2{{Calling 'nullptrDeref'}}
+  // expected-note-re at -1{{{{^}}Passing null pointer value via 1st parameter 'ptr'{{$}}}}
+  // expected-note-re at -2{{{{^}}Calling 'nullptrDeref'{{$}}}}
 }
 
 } // end of namespace note_from_different_but_not_nested_stackframe
@@ -184,26 +184,26 @@ bool coin();
 int *getIntPtr();
 
 void storeValue(int **i) {
-  *i = getIntPtr(); // tracking-note{{Value assigned to 'i'}}
+  *i = getIntPtr(); // tracking-note-re{{{{^}}Value assigned to 'i', which participates in a condition later{{$}}}}
 }
 
 int *conjurePointer() {
   int *i;
-  storeValue(&i); // tracking-note{{Calling 'storeValue'}}
-                  // tracking-note at -1{{Returning from 'storeValue'}}
-  return i;       // tracking-note{{Returning pointer (loaded from 'i')}}
+  storeValue(&i); // tracking-note-re{{{{^}}Calling 'storeValue'{{$}}}}
+                  // tracking-note-re at -1{{{{^}}Returning from 'storeValue'{{$}}}}
+  return i; // tracking-note-re{{{{^}}Returning pointer (loaded from 'i'), which participates in a condition later{{$}}}}
 }
 
 void f(int *ptr) {
-  if (ptr) // expected-note{{Assuming 'ptr' is null}}
-           // expected-note at -1{{Taking false branch}}
+  if (ptr) // expected-note-re{{{{^}}Assuming 'ptr' is null{{$}}}}
+           // expected-note-re at -1{{{{^}}Taking false branch{{$}}}}
     ;
   if (!conjurePointer())
-    // tracking-note at -1{{Calling 'conjurePointer'}}
-    // tracking-note at -2{{Returning from 'conjurePointer'}}
-    // debug-note at -3{{Tracking condition '!conjurePointer()'}}
-    // expected-note at -4{{Assuming the condition is true}}
-    // expected-note at -5{{Taking true branch}}
+    // tracking-note-re at -1{{{{^}}Calling 'conjurePointer'{{$}}}}
+    // tracking-note-re at -2{{{{^}}Returning from 'conjurePointer'{{$}}}}
+    // debug-note-re at -3{{{{^}}Tracking condition '!conjurePointer()'{{$}}}}
+    // expected-note-re at -4{{{{^}}Assuming the condition is true{{$}}}}
+    // expected-note-re at -5{{{{^}}Taking true branch{{$}}}}
     *ptr = 5; // expected-warning{{Dereference of null pointer}}
               // expected-note at -1{{Dereference of null pointer}}
 }
@@ -220,13 +220,13 @@ int *conjurePointer() {
 }
 
 void f(int *ptr) {
-  if (ptr) // expected-note{{Assuming 'ptr' is null}}
-           // expected-note at -1{{Taking false branch}}
+  if (ptr) // expected-note-re{{{{^}}Assuming 'ptr' is null{{$}}}}
+           // expected-note-re at -1{{{{^}}Taking false branch{{$}}}}
     ;
   if (!conjurePointer())
-    // debug-note at -1{{Tracking condition '!conjurePointer()'}}
-    // expected-note at -2{{Assuming the condition is true}}
-    // expected-note at -3{{Taking true branch}}
+    // debug-note-re at -1{{{{^}}Tracking condition '!conjurePointer()'{{$}}}}
+    // expected-note-re at -2{{{{^}}Assuming the condition is true{{$}}}}
+    // expected-note-re at -3{{{{^}}Taking true branch{{$}}}}
     *ptr = 5; // expected-warning{{Dereference of null pointer}}
               // expected-note at -1{{Dereference of null pointer}}
 }
@@ -241,12 +241,12 @@ int *cast(void *P) {
 }
 
 void f() {
-  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{{$}}}}
 
   if (cast(conjure()))
-    // debug-note at -1{{Tracking condition 'cast(conjure())'}}
-    // expected-note at -2{{Assuming the condition is false}}
-    // expected-note at -3{{Taking false branch}}
+    // debug-note-re at -1{{{{^}}Tracking condition 'cast(conjure())'{{$}}}}
+    // expected-note-re at -2{{{{^}}Assuming the condition is false{{$}}}}
+    // expected-note-re at -3{{{{^}}Taking false branch{{$}}}}
     return;
   *x = 5; // expected-warning{{Dereference of null pointer}}
           // expected-note at -1{{Dereference of null pointer}}
@@ -260,13 +260,13 @@ bool coin();
 bool flipCoin() { return coin(); }
 
 void i(int *ptr) {
-  if (ptr) // expected-note{{Assuming 'ptr' is null}}
-           // expected-note at -1{{Taking false branch}}
+  if (ptr) // expected-note-re{{{{^}}Assuming 'ptr' is null{{$}}}}
+           // expected-note-re at -1{{{{^}}Taking false branch{{$}}}}
     ;
   if (!flipCoin())
-    // debug-note at -1{{Tracking condition '!flipCoin()'}}
-    // expected-note at -2{{Assuming the condition is true}}
-    // expected-note at -3{{Taking true branch}}
+    // debug-note-re at -1{{{{^}}Tracking condition '!flipCoin()'{{$}}}}
+    // expected-note-re at -2{{{{^}}Assuming the condition is true{{$}}}}
+    // expected-note-re at -3{{{{^}}Taking true branch{{$}}}}
     *ptr = 5; // expected-warning{{Dereference of null pointer}}
               // expected-note at -1{{Dereference of null pointer}}
 }
@@ -276,23 +276,23 @@ namespace important_returning_value_note
 bool coin();
 
 bool flipCoin() {
-  if (coin()) // tracking-note{{Assuming the condition is false}}
-              // tracking-note at -1{{Taking false branch}}
-              // debug-note at -2{{Tracking condition 'coin()'}}
+  if (coin()) // tracking-note-re{{{{^}}Assuming the condition is false{{$}}}}
+              // tracking-note-re at -1{{{{^}}Taking false branch{{$}}}}
+              // debug-note-re at -2{{{{^}}Tracking condition 'coin()'{{$}}}}
     return true;
-  return coin(); // tracking-note{{Returning value}}
+  return coin(); // tracking-note-re{{{{^}}Returning value, which participates in a condition later{{$}}}}
 }
 
 void i(int *ptr) {
-  if (ptr) // expected-note{{Assuming 'ptr' is null}}
-           // expected-note at -1{{Taking false branch}}
+  if (ptr) // expected-note-re{{{{^}}Assuming 'ptr' is null{{$}}}}
+           // expected-note-re at -1{{{{^}}Taking false branch{{$}}}}
     ;
   if (!flipCoin())
-    // tracking-note at -1{{Calling 'flipCoin'}}
-    // tracking-note at -2{{Returning from 'flipCoin'}}
-    // debug-note at -3{{Tracking condition '!flipCoin()'}}
-    // expected-note at -4{{Assuming the condition is true}}
-    // expected-note at -5{{Taking true branch}}
+    // tracking-note-re at -1{{{{^}}Calling 'flipCoin'{{$}}}}
+    // tracking-note-re at -2{{{{^}}Returning from 'flipCoin'{{$}}}}
+    // debug-note-re at -3{{{{^}}Tracking condition '!flipCoin()'{{$}}}}
+    // expected-note-re at -4{{{{^}}Assuming the condition is true{{$}}}}
+    // expected-note-re at -5{{{{^}}Taking true branch{{$}}}}
     *ptr = 5; // expected-warning{{Dereference of null pointer}}
               // expected-note at -1{{Dereference of null pointer}}
 }
@@ -307,22 +307,22 @@ struct super_complicated_template_hacker
 
 bool flipCoin() {
   if (super_complicated_template_hackery::value)
-    // tracking-note at -1{{'value' is false}}
-    // tracking-note at -2{{Taking false branch}}
+    // tracking-note-re at -1{{{{^}}'value' is false{{$}}}}
+    // tracking-note-re at -2{{{{^}}Taking false branch{{$}}}}
     return true;
-  return coin(); // tracking-note{{Returning value}}
+  return coin(); // tracking-note-re{{{{^}}Returning value, which participates in a condition later{{$}}}}
 }
 
 void i(int *ptr) {
-  if (ptr) // expected-note{{Assuming 'ptr' is null}}
-           // expected-note at -1{{Taking false branch}}
+  if (ptr) // expected-note-re{{{{^}}Assuming 'ptr' is null{{$}}}}
+           // expected-note-re at -1{{{{^}}Taking false branch{{$}}}}
     ;
   if (!flipCoin())
-    // tracking-note at -1{{Calling 'flipCoin'}}
-    // tracking-note at -2{{Returning from 'flipCoin'}}
-    // debug-note at -3{{Tracking condition '!flipCoin()'}}
-    // expected-note at -4{{Assuming the condition is true}}
-    // expected-note at -5{{Taking true branch}}
+    // tracking-note-re at -1{{{{^}}Calling 'flipCoin'{{$}}}}
+    // tracking-note-re at -2{{{{^}}Returning from 'flipCoin'{{$}}}}
+    // debug-note-re at -3{{{{^}}Tracking condition '!flipCoin()'{{$}}}}
+    // expected-note-re at -4{{{{^}}Assuming the condition is true{{$}}}}
+    // expected-note-re at -5{{{{^}}Taking true branch{{$}}}}
     *ptr = 5; // expected-warning{{Dereference of null pointer}}
               // expected-note at -1{{Dereference of null pointer}}
 }
@@ -333,10 +333,10 @@ int getInt();
 
 void f() {
   int flag = getInt();
-  int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
-  if (flag) // expected-note{{Assuming 'flag' is not equal to 0}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  int *x = 0; // expected-note-re{{{{^}}'x' initialized to a null pointer value{{$}}}}
+  if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -350,10 +350,10 @@ void f(int y) {
   y = 1;
   flag = y;
 
-  int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
-  if (flag) // expected-note{{'flag' is 1}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  int *x = 0; // expected-note-re{{{{^}}'x' initialized to a null pointer value{{$}}}}
+  if (flag) // expected-note-re{{{{^}}'flag' is 1{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -366,18 +366,18 @@ int getInt();
 void foo() {
   int y;
   y = 1;
-  flag = y; // tracking-note{{The value 1 is assigned to 'flag'}}
+  flag = y; // tracking-note-re{{{{^}}The value 1 is assigned to 'flag', which participates in a condition later{{$}}}}
 }
 
 void f(int y) {
-  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{{$}}}}
 
-  foo(); // tracking-note{{Calling 'foo'}}
-         // tracking-note at -1{{Returning from 'foo'}}
+  foo(); // tracking-note-re{{{{^}}Calling 'foo'{{$}}}}
+         // tracking-note-re at -1{{{{^}}Returning from 'foo'{{$}}}}
 
-  if (flag) // expected-note{{'flag' is 1}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  if (flag) // expected-note-re{{{{^}}'flag' is 1{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -388,20 +388,20 @@ int flag = 0;
 int getInt();
 
 void foo() {
-  flag = getInt(); // tracking-note{{Value assigned to 'flag'}}
+  flag = getInt(); // tracking-note-re{{{{^}}Value assigned to 'flag', which participates in a condition later{{$}}}}
 }
 
 void f() {
-  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{{$}}}}
   int y = 0;
 
-  foo(); // tracking-note{{Calling 'foo'}}
-         // tracking-note at -1{{Returning from 'foo'}}
+  foo(); // tracking-note-re{{{{^}}Calling 'foo'{{$}}}}
+         // tracking-note-re at -1{{{{^}}Returning from 'foo'{{$}}}}
   y = flag;
 
-  if (y)    // expected-note{{Assuming 'y' is not equal to 0}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'y'}}
+  if (y)    // expected-note-re{{{{^}}Assuming 'y' is not equal to 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'y'{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -412,20 +412,20 @@ namespace collapse_point_not_in_conditio
 [[noreturn]] void halt();
 
 void assert(int b) {
-  if (!b) // tracking-note{{Assuming 'b' is not equal to 0}}
-          // tracking-note at -1{{Taking false branch}}
+  if (!b) // tracking-note-re{{{{^}}Assuming 'b' is not equal to 0{{$}}}}
+          // tracking-note-re at -1{{{{^}}Taking false branch{{$}}}}
     halt();
 }
 
 void f(int flag) {
-  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{{$}}}}
 
-  assert(flag); // tracking-note{{Calling 'assert'}}
-                // tracking-note at -1{{Returning from 'assert'}}
+  assert(flag); // tracking-note-re{{{{^}}Calling 'assert'{{$}}}}
+                // tracking-note-re at -1{{{{^}}Returning from 'assert'{{$}}}}
 
-  if (flag) // expected-note{{'flag' is not equal to 0}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  if (flag) // expected-note-re{{{{^}}'flag' is not equal to 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -437,22 +437,22 @@ namespace unimportant_write_before_colla
 [[noreturn]] void halt();
 
 void assert(int b) {
-  if (!b) // tracking-note{{Assuming 'b' is not equal to 0}}
-          // tracking-note at -1{{Taking false branch}}
+  if (!b) // tracking-note-re{{{{^}}Assuming 'b' is not equal to 0{{$}}}}
+          // tracking-note-re at -1{{{{^}}Taking false branch{{$}}}}
     halt();
 }
 int getInt();
 
 void f(int flag) {
-  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 = getInt();
-  assert(flag); // tracking-note{{Calling 'assert'}}
-                // tracking-note at -1{{Returning from 'assert'}}
+  assert(flag); // tracking-note-re{{{{^}}Calling 'assert'{{$}}}}
+                // tracking-note-re at -1{{{{^}}Returning from 'assert'{{$}}}}
 
-  if (flag) // expected-note{{'flag' is not equal to 0}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  if (flag) // expected-note-re{{{{^}}'flag' is not equal to 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -488,17 +488,17 @@ void bar() {
 }
 
 void f(int flag) {
-  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 = getInt();
 
   bar();
-  assert(cond1); // expected-note{{Assuming 'cond1' is not equal to 0}}
-                 // expected-note at -1{{'?' condition is true}}
+  assert(cond1); // expected-note-re{{{{^}}Assuming 'cond1' is not equal to 0{{$}}}}
+                 // expected-note-re at -1{{{{^}}'?' condition is true{{$}}}}
 
-  if (flag) // expected-note{{'flag' is not equal to 0}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -525,20 +525,20 @@ void bar() {
 }
 
 void f(int flag) {
-  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 = getInt();
 
   bar();
   assert(cond1 && cond2);
-  // expected-note at -1{{Assuming 'cond1' is not equal to 0}}
-  // expected-note at -2{{Assuming 'cond2' is not equal to 0}}
-  // expected-note at -3{{'?' condition is true}}
-  // expected-note at -4{{Left side of '&&' is true}}
-
-  if (flag) // expected-note{{'flag' is not equal to 0}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  // expected-note-re at -1{{{{^}}Assuming 'cond1' is not equal to 0{{$}}}}
+  // expected-note-re at -2{{{{^}}Assuming 'cond2' is not equal to 0{{$}}}}
+  // expected-note-re at -3{{{{^}}'?' condition is true{{$}}}}
+  // expected-note-re at -4{{{{^}}Left side of '&&' is true{{$}}}}
+
+  if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -565,18 +565,18 @@ void bar() {
 }
 
 void f(int flag) {
-  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 = getInt();
 
   bar();
   assert(cond1 || cond2);
-  // expected-note at -1{{Assuming 'cond1' is not equal to 0}}
-  // expected-note at -2{{Left side of '||' is true}}
+  // expected-note-re at -1{{{{^}}Assuming 'cond1' is not equal to 0{{$}}}}
+  // expected-note-re at -2{{{{^}}Left side of '||' is true{{$}}}}
 
-  if (flag) // expected-note{{'flag' is not equal to 0}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -604,18 +604,18 @@ void bar() {
 }
 
 void f(int flag) {
-  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 = getInt();
 
   bar();
-  assert(cond1); // expected-note{{Assuming 'cond1' is not equal to 0}}
-                 // expected-note at -1{{Taking false branch}}
-                 // expected-note at -2{{Loop condition is false.  Exiting loop}}
-
-  if (flag) // expected-note{{'flag' is not equal to 0}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  assert(cond1); // expected-note-re{{{{^}}Assuming 'cond1' is not equal to 0{{$}}}}
+                 // expected-note-re at -1{{{{^}}Taking false branch{{$}}}}
+                 // expected-note-re at -2{{{{^}}Loop condition is false.  Exiting loop{{$}}}}
+
+  if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -645,21 +645,21 @@ void bar() {
 }
 
 void f(int flag) {
-  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 = getInt();
 
   bar();
   assert(cond1 && cond2);
-  // expected-note at -1{{Assuming 'cond1' is not equal to 0}}
-  // expected-note at -2{{Left side of '&&' is true}}
-  // expected-note at -3{{Assuming the condition is false}}
-  // expected-note at -4{{Taking false branch}}
-  // expected-note at -5{{Loop condition is false.  Exiting loop}}
-
-  if (flag) // expected-note{{'flag' is not equal to 0}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  // expected-note-re at -1{{{{^}}Assuming 'cond1' is not equal to 0{{$}}}}
+  // expected-note-re at -2{{{{^}}Left side of '&&' is true{{$}}}}
+  // expected-note-re at -3{{{{^}}Assuming the condition is false{{$}}}}
+  // expected-note-re at -4{{{{^}}Taking false branch{{$}}}}
+  // expected-note-re at -5{{{{^}}Loop condition is false.  Exiting loop{{$}}}}
+
+  if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -689,20 +689,20 @@ void bar() {
 }
 
 void f(int flag) {
-  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 = getInt();
 
   bar();
   assert(cond1 || cond2);
-  // expected-note at -1{{Assuming 'cond1' is not equal to 0}}
-  // expected-note at -2{{Left side of '||' is true}}
-  // expected-note at -3{{Taking false branch}}
-  // expected-note at -4{{Loop condition is false.  Exiting loop}}
-
-  if (flag) // expected-note{{'flag' is not equal to 0}}
-            // expected-note at -1{{Taking true branch}}
-            // debug-note at -2{{Tracking condition 'flag'}}
+  // expected-note-re at -1{{{{^}}Assuming 'cond1' is not equal to 0{{$}}}}
+  // expected-note-re at -2{{{{^}}Left side of '||' is true{{$}}}}
+  // expected-note-re at -3{{{{^}}Taking false branch{{$}}}}
+  // expected-note-re at -4{{{{^}}Loop condition is false.  Exiting loop{{$}}}}
+
+  if (flag) // expected-note-re{{{{^}}Assuming 'flag' is not equal to 0{{$}}}}
+            // expected-note-re at -1{{{{^}}Taking true branch{{$}}}}
+            // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
     *x = 5; // expected-warning{{Dereference of null pointer}}
             // expected-note at -1{{Dereference of null pointer}}
 }
@@ -715,7 +715,7 @@ namespace only_track_the_evaluated_condi
 bool coin();
 
 void bar(int &flag) {
-  flag = coin(); // tracking-note{{Value assigned to 'flag'}}
+  flag = coin(); // tracking-note-re{{{{^}}Value assigned to 'flag', which participates in a condition later{{$}}}}
 }
 
 void bar2(int &flag2) {
@@ -723,19 +723,19 @@ void bar2(int &flag2) {
 }
 
 void f(int *x) {
-  if (x) // expected-note{{Assuming 'x' is null}}
-         // debug-note at -1{{Tracking condition 'x'}}
-         // expected-note at -2{{Taking false branch}}
+  if (x) // expected-note-re{{{{^}}Assuming 'x' is null{{$}}}}
+         // debug-note-re at -1{{{{^}}Tracking condition 'x'{{$}}}}
+         // expected-note-re at -2{{{{^}}Taking false branch{{$}}}}
     return;
 
   int flag, flag2;
-  bar(flag); // tracking-note{{Calling 'bar'}}
-             // tracking-note at -1{{Returning from 'bar'}}
+  bar(flag); // tracking-note-re{{{{^}}Calling 'bar'{{$}}}}
+             // tracking-note-re at -1{{{{^}}Returning from 'bar'{{$}}}}
   bar2(flag2);
 
-  if (flag && flag2) // expected-note   {{Assuming 'flag' is 0}}
-                     // expected-note at -1{{Left side of '&&' is false}}
-                     // debug-note at -2{{Tracking condition 'flag'}}
+  if (flag && flag2) // expected-note-re   {{{{^}}Assuming 'flag' is 0{{$}}}}
+                     // expected-note-re at -1{{{{^}}Left side of '&&' is false{{$}}}}
+                     // debug-note-re at -2{{{{^}}Tracking condition 'flag'{{$}}}}
     return;
 
   *x = 5; // expected-warning{{Dereference of null pointer}}




More information about the cfe-commits mailing list