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

llvm-svn: 301706
This commit is contained in:
Adrian Prantl 2017-04-28 22:25:46 +00:00
parent c20ccd2c02
commit fed4f399d3
36 changed files with 102 additions and 130 deletions

View File

@ -632,11 +632,9 @@ namespace llvm {
/// 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.

View File

@ -1853,45 +1853,40 @@ class DINamespace : public DIScope {
friend class LLVMContextImpl;
friend class MDNode;
unsigned Line;
unsigned ExportSymbols : 1;
DINamespace(LLVMContext &Context, StorageType Storage, unsigned Line,
bool ExportSymbols, ArrayRef<Metadata *> Ops)
DINamespace(LLVMContext &Context, StorageType Storage, bool ExportSymbols,
ArrayRef<Metadata *> 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<DIScope>(getRawScope()); }
StringRef getName() const { return getStringOperand(2); }

View File

@ -4150,15 +4150,13 @@ bool LLParser::ParseDILexicalBlockFile(MDNode *&Result, bool IsDistinct) {
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;
}

View File

@ -1383,16 +1383,20 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
break;
}
case bitc::METADATA_NAMESPACE: {
if (Record.size() != 5)
// Newer versions of DINamespace dropped file and line.
MDString *Name;
if (Record.size() == 3)
Name = getMDString(Record[2]);
else if (Record.size() == 5)
Name = getMDString(Record[3]);
else
return error("Invalid record");
IsDistinct = Record[0] & 1;
bool ExportSymbols = Record[0] & 2;
MetadataList.assignValue(
GET_OR_DISTINCT(DINamespace,
(Context, getMDOrNull(Record[1]),
getMDOrNull(Record[2]), getMDString(Record[3]),
Record[4], ExportSymbols)),
(Context, getMDOrNull(Record[1]), Name, ExportSymbols)),
NextMetadataNo);
NextMetadataNo++;
break;

View File

@ -1646,9 +1646,7 @@ void ModuleBitcodeWriter::writeDINamespace(const DINamespace *N,
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(VE.getMetadataOrNullID(N->getRawName()));
Record.push_back(N->getLine());
Stream.EmitRecord(bitc::METADATA_NAMESPACE, Record, Abbrev);
Record.clear();

View File

@ -375,10 +375,6 @@ void DwarfUnit::addSourceLine(DIE &Die, const DIObjCProperty *Ty) {
addSourceLine(Die, Ty->getLine(), Ty->getFilename(), Ty->getDirectory());
}
void DwarfUnit::addSourceLine(DIE &Die, const DINamespace *NS) {
addSourceLine(Die, NS->getLine(), NS->getFilename(), NS->getDirectory());
}
/* Byref variables, in Blocks, are declared by the programmer as "SomeType
VarName;", but the compiler creates a __Block_byref_x_VarName struct, and
gives the variable VarName either the struct, or a pointer to the struct, as
@ -1085,7 +1081,6 @@ DIE *DwarfUnit::getOrCreateNameSpace(const DINamespace *NS) {
Name = "(anonymous namespace)";
DD->addAccelNamespace(Name, NDie);
addGlobalName(Name, NDie, NS->getScope());
addSourceLine(NDie, NS);
if (NS->getExportSymbols())
addFlag(NDie, dwarf::DW_AT_export_symbols);
return &NDie;

View File

@ -210,7 +210,6 @@ public:
void addSourceLine(DIE &Die, const DIGlobalVariable *G);
void addSourceLine(DIE &Die, const DISubprogram *SP);
void addSourceLine(DIE &Die, const DIType *Ty);
void addSourceLine(DIE &Die, const DINamespace *NS);
void addSourceLine(DIE &Die, const DIObjCProperty *Ty);
/// Add constant value entry in variable DIE.

View File

@ -1756,8 +1756,6 @@ static void writeDINamespace(raw_ostream &Out, const DINamespace *N,
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
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 << ")";
}

View File

@ -728,10 +728,15 @@ DISubprogram *DIBuilder::createMethod(
}
DINamespace *DIBuilder::createNameSpace(DIScope *Scope, StringRef Name,
DIFile *File, unsigned LineNo,
bool ExportSymbols) {
return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), File, Name,
LineNo, ExportSymbols);
// It is okay to *not* make anonymous top-level namespaces distinct, because
// all nodes that have an anonymous namespace as their parent scope are
// guaranteed to be unique and/or are linked to their containing
// DICompileUnit. This decision is an explicit tradeoff of link time versus
// memory usage versus code simplicity and may get revisited in the future.
return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), Name,
ExportSymbols);
}
DIModule *DIBuilder::createModule(DIScope *Scope, StringRef Name,

View File

@ -507,13 +507,13 @@ DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context,
}
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));
// The nullptr is for DIScope's File operand. This should be refactored.
Metadata *Ops[] = {nullptr, Scope, Name};
DEFINE_GETIMPL_STORE(DINamespace, (ExportSymbols), Ops);
}
DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *Scope,

View File

@ -699,26 +699,21 @@ template <> struct MDNodeKeyImpl<DILexicalBlockFile> {
template <> struct MDNodeKeyImpl<DINamespace> {
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);
}
};

View File

@ -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)

View File

@ -10,8 +10,8 @@ target triple = "x86_64-apple-macosx10.12.0"
!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)

View File

@ -49,7 +49,7 @@ attributes #0 = { sspreq }
!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<unsigned long long>", 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}

View File

@ -63,7 +63,7 @@ attributes #1 = { nounwind readnone }
!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)

View File

@ -110,9 +110,9 @@ attributes #1 = { nounwind readnone }
!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)

View File

@ -116,7 +116,7 @@ attributes #1 = { nounwind readnone }
!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}

View File

@ -2,15 +2,15 @@
; 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: DW_AT_decl_file
; CHECK-NOT: DW_AT_decl_line
; 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: DW_AT_decl_file
; CHECK-NOT: DW_AT_decl_line
; CHECK-NOT: NULL
; CHECK: [[I:0x[0-9a-f]*]]:{{ *}}DW_TAG_variable
; CHECK-NEXT: DW_AT_name{{.*}}= "i"
@ -56,15 +56,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 +76,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 +293,8 @@ attributes #1 = { nounwind readnone }
!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)

View File

@ -34,7 +34,7 @@ attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointe
!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}

View File

@ -79,7 +79,7 @@ attributes #2 = { nounwind readnone }
!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}

View File

@ -57,7 +57,7 @@ attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fp
!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)

View File

@ -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 @@ attributes #1 = { nounwind readnone }
!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}

View File

@ -227,9 +227,9 @@ attributes #1 = { nounwind readnone }
!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 @@ attributes #1 = { nounwind readnone }
!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 = !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)

View File

@ -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)"}

View File

@ -318,7 +318,7 @@ attributes #1 = { nounwind readnone }
!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 @@ attributes #1 = { nounwind readnone }
!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 = !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 = !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)

View File

@ -28,9 +28,9 @@ target triple = "x86_64-apple-macosx10.12.0"
!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 = !{}

View File

@ -137,7 +137,7 @@ attributes #2 = { nounwind }
!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)"}

View File

@ -34,7 +34,7 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnon
!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)

View File

@ -90,7 +90,7 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
!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)

View File

@ -94,7 +94,7 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
!7 = !DIFile(filename: "/usr/include/locale.h", directory: "/llvm_cmake_gcc")
!8 = !DICompositeType(tag: DW_TAG_class_type, name: "basic_string<char, std::char_traits<char>, std::allocator<char> >", 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 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
!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 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
!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)

View File

@ -35,7 +35,7 @@ attributes #1 = { nounwind readnone }
!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<float>", scope: !2, file: !3, line: 2, size: 32, align: 32, elements: !5, templateParams: !12)
!5 = !{!6, !8}

View File

@ -29,7 +29,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
!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)

View File

@ -27,7 +27,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
!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)

View File

@ -39,7 +39,7 @@ entry:
!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)

View File

@ -43,7 +43,7 @@ entry:
!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")

View File

@ -1732,31 +1732,18 @@ typedef MetadataTest DINamespaceTest;
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)));