[PATCH] D49213: [analyzer] pr38072: Suppress an assertion failure for eliding the same destructor twice due to the default argument problem.

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 31 14:18:14 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC338441: [analyzer] Fix eliding the same destructor twice due to buggy default arguments. (authored by dergachev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D49213

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/temporaries.cpp


Index: test/Analysis/temporaries.cpp
===================================================================
--- test/Analysis/temporaries.cpp
+++ test/Analysis/temporaries.cpp
@@ -458,6 +458,21 @@
 #endif // TEMPORARY_DTORS
 }
 
+namespace default_param_elided_destructors {
+struct a {
+  ~a();
+};
+struct F {
+  a d;
+  F(char *, a = a());
+};
+void g() {
+  char h[1];
+  for (int i = 0;;)
+    F j(i ? j : h);
+}
+} // namespace default_param_elided_destructors
+
 void testStaticMaterializeTemporaryExpr() {
   static const Trivial &ref = getTrivial();
   clang_analyzer_eval(ref.value == 42); // expected-warning{{TRUE}}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===================================================================
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -460,7 +460,8 @@
                                             const CXXBindTemporaryExpr *BTE,
                                             const LocationContext *LC) {
   ConstructedObjectKey Key({BTE, /*IsElided=*/true}, LC);
-  assert(!State->contains<ObjectsUnderConstruction>(Key));
+  // FIXME: Currently the state might already contain the marker due to
+  // incorrect handling of temporaries bound to default parameters.
   return State->set<ObjectsUnderConstruction>(Key, UnknownVal());
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49213.158384.patch
Type: text/x-patch
Size: 1330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180731/5e2d4abd/attachment.bin>


More information about the cfe-commits mailing list