================ @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -debug-info-kind=limited -gno-column-info -triple=x86_64-pc-linux -emit-llvm %s -o - | FileCheck %s + +// The important thing is that the compare and the conditional branch have +// locs with the same scope (the lexical block for the 'if'). By turning off +// column info, they end up with the same !dbg record, which halves the number +// of checks to verify the scope. + +int c = 2; + +int f() { +#line 100 + if (int a = 5; a > c) + return 1; + return 0; +} +// CHECK-LABEL: define {{.*}} @_Z1fv() +// CHECK: = icmp {{.*}} !dbg [[F_CMP:![0-9]+]] +// CHECK-NEXT: br i1 {{.*}} !dbg [[F_CMP]] ---------------- pogo59 wrote:
I followed this where my test case led me. You're right it's worth looking at other control structures that have implied lexical blocks. > & I guess this all only applies when the control structure doesn't have `{}`? > (that being why the test doesn't have braces?) No, this applies in all cases. ``` if (int a = 5; b > c) { return a; } else { return a + 1; } ``` The implied lexical block started by the `if` statement spans its then and else parts; whether those parts are simple or compound doesn't matter. Analogous to how a function definition has an implied lexical block at the opening paren of the parameter list; the function name is visible in the containing scope, the parameter names are not. https://github.com/llvm/llvm-project/pull/108300 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits