2015-10-08 12:24:12 +08:00
|
|
|
// RUN: %clang_cc1 -debug-info-kind=limited -S -emit-llvm %s -o - | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -debug-info-kind=line-tables-only -S -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-GMLT %s
|
|
|
|
// RUN: %clang_cc1 -debug-info-kind=standalone -S -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-NOLIMIT %s
|
2010-10-28 07:23:58 +08:00
|
|
|
|
|
|
|
namespace A {
|
2013-03-21 03:10:57 +08:00
|
|
|
#line 1 "foo.cpp"
|
|
|
|
namespace B {
|
2014-11-06 03:19:04 +08:00
|
|
|
extern int i;
|
|
|
|
int f1() { return 0; }
|
2013-05-20 12:58:53 +08:00
|
|
|
void f1(int) { }
|
|
|
|
struct foo;
|
|
|
|
struct bar { };
|
|
|
|
typedef bar baz;
|
2014-11-18 11:40:51 +08:00
|
|
|
extern int var_decl;
|
|
|
|
void func_decl(void);
|
|
|
|
extern int var_fwd;
|
|
|
|
void func_fwd(void);
|
2010-10-28 07:23:58 +08:00
|
|
|
}
|
2013-08-17 06:52:07 +08:00
|
|
|
}
|
|
|
|
namespace A {
|
2013-04-26 13:41:06 +08:00
|
|
|
using namespace B;
|
2013-03-21 03:10:57 +08:00
|
|
|
}
|
2010-10-28 07:23:58 +08:00
|
|
|
|
2013-04-26 13:41:06 +08:00
|
|
|
using namespace A;
|
2013-05-21 06:50:41 +08:00
|
|
|
namespace E = A;
|
2014-11-06 03:19:04 +08:00
|
|
|
int B::i = f1();
|
2013-05-07 07:33:13 +08:00
|
|
|
int func(bool b) {
|
|
|
|
if (b) {
|
|
|
|
using namespace A::B;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
using namespace A;
|
2013-05-20 12:58:53 +08:00
|
|
|
using B::foo;
|
|
|
|
using B::bar;
|
|
|
|
using B::f1;
|
|
|
|
using B::i;
|
|
|
|
using B::baz;
|
2013-05-21 06:50:41 +08:00
|
|
|
namespace X = A;
|
|
|
|
namespace Y = X;
|
2014-11-18 11:40:51 +08:00
|
|
|
using B::var_decl;
|
|
|
|
using B::func_decl;
|
|
|
|
using B::var_fwd;
|
|
|
|
using B::func_fwd;
|
2013-05-21 06:50:41 +08:00
|
|
|
return i + X::B::i + Y::B::i;
|
2013-04-22 14:13:21 +08:00
|
|
|
}
|
|
|
|
|
2014-02-16 05:03:07 +08:00
|
|
|
namespace A {
|
|
|
|
using B::i;
|
2014-11-18 11:40:51 +08:00
|
|
|
namespace B {
|
|
|
|
int var_fwd = i;
|
|
|
|
}
|
2014-02-16 05:03:07 +08:00
|
|
|
}
|
2014-11-18 11:40:51 +08:00
|
|
|
void B::func_fwd() {}
|
2014-02-16 05:03:07 +08:00
|
|
|
|
2013-05-20 12:58:53 +08:00
|
|
|
// This should work even if 'i' and 'func' were declarations & not definitions,
|
|
|
|
// but it doesn't yet.
|
|
|
|
|
2015-07-01 02:32:50 +08:00
|
|
|
// CHECK: [[CU:![0-9]+]] = distinct !DICompileUnit(
|
2015-03-04 01:25:55 +08:00
|
|
|
// CHECK-SAME: imports: [[MODULES:![0-9]*]]
|
2016-04-24 06:29:26 +08:00
|
|
|
// CHECK: [[I:![0-9]+]] = distinct !DIGlobalVariable(name: "i",{{.*}} scope: [[NS:![0-9]+]],
|
2016-04-24 05:08:27 +08:00
|
|
|
// CHECK: [[NS]] = !DINamespace(name: "B", scope: [[CTXT:![0-9]+]], file: [[FOOCPP:![0-9]+]], line: 1)
|
|
|
|
// CHECK: [[FOOCPP]] = !DIFile(filename: "foo.cpp"
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[CTXT]] = !DINamespace(name: "A", scope: null, file: [[FILE:![0-9]+]], line: 5)
|
|
|
|
// CHECK: [[FILE]] = !DIFile(filename: "{{.*}}debug-info-namespace.cpp",
|
2016-04-24 06:29:26 +08:00
|
|
|
// CHECK: [[VAR_FWD:![0-9]+]] = distinct !DIGlobalVariable(name: "var_fwd",{{.*}} scope: [[NS]],
|
|
|
|
// CHECK-SAME: line: 44
|
|
|
|
// CHECK-SAME: isDefinition: true
|
2015-03-04 01:25:55 +08:00
|
|
|
// CHECK: [[MODULES]] = !{[[M1:![0-9]+]], [[M2:![0-9]+]], [[M3:![0-9]+]], [[M4:![0-9]+]], [[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]+]]}
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[M1]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CTXT]], entity: [[NS]], line: 15)
|
2016-04-24 05:08:27 +08:00
|
|
|
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[M2]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CU]], entity: [[CTXT]],
|
|
|
|
// CHECK: [[M3]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "E", scope: [[CU]], entity: [[CTXT]], line: 19)
|
|
|
|
// CHECK: [[M4]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[LEX2:![0-9]+]], entity: [[NS]], line: 23)
|
|
|
|
// CHECK: [[LEX2]] = distinct !DILexicalBlock(scope: [[LEX1:![0-9]+]], file: [[FOOCPP]],
|
2016-04-15 23:55:45 +08:00
|
|
|
// CHECK: [[LEX1]] = distinct !DILexicalBlock(scope: [[FUNC:![0-9]+]], file: [[FOOCPP]],
|
|
|
|
|
2016-04-24 05:08:27 +08:00
|
|
|
// CHECK: [[FUNC:![0-9]+]] = distinct !DISubprogram(name: "func",{{.*}} isDefinition: true
|
|
|
|
// CHECK: [[M5]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[FUNC]], entity: [[CTXT:![0-9]+]],
|
|
|
|
// CHECK: [[M6]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[FOO:![0-9]+]], line: 27)
|
|
|
|
// CHECK: [[FOO]] = !DICompositeType(tag: DW_TAG_structure_type, name: "foo",
|
|
|
|
// CHECK-SAME: line: 5
|
|
|
|
// CHECK-SAME: DIFlagFwdDecl
|
|
|
|
// CHECK: [[M7]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[BAR:![0-9]+]]
|
|
|
|
// CHECK: [[BAR]] = !DICompositeType(tag: DW_TAG_structure_type, name: "bar",
|
|
|
|
// CHECK-SAME: line: 6
|
|
|
|
// CHECK-SAME: DIFlagFwdDecl
|
|
|
|
|
2016-04-15 23:55:45 +08:00
|
|
|
// CHECK: [[M8]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[F1:![0-9]+]]
|
|
|
|
// CHECK: [[F1:![0-9]+]] = distinct !DISubprogram(name: "f1",{{.*}} line: 4
|
|
|
|
// CHECK-SAME: isDefinition: true
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[M9]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[I]]
|
|
|
|
// CHECK: [[M10]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[BAZ:![0-9]+]]
|
|
|
|
// CHECK: [[BAZ]] = !DIDerivedType(tag: DW_TAG_typedef, name: "baz", scope: [[NS]], file: [[FOOCPP]],
|
2016-04-24 05:08:27 +08:00
|
|
|
// CHECK-SAME: baseType: [[BAR]]
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[M11]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "X", scope: [[FUNC]], entity: [[CTXT]]
|
|
|
|
// CHECK: [[M12]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "Y", scope: [[FUNC]], entity: [[M11]]
|
|
|
|
// CHECK: [[M13]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[VAR_DECL:![0-9]+]]
|
2016-07-01 01:41:27 +08:00
|
|
|
// CHECK: [[VAR_DECL]] = !DIGlobalVariable(name: "var_decl", linkageName: "{{[^"]*var_decl[^"]*}}", scope: [[NS]],{{.*}} line: 8,
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[M14]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[FUNC_DECL:![0-9]+]]
|
|
|
|
// CHECK: [[FUNC_DECL]] = !DISubprogram(name: "func_decl",
|
2015-03-04 01:25:55 +08:00
|
|
|
// CHECK-SAME: scope: [[NS]], file: [[FOOCPP]], line: 9
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[M15]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[VAR_FWD:![0-9]+]]
|
|
|
|
// CHECK: [[M16]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[FUNC_FWD:![0-9]+]]
|
2016-04-15 23:55:45 +08:00
|
|
|
// CHECK: [[FUNC_FWD]] = distinct !DISubprogram(name: "func_fwd",{{.*}} line: 47,{{.*}} isDefinition: true
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[M17]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[CTXT]], entity: [[I]]
|
2015-03-04 01:25:55 +08:00
|
|
|
|
2015-07-01 02:32:50 +08:00
|
|
|
// CHECK-GMLT: [[CU:![0-9]+]] = distinct !DICompileUnit(
|
2016-04-01 07:57:45 +08:00
|
|
|
// CHECK-GMLT-SAME: emissionKind: LineTablesOnly,
|
2015-07-07 00:36:04 +08:00
|
|
|
// CHECK-GMLT-NOT: imports:
|
2013-05-20 12:58:53 +08:00
|
|
|
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK-NOLIMIT: !DICompositeType(tag: DW_TAG_structure_type, name: "bar",{{.*}} line: 6,
|
2015-03-04 01:25:55 +08:00
|
|
|
// CHECK-NOLIMIT-NOT: DIFlagFwdDecl
|
|
|
|
// CHECK-NOLIMIT-SAME: ){{$}}
|