[clang] [clang][DebugInfo] Preserve scopes for declarations in unbraced if arms (PR #243767)
Longjun Luo via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 18 06:45:55 PST 2026
anatasluo wrote:
I reproduced this with Clang 24.0.0git (`6fba582ee46d`) and GDB 17.2 on x86-64 Linux.
```cpp
// arm.cpp
int mark(int *p) { return 1; }
int main(int argc, char **) {
if (argc > 1)
static int x = mark(&x);
else
static int x = mark(&x);
}
```
```sh
clang++ -O0 -g arm.cpp -o arm
gdb -q -nx -batch ./arm -ex 'break mark' -ex run \
-ex 'set $actual = p' -ex up -ex 'print &x == $actual'
```
With no arguments, `main` takes the `else` arm. Its `&x` should match the pointer passed to `mark`. GDB prints `false` on main and `true` with the patch.
https://github.com/llvm/llvm-project/pull/243767
More information about the cfe-commits
mailing list