diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-11-19 19:42:40 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-11-19 19:42:40 +0000 |
commit | 423eb5a6a5a60a67bc5e1030a233e7977fc15b3f (patch) | |
tree | ad3d84278b26f5112f7175ea86f7ddec1fb37f07 /clang/test/CodeGenCXX/debug-info-static-member.cpp | |
parent | 3563938ee46c0d3f33436ec65a870c082e855f98 (diff) | |
download | bcm5719-llvm-423eb5a6a5a60a67bc5e1030a233e7977fc15b3f.tar.gz bcm5719-llvm-423eb5a6a5a60a67bc5e1030a233e7977fc15b3f.zip |
DebugInfo: Don't emit a 'global variable' when a static member declaration is referenced without a definition, just ensure the enclosing class (with the static member declaration) is emitted.
Addresses PR21511 by emitting appropriate metadata rather than
faux-global definitions for a variable that doesn't have a definition.
llvm-svn: 222377
Diffstat (limited to 'clang/test/CodeGenCXX/debug-info-static-member.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/debug-info-static-member.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/debug-info-static-member.cpp b/clang/test/CodeGenCXX/debug-info-static-member.cpp index c65ccd64dd7..803d0dc1c7f 100644 --- a/clang/test/CodeGenCXX/debug-info-static-member.cpp +++ b/clang/test/CodeGenCXX/debug-info-static-member.cpp @@ -43,10 +43,28 @@ int main() // CHECK: metadata !"0xd\00const_c\00{{.*}}", {{.*}} [ DW_TAG_member ] [const_c] [line {{.*}}, size 0, align 0, offset 0] [public] [static] // CHECK: metadata !"0xd\00x_a\00{{.*}}", {{.*}} [ DW_TAG_member ] [x_a] {{.*}} [public] [static] // CHECK: [[NS_X:![0-9]+]] = {{.*}} ; [ DW_TAG_namespace ] [x] + +// Test this in an anonymous namespace to ensure the type is retained even when +// it doesn't get automatically retained by the string type reference machinery. +namespace { +struct anon_static_decl_struct { + static const int anon_static_decl_var = 117; +}; +} + +// CHECK: ; [ DW_TAG_structure_type ] [anon_static_decl_struct] {{.*}} [def] +// CHECK: ; [ DW_TAG_member ] [anon_static_decl_var] + +int ref() { + return anon_static_decl_struct::anon_static_decl_var; +} + // CHECK: metadata !{metadata !"0x34\00a\00{{.*}}", null, {{.*}} @_ZN1C1aE, metadata ![[DECL_A]]} ; [ DW_TAG_variable ] [a] {{.*}} [def] // CHECK: metadata !{metadata !"0x34\00b\00{{.*}}", null, {{.*}} @_ZN1C1bE, metadata ![[DECL_B]]} ; [ DW_TAG_variable ] [b] {{.*}} [def] // CHECK: metadata !{metadata !"0x34\00c\00{{.*}}", null, {{.*}} @_ZN1C1cE, metadata ![[DECL_C]]} ; [ DW_TAG_variable ] [c] {{.*}} [def] +// CHECK-NOT: ; [ DW_TAG_variable ] [anon_static_decl_var] + // Verify that even when a static member declaration is created lazily when // creating the definition, the declaration line is that of the canonical // declaration, not the definition. Also, since we look at the canonical |