This revision was automatically updated to reflect the committed changes.
Closed by commit rL368853: [analyzer][NFC] Prove that we only track the 
evaluated part of the condition (authored by Szelethus, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65290?vs=211779&id=215110#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D65290

Files:
  cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp


Index: cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp
===================================================================
--- cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp
+++ cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp
@@ -532,6 +532,7 @@
 }
 
 #undef assert
+
 } // end of namespace dont_track_assertlike_and_conditions
 
 namespace dont_track_assertlike_or_conditions {
@@ -697,3 +698,37 @@
 
 #undef assert
 } // end of namespace dont_track_assert2like_or_conditions
+
+namespace only_track_the_evaluated_condition {
+
+bool coin();
+
+void bar(int &flag) {
+  flag = coin(); // tracking-note{{Value assigned to 'flag'}}
+}
+
+void bar2(int &flag2) {
+  flag2 = coin();
+}
+
+void f(int *x) {
+  if (x) // expected-note{{Assuming 'x' is null}}
+         // debug-note@-1{{Tracking condition 'x'}}
+         // expected-note@-2{{Taking false branch}}
+    return;
+
+  int flag, flag2;
+  bar(flag); // tracking-note{{Calling 'bar'}}
+             // tracking-note@-1{{Returning from 'bar'}}
+  bar2(flag2);
+
+  if (flag && flag2) // expected-note   {{Assuming 'flag' is 0}}
+                     // expected-note@-1{{Left side of '&&' is false}}
+                     // debug-note@-2{{Tracking condition 'flag'}}
+    return;
+
+  *x = 5; // expected-warning{{Dereference of null pointer}}
+          // expected-note@-1{{Dereference of null pointer}}
+}
+
+} // end of namespace only_track_the_evaluated_condition


Index: cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp
===================================================================
--- cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp
+++ cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp
@@ -532,6 +532,7 @@
 }
 
 #undef assert
+
 } // end of namespace dont_track_assertlike_and_conditions
 
 namespace dont_track_assertlike_or_conditions {
@@ -697,3 +698,37 @@
 
 #undef assert
 } // end of namespace dont_track_assert2like_or_conditions
+
+namespace only_track_the_evaluated_condition {
+
+bool coin();
+
+void bar(int &flag) {
+  flag = coin(); // tracking-note{{Value assigned to 'flag'}}
+}
+
+void bar2(int &flag2) {
+  flag2 = coin();
+}
+
+void f(int *x) {
+  if (x) // expected-note{{Assuming 'x' is null}}
+         // debug-note@-1{{Tracking condition 'x'}}
+         // expected-note@-2{{Taking false branch}}
+    return;
+
+  int flag, flag2;
+  bar(flag); // tracking-note{{Calling 'bar'}}
+             // tracking-note@-1{{Returning from 'bar'}}
+  bar2(flag2);
+
+  if (flag && flag2) // expected-note   {{Assuming 'flag' is 0}}
+                     // expected-note@-1{{Left side of '&&' is false}}
+                     // debug-note@-2{{Tracking condition 'flag'}}
+    return;
+
+  *x = 5; // expected-warning{{Dereference of null pointer}}
+          // expected-note@-1{{Dereference of null pointer}}
+}
+
+} // end of namespace only_track_the_evaluated_condition
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to