summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2017-07-19 00:09:54 +0000
committerAdrian Prantl <aprantl@apple.com>2017-07-19 00:09:54 +0000
commit9563b5a5e126f25d1966ac92a07bf033de01bc81 (patch)
tree7acb1dedd26abc711feb617c458d246e6a92d66d /include
parent35375a35c17d7c45f3067362f87388533ee5c558 (diff)
Debug Info: Add a file: field to DIImportedEntity.
DIImportedEntity has a line number, but not a file field. To determine the decl_line/decl_file we combine the line number from the DIImportedEntity with the file from the DIImportedEntity's scope. This does not work correctly when the parent scope is a DINamespace or a DIModule, both of which do not have a source file. This patch adds a file field to DIImportedEntity to unambiguously identify the source location of the using/import declaration. Most testcase updates are mechanical, the interesting one is the removal of the FIXME in test/DebugInfo/Generic/namespace.ll. This fixes PR33822. See https://bugs.llvm.org/show_bug.cgi?id=33822 for more context. <rdar://problem/33357889> https://bugs.llvm.org/show_bug.cgi?id=33822 Differential Revision: https://reviews.llvm.org/D35583 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308398 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/IR/DIBuilder.h37
-rw-r--r--include/llvm/IR/DebugInfoMetadata.h20
2 files changed, 32 insertions, 25 deletions
diff --git a/include/llvm/IR/DIBuilder.h b/include/llvm/IR/DIBuilder.h
index 8e6bb4baccaf..6a14f783005d 100644
--- a/include/llvm/IR/DIBuilder.h
+++ b/include/llvm/IR/DIBuilder.h
@@ -674,32 +674,37 @@ namespace llvm {
/// Create a descriptor for an imported module.
/// \param Context The scope this module is imported into
- /// \param NS The namespace being imported here
- /// \param Line Line number
+ /// \param NS The namespace being imported here.
+ /// \param File File where the declaration is located.
+ /// \param Line Line number of the declaration.
DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS,
- unsigned Line);
+ DIFile *File, unsigned Line);
/// Create a descriptor for an imported module.
- /// \param Context The scope this module is imported into
- /// \param NS An aliased namespace
- /// \param Line Line number
+ /// \param Context The scope this module is imported into.
+ /// \param NS An aliased namespace.
+ /// \param File File where the declaration is located.
+ /// \param Line Line number of the declaration.
DIImportedEntity *createImportedModule(DIScope *Context,
- DIImportedEntity *NS, unsigned Line);
+ DIImportedEntity *NS, DIFile *File,
+ unsigned Line);
/// Create a descriptor for an imported module.
- /// \param Context The scope this module is imported into
- /// \param M The module being imported here
- /// \param Line Line number
+ /// \param Context The scope this module is imported into.
+ /// \param M The module being imported here
+ /// \param File File where the declaration is located.
+ /// \param Line Line number of the declaration.
DIImportedEntity *createImportedModule(DIScope *Context, DIModule *M,
- unsigned Line);
+ DIFile *File, unsigned Line);
/// Create a descriptor for an imported function.
- /// \param Context The scope this module is imported into
- /// \param Decl The declaration (or definition) of a function, type, or
- /// variable
- /// \param Line Line number
+ /// \param Context The scope this module is imported into.
+ /// \param Decl The declaration (or definition) of a function, type, or
+ /// variable.
+ /// \param File File where the declaration is located.
+ /// \param Line Line number of the declaration.
DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl,
- unsigned Line,
+ DIFile *File, unsigned Line,
StringRef Name = "");
/// Insert a new llvm.dbg.declare intrinsic call.
diff --git a/include/llvm/IR/DebugInfoMetadata.h b/include/llvm/IR/DebugInfoMetadata.h
index f472e4b3de69..678a43ae7926 100644
--- a/include/llvm/IR/DebugInfoMetadata.h
+++ b/include/llvm/IR/DebugInfoMetadata.h
@@ -2551,32 +2551,32 @@ class DIImportedEntity : public DINode {
static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
DIScope *Scope, DINodeRef Entity,
- unsigned Line, StringRef Name,
+ DIFile *File, unsigned Line, StringRef Name,
StorageType Storage,
bool ShouldCreate = true) {
- return getImpl(Context, Tag, Scope, Entity, Line,
+ return getImpl(Context, Tag, Scope, Entity, File, Line,
getCanonicalMDString(Context, Name), Storage, ShouldCreate);
}
static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
Metadata *Scope, Metadata *Entity,
- unsigned Line, MDString *Name,
- StorageType Storage,
+ Metadata *File, unsigned Line,
+ MDString *Name, StorageType Storage,
bool ShouldCreate = true);
TempDIImportedEntity cloneImpl() const {
return getTemporary(getContext(), getTag(), getScope(), getEntity(),
- getLine(), getName());
+ getFile(), getLine(), getName());
}
public:
DEFINE_MDNODE_GET(DIImportedEntity,
(unsigned Tag, DIScope *Scope, DINodeRef Entity,
- unsigned Line, StringRef Name = ""),
- (Tag, Scope, Entity, Line, Name))
+ DIFile *File, unsigned Line, StringRef Name = ""),
+ (Tag, Scope, Entity, File, Line, Name))
DEFINE_MDNODE_GET(DIImportedEntity,
(unsigned Tag, Metadata *Scope, Metadata *Entity,
- unsigned Line, MDString *Name),
- (Tag, Scope, Entity, Line, Name))
+ Metadata *File, unsigned Line, MDString *Name),
+ (Tag, Scope, Entity, File, Line, Name))
TempDIImportedEntity clone() const { return cloneImpl(); }
@@ -2584,10 +2584,12 @@ public:
DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
DINodeRef getEntity() const { return DINodeRef(getRawEntity()); }
StringRef getName() const { return getStringOperand(2); }
+ DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
Metadata *getRawScope() const { return getOperand(0); }
Metadata *getRawEntity() const { return getOperand(1); }
MDString *getRawName() const { return getOperandAs<MDString>(2); }
+ Metadata *getRawFile() const { return getOperand(3); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIImportedEntityKind;