2013-09-04 12:12:25 +08:00
|
|
|
// RUN: %clangxx -target x86_64-unknown-unknown -g %s -emit-llvm -S -o - | FileCheck %s
|
2013-01-17 03:54:35 +08:00
|
|
|
// PR14471
|
|
|
|
|
2013-08-18 04:01:53 +08:00
|
|
|
enum X {
|
|
|
|
Y
|
|
|
|
};
|
2013-01-17 03:54:35 +08:00
|
|
|
class C
|
|
|
|
{
|
|
|
|
static int a;
|
2013-01-20 09:19:17 +08:00
|
|
|
const static bool const_a = true;
|
2013-01-17 03:54:35 +08:00
|
|
|
protected:
|
|
|
|
static int b;
|
2013-01-20 09:19:17 +08:00
|
|
|
const static float const_b = 3.14;
|
2013-01-17 03:54:35 +08:00
|
|
|
public:
|
|
|
|
static int c;
|
|
|
|
const static int const_c = 18;
|
|
|
|
int d;
|
2013-08-18 04:01:53 +08:00
|
|
|
static X x_a;
|
2013-01-17 03:54:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
int C::a = 4;
|
|
|
|
int C::b = 2;
|
|
|
|
int C::c = 1;
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
C instance_C;
|
|
|
|
instance_C.d = 8;
|
|
|
|
return C::c;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The definition of C::a drives the emission of class C, which is
|
|
|
|
// why the definition of "a" comes before the declarations while
|
|
|
|
// "b" and "c" come after.
|
|
|
|
|
2013-08-30 07:19:58 +08:00
|
|
|
// CHECK: metadata !"_ZTS1X"} ; [ DW_TAG_enumeration_type ] [X]
|
|
|
|
// CHECK: metadata !"_ZTS1C"} ; [ DW_TAG_class_type ] [C]
|
2014-08-30 06:44:27 +08:00
|
|
|
// CHECK: ![[DECL_A:[0-9]+]] = metadata {{.*}} [ DW_TAG_member ] [a] [line {{.*}}, size 0, align 0, offset 0] [static]
|
2014-10-04 04:01:52 +08:00
|
|
|
// CHECK: metadata !"0xd\00const_a\00{{.*}}", {{.*}}, i1 true} ; [ DW_TAG_member ] [const_a] [line {{.*}}, size 0, align 0, offset 0] [static]
|
|
|
|
// CHECK: ![[DECL_B:[0-9]+]] = metadata !{metadata !"0xd\00b\00{{.*}}", {{.*}} [ DW_TAG_member ] [b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static]
|
|
|
|
// CHECK: metadata !"0xd\00const_b\00{{.*}}", {{.*}}, float 0x{{.*}}} ; [ DW_TAG_member ] [const_b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static]
|
|
|
|
// CHECK: ![[DECL_C:[0-9]+]] = metadata !{metadata !"0xd\00c\00{{.*}}", {{.*}} [ DW_TAG_member ] [c] [line {{.*}}, size 0, align 0, offset 0] [public] [static]
|
|
|
|
// 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]
|
2014-10-24 00:39:49 +08:00
|
|
|
// CHECK: [[NS_X:![0-9]+]] = {{.*}} ; [ DW_TAG_namespace ] [x]
|
2014-11-20 03:42:40 +08:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2014-10-24 00:39:49 +08:00
|
|
|
// 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]
|
2014-10-15 06:22:17 +08:00
|
|
|
|
2014-11-20 03:42:40 +08:00
|
|
|
// CHECK-NOT: ; [ DW_TAG_variable ] [anon_static_decl_var]
|
|
|
|
|
2014-10-15 06:22:17 +08:00
|
|
|
// Verify that even when a static member declaration is created lazily when
|
|
|
|
// creating the definition, the declaration line is that of the canonical
|
2014-10-17 02:38:36 +08:00
|
|
|
// declaration, not the definition. Also, since we look at the canonical
|
|
|
|
// definition, we should also correctly emit the constant value (42) into the
|
|
|
|
// debug info.
|
2014-10-15 06:22:17 +08:00
|
|
|
struct V {
|
|
|
|
virtual ~V(); // cause the definition of 'V' to be omitted by no-standalone-debug optimization
|
|
|
|
static const int const_va = 42;
|
|
|
|
};
|
2014-10-17 02:38:36 +08:00
|
|
|
// CHECK: i32 42} ; [ DW_TAG_member ] [const_va] [line [[@LINE-2]],
|
2014-10-15 06:22:17 +08:00
|
|
|
const int V::const_va;
|
2014-10-24 00:39:49 +08:00
|
|
|
|
|
|
|
namespace x {
|
|
|
|
struct y {
|
|
|
|
static int z;
|
|
|
|
};
|
|
|
|
int y::z;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: metadata !{metadata !"0x34\00z\00{{.*}}", metadata [[NS_X]], {{.*}} ; [ DW_TAG_variable ] [z] {{.*}} [def]
|