diff options
author | Adrian Prantl <aprantl@apple.com> | 2017-07-19 00:09:54 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2017-07-19 00:09:54 +0000 |
commit | 9563b5a5e126f25d1966ac92a07bf033de01bc81 (patch) | |
tree | 7acb1dedd26abc711feb617c458d246e6a92d66d /unittests/IR/MetadataTest.cpp | |
parent | 35375a35c17d7c45f3067362f87388533ee5c558 (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 'unittests/IR/MetadataTest.cpp')
-rw-r--r-- | unittests/IR/MetadataTest.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/unittests/IR/MetadataTest.cpp b/unittests/IR/MetadataTest.cpp index cb38b30f43e..e47afca532d 100644 --- a/unittests/IR/MetadataTest.cpp +++ b/unittests/IR/MetadataTest.cpp @@ -2116,29 +2116,35 @@ TEST_F(DIImportedEntityTest, get) { unsigned Tag = dwarf::DW_TAG_imported_module; DIScope *Scope = getSubprogram(); DINode *Entity = getCompositeType(); + DIFile *File = getFile(); unsigned Line = 5; StringRef Name = "name"; - auto *N = DIImportedEntity::get(Context, Tag, Scope, Entity, Line, Name); + auto *N = + DIImportedEntity::get(Context, Tag, Scope, Entity, File, Line, Name); EXPECT_EQ(Tag, N->getTag()); EXPECT_EQ(Scope, N->getScope()); EXPECT_EQ(Entity, N->getEntity()); + EXPECT_EQ(File, N->getFile()); EXPECT_EQ(Line, N->getLine()); EXPECT_EQ(Name, N->getName()); - EXPECT_EQ(N, DIImportedEntity::get(Context, Tag, Scope, Entity, Line, Name)); + EXPECT_EQ( + N, DIImportedEntity::get(Context, Tag, Scope, Entity, File, Line, Name)); EXPECT_NE(N, DIImportedEntity::get(Context, dwarf::DW_TAG_imported_declaration, - Scope, Entity, Line, Name)); + Scope, Entity, File, Line, Name)); EXPECT_NE(N, DIImportedEntity::get(Context, Tag, getSubprogram(), Entity, - Line, Name)); + File, Line, Name)); EXPECT_NE(N, DIImportedEntity::get(Context, Tag, Scope, getCompositeType(), - Line, Name)); - EXPECT_NE(N, - DIImportedEntity::get(Context, Tag, Scope, Entity, Line + 1, Name)); - EXPECT_NE(N, - DIImportedEntity::get(Context, Tag, Scope, Entity, Line, "other")); + File, Line, Name)); + EXPECT_NE(N, DIImportedEntity::get(Context, Tag, Scope, Entity, nullptr, Line, + Name)); + EXPECT_NE(N, DIImportedEntity::get(Context, Tag, Scope, Entity, File, + Line + 1, Name)); + EXPECT_NE(N, DIImportedEntity::get(Context, Tag, Scope, Entity, File, Line, + "other")); TempDIImportedEntity Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); |