[cfe-commits] r89773 - in /cfe/trunk: lib/CodeGen/CGStmt.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenCXX/condition.cpp
Douglas Gregor
dgregor at apple.com
Mon Nov 30 11:52:44 PST 2009
On Nov 30, 2009, at 11:48 AM, Daniel Dunbar wrote:
> Hi Doug,
>
> On Tue, Nov 24, 2009 at 8:43 AM, Douglas Gregor <dgregor at apple.com>
> wrote:
>> Author: dgregor
>> Date: Tue Nov 24 10:43:22 2009
>> New Revision: 89773
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=89773&view=rev
>> Log:
>> Introduce cleanup scopes for "if" statements in two places:
>> - Outside the "if", to ensure that we destroy the condition variable
>> at the end of the "if" statement rather than at the end of the
>> block containing the "if" statement.
>
> Yay!
>
>> - Inside the "then" and "else" branches, so that we emit then- or
>> else-local cleanups at the end of the corresponding block when the
>> block is not a compound statement.
>
> I can't convince myself these are necessary. Cleanups are run in FIFO
> order so how is this different than putting them on the cleanup for
> the containing statement, since no code is run after the then/else
> branches terminate.
It's for disgusting cases like:
if (rand() % 2 == 1)
std::string s = "foo";
std::string t = "bar";
so that we destroy "s" after the if statement but before "t", but only
if we took the "then" branch.
- Doug
More information about the cfe-commits
mailing list