1 // 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 10 // Simple global variable declaration and definition. 11 // Use the declaration so it gets emitted. 12 NODEBUG int global_int_decl; 13 NODEBUG int global_int_def = global_int_decl; 14 // YESINFO-DAG: !DIGlobalVariable(name: "global_int_decl" 15 // NOINFO-NOT: !DIGlobalVariable(name: "global_int_decl" 16 // YESINFO-DAG: !DIGlobalVariable(name: "global_int_def" 17 // NOINFO-NOT: !DIGlobalVariable(name: "global_int_def" 18 19 // Const global variable. Use it so it gets emitted. 20 NODEBUG static const int const_global_int_def = 1; 21 void func1(int); 22 void func2() { func1(const_global_int_def); } 23 // YESINFO-DAG: !DIGlobalVariable(name: "const_global_int_def" 24 // NOINFO-NOT: !DIGlobalVariable(name: "const_global_int_def" 25 26 // Global variable with a more involved type. 27 // If the variable has no debug info, the type should not appear either. 28 struct S1 { 29 int a; 30 int b; 31 }; 32 NODEBUG S1 global_struct = { 2, 3 }; 33 // YESINFO-DAG: !DICompositeType({{.*}} name: "S1" 34 // NOINFO-NOT: !DICompositeType({{.*}} name: "S1" 35 // YESINFO-DAG: !DIGlobalVariable(name: "global_struct" 36 // NOINFO-NOT: !DIGlobalVariable(name: "global_struct" 37 38 // Static data members. Const member needs a use. 39 struct S2 { 40 NODEBUG static int static_member; 41 NODEBUG static const int static_const_member = 4; 42 }; 43 int S2::static_member = 5; 44 int junk = S2::static_const_member; 45 // YESINFO-DAG: !DIGlobalVariable(name: "static_member" 46 // NOINFO-NOT: !DIGlobalVariable(name: "static_member" 47 // YESINFO-DAG: !DIDerivedType({{.*}} name: "static_const_member" 48 // NOINFO-NOT: !DIDerivedType({{.*}} name: "static_const_member" 49 50 // Function-local static variable. 51 void func3() { 52 NODEBUG static int func_local = 6; 53 } 54 // YESINFO-DAG: !DIGlobalVariable(name: "func_local" 55 // NOINFO-NOT: !DIGlobalVariable(name: "func_local" 56