On Mon, Nov 30, 2009 at 11:52 AM, Douglas Gregor <[email protected]> wrote: > > On Nov 30, 2009, at 11:48 AM, Daniel Dunbar wrote: > >> Hi Doug, >> >> On Tue, Nov 24, 2009 at 8:43 AM, Douglas Gregor <[email protected]> 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.
Right, I follow that, but there is a cleanup scope around the if statement itself, so the cleanups for s can still go there and still be run before t, no? - Daniel _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
