<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 6, 2014 at 9:46 AM, Frederic Riss <span dir="ltr"><<a href="mailto:friss@apple.com" target="_blank">friss@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: friss<br>
Date: Thu Nov  6 11:46:55 2014<br>
New Revision: 221466<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221466&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=221466&view=rev</a><br>
Log:<br>
Change DIBuilder::createImportedDeclaration from taking a DIScope to a DIDescriptor.<br>
<br>
Imported declarations can be DIGlobalVariables which aren't a DIScope.</blockquote><div><br>Sounds good - thanks!<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Today<br>
clang (unknowingly I believe)</blockquote><div><br>Yep, the DIDescriptor hierarchy is pretty loose - implicitly constructible from any MDNode* without validating, etc... (we could probably add an assertion into the various DIDescriptor ctors)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> shoehorns these into a DIScope and it all works<br>
just because we never access the fields.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/IR/DIBuilder.h<br>
    llvm/trunk/lib/IR/DIBuilder.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/IR/DIBuilder.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=221466&r1=221465&r2=221466&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=221466&r1=221465&r2=221466&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/IR/DIBuilder.h (original)<br>
+++ llvm/trunk/include/llvm/IR/DIBuilder.h Thu Nov  6 11:46:55 2014<br>
@@ -651,7 +651,7 @@ namespace llvm {<br>
     /// @param Decl The declaration (or definition) of a function, type, or<br>
     ///             variable<br>
     /// @param Line Line number<br>
-    DIImportedEntity createImportedDeclaration(DIScope Context, DIScope Decl,<br>
+    DIImportedEntity createImportedDeclaration(DIScope Context, DIDescriptor Decl,<br>
                                                unsigned Line,<br>
                                                StringRef Name = StringRef());<br>
     DIImportedEntity createImportedDeclaration(DIScope Context,<br>
<br>
Modified: llvm/trunk/lib/IR/DIBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=221466&r1=221465&r2=221466&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=221466&r1=221465&r2=221466&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)<br>
+++ llvm/trunk/lib/IR/DIBuilder.cpp Thu Nov  6 11:46:55 2014<br>
@@ -190,10 +190,13 @@ DIImportedEntity DIBuilder::createImport<br>
 }<br>
<br>
 DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,<br>
-                                                      DIScope Decl,<br>
+                                                      DIDescriptor Decl,<br>
                                                       unsigned Line, StringRef Name) {<br>
+  // Make sure to use the unique identifier based metadata reference for<br>
+  // types that have one.<br>
+  Value *V = Decl.isType() ? DIType(Decl).getRef() : Decl;</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
   return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,<br>
-                                Context, Decl.getRef(), Line, Name,<br>
+                                Context, V, Line, Name,<br>
                                 AllImportedModules);<br>
 }<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>