[PATCH] Proposal on how to fix temporary dtors.

Manuel Klimek klimek at google.com
Fri May 23 05:41:28 PDT 2014


On Thu, May 22, 2014 at 5:23 AM, Jordan Rose <jordan_rose at apple.com> wrote:

> ================
> 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)) {
>

Putting the recursive call into the condition, of course :)


>       *(volatile int *)0 = 1; // should warn
>

The analyzer now presents a puzzle:
Your test works (does not warn currently, warns when I add the stack-frame
info).
The problem is that when I replace that line with:
clang_analyzer_eval(true); // expected-warning{{TRUE}}
I do not get that warning.

What's the difference?

Thanks!
/Manuel


>     }
>   }
>   void topLevel() {
>     test(false);
>   }
>
> http://reviews.llvm.org/D3627
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140523/e1ddc876/attachment.html>


More information about the cfe-commits mailing list