[PATCH] Proposal on how to fix temporary dtors.

Jordan Rose jordan_rose at apple.com
Wed May 21 20:23:12 PDT 2014


================
Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:54-56
@@ -53,1 +53,5 @@
 
+REGISTER_TRAIT_WITH_PROGRAMSTATE(
+    InitializedTemporariesSet,
+    llvm::ImmutableSet<const CXXBindTemporaryExpr *>);
+
----------------
Manuel Klimek wrote:
> Jordan Rose wrote:
> > This needs to include the current StackFrameContext as well (for recursive functions). You can get that from the current LocationContext.
> Can you elaborate on how I would put that into a datastructure? Just use a std::pair? (doesn't seem to work with ImmutableSet though)
> 
> Also, I seem unable to write a test that breaks because of this - any hints would be highly welcome.
We'd have to write a specialization of ImutProfileInfo for std::pair, but that's probably not a bad idea anyway. Please feel free to add one to ImmutableSet.h.

I would guess the test case would look something like this:

  static bool test(bool isInner) {
    if (isInner || NoReturnDtor() || test(true)) {
      *(volatile int *)0 = 1; // should warn
    }
  }
  void topLevel() {
    test(false);
  }

http://reviews.llvm.org/D3627






More information about the cfe-commits mailing list