DebugInfo: Support namespace aliases as DW_TAG_imported_declaration instead of DW_TAG_imported_module

I really should read the spec more often (and test GCC more often too).
I just assumed that namespace aliases would be the same as using
directives, except with a name. But apparently that's not how the DWARF
standards suggests they be implemented. DWARF4 provides an example and
other non-normative text suggesting that namespace aliases be
implemented by named imported declarations intsead of named imported
modules.

So be it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205685 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2014-04-06 06:29:01 +00:00
parent 20384a5583
commit 1c41705d34
3 changed files with 35 additions and 33 deletions

View File

@ -146,13 +146,13 @@ DICompileUnit DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
}
static DIImportedEntity
createImportedModule(LLVMContext &C, DIScope Context, DIDescriptor NS,
unsigned Line, StringRef Name,
SmallVectorImpl<TrackingVH<MDNode> > &AllImportedModules) {
createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope Context,
Value *NS, unsigned Line, StringRef Name,
SmallVectorImpl<TrackingVH<MDNode>> &AllImportedModules) {
const MDNode *R;
if (Name.empty()) {
Value *Elts[] = {
GetTagConstant(C, dwarf::DW_TAG_imported_module),
GetTagConstant(C, Tag),
Context,
NS,
ConstantInt::get(Type::getInt32Ty(C), Line),
@ -160,7 +160,7 @@ createImportedModule(LLVMContext &C, DIScope Context, DIDescriptor NS,
R = MDNode::get(C, Elts);
} else {
Value *Elts[] = {
GetTagConstant(C, dwarf::DW_TAG_imported_module),
GetTagConstant(C, Tag),
Context,
NS,
ConstantInt::get(Type::getInt32Ty(C), Line),
@ -175,33 +175,32 @@ createImportedModule(LLVMContext &C, DIScope Context, DIDescriptor NS,
}
DIImportedEntity DIBuilder::createImportedModule(DIScope Context,
DINameSpace NS, unsigned Line,
StringRef Name) {
return ::createImportedModule(VMContext, Context, NS, Line, Name,
AllImportedModules);
DINameSpace NS,
unsigned Line) {
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
Context, NS, Line, StringRef(), AllImportedModules);
}
DIImportedEntity DIBuilder::createImportedModule(DIScope Context,
DIImportedEntity NS,
unsigned Line,
StringRef Name) {
return ::createImportedModule(VMContext, Context, NS, Line, Name,
AllImportedModules);
unsigned Line) {
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
Context, NS, Line, StringRef(), AllImportedModules);
}
DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,
DIScope Decl,
unsigned Line) {
Value *Elts[] = {
GetTagConstant(VMContext, dwarf::DW_TAG_imported_declaration),
Context,
Decl.getRef(),
ConstantInt::get(Type::getInt32Ty(VMContext), Line),
};
DIImportedEntity M(MDNode::get(VMContext, Elts));
assert(M.Verify() && "Imported module should be valid");
AllImportedModules.push_back(TrackingVH<MDNode>(M));
return M;
unsigned Line, StringRef Name) {
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
Context, Decl.getRef(), Line, Name,
AllImportedModules);
}
DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,
DIImportedEntity Imp,
unsigned Line, StringRef Name) {
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
Context, Imp, Line, Name, AllImportedModules);
}
/// createFile - Create a file descriptor to hold debugging information