brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.6 KiB · 7885883 Raw
135 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s2// RUN: %clang_cc1 -std=c++11 -debug-info-kind=line-tables-only -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-GMLT %s3// RUN: %clang_cc1 -std=c++11 -debug-info-kind=line-directives-only -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-GMLI %s4// RUN: %clang_cc1 -std=c++11 -debug-info-kind=standalone -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-NOLIMIT %s5 6namespace A {7#line 1 "foo.cpp"8namespace B {9extern int i;10int f1() { return 0; }11void f1(int) { }12struct foo;13struct bar { };14typedef bar baz;15extern int var_decl;16void func_decl(void);17extern int var_fwd;18void func_fwd(void);19}20}21namespace A {22using namespace B;23}24 25using namespace A;26namespace E = A;27int B::i = f1();28int func(bool b) {29  if (b) {30    using namespace A::B;31    return i;32  }33  using namespace A;34  using B::foo;35  using B::bar;36  using B::f1;37  using B::i;38  using B::baz;39  namespace X = A;40  namespace Y = X;41  using B::var_decl;42  using B::func_decl;43  using B::var_fwd;44  using B::func_fwd;45  return i + X::B::i + Y::B::i;46}47 48namespace A {49using B::i;50namespace B {51int var_fwd = i;52}53inline namespace I {54int var_i;55}56}57namespace {58int anonymous;59}60void B::func_fwd() {61  anonymous = 0;62}63 64namespace C {65  void c();66}67void C::c() {}68 69// This should work even if 'i' and 'func' were declarations & not definitions,70// but it doesn't yet.71 72// CHECK: [[I:![0-9]+]] = distinct !DIGlobalVariable(name: "i",{{.*}} scope: [[NS:![0-9]+]],73// CHECK: [[NS]] = !DINamespace(name: "B", scope: [[CTXT:![0-9]+]])74// CHECK: [[CTXT]] = !DINamespace(name: "A", scope: null)75// CHECK: [[FOOCPP:.*]] = !DIFile(filename: "foo.cpp"76// CHECK: [[VAR_FWD:![0-9]+]] = distinct !DIGlobalVariable(name: "var_fwd",{{.*}} scope: [[NS]],77// CHECK-SAME:                                             line: 4478// CHECK-SAME:                                             isDefinition: true79// CHECK: distinct !DIGlobalVariable(name: "var_i",{{.*}} scope: [[INLINE:![0-9]+]],80// CHECK: [[INLINE]] = !DINamespace(name: "I", scope: [[CTXT]], exportSymbols: true)81// CHECK: !DINamespace(scope: null)82// CHECK: [[CU:![0-9]+]] = distinct !DICompileUnit(83// CHECK-SAME:                            imports: [[MODULES:![0-9]*]]84// CHECK: [[MODULES]] = !{[[M1:![0-9]+]], [[M2:![0-9]+]], [[M3:![0-9]+]], [[M4:![0-9]+]]}85// CHECK: [[M1]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CTXT]], entity: [[NS]], file: [[FOOCPP]], line: 15)86// CHECK: [[M2]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CU]], entity: [[CTXT]],87// CHECK: [[M3]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "E", scope: [[CU]], entity: [[CTXT]], file: [[FOOCPP]], line: 19)88// CHECK: [[M4]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[CTXT]], entity: [[I]]89// CHECK: [[F1:![0-9]+]] = distinct !DISubprogram(name: "f1",{{.*}} line: 490// CHECK-SAME:                           DISPFlagDefinition91// CHECK: [[FUNC:![0-9]+]] = distinct !DISubprogram(name: "func",{{.*}} DISPFlagDefinition92// CHECK-SAME:                             retainedNodes: [[FUNC_NODES:![0-9]*]]93// CHECK: [[FUNC_NODES]] = !{[[M5:![0-9]+]], [[M6:![0-9]+]], [[M7:![0-9]+]], [[M8:![0-9]+]], [[M9:![0-9]+]], [[M10:![0-9]+]], [[M11:![0-9]+]], [[M12:![0-9]+]], [[M13:![0-9]+]], [[M14:![0-9]+]], [[M15:![0-9]+]], [[M16:![0-9]+]], [[M17:![0-9]+]]}94// CHECK: [[M5]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[LEX2:![0-9]+]], entity: [[NS]], file: [[FOOCPP]], line: 23)95// CHECK: [[LEX2]] = distinct !DILexicalBlock(scope: [[LEX1:![0-9]+]], file: [[FOOCPP]],96// CHECK: [[LEX1]] = distinct !DILexicalBlock(scope: [[FUNC:![0-9]+]], file: [[FOOCPP]],97// CHECK: [[M6]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[FUNC]], entity: [[CTXT]],98// CHECK: [[M7]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[FOO:![0-9]+]], file: [[FOOCPP]], line: 27)99// CHECK: [[FOO]] = !DICompositeType(tag: DW_TAG_structure_type, name: "foo",100// CHECK-SAME:                               line: 5101// CHECK-SAME:                               DIFlagFwdDecl102// CHECK: [[M8]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[BAR:![0-9]+]]103// CHECK: [[BAR]] = !DICompositeType(tag: DW_TAG_structure_type, name: "bar",104// CHECK-SAME:                               line: 6105// CHECK-SAME:                               DIFlagFwdDecl106// CHECK: [[M9]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[F1]]107// CHECK: [[M10]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[I]]108// CHECK: [[M11]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[BAZ:![0-9]+]]109// CHECK: [[BAZ]] = !DIDerivedType(tag: DW_TAG_typedef, name: "baz", scope: [[NS]], file: [[FOOCPP]],110// CHECK-SAME:                     baseType: [[BAR]]111// CHECK: [[M12]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "X", scope: [[FUNC]], entity: [[CTXT]]112// CHECK: [[M13]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "Y", scope: [[FUNC]], entity: [[M12]]113// CHECK: [[M14]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[VAR_DECL:![0-9]+]]114// CHECK: [[VAR_DECL]] = !DIGlobalVariable(name: "var_decl", linkageName: "{{[^"]*var_decl[^"]*}}", scope: [[NS]],{{.*}} line: 8,115// CHECK: [[M15]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[FUNC_DECL:![0-9]+]]116// CHECK: [[FUNC_DECL]] = !DISubprogram(name: "func_decl",117// CHECK-SAME:                          scope: [[NS]], file: [[FOOCPP]], line: 9118// CHECK: [[M16]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[VAR_FWD:![0-9]+]]119// CHECK: [[M17]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[FUNC_FWD:![0-9]+]]120// CHECK: [[FUNC_FWD]] = distinct !DISubprogram(name: "func_fwd",{{.*}} line: 53,{{.*}} DISPFlagDefinition121// CHECK: distinct !DISubprogram(name: "c",{{.*}}, scope: ![[C:[0-9]+]],{{.*}}, line: 60,{{.*}} DISPFlagDefinition122// CHECK: ![[C]] = !DINamespace(name: "C",123 124// CHECK-GMLT: [[CU:![0-9]+]] = distinct !DICompileUnit(125// CHECK-GMLT-SAME:                            emissionKind: LineTablesOnly,126// CHECK-GMLT-NOT:                             imports:127 128// CHECK-GMLI: [[CU:![0-9]+]] = distinct !DICompileUnit(129// CHECK-GMLI-SAME:                            emissionKind: DebugDirectivesOnly,130// CHECK-GMLI-NOT:                             imports:131 132// CHECK-NOLIMIT: !DICompositeType(tag: DW_TAG_structure_type, name: "bar",{{.*}} line: 6,133// CHECK-NOLIMIT-NOT:              DIFlagFwdDecl134// CHECK-NOLIMIT-SAME:             ){{$}}135