llvm.org GIT mirror llvm / 841400b
Remove line and file from DINamespace. Fixes the issue highlighted in http://lists.llvm.org/pipermail/cfe-dev/2014-June/037500.html. The DW_AT_decl_file and DW_AT_decl_line attributes on namespaces can prevent LLVM from uniquing types that are in the same namespace. They also don't carry any meaningful information. rdar://problem/17484998 Differential Revision: https://reviews.llvm.org/D32648 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301706 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 3 years ago
36 changed file(s) with 107 addition(s) and 135 deletion(s). Raw diff Collapse all Expand all
631631 /// parent scope.
632632 /// \param Scope Namespace scope
633633 /// \param Name Name of this namespace
634 /// \param File Source file
635 /// \param LineNo Line number
636634 /// \param ExportSymbols True for C++ inline namespaces.
637 DINamespace *createNameSpace(DIScope *Scope, StringRef Name, DIFile *File,
638 unsigned LineNo, bool ExportSymbols);
635 DINamespace *createNameSpace(DIScope *Scope, StringRef Name,
636 bool ExportSymbols);
639637
640638 /// This creates new descriptor for a module with the specified
641639 /// parent scope.
18521852 friend class LLVMContextImpl;
18531853 friend class MDNode;
18541854
1855 unsigned Line;
18561855 unsigned ExportSymbols : 1;
18571856
1858 DINamespace(LLVMContext &Context, StorageType Storage, unsigned Line,
1859 bool ExportSymbols, ArrayRef Ops)
1857 DINamespace(LLVMContext &Context, StorageType Storage, bool ExportSymbols,
1858 ArrayRef Ops)
18601859 : DIScope(Context, DINamespaceKind, Storage, dwarf::DW_TAG_namespace,
18611860 Ops),
1862 Line(Line), ExportSymbols(ExportSymbols) {}
1861 ExportSymbols(ExportSymbols) {}
18631862 ~DINamespace() = default;
18641863
18651864 static DINamespace *getImpl(LLVMContext &Context, DIScope *Scope,
1866 DIFile *File, StringRef Name, unsigned Line,
1867 bool ExportSymbols, StorageType Storage,
1868 bool ShouldCreate = true) {
1869 return getImpl(Context, Scope, File, getCanonicalMDString(Context, Name),
1870 Line, ExportSymbols, Storage, ShouldCreate);
1865 StringRef Name, bool ExportSymbols,
1866 StorageType Storage, bool ShouldCreate = true) {
1867 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
1868 ExportSymbols, Storage, ShouldCreate);
18711869 }
18721870 static DINamespace *getImpl(LLVMContext &Context, Metadata *Scope,
1873 Metadata *File, MDString *Name, unsigned Line,
1874 bool ExportSymbols, StorageType Storage,
1875 bool ShouldCreate = true);
1871 MDString *Name, bool ExportSymbols,
1872 StorageType Storage, bool ShouldCreate = true);
18761873
18771874 TempDINamespace cloneImpl() const {
1878 return getTemporary(getContext(), getScope(), getFile(), getName(),
1879 getLine(), getExportSymbols());
1880 }
1881
1882 public:
1883 DEFINE_MDNODE_GET(DINamespace, (DIScope * Scope, DIFile *File, StringRef Name,
1884 unsigned Line, bool ExportSymbols),
1885 (Scope, File, Name, Line, ExportSymbols))
1875 return getTemporary(getContext(), getScope(), getName(),
1876 getExportSymbols());
1877 }
1878
1879 public:
18861880 DEFINE_MDNODE_GET(DINamespace,
1887 (Metadata * Scope, Metadata *File, MDString *Name,
1888 unsigned Line, bool ExportSymbols),
1889 (Scope, File, Name, Line, ExportSymbols))
1881 (DIScope *Scope, StringRef Name, bool ExportSymbols),
1882 (Scope, Name, ExportSymbols))
1883 DEFINE_MDNODE_GET(DINamespace,
1884 (Metadata *Scope, MDString *Name, bool ExportSymbols),
1885 (Scope, Name, ExportSymbols))
18901886
18911887 TempDINamespace clone() const { return cloneImpl(); }
18921888
1893 unsigned getLine() const { return Line; }
18941889 bool getExportSymbols() const { return ExportSymbols; }
18951890 DIScope *getScope() const { return cast_or_null(getRawScope()); }
18961891 StringRef getName() const { return getStringOperand(2); }
41494149 bool LLParser::ParseDINamespace(MDNode *&Result, bool IsDistinct) {
41504150 #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
41514151 REQUIRED(scope, MDField, ); \
4152 OPTIONAL(file, MDField, ); \
41534152 OPTIONAL(name, MDStringField, ); \
4154 OPTIONAL(line, LineField, ); \
41554153 OPTIONAL(exportSymbols, MDBoolField, );
41564154 PARSE_MD_FIELDS();
41574155 #undef VISIT_MD_FIELDS
41584156
41594157 Result = GET_OR_DISTINCT(DINamespace,
4160 (Context, scope.Val, file.Val, name.Val, line.Val, exportSymbols.Val));
4158 (Context, scope.Val, name.Val, exportSymbols.Val));
41614159 return false;
41624160 }
41634161
13821382 break;
13831383 }
13841384 case bitc::METADATA_NAMESPACE: {
1385 if (Record.size() != 5)
1385 // Newer versions of DINamespace dropped file and line.
1386 MDString *Name;
1387 if (Record.size() == 3)
1388 Name = getMDString(Record[2]);
1389 else if (Record.size() == 5)
1390 Name = getMDString(Record[3]);
1391 else
13861392 return error("Invalid record");
13871393
13881394 IsDistinct = Record[0] & 1;
13891395 bool ExportSymbols = Record[0] & 2;
13901396 MetadataList.assignValue(
13911397 GET_OR_DISTINCT(DINamespace,
1392 (Context, getMDOrNull(Record[1]),
1393 getMDOrNull(Record[2]), getMDString(Record[3]),
1394 Record[4], ExportSymbols)),
1398 (Context, getMDOrNull(Record[1]), Name, ExportSymbols)),
13951399 NextMetadataNo);
13961400 NextMetadataNo++;
13971401 break;
16451645 unsigned Abbrev) {
16461646 Record.push_back(N->isDistinct() | N->getExportSymbols() << 1);
16471647 Record.push_back(VE.getMetadataOrNullID(N->getScope()));
1648 Record.push_back(VE.getMetadataOrNullID(N->getFile()));
16491648 Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1650 Record.push_back(N->getLine());
16511649
16521650 Stream.EmitRecord(bitc::METADATA_NAMESPACE, Record, Abbrev);
16531651 Record.clear();
372372 assert(Ty);
373373
374374 addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
375 }
376
377 void DwarfUnit::addSourceLine(DIE &Die, const DINamespace *NS) {
378 addSourceLine(Die, NS->getLine(), NS->getFilename(), NS->getDirectory());
379375 }
380376
381377 /* Byref variables, in Blocks, are declared by the programmer as "SomeType
10841080 Name = "(anonymous namespace)";
10851081 DD->addAccelNamespace(Name, NDie);
10861082 addGlobalName(Name, NDie, NS->getScope());
1087 addSourceLine(NDie, NS);
10881083 if (NS->getExportSymbols())
10891084 addFlag(NDie, dwarf::DW_AT_export_symbols);
10901085 return &NDie;
209209 void addSourceLine(DIE &Die, const DIGlobalVariable *G);
210210 void addSourceLine(DIE &Die, const DISubprogram *SP);
211211 void addSourceLine(DIE &Die, const DIType *Ty);
212 void addSourceLine(DIE &Die, const DINamespace *NS);
213212 void addSourceLine(DIE &Die, const DIObjCProperty *Ty);
214213
215214 /// Add constant value entry in variable DIE.
17551755 MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
17561756 Printer.printString("name", N->getName());
17571757 Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false);
1758 Printer.printMetadata("file", N->getRawFile());
1759 Printer.printInt("line", N->getLine());
17601758 Printer.printBool("exportSymbols", N->getExportSymbols(), false);
17611759 Out << ")";
17621760 }
727727 }
728728
729729 DINamespace *DIBuilder::createNameSpace(DIScope *Scope, StringRef Name,
730 DIFile *File, unsigned LineNo,
731730 bool ExportSymbols) {
732 return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), File, Name,
733 LineNo, ExportSymbols);
731
732 // It is okay to *not* make anonymous top-level namespaces distinct, because
733 // all nodes that have an anonymous namespace as their parent scope are
734 // guaranteed to be unique and/or are linked to their containing
735 // DICompileUnit. This decision is an explicit tradeoff of link time versus
736 // memory usage versus code simplicity and may get revisited in the future.
737 return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), Name,
738 ExportSymbols);
734739 }
735740
736741 DIModule *DIBuilder::createModule(DIScope *Scope, StringRef Name,
506506 }
507507
508508 DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope,
509 Metadata *File, MDString *Name, unsigned Line,
510 bool ExportSymbols, StorageType Storage,
511 bool ShouldCreate) {
512 assert(isCanonical(Name) && "Expected canonical MDString");
513 DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, File, Name, Line, ExportSymbols));
514 Metadata *Ops[] = {File, Scope, Name};
515 DEFINE_GETIMPL_STORE(DINamespace, (Line, ExportSymbols), Ops);
509 MDString *Name, bool ExportSymbols,
510 StorageType Storage, bool ShouldCreate) {
511 assert(isCanonical(Name) && "Expected canonical MDString");
512 DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, Name, ExportSymbols));
513 // The nullptr is for DIScope's File operand. This should be refactored.
514 Metadata *Ops[] = {nullptr, Scope, Name};
515 DEFINE_GETIMPL_STORE(DINamespace, (ExportSymbols), Ops);
516516 }
517517
518518 DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *Scope,
698698
699699 template <> struct MDNodeKeyImpl {
700700 Metadata *Scope;
701 Metadata *File;
702 MDString *Name;
703 unsigned Line;
701 MDString *Name;
704702 bool ExportSymbols;
705703
706 MDNodeKeyImpl(Metadata *Scope, Metadata *File, MDString *Name, unsigned Line,
707 bool ExportSymbols)
708 : Scope(Scope), File(File), Name(Name), Line(Line),
709 ExportSymbols(ExportSymbols) {}
704 MDNodeKeyImpl(Metadata *Scope, MDString *Name, bool ExportSymbols)
705 : Scope(Scope), Name(Name), ExportSymbols(ExportSymbols) {}
710706 MDNodeKeyImpl(const DINamespace *N)
711 : Scope(N->getRawScope()), File(N->getRawFile()), Name(N->getRawName()),
712 Line(N->getLine()), ExportSymbols(N->getExportSymbols()) {}
707 : Scope(N->getRawScope()), Name(N->getRawName()),
708 ExportSymbols(N->getExportSymbols()) {}
713709
714710 bool isKeyOf(const DINamespace *RHS) const {
715 return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
716 Name == RHS->getRawName() && Line == RHS->getLine() &&
711 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
717712 ExportSymbols == RHS->getExportSymbols();
718713 }
719714 unsigned getHashValue() const {
720 return hash_combine(Scope, File, Name, Line);
715 return hash_combine(Scope, Name);
721716 }
722717 };
723718
77 !1 = distinct !{}
88 !2 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
99
10 ; CHECK: !3 = !DINamespace(name: "Namespace", scope: !0, file: !2, line: 7)
11 !3 = !DINamespace(name: "Namespace", scope: !0, file: !2, line: 7)
10 ; CHECK: !3 = !DINamespace(name: "Namespace", scope: !0)
11 !3 = !DINamespace(name: "Namespace", scope: !0)
1212
1313 ; CHECK: !4 = !DINamespace(scope: !0)
14 !4 = !DINamespace(name: "", scope: !0, file: null, line: 0)
14 !4 = !DINamespace(name: "", scope: !0)
1515 !5 = !DINamespace(scope: !0)
1616 !6 = !DINamespace(scope: !0, exportSymbols: false)
1717 ; CHECK: !5 = !DINamespace(scope: !0, exportSymbols: true)
99
1010 !0 = distinct !DIGlobalVariable(name: "i", linkageName: "_ZN1N1iE", scope: !1, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true)
1111 ; Test bitcode upgrade for DINamespace without an exportSymbols field.
12 ; CHECK: !DINamespace(name: "N", scope: null, file: !{{[0-9]+}}, line: 1)
13 !1 = !DINamespace(name: "N", scope: null, file: !2, line: 1)
12 ; CHECK: !DINamespace(name: "N", scope: null)
13 !1 = !DINamespace(name: "N", scope: null)
1414 !2 = !DIFile(filename: "dinamespace.cpp", directory: "/")
1515 !3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
1616 !4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 4.0.0 (trunk 283228) (llvm/trunk 283225)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, globals: !6)
4848 !22 = !{i64* getelementptr inbounds ({ i64, [56 x i8] }, { i64, [56 x i8] }* @a, i32 0, i32 0)}
4949 !23 = !DILocalVariable(name: "p2", line: 12, arg: 2, scope: !24, file: !10, type: !32)
5050 !24 = distinct !DISubprogram(name: "min", linkageName: "_ZN3__13minIyEERKT_S3_RS1_", line: 12, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 12, file: !1, scope: !25, type: !27, templateParams: !33, variables: !35)
51 !25 = !DINamespace(name: "__1", line: 1, file: !26, scope: null)
51 !25 = !DINamespace(name: "__1", scope: null)
5252 !26 = !DIFile(filename: "main.cpp", directory: "/Users/matt/ryan_bug")
5353 !27 = !DISubroutineType(types: !28)
5454 !28 = !{!29, !29, !32}
6262 !4 = !{i32 2, !"Debug Info Version", i32 3}
6363 !5 = !{!"clang version 3.9.0 "}
6464 !6 = distinct !DISubprogram(name: "bar", linkageName: "\01?bar@foo@@YAHH@Z", scope: !7, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
65 !7 = !DINamespace(name: "foo", scope: null, file: !1, line: 1)
65 !7 = !DINamespace(name: "foo", scope: null)
6666 !8 = !DISubroutineType(types: !9)
6767 !9 = !{!10, !10}
6868 !10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
109109
110110 !0 = distinct !DIGlobalVariableExpression(var: !1)
111111 !1 = !DIGlobalVariable(name: "g", linkageName: "\01?g@bar@foo@@3UGlobalRecord@12@A", scope: !2, file: !3, line: 12, type: !5, isLocal: false, isDefinition: true)
112 !2 = !DINamespace(name: "bar", scope: !4, file: !3, line: 2)
112 !2 = !DINamespace(name: "bar", scope: !4)
113113 !3 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
114 !4 = !DINamespace(name: "foo", scope: null, file: !3, line: 1)
114 !4 = !DINamespace(name: "foo", scope: null)
115115 !5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "GlobalRecord", scope: !2, file: !3, line: 9, size: 32, align: 32, elements: !6, identifier: ".?AUGlobalRecord@bar@foo@@")
116116 !6 = !{!7, !9}
117117 !7 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !5, file: !3, line: 10, baseType: !8, size: 32, align: 32)
115115 !16 = !DIGlobalVariable(name: "global_variable", scope: null, file: !3, line: 17, type: !2, isLocal: false, isDefinition: true) ; previously: invalid DW_TAG_base_type
116116 !17 = !DIGlobalVariableExpression(var: !18)
117117 !18 = !DIGlobalVariable(name: "global_namespace_variable", linkageName: "_ZN2ns25global_namespace_variableE", scope: !19, file: !3, line: 27, type: !6, isLocal: false, isDefinition: true)
118 !19 = !DINamespace(name: "ns", scope: null, file: !3, line: 23)
118 !19 = !DINamespace(name: "ns", scope: null)
119119 !20 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.3 (http://llvm.org/git/clang.git a09cd8103a6a719cb2628cdf0c91682250a17bd2) (http://llvm.org/git/llvm.git 47d03cec0afca0c01ae42b82916d1d731716cd20)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !11, retainedTypes: !11, globals: !21, imports: !11) ; previously: invalid DW_TAG_base_type
120120 !21 = !{!0, !15, !17}
121121 !22 = !{i32 1, !"Debug Info Version", i32 3}
11
22 ; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=All < %s | llvm-dwarfdump - | FileCheck %s
33 ; CHECK: debug_info contents
4 ; CHECK: DW_AT_name{{.*}}= [[F1:.*]])
45 ; CHECK: [[NS1:0x[0-9a-f]*]]:{{ *}}DW_TAG_namespace
5 ; CHECK-NEXT: DW_AT_name{{.*}} = "A"
6 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F1:".*debug-info-namespace.cpp"]])
7 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(5)
6 ; CHECK-NOT: DW_AT_decl_file
7 ; CHECK-NOT: DW_AT_decl_line
88 ; CHECK-NOT: NULL
99 ; CHECK: [[NS2:0x[0-9a-f]*]]:{{ *}}DW_TAG_namespace
1010 ; CHECK-NEXT: DW_AT_name{{.*}} = "B"
11 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2:".*foo.cpp"]])
12 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(1)
11 ; CHECK-NOT: DW_AT_decl_file
12 ; CHECK-NOT: DW_AT_decl_line
1313 ; CHECK-NOT: NULL
1414 ; CHECK: [[I:0x[0-9a-f]*]]:{{ *}}DW_TAG_variable
1515 ; CHECK-NEXT: DW_AT_name{{.*}}= "i"
5555 ; CHECK: DW_TAG_imported_module
5656 ; This is a bug, it should be in F2 but it inherits the file from its
5757 ; enclosing scope
58 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F1]])
58 ; CHECK-NEXT: DW_AT_decl_file{{.*}}stdin
5959 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(15)
6060 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS2]]})
6161 ; CHECK: NULL
6262 ; CHECK-NOT: NULL
6363
6464 ; CHECK: DW_TAG_imported_module
65 ; Same bug as above, this should be F2, not F1
66 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F1]])
65 ; Same bug as above, this should be F2
66 ; CHECK-NEXT: DW_AT_decl_file{{.*}}debug-info-namespace.cpp
6767 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(18)
6868 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS1]]})
6969 ; CHECK-NOT: NULL
7575 ; CHECK: DW_AT_name{{.*}}= "func"
7676 ; CHECK-NOT: NULL
7777 ; CHECK: DW_TAG_imported_module
78 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])
78 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2:.*]])
7979 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(26)
8080 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS1]]})
8181 ; CHECK-NOT: NULL
292292 !3 = !{!4, !8}
293293 !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", line: 5, flags: DIFlagFwdDecl, file: !5, scope: !6, identifier: "_ZTSN1A1B3fooE")
294294 !5 = !DIFile(filename: "foo.cpp", directory: "/tmp")
295 !6 = !DINamespace(name: "B", line: 1, file: !5, scope: !7)
296 !7 = !DINamespace(name: "A", line: 5, file: !1, scope: null)
295 !6 = !DINamespace(name: "B", scope: !7)
296 !7 = !DINamespace(name: "A", scope: null)
297297 !8 = !DICompositeType(tag: DW_TAG_structure_type, name: "bar", line: 6, size: 8, align: 8, file: !5, scope: !6, elements: !2, identifier: "_ZTSN1A1B3barE")
298298 !10 = distinct !DISubprogram(name: "f1", linkageName: "_ZN1A1B2f1Ev", line: 3, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !5, scope: !6, type: !11, variables: !2)
299299 !11 = !DISubroutineType(types: !12)
3333 !1 = !DIFile(filename: "namespace_function_definition.cpp", directory: "/tmp/dbginfo")
3434 !2 = !{}
3535 !4 = distinct !DISubprogram(name: "func", linkageName: "_ZN2ns4funcEv", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 2, file: !1, scope: !5, type: !6, variables: !2)
36 !5 = !DINamespace(name: "ns", line: 1, file: !1, scope: null)
36 !5 = !DINamespace(name: "ns", scope: null)
3737 !6 = !DISubroutineType(types: !7)
3838 !7 = !{null}
3939 !8 = !{i32 2, !"Dwarf Version", i32 4}
7878 !7 = !{!8}
7979 !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
8080 !9 = distinct !DISubprogram(name: "func", linkageName: "_ZN2ns4funcEi", line: 6, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 6, file: !1, scope: !10, type: !11, variables: !2)
81 !10 = !DINamespace(name: "ns", line: 1, file: !1, scope: null)
81 !10 = !DINamespace(name: "ns", scope: null)
8282 !11 = !DISubroutineType(types: !12)
8383 !12 = !{!8, !8}
8484 !13 = !{i32 2, !"Dwarf Version", i32 4}
5656
5757 !0 = !DIGlobalVariableExpression(var: !1)
5858 !1 = !DIGlobalVariable(name: "global_var", linkageName: "_ZN4test10global_varE", scope: !2, file: !3, line: 2, type: !4, isLocal: false, isDefinition: true)
59 !2 = !DINamespace(name: "test", scope: null, file: !3, line: 1)
59 !2 = !DINamespace(name: "test", scope: null)
6060 !3 = !DIFile(filename: "dwarf-linkage-names.cpp", directory: "/home/probinson/projects/scratch")
6161 !4 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
6262 !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.8.0 (trunk 244662)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !6, globals: !7)
4242
4343 ; Skip the output to the header of the pubnames section.
4444 ; LINUX: debug_pubnames
45 ; LINUX-NEXT: unit_size = 0x0000012a
45 ; LINUX-NEXT: unit_size = 0x00000128
4646
4747 ; Check for each name in the output.
4848 ; LINUX-DAG: "ns"
121121 !16 = !DIGlobalVariable(name: "global_variable", scope: null, file: !3, line: 17, type: !2, isLocal: false, isDefinition: true) ; previously: invalid DW_TAG_base_type
122122 !17 = !DIGlobalVariableExpression(var: !18)
123123 !18 = !DIGlobalVariable(name: "global_namespace_variable", linkageName: "_ZN2ns25global_namespace_variableE", scope: !19, file: !3, line: 27, type: !6, isLocal: false, isDefinition: true)
124 !19 = !DINamespace(name: "ns", scope: null, file: !3, line: 23)
124 !19 = !DINamespace(name: "ns", scope: null)
125125 !20 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.3 (http://llvm.org/git/clang.git a09cd8103a6a719cb2628cdf0c91682250a17bd2) (http://llvm.org/git/llvm.git 47d03cec0afca0c01ae42b82916d1d731716cd20)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !11, retainedTypes: !11, globals: !21, imports: !11) ; previously: invalid DW_TAG_base_type
126126 !21 = !{!0, !15, !17}
127127 !22 = !{i32 1, !"Debug Info Version", i32 3}
226226 !5 = !{}
227227 !6 = !DIGlobalVariableExpression(var: !7)
228228 !7 = !DIGlobalVariable(name: "animal", linkageName: "_ZN7echidna8capybara8mongoose6animalE", scope: !8, file: !2, line: 18, type: !11, isLocal: false, isDefinition: true)
229 !8 = !DINamespace(name: "mongoose", scope: !9, file: !2, line: 12)
230 !9 = !DINamespace(name: "capybara", scope: !10, file: !2, line: 11)
231 !10 = !DINamespace(name: "echidna", scope: null, file: !2, line: 10)
229 !8 = !DINamespace(name: "mongoose", scope: !9)
230 !9 = !DINamespace(name: "capybara", scope: !10)
231 !10 = !DINamespace(name: "echidna", scope: null)
232232 !11 = !DICompositeType(tag: DW_TAG_class_type, name: "fluffy", scope: !8, file: !2, line: 13, size: 64, align: 32, elements: !12, identifier: "_ZTSN7echidna8capybara8mongoose6fluffyE")
233233 !12 = !{!13, !15}
234234 !13 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !11, file: !2, line: 14, baseType: !14, size: 32, align: 32, flags: DIFlagPrivate)
237237 !16 = !DIGlobalVariableExpression(var: !17)
238238 !17 = !DIGlobalVariable(name: "w", scope: null, file: !2, line: 29, type: !18, isLocal: true, isDefinition: true)
239239 !18 = !DICompositeType(tag: DW_TAG_structure_type, name: "walrus", scope: !19, file: !2, line: 24, size: 8, align: 8, elements: !20)
240 !19 = !DINamespace(scope: null, file: !2, line: 23)
240 !19 = !DINamespace(scope: null)
241241 !20 = !{!21}
242242 !21 = !DISubprogram(name: "walrus", scope: !18, file: !2, line: 25, type: !22, isLocal: false, isDefinition: false, scopeLine: 25, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false)
243243 !22 = !DISubroutineType(types: !23)
4646 !7 = !{!8}
4747 !8 = !DIDerivedType(tag: DW_TAG_member, name: "f", scope: !6, file: !3, line: 6, baseType: !9, size: 8)
4848 !9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", scope: !10, file: !3, line: 2, size: 8, elements: !4, identifier: "_ZTSN2ns3fooE")
49 !10 = !DINamespace(name: "ns", scope: null, file: !3, line: 1)
49 !10 = !DINamespace(name: "ns", scope: null)
5050 !11 = !{i32 2, !"Dwarf Version", i32 4}
5151 !12 = !{i32 2, !"Debug Info Version", i32 3}
5252 !13 = !{!"clang version 5.0.0 (trunk 293904) (llvm/trunk 293908)"}
317317 !15 = !DISubroutineType(types: !16)
318318 !16 = !{!9}
319319 !17 = !DICompositeType(tag: DW_TAG_structure_type, name: "D", scope: !18, file: !3, line: 29, size: 32, align: 32, elements: !19, identifier: "_ZTSN2ns1DE")
320 !18 = !DINamespace(name: "ns", scope: null, file: !3, line: 23)
320 !18 = !DINamespace(name: "ns", scope: null)
321321 !19 = !{!20}
322322 !20 = !DIDerivedType(tag: DW_TAG_member, name: "A", scope: !17, file: !3, line: 30, baseType: !9, size: 32, align: 32)
323323 !21 = !{!0, !22, !24, !26, !28, !34, !37, !40}
335335 !33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64, align: 64)
336336 !34 = !DIGlobalVariableExpression(var: !35)
337337 !35 = !DIGlobalVariable(name: "i", linkageName: "_ZN12_GLOBAL__N_11iE", scope: !36, file: !3, line: 37, type: !9, isLocal: true, isDefinition: true)
338 !36 = !DINamespace(scope: null, file: !3, line: 36)
338 !36 = !DINamespace(scope: null)
339339 !37 = !DIGlobalVariableExpression(var: !38)
340340 !38 = !DIGlobalVariable(name: "b", linkageName: "_ZN12_GLOBAL__N_15inner1bE", scope: !39, file: !3, line: 47, type: !9, isLocal: true, isDefinition: true)
341 !39 = !DINamespace(name: "inner", scope: !36, file: !3, line: 46)
341 !39 = !DINamespace(name: "inner", scope: !36)
342342 !40 = !DIGlobalVariableExpression(var: !41)
343343 !41 = !DIGlobalVariable(name: "c", linkageName: "_ZN5outer12_GLOBAL__N_11cE", scope: !42, file: !3, line: 53, type: !9, isLocal: true, isDefinition: true)
344 !42 = !DINamespace(scope: !43, file: !3, line: 52)
345 !43 = !DINamespace(name: "outer", scope: null, file: !3, line: 51)
344 !42 = !DINamespace(scope: !43)
345 !43 = !DINamespace(name: "outer", scope: null)
346346 !44 = !{!45, !47}
347347 !45 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !2, entity: !46, line: 34)
348348 !46 = !DIGlobalVariable(name: "global_namespace_variable_decl", linkageName: "_ZN2ns30global_namespace_variable_declE", scope: !18, file: !3, line: 28, type: !9, isLocal: false, isDefinition: false)
2727
2828 !0 = distinct !DIGlobalVariableExpression(var: !1)
2929 !1 = !DIGlobalVariable(name: "i", linkageName: "_ZN6normal7inlined1iE", scope: !2, file: !3, line: 1, type: !5, isLocal: false, isDefinition: true)
30 !2 = !DINamespace(name: "inlined", scope: !4, file: !3, line: 1, exportSymbols: true)
30 !2 = !DINamespace(name: "inlined", scope: !4, exportSymbols: true)
3131 !3 = !DIFile(filename: "namespace.cpp", directory: "/")
32 !4 = !DINamespace(name: "normal", scope: null, file: !3, line: 1)
32 !4 = !DINamespace(name: "normal", scope: null)
3333 !5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
3434 !6 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 4.0.0 (trunk 285825) (llvm/trunk 285822)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !7, globals: !8)
3535 !7 = !{}
136136 !11 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !12, entity: !14, line: 1)
137137 !12 = !DILexicalBlockFile(scope: !13, file: !9, discriminator: 0)
138138 !13 = distinct !DILexicalBlock(scope: !4, file: !1, line: 3)
139 !14 = !DINamespace(name: "N", scope: null, file: !1, line: 1)
139 !14 = !DINamespace(name: "N", scope: null)
140140 !15 = !{i32 2, !"Dwarf Version", i32 4}
141141 !16 = !{i32 2, !"Debug Info Version", i32 3}
142142 !17 = !{!"clang version 3.9.0 (trunk 264349)"}
3333
3434 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.3 (trunk 174207)", isOptimized: true, emissionKind: FullDebug, file: !1802, enums: !1, retainedTypes: !955, globals: !1786, imports: !955)
3535 !1 = !{!26}
36 !4 = !DINamespace(name: "std", line: 48, scope: !5)
36 !4 = !DINamespace(name: "std", scope: !5)
3737 !5 = !DIFile(filename: "os_base.h", directory: "/privite/tmp")
3838 !25 = !DIEnumerator(name: "_S_os_fmtflags_end", value: 65536) ; [ DW_TAG_enumerator ]
3939 !26 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "_Ios_Iostate", line: 146, size: 32, align: 32, file: !1801, scope: !4, elements: !27)
8989 !1 = !DIFile(filename: "pass.cpp", directory: "/tmp")
9090 !2 = !{}
9191 !4 = distinct !DISubprogram(name: "func", linkageName: "_ZN7pr147634funcENS_3fooE", line: 6, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 6, file: !1, scope: !5, type: !6, variables: !2)
92 !5 = !DINamespace(name: "pr14763", line: 1, file: !1, scope: null)
92 !5 = !DINamespace(name: "pr14763", scope: null)
9393 !6 = !DISubroutineType(types: !7)
9494 !7 = !{!8, !8}
9595 !8 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", line: 2, size: 8, align: 8, file: !1, scope: !5, elements: !9)
9393 !7 = !DIFile(filename: "/usr/include/locale.h", directory: "/llvm_cmake_gcc")
9494 !8 = !DICompositeType(tag: DW_TAG_class_type, name: "basic_string, std::allocator >", line: 1134, flags: DIFlagFwdDecl, file: !9, scope: !10, identifier: "_ZTSSs")
9595 !9 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/basic_string.tcc", directory: "/llvm_cmake_gcc")
96 !10 = !DINamespace(name: "std", line: 153, file: !11, scope: null)
96 !10 = !DINamespace(name: "std", scope: null)
9797 !11 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/x86_64-linux-gnu/bits/c++config.h", directory: "/llvm_cmake_gcc")
9898 !13 = distinct !DISubprogram(name: "parse_range", linkageName: "_Z11parse_rangeRyS_Ss", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 4, file: !1, scope: !14, type: !15, variables: !2)
9999 !14 = !DIFile(filename: "pr19307.cc", directory: "/llvm_cmake_gcc")
105105 !20 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/stringfwd.h", directory: "/llvm_cmake_gcc")
106106 !21 = !{!22, !26, !29, !33, !38, !41}
107107 !22 = !DIImportedEntity(tag: DW_TAG_imported_module, line: 57, scope: !23, entity: !25)
108 !23 = !DINamespace(name: "__gnu_debug", line: 55, file: !24, scope: null)
108 !23 = !DINamespace(name: "__gnu_debug", scope: null)
109109 !24 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/debug/debug.h", directory: "/llvm_cmake_gcc")
110 !25 = !DINamespace(name: "__debug", line: 49, file: !24, scope: !10)
110 !25 = !DINamespace(name: "__debug", scope: !10)
111111 !26 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 66, scope: !10, entity: !27)
112112 !27 = !DIDerivedType(tag: DW_TAG_typedef, name: "mbstate_t", line: 106, file: !5, baseType: !28)
113113 !28 = !DIDerivedType(tag: DW_TAG_typedef, name: "__mbstate_t", line: 95, file: !5, baseType: !4)
116116 !31 = !DIFile(filename: "/llvm_cmake_gcc/bin/../lib/clang/3.5.0/include/stddef.h", directory: "/llvm_cmake_gcc")
117117 !32 = !DIBasicType(tag: DW_TAG_base_type, name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
118118 !33 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 42, scope: !34, entity: !36)
119 !34 = !DINamespace(name: "__gnu_cxx", line: 69, file: !35, scope: null)
119 !34 = !DINamespace(name: "__gnu_cxx", scope: null)
120120 !35 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/cpp_type_traits.h", directory: "/llvm_cmake_gcc")
121121 !36 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_t", line: 155, file: !11, scope: !10, baseType: !37)
122122 !37 = !DIBasicType(tag: DW_TAG_base_type, name: "long unsigned int", size: 64, align: 64, encoding: DW_ATE_unsigned)
3434
3535 !0 = !DIGlobalVariableExpression(var: !1)
3636 !1 = !DIGlobalVariable(name: "f", linkageName: "_ZN7PR156371fE", scope: !2, file: !3, line: 6, type: !4, isLocal: false, isDefinition: true)
37 !2 = !DINamespace(name: "PR15637", scope: null, file: !3, line: 1)
37 !2 = !DINamespace(name: "PR15637", scope: null)
3838 !3 = !DIFile(filename: "foo.cc", directory: "/usr/local/google/home/echristo/tmp")
3939 !4 = !DICompositeType(tag: DW_TAG_union_type, name: "Value", scope: !2, file: !3, line: 2, size: 32, align: 32, elements: !5, templateParams: !12)
4040 !5 = !{!6, !8}
2828 !8 = !{null}
2929 !9 = !DILocalVariable(name: "mya", line: 4, arg: 1, scope: !5, file: !6, type: !10)
3030 !10 = !DICompositeType(tag: DW_TAG_class_type, name: "A", line: 3, size: 8, align: 8, file: !17, scope: !11, elements: !2)
31 !11 = !DINamespace(name: "N1", line: 2, file: !17, scope: null)
31 !11 = !DINamespace(name: "N1", scope: null)
3232 !12 = !DIFile(filename: "./n.h", directory: "/private/tmp")
3333 !13 = !DILocation(line: 4, column: 12, scope: !5)
3434 !14 = !DILocation(line: 4, column: 18, scope: !15)
2626 !8 = !{null}
2727 !9 = !DILocalVariable(name: "youra", line: 4, arg: 1, scope: !5, file: !6, type: !10)
2828 !10 = !DICompositeType(tag: DW_TAG_class_type, name: "A", line: 3, size: 8, align: 8, file: !17, scope: !11, elements: !2)
29 !11 = !DINamespace(name: "N1", line: 2, file: !17, scope: null)
29 !11 = !DINamespace(name: "N1", scope: null)
3030 !12 = !DIFile(filename: "./n.h", directory: "/private/tmp")
3131 !13 = !DILocation(line: 4, column: 12, scope: !5)
3232 !14 = !DILocation(line: 4, column: 20, scope: !15)
3838 !1 = !DIFile(filename: "a2.cc", directory: "")
3939 !2 = !{}
4040 !4 = distinct !DISubprogram(name: "a", linkageName: "_ZN1A1aEv", scope: !5, file: !1, line: 7, type: !6, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
41 !5 = !DINamespace(name: "A", scope: null, file: !1, line: 1)
41 !5 = !DINamespace(name: "A", scope: null)
4242 !6 = !DISubroutineType(types: !7)
4343 !7 = !{null}
4444 !8 = distinct !DISubprogram(name: "b", linkageName: "_ZN1A1bEv", scope: !5, file: !1, line: 8, type: !6, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
4242 !1 = !DIFile(filename: "a2.cc", directory: "")
4343 !2 = !{!3}
4444 !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "enum1", scope: !4, file: !1, line: 50, size: 32, elements: !5, identifier: "_ZTSN9__gnu_cxx12_Lock_policyE")
45 !4 = !DINamespace(name: "A", scope: null, file: !1, line: 1)
45 !4 = !DINamespace(name: "A", scope: null)
4646 !5 = !{}
4747 !6 = !{!7}
4848 !7 = !DICompositeType(tag: DW_TAG_structure_type, name: "Base", file: !1, line: 1, size: 32, align: 32, elements: !5, identifier: "_ZTS4Base")
17311731
17321732 TEST_F(DINamespaceTest, get) {
17331733 DIScope *Scope = getFile();
1734 DIFile *File = getFile();
17351734 StringRef Name = "namespace";
1736 unsigned Line = 5;
17371735 bool ExportSymbols = true;
17381736
1739 auto *N = DINamespace::get(Context, Scope, File, Name, Line, ExportSymbols);
1737 auto *N = DINamespace::get(Context, Scope, Name, ExportSymbols);
17401738
17411739 EXPECT_EQ(dwarf::DW_TAG_namespace, N->getTag());
17421740 EXPECT_EQ(Scope, N->getScope());
1743 EXPECT_EQ(File, N->getFile());
17441741 EXPECT_EQ(Name, N->getName());
1745 EXPECT_EQ(Line, N->getLine());
1746 EXPECT_EQ(N,
1747 DINamespace::get(Context, Scope, File, Name, Line, ExportSymbols));
1748
1749 EXPECT_NE(N,
1750 DINamespace::get(Context, getFile(), File, Name, Line, ExportSymbols));
1751 EXPECT_NE(N,
1752 DINamespace::get(Context, Scope, getFile(), Name, Line, ExportSymbols));
1753 EXPECT_NE(N,
1754 DINamespace::get(Context, Scope, File, "other", Line, ExportSymbols));
1755 EXPECT_NE(N,
1756 DINamespace::get(Context, Scope, File, Name, Line + 1, ExportSymbols));
1757 EXPECT_NE(N,
1758 DINamespace::get(Context, Scope, File, Name, Line, !ExportSymbols));
1742 EXPECT_EQ(N, DINamespace::get(Context, Scope, Name, ExportSymbols));
1743 EXPECT_NE(N, DINamespace::get(Context, getFile(), Name, ExportSymbols));
1744 EXPECT_NE(N, DINamespace::get(Context, Scope, "other", ExportSymbols));
1745 EXPECT_NE(N, DINamespace::get(Context, Scope, Name, !ExportSymbols));
17591746
17601747 TempDINamespace Temp = N->clone();
17611748 EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));