[llvm] r221466 - Change DIBuilder::createImportedDeclaration from taking a DIScope to a DIDescriptor.
Frederic Riss
friss at apple.com
Thu Nov 6 09:46:56 PST 2014
Author: friss
Date: Thu Nov 6 11:46:55 2014
New Revision: 221466
URL: http://llvm.org/viewvc/llvm-project?rev=221466&view=rev
Log:
Change DIBuilder::createImportedDeclaration from taking a DIScope to a DIDescriptor.
Imported declarations can be DIGlobalVariables which aren't a DIScope. Today
clang (unknowingly I believe) shoehorns these into a DIScope and it all works
just because we never access the fields.
Modified:
llvm/trunk/include/llvm/IR/DIBuilder.h
llvm/trunk/lib/IR/DIBuilder.cpp
Modified: llvm/trunk/include/llvm/IR/DIBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=221466&r1=221465&r2=221466&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DIBuilder.h (original)
+++ llvm/trunk/include/llvm/IR/DIBuilder.h Thu Nov 6 11:46:55 2014
@@ -651,7 +651,7 @@ namespace llvm {
/// @param Decl The declaration (or definition) of a function, type, or
/// variable
/// @param Line Line number
- DIImportedEntity createImportedDeclaration(DIScope Context, DIScope Decl,
+ DIImportedEntity createImportedDeclaration(DIScope Context, DIDescriptor Decl,
unsigned Line,
StringRef Name = StringRef());
DIImportedEntity createImportedDeclaration(DIScope Context,
Modified: llvm/trunk/lib/IR/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=221466&r1=221465&r2=221466&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)
+++ llvm/trunk/lib/IR/DIBuilder.cpp Thu Nov 6 11:46:55 2014
@@ -190,10 +190,13 @@ DIImportedEntity DIBuilder::createImport
}
DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,
- DIScope Decl,
+ DIDescriptor Decl,
unsigned Line, StringRef Name) {
+ // Make sure to use the unique identifier based metadata reference for
+ // types that have one.
+ Value *V = Decl.isType() ? DIType(Decl).getRef() : Decl;
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
- Context, Decl.getRef(), Line, Name,
+ Context, V, Line, Name,
AllImportedModules);
}
More information about the llvm-commits
mailing list