[PATCH] Proposal on how to fix temporary dtors.

Jordan Rose jordan_rose at apple.com
Mon Jun 2 17:06:24 PDT 2014


Still missing a blocks example. :-)

================
Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:765-766
@@ +764,4 @@
+      ExplodedNodeSet Next;
+      VisitCXXBindTemporaryExpr(cast<CXXBindTemporaryExpr>(S), Pred, PreVisit,
+                                Next);
+      getCheckerManager().runCheckersForPostStmt(Dst, Next, S, *this);
----------------
Why is `Pred` being passed here? The `PreVisit` set has the same information.

================
Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:521-527
@@ +520,9 @@
+  }
+  StmtNodeBuilder StmtBldr(PreVisit, Dst, *currBldrCtx);
+  ProgramStateRef State = Pred->getState();
+  assert(!State->contains<InitializedTemporariesSet>(
+      std::make_pair(BTE, Pred->getStackFrame())));
+  State = State->add<InitializedTemporariesSet>(
+      std::make_pair(BTE, Pred->getStackFrame()));
+  StmtBldr.generateNode(BTE, Pred, State);
+}
----------------
Right, this is not correct. We need to iterate over the nodes in the pre-visit set and update //all// of them to generate `Dst`.

================
Comment at: test/Analysis/temporaries.cpp:291-294
@@ +290,6 @@
+  void testNestedFullStatements() {
+    []() { check(NoReturnDtor()); } != nullptr || check(Dtor());
+    // The CFG for this now looks correct, but we still do not reach the line
+    // below.
+    clang_analyzer_warnIfReached(); // FIXME: Should warn.
+  }
----------------
I don't think we assume that lambda-exprs are always non-null. We should.

http://reviews.llvm.org/D3627






More information about the cfe-commits mailing list