[llvm] r221466 - Change DIBuilder::createImportedDeclaration from taking a DIScope to a DIDescriptor.

David Blaikie dblaikie at gmail.com
Thu Nov 6 10:13:02 PST 2014


On Thu, Nov 6, 2014 at 9:46 AM, Frederic Riss <friss at apple.com> wrote:

> 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.


Sounds good - thanks!


> Today
> clang (unknowingly I believe)


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)


> 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);
>  }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141106/1311536f/attachment.html>


More information about the llvm-commits mailing list