Index: include/llvm/IR/DIBuilder.h =================================================================== --- include/llvm/IR/DIBuilder.h +++ include/llvm/IR/DIBuilder.h @@ -632,11 +632,9 @@ /// parent scope. /// \param Scope Namespace scope /// \param Name Name of this namespace - /// \param File Source file - /// \param LineNo Line number /// \param ExportSymbols True for C++ inline namespaces. - DINamespace *createNameSpace(DIScope *Scope, StringRef Name, DIFile *File, - unsigned LineNo, bool ExportSymbols); + DINamespace *createNameSpace(DIScope *Scope, StringRef Name, + bool ExportSymbols); /// This creates new descriptor for a module with the specified /// parent scope. Index: include/llvm/IR/DebugInfoMetadata.h =================================================================== --- include/llvm/IR/DebugInfoMetadata.h +++ include/llvm/IR/DebugInfoMetadata.h @@ -1851,45 +1851,40 @@ friend class LLVMContextImpl; friend class MDNode; - unsigned Line; unsigned ExportSymbols : 1; - DINamespace(LLVMContext &Context, StorageType Storage, unsigned Line, - bool ExportSymbols, ArrayRef Ops) + DINamespace(LLVMContext &Context, StorageType Storage, bool ExportSymbols, + ArrayRef Ops) : DIScope(Context, DINamespaceKind, Storage, dwarf::DW_TAG_namespace, Ops), - Line(Line), ExportSymbols(ExportSymbols) {} + ExportSymbols(ExportSymbols) {} ~DINamespace() = default; static DINamespace *getImpl(LLVMContext &Context, DIScope *Scope, - DIFile *File, StringRef Name, unsigned Line, - bool ExportSymbols, StorageType Storage, - bool ShouldCreate = true) { - return getImpl(Context, Scope, File, getCanonicalMDString(Context, Name), - Line, ExportSymbols, Storage, ShouldCreate); + StringRef Name, bool ExportSymbols, + StorageType Storage, bool ShouldCreate = true) { + return getImpl(Context, Scope, getCanonicalMDString(Context, Name), + ExportSymbols, Storage, ShouldCreate); } static DINamespace *getImpl(LLVMContext &Context, Metadata *Scope, - Metadata *File, MDString *Name, unsigned Line, - bool ExportSymbols, StorageType Storage, - bool ShouldCreate = true); + MDString *Name, bool ExportSymbols, + StorageType Storage, bool ShouldCreate = true); TempDINamespace cloneImpl() const { - return getTemporary(getContext(), getScope(), getFile(), getName(), - getLine(), getExportSymbols()); + return getTemporary(getContext(), getScope(), getName(), + getExportSymbols()); } public: - DEFINE_MDNODE_GET(DINamespace, (DIScope * Scope, DIFile *File, StringRef Name, - unsigned Line, bool ExportSymbols), - (Scope, File, Name, Line, ExportSymbols)) DEFINE_MDNODE_GET(DINamespace, - (Metadata * Scope, Metadata *File, MDString *Name, - unsigned Line, bool ExportSymbols), - (Scope, File, Name, Line, ExportSymbols)) + (DIScope *Scope, StringRef Name, bool ExportSymbols), + (Scope, Name, ExportSymbols)) + DEFINE_MDNODE_GET(DINamespace, + (Metadata *Scope, MDString *Name, bool ExportSymbols), + (Scope, Name, ExportSymbols)) TempDINamespace clone() const { return cloneImpl(); } - unsigned getLine() const { return Line; } bool getExportSymbols() const { return ExportSymbols; } DIScope *getScope() const { return cast_or_null(getRawScope()); } StringRef getName() const { return getStringOperand(2); } Index: lib/AsmParser/LLParser.cpp =================================================================== --- lib/AsmParser/LLParser.cpp +++ lib/AsmParser/LLParser.cpp @@ -4149,15 +4149,13 @@ bool LLParser::ParseDINamespace(MDNode *&Result, bool IsDistinct) { #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ REQUIRED(scope, MDField, ); \ - OPTIONAL(file, MDField, ); \ OPTIONAL(name, MDStringField, ); \ - OPTIONAL(line, LineField, ); \ OPTIONAL(exportSymbols, MDBoolField, ); PARSE_MD_FIELDS(); #undef VISIT_MD_FIELDS Result = GET_OR_DISTINCT(DINamespace, - (Context, scope.Val, file.Val, name.Val, line.Val, exportSymbols.Val)); + (Context, scope.Val, name.Val, exportSymbols.Val)); return false; } Index: lib/Bitcode/Reader/MetadataLoader.cpp =================================================================== --- lib/Bitcode/Reader/MetadataLoader.cpp +++ lib/Bitcode/Reader/MetadataLoader.cpp @@ -1386,13 +1386,13 @@ if (Record.size() != 5) return error("Invalid record"); - IsDistinct = Record[0] & 1; + // Upgrade: make anonymous namespaces distinct. + auto *Name = getMDString(Record[3]); + IsDistinct = Record[0] & 1 || !Name; bool ExportSymbols = Record[0] & 2; MetadataList.assignValue( - GET_OR_DISTINCT(DINamespace, - (Context, getMDOrNull(Record[1]), - getMDOrNull(Record[2]), getMDString(Record[3]), - Record[4], ExportSymbols)), + GET_OR_DISTINCT(DINamespace, (Context, getMDOrNull(Record[1]), + Name, ExportSymbols)), NextMetadataNo); NextMetadataNo++; break; Index: lib/Bitcode/Writer/BitcodeWriter.cpp =================================================================== --- lib/Bitcode/Writer/BitcodeWriter.cpp +++ lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1644,9 +1644,9 @@ unsigned Abbrev) { Record.push_back(N->isDistinct() | N->getExportSymbols() << 1); Record.push_back(VE.getMetadataOrNullID(N->getScope())); - Record.push_back(VE.getMetadataOrNullID(N->getFile())); + Record.push_back(0); // Deprecated: File. Record.push_back(VE.getMetadataOrNullID(N->getRawName())); - Record.push_back(N->getLine()); + Record.push_back(0); // Deprecated: Line. Stream.EmitRecord(bitc::METADATA_NAMESPACE, Record, Abbrev); Record.clear(); Index: lib/CodeGen/AsmPrinter/DwarfUnit.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -376,7 +376,7 @@ } void DwarfUnit::addSourceLine(DIE &Die, const DINamespace *NS) { - addSourceLine(Die, NS->getLine(), NS->getFilename(), NS->getDirectory()); + addSourceLine(Die, 0, NS->getFilename(), NS->getDirectory()); } /* Byref variables, in Blocks, are declared by the programmer as "SomeType Index: lib/IR/AsmWriter.cpp =================================================================== --- lib/IR/AsmWriter.cpp +++ lib/IR/AsmWriter.cpp @@ -1757,7 +1757,6 @@ Printer.printString("name", N->getName()); Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false); Printer.printMetadata("file", N->getRawFile()); - Printer.printInt("line", N->getLine()); Printer.printBool("exportSymbols", N->getExportSymbols(), false); Out << ")"; } Index: lib/IR/DIBuilder.cpp =================================================================== --- lib/IR/DIBuilder.cpp +++ lib/IR/DIBuilder.cpp @@ -728,10 +728,14 @@ } DINamespace *DIBuilder::createNameSpace(DIScope *Scope, StringRef Name, - DIFile *File, unsigned LineNo, bool ExportSymbols) { - return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), File, Name, - LineNo, ExportSymbols); + + // Anonymous namespaces may not be merged by llvm-link. + if (Name.empty()) + return DINamespace::getDistinct(VMContext, getNonCompileUnitScope(Scope), + Name, ExportSymbols); + return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), Name, + ExportSymbols); } DIModule *DIBuilder::createModule(DIScope *Scope, StringRef Name, Index: lib/IR/DebugInfoMetadata.cpp =================================================================== --- lib/IR/DebugInfoMetadata.cpp +++ lib/IR/DebugInfoMetadata.cpp @@ -506,13 +506,12 @@ } DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope, - Metadata *File, MDString *Name, unsigned Line, - bool ExportSymbols, StorageType Storage, - bool ShouldCreate) { + MDString *Name, bool ExportSymbols, + StorageType Storage, bool ShouldCreate) { assert(isCanonical(Name) && "Expected canonical MDString"); - DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, File, Name, Line, ExportSymbols)); - Metadata *Ops[] = {File, Scope, Name}; - DEFINE_GETIMPL_STORE(DINamespace, (Line, ExportSymbols), Ops); + DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, Name, ExportSymbols)); + Metadata *Ops[] = {nullptr, Scope, Name}; + DEFINE_GETIMPL_STORE(DINamespace, (ExportSymbols), Ops); } DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *Scope, Index: lib/IR/LLVMContextImpl.h =================================================================== --- lib/IR/LLVMContextImpl.h +++ lib/IR/LLVMContextImpl.h @@ -699,26 +699,21 @@ template <> struct MDNodeKeyImpl { Metadata *Scope; - Metadata *File; MDString *Name; - unsigned Line; bool ExportSymbols; - MDNodeKeyImpl(Metadata *Scope, Metadata *File, MDString *Name, unsigned Line, - bool ExportSymbols) - : Scope(Scope), File(File), Name(Name), Line(Line), - ExportSymbols(ExportSymbols) {} + MDNodeKeyImpl(Metadata *Scope, MDString *Name, bool ExportSymbols) + : Scope(Scope), Name(Name), ExportSymbols(ExportSymbols) {} MDNodeKeyImpl(const DINamespace *N) - : Scope(N->getRawScope()), File(N->getRawFile()), Name(N->getRawName()), - Line(N->getLine()), ExportSymbols(N->getExportSymbols()) {} + : Scope(N->getRawScope()), Name(N->getRawName()), + ExportSymbols(N->getExportSymbols()) {} bool isKeyOf(const DINamespace *RHS) const { - return Scope == RHS->getRawScope() && File == RHS->getRawFile() && - Name == RHS->getRawName() && Line == RHS->getLine() && + return Scope == RHS->getRawScope() && Name == RHS->getRawName() && ExportSymbols == RHS->getExportSymbols(); } unsigned getHashValue() const { - return hash_combine(Scope, File, Name, Line); + return hash_combine(Scope, Name); } }; Index: test/Assembler/dinamespace.ll =================================================================== --- test/Assembler/dinamespace.ll +++ test/Assembler/dinamespace.ll @@ -8,11 +8,11 @@ !1 = distinct !{} !2 = !DIFile(filename: "path/to/file", directory: "/path/to/dir") -; CHECK: !3 = !DINamespace(name: "Namespace", scope: !0, file: !2, line: 7) -!3 = !DINamespace(name: "Namespace", scope: !0, file: !2, line: 7) +; CHECK: !3 = !DINamespace(name: "Namespace", scope: !0) +!3 = !DINamespace(name: "Namespace", scope: !0) ; CHECK: !4 = !DINamespace(scope: !0) -!4 = !DINamespace(name: "", scope: !0, file: null, line: 0) +!4 = !DINamespace(name: "", scope: !0) !5 = !DINamespace(scope: !0) !6 = !DINamespace(scope: !0, exportSymbols: false) ; CHECK: !5 = !DINamespace(scope: !0, exportSymbols: true) Index: test/Bitcode/DINamespace-anonymous.ll =================================================================== --- /dev/null +++ test/Bitcode/DINamespace-anonymous.ll @@ -0,0 +1,22 @@ +; RUN: llvm-dis %s.bc -o - | FileCheck %s +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.12.0" + +@_ZN1N1iE = global i32 0, align 4, !dbg !0 + +!llvm.dbg.cu = !{!4} +!llvm.module.flags = !{!7, !8, !9} + +!0 = distinct !DIGlobalVariableExpression(var: !10) +; Test bitcode upgrade for anonymous DINamespaces. +; CHECK: distinct !DINamespace(scope: null) +!1 = !DINamespace(file: !2, line: 1, scope: null) +!2 = !DIFile(filename: "dinamespace.cpp", directory: "/") +!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 4.0.0 (trunk 301585) (llvm/trunk 301587)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, globals: !6) +!5 = !{} +!6 = !{!0} +!7 = !{i32 2, !"Dwarf Version", i32 4} +!8 = !{i32 2, !"Debug Info Version", i32 3} +!9 = !{i32 1, !"PIC Level", i32 2} +!10 = distinct !DIGlobalVariable(name: "i", linkageName: "_ZN1N1iE", scope: !1, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true) Index: test/Bitcode/DINamespace.ll =================================================================== --- test/Bitcode/DINamespace.ll +++ test/Bitcode/DINamespace.ll @@ -10,8 +10,8 @@ !0 = distinct !DIGlobalVariable(name: "i", linkageName: "_ZN1N1iE", scope: !1, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true) ; Test bitcode upgrade for DINamespace without an exportSymbols field. -; CHECK: !DINamespace(name: "N", scope: null, file: !{{[0-9]+}}, line: 1) -!1 = !DINamespace(name: "N", scope: null, file: !2, line: 1) +; CHECK: !DINamespace(name: "N", scope: null) +!1 = !DINamespace(name: "N", scope: null) !2 = !DIFile(filename: "dinamespace.cpp", directory: "/") !3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) !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) Index: test/CodeGen/X86/stack-protector-dbginfo.ll =================================================================== --- test/CodeGen/X86/stack-protector-dbginfo.ll +++ test/CodeGen/X86/stack-protector-dbginfo.ll @@ -49,7 +49,7 @@ !22 = !{i64* getelementptr inbounds ({ i64, [56 x i8] }, { i64, [56 x i8] }* @a, i32 0, i32 0)} !23 = !DILocalVariable(name: "p2", line: 12, arg: 2, scope: !24, file: !10, type: !32) !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) -!25 = !DINamespace(name: "__1", line: 1, file: !26, scope: null) +!25 = !DINamespace(name: "__1", scope: null) !26 = !DIFile(filename: "main.cpp", directory: "/Users/matt/ryan_bug") !27 = !DISubroutineType(types: !28) !28 = !{!29, !29, !32} Index: test/CodeGenCXX/debug-info-anon-namespace.cpp =================================================================== --- test/CodeGenCXX/debug-info-anon-namespace.cpp +++ test/CodeGenCXX/debug-info-anon-namespace.cpp @@ -18,9 +18,9 @@ int *b2 = &a2; -// PS4: [[NS:![0-9]+]] = !DINamespace +// PS4: [[NS:![0-9]+]] = distinct !DINamespace // PS4: [[CU:![0-9]+]] = distinct !DICompileUnit -// PS4: [[NS2:![0-9]+]] = !DINamespace +// PS4: [[NS2:![0-9]+]] = distinct !DINamespace // PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CU]], entity: [[NS]]) // PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[NS]], entity: [[NS2]], line: {{[0-9]+}}) // NON-PS4-NOT: !DIImportedEntity Index: test/DebugInfo/COFF/cpp-mangling.ll =================================================================== --- test/DebugInfo/COFF/cpp-mangling.ll +++ test/DebugInfo/COFF/cpp-mangling.ll @@ -63,7 +63,7 @@ !4 = !{i32 2, !"Debug Info Version", i32 3} !5 = !{!"clang version 3.9.0 "} !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) -!7 = !DINamespace(name: "foo", scope: null, file: !1, line: 1) +!7 = !DINamespace(name: "foo", scope: null) !8 = !DISubroutineType(types: !9) !9 = !{!10, !10} !10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) Index: test/DebugInfo/COFF/scopes.ll =================================================================== --- test/DebugInfo/COFF/scopes.ll +++ test/DebugInfo/COFF/scopes.ll @@ -110,9 +110,9 @@ !0 = distinct !DIGlobalVariableExpression(var: !1) !1 = !DIGlobalVariable(name: "g", linkageName: "\01?g@bar@foo@@3UGlobalRecord@12@A", scope: !2, file: !3, line: 12, type: !5, isLocal: false, isDefinition: true) -!2 = !DINamespace(name: "bar", scope: !4, file: !3, line: 2) +!2 = !DINamespace(name: "bar", scope: !4) !3 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild") -!4 = !DINamespace(name: "foo", scope: null, file: !3, line: 1) +!4 = !DINamespace(name: "foo", scope: null) !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@@") !6 = !{!7, !9} !7 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !5, file: !3, line: 10, baseType: !8, size: 32, align: 32) Index: test/DebugInfo/Generic/dwarf-public-names.ll =================================================================== --- test/DebugInfo/Generic/dwarf-public-names.ll +++ test/DebugInfo/Generic/dwarf-public-names.ll @@ -116,7 +116,7 @@ !16 = !DIGlobalVariable(name: "global_variable", scope: null, file: !3, line: 17, type: !2, isLocal: false, isDefinition: true) ; previously: invalid DW_TAG_base_type !17 = !DIGlobalVariableExpression(var: !18) !18 = !DIGlobalVariable(name: "global_namespace_variable", linkageName: "_ZN2ns25global_namespace_variableE", scope: !19, file: !3, line: 27, type: !6, isLocal: false, isDefinition: true) -!19 = !DINamespace(name: "ns", scope: null, file: !3, line: 23) +!19 = !DINamespace(name: "ns", scope: null) !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 !21 = !{!0, !15, !17} !22 = !{i32 1, !"Debug Info Version", i32 3} Index: test/DebugInfo/Generic/namespace.ll =================================================================== --- test/DebugInfo/Generic/namespace.ll +++ test/DebugInfo/Generic/namespace.ll @@ -2,15 +2,12 @@ ; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=All < %s | llvm-dwarfdump - | FileCheck %s ; CHECK: debug_info contents +; CHECK: DW_AT_name{{.*}}= [[F1:.*]]) ; CHECK: [[NS1:0x[0-9a-f]*]]:{{ *}}DW_TAG_namespace ; CHECK-NEXT: DW_AT_name{{.*}} = "A" -; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F1:".*debug-info-namespace.cpp"]]) -; CHECK-NEXT: DW_AT_decl_line{{.*}}(5) ; CHECK-NOT: NULL ; CHECK: [[NS2:0x[0-9a-f]*]]:{{ *}}DW_TAG_namespace ; CHECK-NEXT: DW_AT_name{{.*}} = "B" -; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2:".*foo.cpp"]]) -; CHECK-NEXT: DW_AT_decl_line{{.*}}(1) ; CHECK-NOT: NULL ; CHECK: [[I:0x[0-9a-f]*]]:{{ *}}DW_TAG_variable ; CHECK-NEXT: DW_AT_name{{.*}}= "i" @@ -56,15 +53,15 @@ ; CHECK: DW_TAG_imported_module ; This is a bug, it should be in F2 but it inherits the file from its ; enclosing scope -; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F1]]) +; CHECK-NEXT: DW_AT_decl_file{{.*}}stdin ; CHECK-NEXT: DW_AT_decl_line{{.*}}(15) ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS2]]}) ; CHECK: NULL ; CHECK-NOT: NULL ; CHECK: DW_TAG_imported_module -; Same bug as above, this should be F2, not F1 -; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F1]]) +; Same bug as above, this should be F2 +; CHECK-NEXT: DW_AT_decl_file{{.*}}debug-info-namespace.cpp ; CHECK-NEXT: DW_AT_decl_line{{.*}}(18) ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS1]]}) ; CHECK-NOT: NULL @@ -76,7 +73,7 @@ ; CHECK: DW_AT_name{{.*}}= "func" ; CHECK-NOT: NULL ; CHECK: DW_TAG_imported_module -; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]]) +; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2:.*]]) ; CHECK-NEXT: DW_AT_decl_line{{.*}}(26) ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS1]]}) ; CHECK-NOT: NULL @@ -293,8 +290,8 @@ !3 = !{!4, !8} !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", line: 5, flags: DIFlagFwdDecl, file: !5, scope: !6, identifier: "_ZTSN1A1B3fooE") !5 = !DIFile(filename: "foo.cpp", directory: "/tmp") -!6 = !DINamespace(name: "B", line: 1, file: !5, scope: !7) -!7 = !DINamespace(name: "A", line: 5, file: !1, scope: null) +!6 = !DINamespace(name: "B", scope: !7) +!7 = !DINamespace(name: "A", scope: null) !8 = !DICompositeType(tag: DW_TAG_structure_type, name: "bar", line: 6, size: 8, align: 8, file: !5, scope: !6, elements: !2, identifier: "_ZTSN1A1B3barE") !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) !11 = !DISubroutineType(types: !12) Index: test/DebugInfo/Generic/namespace_function_definition.ll =================================================================== --- test/DebugInfo/Generic/namespace_function_definition.ll +++ test/DebugInfo/Generic/namespace_function_definition.ll @@ -34,7 +34,7 @@ !1 = !DIFile(filename: "namespace_function_definition.cpp", directory: "/tmp/dbginfo") !2 = !{} !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) -!5 = !DINamespace(name: "ns", line: 1, file: !1, scope: null) +!5 = !DINamespace(name: "ns", scope: null) !6 = !DISubroutineType(types: !7) !7 = !{null} !8 = !{i32 2, !"Dwarf Version", i32 4} Index: test/DebugInfo/Generic/namespace_inline_function_definition.ll =================================================================== --- test/DebugInfo/Generic/namespace_inline_function_definition.ll +++ test/DebugInfo/Generic/namespace_inline_function_definition.ll @@ -79,7 +79,7 @@ !7 = !{!8} !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) !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) -!10 = !DINamespace(name: "ns", line: 1, file: !1, scope: null) +!10 = !DINamespace(name: "ns", scope: null) !11 = !DISubroutineType(types: !12) !12 = !{!8, !8} !13 = !{i32 2, !"Dwarf Version", i32 4} Index: test/DebugInfo/X86/dwarf-linkage-names.ll =================================================================== --- test/DebugInfo/X86/dwarf-linkage-names.ll +++ test/DebugInfo/X86/dwarf-linkage-names.ll @@ -57,7 +57,7 @@ !0 = !DIGlobalVariableExpression(var: !1) !1 = !DIGlobalVariable(name: "global_var", linkageName: "_ZN4test10global_varE", scope: !2, file: !3, line: 2, type: !4, isLocal: false, isDefinition: true) -!2 = !DINamespace(name: "test", scope: null, file: !3, line: 1) +!2 = !DINamespace(name: "test", scope: null) !3 = !DIFile(filename: "dwarf-linkage-names.cpp", directory: "/home/probinson/projects/scratch") !4 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) !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) Index: test/DebugInfo/X86/dwarf-public-names.ll =================================================================== --- test/DebugInfo/X86/dwarf-public-names.ll +++ test/DebugInfo/X86/dwarf-public-names.ll @@ -43,7 +43,7 @@ ; Skip the output to the header of the pubnames section. ; LINUX: debug_pubnames -; LINUX-NEXT: unit_size = 0x0000012a +; LINUX-NEXT: unit_size = 0x00000128 ; Check for each name in the output. ; LINUX-DAG: "ns" @@ -122,7 +122,7 @@ !16 = !DIGlobalVariable(name: "global_variable", scope: null, file: !3, line: 17, type: !2, isLocal: false, isDefinition: true) ; previously: invalid DW_TAG_base_type !17 = !DIGlobalVariableExpression(var: !18) !18 = !DIGlobalVariable(name: "global_namespace_variable", linkageName: "_ZN2ns25global_namespace_variableE", scope: !19, file: !3, line: 27, type: !6, isLocal: false, isDefinition: true) -!19 = !DINamespace(name: "ns", scope: null, file: !3, line: 23) +!19 = !DINamespace(name: "ns", scope: null) !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 !21 = !{!0, !15, !17} !22 = !{i32 1, !"Debug Info Version", i32 3} Index: test/DebugInfo/X86/generate-odr-hash.ll =================================================================== --- test/DebugInfo/X86/generate-odr-hash.ll +++ test/DebugInfo/X86/generate-odr-hash.ll @@ -227,9 +227,9 @@ !5 = !{} !6 = !DIGlobalVariableExpression(var: !7) !7 = !DIGlobalVariable(name: "animal", linkageName: "_ZN7echidna8capybara8mongoose6animalE", scope: !8, file: !2, line: 18, type: !11, isLocal: false, isDefinition: true) -!8 = !DINamespace(name: "mongoose", scope: !9, file: !2, line: 12) -!9 = !DINamespace(name: "capybara", scope: !10, file: !2, line: 11) -!10 = !DINamespace(name: "echidna", scope: null, file: !2, line: 10) +!8 = !DINamespace(name: "mongoose", scope: !9) +!9 = !DINamespace(name: "capybara", scope: !10) +!10 = !DINamespace(name: "echidna", scope: null) !11 = !DICompositeType(tag: DW_TAG_class_type, name: "fluffy", scope: !8, file: !2, line: 13, size: 64, align: 32, elements: !12, identifier: "_ZTSN7echidna8capybara8mongoose6fluffyE") !12 = !{!13, !15} !13 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !11, file: !2, line: 14, baseType: !14, size: 32, align: 32, flags: DIFlagPrivate) @@ -238,7 +238,7 @@ !16 = !DIGlobalVariableExpression(var: !17) !17 = !DIGlobalVariable(name: "w", scope: null, file: !2, line: 29, type: !18, isLocal: true, isDefinition: true) !18 = !DICompositeType(tag: DW_TAG_structure_type, name: "walrus", scope: !19, file: !2, line: 24, size: 8, align: 8, elements: !20) -!19 = !DINamespace(scope: null, file: !2, line: 23) +!19 = distinct !DINamespace(scope: null) !20 = !{!21} !21 = !DISubprogram(name: "walrus", scope: !18, file: !2, line: 25, type: !22, isLocal: false, isDefinition: false, scopeLine: 25, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false) !22 = !DISubroutineType(types: !23) Index: test/DebugInfo/X86/gnu-public-names-tu.ll =================================================================== --- test/DebugInfo/X86/gnu-public-names-tu.ll +++ test/DebugInfo/X86/gnu-public-names-tu.ll @@ -47,7 +47,7 @@ !7 = !{!8} !8 = !DIDerivedType(tag: DW_TAG_member, name: "f", scope: !6, file: !3, line: 6, baseType: !9, size: 8) !9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", scope: !10, file: !3, line: 2, size: 8, elements: !4, identifier: "_ZTSN2ns3fooE") -!10 = !DINamespace(name: "ns", scope: null, file: !3, line: 1) +!10 = !DINamespace(name: "ns", scope: null) !11 = !{i32 2, !"Dwarf Version", i32 4} !12 = !{i32 2, !"Debug Info Version", i32 3} !13 = !{!"clang version 5.0.0 (trunk 293904) (llvm/trunk 293908)"} Index: test/DebugInfo/X86/gnu-public-names.ll =================================================================== --- test/DebugInfo/X86/gnu-public-names.ll +++ test/DebugInfo/X86/gnu-public-names.ll @@ -318,7 +318,7 @@ !15 = !DISubroutineType(types: !16) !16 = !{!9} !17 = !DICompositeType(tag: DW_TAG_structure_type, name: "D", scope: !18, file: !3, line: 29, size: 32, align: 32, elements: !19, identifier: "_ZTSN2ns1DE") -!18 = !DINamespace(name: "ns", scope: null, file: !3, line: 23) +!18 = !DINamespace(name: "ns", scope: null) !19 = !{!20} !20 = !DIDerivedType(tag: DW_TAG_member, name: "A", scope: !17, file: !3, line: 30, baseType: !9, size: 32, align: 32) !21 = !{!0, !22, !24, !26, !28, !34, !37, !40} @@ -336,14 +336,14 @@ !33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64, align: 64) !34 = !DIGlobalVariableExpression(var: !35) !35 = !DIGlobalVariable(name: "i", linkageName: "_ZN12_GLOBAL__N_11iE", scope: !36, file: !3, line: 37, type: !9, isLocal: true, isDefinition: true) -!36 = !DINamespace(scope: null, file: !3, line: 36) +!36 = distinct !DINamespace(scope: null) !37 = !DIGlobalVariableExpression(var: !38) !38 = !DIGlobalVariable(name: "b", linkageName: "_ZN12_GLOBAL__N_15inner1bE", scope: !39, file: !3, line: 47, type: !9, isLocal: true, isDefinition: true) -!39 = !DINamespace(name: "inner", scope: !36, file: !3, line: 46) +!39 = !DINamespace(name: "inner", scope: !36) !40 = !DIGlobalVariableExpression(var: !41) !41 = !DIGlobalVariable(name: "c", linkageName: "_ZN5outer12_GLOBAL__N_11cE", scope: !42, file: !3, line: 53, type: !9, isLocal: true, isDefinition: true) -!42 = !DINamespace(scope: !43, file: !3, line: 52) -!43 = !DINamespace(name: "outer", scope: null, file: !3, line: 51) +!42 = distinct !DINamespace(scope: !43) +!43 = !DINamespace(name: "outer", scope: null) !44 = !{!45, !47} !45 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !2, entity: !46, line: 34) !46 = !DIGlobalVariable(name: "global_namespace_variable_decl", linkageName: "_ZN2ns30global_namespace_variable_declE", scope: !18, file: !3, line: 28, type: !9, isLocal: false, isDefinition: false) Index: test/DebugInfo/X86/inline-namespace.ll =================================================================== --- test/DebugInfo/X86/inline-namespace.ll +++ test/DebugInfo/X86/inline-namespace.ll @@ -28,9 +28,9 @@ !0 = distinct !DIGlobalVariableExpression(var: !1) !1 = !DIGlobalVariable(name: "i", linkageName: "_ZN6normal7inlined1iE", scope: !2, file: !3, line: 1, type: !5, isLocal: false, isDefinition: true) -!2 = !DINamespace(name: "inlined", scope: !4, file: !3, line: 1, exportSymbols: true) +!2 = !DINamespace(name: "inlined", scope: !4, exportSymbols: true) !3 = !DIFile(filename: "namespace.cpp", directory: "/") -!4 = !DINamespace(name: "normal", scope: null, file: !3, line: 1) +!4 = !DINamespace(name: "normal", scope: null) !5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !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) !7 = !{} Index: test/DebugInfo/X86/lexical-block-file-inline.ll =================================================================== --- test/DebugInfo/X86/lexical-block-file-inline.ll +++ test/DebugInfo/X86/lexical-block-file-inline.ll @@ -137,7 +137,7 @@ !11 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !12, entity: !14, line: 1) !12 = !DILexicalBlockFile(scope: !13, file: !9, discriminator: 0) !13 = distinct !DILexicalBlock(scope: !4, file: !1, line: 3) -!14 = !DINamespace(name: "N", scope: null, file: !1, line: 1) +!14 = !DINamespace(name: "N", scope: null) !15 = !{i32 2, !"Dwarf Version", i32 4} !16 = !{i32 2, !"Debug Info Version", i32 3} !17 = !{!"clang version 3.9.0 (trunk 264349)"} Index: test/DebugInfo/X86/multiple-at-const-val.ll =================================================================== --- test/DebugInfo/X86/multiple-at-const-val.ll +++ test/DebugInfo/X86/multiple-at-const-val.ll @@ -34,7 +34,7 @@ !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) !1 = !{!26} -!4 = !DINamespace(name: "std", line: 48, scope: !5) +!4 = !DINamespace(name: "std", scope: !5) !5 = !DIFile(filename: "os_base.h", directory: "/privite/tmp") !25 = !DIEnumerator(name: "_S_os_fmtflags_end", value: 65536) ; [ DW_TAG_enumerator ] !26 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "_Ios_Iostate", line: 146, size: 32, align: 32, file: !1801, scope: !4, elements: !27) Index: test/DebugInfo/X86/parameters.ll =================================================================== --- test/DebugInfo/X86/parameters.ll +++ test/DebugInfo/X86/parameters.ll @@ -90,7 +90,7 @@ !1 = !DIFile(filename: "pass.cpp", directory: "/tmp") !2 = !{} !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) -!5 = !DINamespace(name: "pr14763", line: 1, file: !1, scope: null) +!5 = !DINamespace(name: "pr14763", scope: null) !6 = !DISubroutineType(types: !7) !7 = !{!8, !8} !8 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", line: 2, size: 8, align: 8, file: !1, scope: !5, elements: !9) Index: test/DebugInfo/X86/pr19307.ll =================================================================== --- test/DebugInfo/X86/pr19307.ll +++ test/DebugInfo/X86/pr19307.ll @@ -94,7 +94,7 @@ !7 = !DIFile(filename: "/usr/include/locale.h", directory: "/llvm_cmake_gcc") !8 = !DICompositeType(tag: DW_TAG_class_type, name: "basic_string, std::allocator >", line: 1134, flags: DIFlagFwdDecl, file: !9, scope: !10, identifier: "_ZTSSs") !9 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/basic_string.tcc", directory: "/llvm_cmake_gcc") -!10 = !DINamespace(name: "std", line: 153, file: !11, scope: null) +!10 = !DINamespace(name: "std", scope: null) !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") !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) !14 = !DIFile(filename: "pr19307.cc", directory: "/llvm_cmake_gcc") @@ -106,9 +106,9 @@ !20 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/stringfwd.h", directory: "/llvm_cmake_gcc") !21 = !{!22, !26, !29, !33, !38, !41} !22 = !DIImportedEntity(tag: DW_TAG_imported_module, line: 57, scope: !23, entity: !25) -!23 = !DINamespace(name: "__gnu_debug", line: 55, file: !24, scope: null) +!23 = !DINamespace(name: "__gnu_debug", scope: null) !24 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/debug/debug.h", directory: "/llvm_cmake_gcc") -!25 = !DINamespace(name: "__debug", line: 49, file: !24, scope: !10) +!25 = !DINamespace(name: "__debug", scope: !10) !26 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 66, scope: !10, entity: !27) !27 = !DIDerivedType(tag: DW_TAG_typedef, name: "mbstate_t", line: 106, file: !5, baseType: !28) !28 = !DIDerivedType(tag: DW_TAG_typedef, name: "__mbstate_t", line: 95, file: !5, baseType: !4) @@ -117,7 +117,7 @@ !31 = !DIFile(filename: "/llvm_cmake_gcc/bin/../lib/clang/3.5.0/include/stddef.h", directory: "/llvm_cmake_gcc") !32 = !DIBasicType(tag: DW_TAG_base_type, name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned) !33 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 42, scope: !34, entity: !36) -!34 = !DINamespace(name: "__gnu_cxx", line: 69, file: !35, scope: null) +!34 = !DINamespace(name: "__gnu_cxx", scope: null) !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") !36 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_t", line: 155, file: !11, scope: !10, baseType: !37) !37 = !DIBasicType(tag: DW_TAG_base_type, name: "long unsigned int", size: 64, align: 64, encoding: DW_ATE_unsigned) Index: test/DebugInfo/X86/union-template.ll =================================================================== --- test/DebugInfo/X86/union-template.ll +++ test/DebugInfo/X86/union-template.ll @@ -35,7 +35,7 @@ !0 = !DIGlobalVariableExpression(var: !1) !1 = !DIGlobalVariable(name: "f", linkageName: "_ZN7PR156371fE", scope: !2, file: !3, line: 6, type: !4, isLocal: false, isDefinition: true) -!2 = !DINamespace(name: "PR15637", scope: null, file: !3, line: 1) +!2 = !DINamespace(name: "PR15637", scope: null) !3 = !DIFile(filename: "foo.cc", directory: "/usr/local/google/home/echristo/tmp") !4 = !DICompositeType(tag: DW_TAG_union_type, name: "Value", scope: !2, file: !3, line: 2, size: 32, align: 32, elements: !5, templateParams: !12) !5 = !{!6, !8} Index: test/Linker/2011-08-18-unique-class-type.ll =================================================================== --- test/Linker/2011-08-18-unique-class-type.ll +++ test/Linker/2011-08-18-unique-class-type.ll @@ -29,7 +29,7 @@ !8 = !{null} !9 = !DILocalVariable(name: "mya", line: 4, arg: 1, scope: !5, file: !6, type: !10) !10 = !DICompositeType(tag: DW_TAG_class_type, name: "A", line: 3, size: 8, align: 8, file: !17, scope: !11, elements: !2) -!11 = !DINamespace(name: "N1", line: 2, file: !17, scope: null) +!11 = !DINamespace(name: "N1", scope: null) !12 = !DIFile(filename: "./n.h", directory: "/private/tmp") !13 = !DILocation(line: 4, column: 12, scope: !5) !14 = !DILocation(line: 4, column: 18, scope: !15) Index: test/Linker/2011-08-18-unique-class-type2.ll =================================================================== --- test/Linker/2011-08-18-unique-class-type2.ll +++ test/Linker/2011-08-18-unique-class-type2.ll @@ -27,7 +27,7 @@ !8 = !{null} !9 = !DILocalVariable(name: "youra", line: 4, arg: 1, scope: !5, file: !6, type: !10) !10 = !DICompositeType(tag: DW_TAG_class_type, name: "A", line: 3, size: 8, align: 8, file: !17, scope: !11, elements: !2) -!11 = !DINamespace(name: "N1", line: 2, file: !17, scope: null) +!11 = !DINamespace(name: "N1", scope: null) !12 = !DIFile(filename: "./n.h", directory: "/private/tmp") !13 = !DILocation(line: 4, column: 12, scope: !5) !14 = !DILocation(line: 4, column: 20, scope: !15) Index: test/Linker/pr26037.ll =================================================================== --- test/Linker/pr26037.ll +++ test/Linker/pr26037.ll @@ -39,7 +39,7 @@ !1 = !DIFile(filename: "a2.cc", directory: "") !2 = !{} !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) -!5 = !DINamespace(name: "A", scope: null, file: !1, line: 1) +!5 = !DINamespace(name: "A", scope: null) !6 = !DISubroutineType(types: !7) !7 = !{null} !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) Index: test/ThinLTO/X86/debuginfo-cu-import.ll =================================================================== --- test/ThinLTO/X86/debuginfo-cu-import.ll +++ test/ThinLTO/X86/debuginfo-cu-import.ll @@ -43,7 +43,7 @@ !1 = !DIFile(filename: "a2.cc", directory: "") !2 = !{!3} !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") -!4 = !DINamespace(name: "A", scope: null, file: !1, line: 1) +!4 = !DINamespace(name: "A", scope: null) !5 = !{} !6 = !{!7} !7 = !DICompositeType(tag: DW_TAG_structure_type, name: "Base", file: !1, line: 1, size: 32, align: 32, elements: !5, identifier: "_ZTS4Base") Index: tools/clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- tools/clang/lib/CodeGen/CGDebugInfo.cpp +++ tools/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4034,11 +4034,9 @@ if (I != NameSpaceCache.end()) return cast(I->second); - unsigned LineNo = getLineNumber(NSDecl->getLocation()); - llvm::DIFile *FileD = getOrCreateFile(NSDecl->getLocation()); llvm::DIScope *Context = getDeclContextDescriptor(NSDecl); - llvm::DINamespace *NS = DBuilder.createNameSpace( - Context, NSDecl->getName(), FileD, LineNo, NSDecl->isInline()); + llvm::DINamespace *NS = + DBuilder.createNameSpace(Context, NSDecl->getName(), NSDecl->isInline()); NameSpaceCache[NSDecl].reset(NS); return NS; } Index: tools/clang/test/CodeGenCXX/debug-info-namespace.cpp =================================================================== --- tools/clang/test/CodeGenCXX/debug-info-namespace.cpp +++ tools/clang/test/CodeGenCXX/debug-info-namespace.cpp @@ -53,21 +53,27 @@ int var_i; } } -void B::func_fwd() {} +namespace { +int anonymous; +} +void B::func_fwd() { + anonymous = 0; +} + // This should work even if 'i' and 'func' were declarations & not definitions, // but it doesn't yet. // CHECK: [[I:![0-9]+]] = distinct !DIGlobalVariable(name: "i",{{.*}} scope: [[NS:![0-9]+]], -// CHECK: [[NS]] = !DINamespace(name: "B", scope: [[CTXT:![0-9]+]], file: [[FOOCPP:![0-9]+]], line: 1) -// CHECK: [[FOOCPP]] = !DIFile(filename: "foo.cpp" -// CHECK: [[CTXT]] = !DINamespace(name: "A", scope: null, file: [[FILE:![0-9]+]], line: 5) -// CHECK: [[FILE]] = !DIFile(filename: "{{.*}}debug-info-namespace.cpp", +// CHECK: [[NS]] = !DINamespace(name: "B", scope: [[CTXT:![0-9]+]]) +// CHECK: [[CTXT]] = !DINamespace(name: "A", scope: null) +// CHECK: [[FOOCPP:.*]] = !DIFile(filename: "foo.cpp" // CHECK: [[VAR_FWD:![0-9]+]] = distinct !DIGlobalVariable(name: "var_fwd",{{.*}} scope: [[NS]], // CHECK-SAME: line: 44 // CHECK-SAME: isDefinition: true // CHECK: distinct !DIGlobalVariable(name: "var_i",{{.*}} scope: [[INLINE:![0-9]+]], -// CHECK: [[INLINE]] = !DINamespace(name: "I", scope: [[CTXT]], file: [[FOOCPP]], line: 46, exportSymbols: true) +// CHECK: [[INLINE]] = !DINamespace(name: "I", scope: [[CTXT]], exportSymbols: true) +// CHECK: distinct !DINamespace(scope: null) // CHECK: [[CU:![0-9]+]] = distinct !DICompileUnit( // CHECK-SAME: imports: [[MODULES:![0-9]*]] // 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]+]]} @@ -106,7 +112,7 @@ // CHECK-SAME: scope: [[NS]], file: [[FOOCPP]], line: 9 // 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]+]] -// CHECK: [[FUNC_FWD]] = distinct !DISubprogram(name: "func_fwd",{{.*}} line: 50,{{.*}} isDefinition: true +// CHECK: [[FUNC_FWD]] = distinct !DISubprogram(name: "func_fwd",{{.*}} line: 53,{{.*}} isDefinition: true // CHECK: [[M17]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[CTXT]], entity: [[I]] // CHECK-GMLT: [[CU:![0-9]+]] = distinct !DICompileUnit( Index: tools/clang/test/Modules/ExtDebugInfo.cpp =================================================================== --- tools/clang/test/Modules/ExtDebugInfo.cpp +++ tools/clang/test/Modules/ExtDebugInfo.cpp @@ -76,7 +76,7 @@ // CHECK-SAME: flags: DIFlagFwdDecl, // CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE") -// CHECK: ![[NS]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]], +// CHECK: ![[NS]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]]) // CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugCXX // This type is anchored in the module by an explicit template instantiation. Index: unittests/IR/MetadataTest.cpp =================================================================== --- unittests/IR/MetadataTest.cpp +++ unittests/IR/MetadataTest.cpp @@ -1732,31 +1732,18 @@ TEST_F(DINamespaceTest, get) { DIScope *Scope = getFile(); - DIFile *File = getFile(); StringRef Name = "namespace"; - unsigned Line = 5; bool ExportSymbols = true; - auto *N = DINamespace::get(Context, Scope, File, Name, Line, ExportSymbols); + auto *N = DINamespace::get(Context, Scope, Name, ExportSymbols); EXPECT_EQ(dwarf::DW_TAG_namespace, N->getTag()); EXPECT_EQ(Scope, N->getScope()); - EXPECT_EQ(File, N->getFile()); EXPECT_EQ(Name, N->getName()); - EXPECT_EQ(Line, N->getLine()); - EXPECT_EQ(N, - DINamespace::get(Context, Scope, File, Name, Line, ExportSymbols)); - - EXPECT_NE(N, - DINamespace::get(Context, getFile(), File, Name, Line, ExportSymbols)); - EXPECT_NE(N, - DINamespace::get(Context, Scope, getFile(), Name, Line, ExportSymbols)); - EXPECT_NE(N, - DINamespace::get(Context, Scope, File, "other", Line, ExportSymbols)); - EXPECT_NE(N, - DINamespace::get(Context, Scope, File, Name, Line + 1, ExportSymbols)); - EXPECT_NE(N, - DINamespace::get(Context, Scope, File, Name, Line, !ExportSymbols)); + EXPECT_EQ(N, DINamespace::get(Context, Scope, Name, ExportSymbols)); + EXPECT_NE(N, DINamespace::get(Context, getFile(), Name, ExportSymbols)); + EXPECT_NE(N, DINamespace::get(Context, Scope, "other", ExportSymbols)); + EXPECT_NE(N, DINamespace::get(Context, Scope, Name, !ExportSymbols)); TempDINamespace Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));