blob: f4cab6390d478989163ae9054dc9c829593fc146 [file] [log] [blame]
Paul Robinsonb17327d2016-04-27 17:37:12 +00001// RUN: %clang_cc1 -DSETNODEBUG=0 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s --check-prefix=YESINFO
2// RUN: %clang_cc1 -DSETNODEBUG=1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s --check-prefix=NOINFO
3
4#if SETNODEBUG
5#define NODEBUG __attribute__((nodebug))
6#else
7#define NODEBUG
8#endif
9
Paul Robinsonb17327d2016-04-27 17:37:12 +000010// Const global variable. Use it so it gets emitted.
11NODEBUG static const int const_global_int_def = 1;
12void func1(int);
13void func2() { func1(const_global_int_def); }
14// YESINFO-DAG: !DIGlobalVariable(name: "const_global_int_def"
15// NOINFO-NOT: !DIGlobalVariable(name: "const_global_int_def"
16
17// Global variable with a more involved type.
18// If the variable has no debug info, the type should not appear either.
19struct S1 {
20 int a;
21 int b;
22};
23NODEBUG S1 global_struct = { 2, 3 };
24// YESINFO-DAG: !DICompositeType({{.*}} name: "S1"
25// NOINFO-NOT: !DICompositeType({{.*}} name: "S1"
26// YESINFO-DAG: !DIGlobalVariable(name: "global_struct"
27// NOINFO-NOT: !DIGlobalVariable(name: "global_struct"
28
29// Static data members. Const member needs a use.
30struct S2 {
31 NODEBUG static int static_member;
32 NODEBUG static const int static_const_member = 4;
33};
34int S2::static_member = 5;
Paul Robinson1c6fc202016-04-27 22:18:46 +000035void func3() { func1(S2::static_const_member); }
Paul Robinsonb17327d2016-04-27 17:37:12 +000036// YESINFO-DAG: !DIGlobalVariable(name: "static_member"
37// NOINFO-NOT: !DIGlobalVariable(name: "static_member"
38// YESINFO-DAG: !DIDerivedType({{.*}} name: "static_const_member"
39// NOINFO-NOT: !DIDerivedType({{.*}} name: "static_const_member"
40
41// Function-local static variable.
Paul Robinson1c6fc202016-04-27 22:18:46 +000042void func4() {
43 NODEBUG static int static_local = 6;
Paul Robinsonb17327d2016-04-27 17:37:12 +000044}
Paul Robinson1c6fc202016-04-27 22:18:46 +000045// YESINFO-DAG: !DIGlobalVariable(name: "static_local"
46// NOINFO-NOT: !DIGlobalVariable(name: "static_local"