and as artificial local variables in the debug info. This is a follow-up to r236059. We can't get rid of the local variables entirely because the gdb buildbot depends on them, but we can mark them as artificial while still emitting the correct debug info. As I learned from review comments other compilers also follow this model. A paired commit in LLVM temporarily relaxes the debug info verifier to not check the integrity of DW_OP_bit_pieces of artificial variables. rdar://problem/20730771 llvm-svn: 236125
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
// RUN: %clang_cc1 -emit-llvm -gdwarf-4 -triple x86_64-linux-gnu %s -o - | FileCheck %s
|
|
|
|
// Make sure that we emit a global variable for each of the members of the
|
|
// anonymous union.
|
|
|
|
static union {
|
|
int c;
|
|
int d;
|
|
union {
|
|
int a;
|
|
};
|
|
struct {
|
|
int b;
|
|
};
|
|
};
|
|
|
|
int test_it() {
|
|
c = 1;
|
|
d = 2;
|
|
a = 4;
|
|
return (c == 1);
|
|
}
|
|
|
|
void foo() {
|
|
union {
|
|
int i;
|
|
char c;
|
|
};
|
|
i = 8;
|
|
}
|
|
|
|
// CHECK: [[FILE:.*]] = !DIFile(filename: "{{.*}}debug-info-anon-union-vars.cpp",
|
|
// CHECK: !DIGlobalVariable(name: "c",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
|
|
// CHECK: !DIGlobalVariable(name: "d",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
|
|
// CHECK: !DIGlobalVariable(name: "a",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
|
|
// CHECK: !DIGlobalVariable(name: "b",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
|
|
// CHECK: !DILocalVariable(tag: DW_TAG_auto_variable, name: "i", {{.*}}, flags: DIFlagArtificial
|
|
// CHECK: !DILocalVariable(tag: DW_TAG_auto_variable, name: "c", {{.*}}, flags: DIFlagArtificial
|
|
// CHECK: !DILocalVariable(
|
|
// CHECK-NOT: name:
|
|
// CHECK: type: ![[UNION:[0-9]+]]
|
|
// CHECK: ![[UNION]] = !DICompositeType(tag: DW_TAG_union_type,
|
|
// CHECK-NOT: name:
|
|
// CHECK: elements
|
|
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i", scope: ![[UNION]],
|
|
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "c", scope: ![[UNION]],
|