]> granicus.if.org Git - clang/commit
Debug Info: Represent local anonymous unions as anonymous unions
authorAdrian Prantl <aprantl@apple.com>
Tue, 28 Apr 2015 23:01:24 +0000 (23:01 +0000)
committerAdrian Prantl <aprantl@apple.com>
Tue, 28 Apr 2015 23:01:24 +0000 (23:01 +0000)
commit79a35c23d38a192ada157233984da53cdd77a081
treed20d197ca98254e9bbbd6f98dd17df60dc34c06e
parent1ceb94e36571b87ea68455d05eb9c0592cd8eda4
Debug Info: Represent local anonymous unions as anonymous unions
in the debug info. This patch deletes a hack that emits the members
of local anonymous unions as local variables.

Besides being morally wrong, the existing representation using local
variables breaks internal assumptions about the local variables' storage
size.

Compiling

```
   void fn1() {
     union {
       int i;
       char c;
     };
     i = c;
   }

```

with -g -O3 -verify will cause the verifier to fail after SROA splits
the 32-bit storage for the "local variable" c into two pieces because the
second piece is clearly outside the 8-bit range that is expected for a
variable of type char. Given the choice I'd rather fix the debug
representation than weaken the verifier.

Debuggers generally already know how to deal with anonymous unions when
they are members of C++ record types, but they may have problems finding
the local anonymous struct members in the expression evaluator.

rdar://problem/20730771

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236059 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGDebugInfo.cpp
test/CodeGenCXX/debug-info-anon-union-vars.cpp