From 6df2a3be33099024fbb31d8e05e364d31ae5aaf1 Mon Sep 17 00:00:00 2001 From: Frederic Riss Date: Thu, 6 Nov 2014 17:46:55 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221466 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DIBuilder.h | 2 +- lib/IR/DIBuilder.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/llvm/IR/DIBuilder.h b/include/llvm/IR/DIBuilder.h index 8484d04e914..78ab3dc9756 100644 --- a/include/llvm/IR/DIBuilder.h +++ b/include/llvm/IR/DIBuilder.h @@ -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, diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index 3276fe6452a..fbd19596377 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -190,10 +190,13 @@ DIImportedEntity DIBuilder::createImportedModule(DIScope Context, } 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); }