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

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 25 16:59:49 PDT 2018


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<ParenExpr>(E)) {
       E = PE->getSubExpr();
+    } else if (const auto *EWC = dyn_cast<ExprWithCleanups>(E)) {
+      E = EWC->getSubExpr();
     } else {
       // Other arbitrary stuff.
       break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48204.152810.patch
Type: text/x-patch
Size: 1184 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180625/0a64f03b/attachment.bin>


More information about the cfe-commits mailing list