r183597 - Debug info: An if condition now creates a lexical scope of its own.
Adrian Prantl
aprantl at apple.com
Mon Jun 10 15:36:10 PDT 2013
On Jun 10, 2013, at 11:38 AM, David Blaikie <dblaikie at gmail.com> wrote:
> With this (or Eric's) change do we get the right (same as (or
> justified if different) GCC) number/placement of scopes/variables for:
>
> if (x)
> a();
> else
> b();
>
> if (int x = ...)
> a();
> else
> b();
>
> if (int x = ...) {
> int y = ...;
> a();
> } else {
> int z = ...;
> }
>
> (in theory 'x' should be in-scope across both the if and the else, but
> we probably don't bother creating a scope if there's no variable in
> that scope - and just create one for the if/else bodies... but not
> sure)
I’m not sure if I understand what you are trying to say...
For the code above we generate a
(unsure)
DW_TAG_lexical scope
DW_TAG_variable (x)
DW_TAG_lexical scope
DW_TAG_variable (x)
DW_TAG_lexical scope
DW_TAG_variable (y)
DW_TAG_lexical scope
DW_TAG_variable (z)
I’m not sure how to interpret the x at the beginning of the function.
The only difference between GCC and clang I can spot is that GCC puts the entire function into a DW_TAG_lexical scope, but I don’t think that this is strictly necessary.
Does that answer the question?
-- adrian
More information about the cfe-commits
mailing list