[PATCH] D48204: [analyzer] Make getDerefExpr() skip cleanups.

2018-06-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC335559: [analyzer] Track null and undef values through 
expressions with cleanups. (authored by dergachev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48204?vs=151450&id=152810#toc

Repository:
  rC Clang

https://reviews.llvm.org/D48204

Files:
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  test/Analysis/inlining/inline-defensive-checks.cpp


Index: test/Analysis/inlining/inline-defensive-checks.cpp
===
--- test/Analysis/inlining/inline-defensive-checks.cpp
+++ test/Analysis/inlining/inline-defensive-checks.cpp
@@ -84,3 +84,20 @@
   int &x = b->x; // no-warning
   x = 5;
 }
+
+namespace get_deref_expr_with_cleanups {
+struct S {
+~S();
+};
+S *conjure();
+// The argument won't be used, but it'll cause cleanups
+// to appear around the call site.
+S *get_conjured(S _) {
+  S *s = conjure();
+  if (s) {}
+  return s;
+}
+void test_conjured() {
+  S &s = *get_conjured(S()); // no-warning
+}
+} // namespace get_deref_expr_with_cleanups
Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -141,6 +141,8 @@
   E = AE->getBase();
 } else if (const auto *PE = dyn_cast(E)) {
   E = PE->getSubExpr();
+} else if (const auto *EWC = dyn_cast(E)) {
+  E = EWC->getSubExpr();
 } else {
   // Other arbitrary stuff.
   break;


Index: test/Analysis/inlining/inline-defensive-checks.cpp
===
--- test/Analysis/inlining/inline-defensive-checks.cpp
+++ test/Analysis/inlining/inline-defensive-checks.cpp
@@ -84,3 +84,20 @@
   int &x = b->x; // no-warning
   x = 5;
 }
+
+namespace get_deref_expr_with_cleanups {
+struct S {
+~S();
+};
+S *conjure();
+// The argument won't be used, but it'll cause cleanups
+// to appear around the call site.
+S *get_conjured(S _) {
+  S *s = conjure();
+  if (s) {}
+  return s;
+}
+void test_conjured() {
+  S &s = *get_conjured(S()); // no-warning
+}
+} // namespace get_deref_expr_with_cleanups
Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -141,6 +141,8 @@
   E = AE->getBase();
 } else if (const auto *PE = dyn_cast(E)) {
   E = PE->getSubExpr();
+} else if (const auto *EWC = dyn_cast(E)) {
+  E = EWC->getSubExpr();
 } else {
   // Other arbitrary stuff.
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48204: [analyzer] Make getDerefExpr() skip cleanups.

2018-06-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/inlining/inline-defensive-checks.cpp:93
+S *conjure();
+S *get_conjured(S _) {
+  S *s = conjure();

george.karpenkov wrote:
> what is the argument doing?
Causing cleanups (:


Repository:
  rC Clang

https://reviews.llvm.org/D48204



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


[PATCH] D48204: [analyzer] Make getDerefExpr() skip cleanups.

2018-06-15 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: test/Analysis/inlining/inline-defensive-checks.cpp:93
+S *conjure();
+S *get_conjured(S _) {
+  S *s = conjure();

what is the argument doing?


Repository:
  rC Clang

https://reviews.llvm.org/D48204



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


[PATCH] D48204: [analyzer] Make getDerefExpr() skip cleanups.

2018-06-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

This is supposed to suppress a few Inlined-Defensive-Checks-related false 
positives that accidentally spiked up during my testing of copy elision.


Repository:
  rC Clang

https://reviews.llvm.org/D48204



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


[PATCH] D48204: [analyzer] Make getDerefExpr() skip cleanups.

2018-06-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, 
rnkovacs.
Herald added subscribers: cfe-commits, mikhail.ramalho, baloghadamsoftware, 
eraman.

`ExprWithCleanups` that cleans up function arguments (or any other stuff) at 
the end of the full-expression may break AST pattern-matching for figuring out 
that a null pointer was produced by the inlined function during 
`trackNullOrUndefValue()`. Because this expression doesn't do anything, skip it 
during `getDerefExpr()`.


Repository:
  rC Clang

https://reviews.llvm.org/D48204

Files:
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  test/Analysis/inlining/inline-defensive-checks.cpp


Index: test/Analysis/inlining/inline-defensive-checks.cpp
===
--- test/Analysis/inlining/inline-defensive-checks.cpp
+++ test/Analysis/inlining/inline-defensive-checks.cpp
@@ -84,3 +84,18 @@
   int &x = b->x; // no-warning
   x = 5;
 }
+
+namespace get_deref_expr_with_cleanups {
+struct S {
+~S();
+};
+S *conjure();
+S *get_conjured(S _) {
+  S *s = conjure();
+  if (s) {}
+  return s;
+}
+void test_conjured() {
+  S &s = *get_conjured(S()); // no-warning
+}
+} // namespace get_deref_expr_with_cleanups
Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -140,6 +140,8 @@
   E = AE->getBase();
 } else if (const auto *PE = dyn_cast(E)) {
   E = PE->getSubExpr();
+} else if (const auto *EWC = dyn_cast(E)) {
+  E = EWC->getSubExpr();
 } else {
   // Other arbitrary stuff.
   break;


Index: test/Analysis/inlining/inline-defensive-checks.cpp
===
--- test/Analysis/inlining/inline-defensive-checks.cpp
+++ test/Analysis/inlining/inline-defensive-checks.cpp
@@ -84,3 +84,18 @@
   int &x = b->x; // no-warning
   x = 5;
 }
+
+namespace get_deref_expr_with_cleanups {
+struct S {
+~S();
+};
+S *conjure();
+S *get_conjured(S _) {
+  S *s = conjure();
+  if (s) {}
+  return s;
+}
+void test_conjured() {
+  S &s = *get_conjured(S()); // no-warning
+}
+} // namespace get_deref_expr_with_cleanups
Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -140,6 +140,8 @@
   E = AE->getBase();
 } else if (const auto *PE = dyn_cast(E)) {
   E = PE->getSubExpr();
+} else if (const auto *EWC = dyn_cast(E)) {
+  E = EWC->getSubExpr();
 } else {
   // Other arbitrary stuff.
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits