1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

Fixed DIBuilder to verify that same imported entity will not be added twice to the "imports" list of the DICompileUnit.

Differential Revision: http://reviews.llvm.org/D17884

llvm-svn: 263379
This commit is contained in:
Amjad Aboud 2016-03-13 11:11:39 +00:00
parent 4253ad553a
commit 9bfdf16f5b
2 changed files with 21 additions and 1 deletions

View File

@ -19,6 +19,7 @@
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/Dwarf.h" #include "llvm/Support/Dwarf.h"
#include "LLVMContextImpl.h"
using namespace llvm; using namespace llvm;
using namespace llvm::dwarf; using namespace llvm::dwarf;
@ -168,8 +169,12 @@ static DIImportedEntity *
createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context, createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context,
Metadata *NS, unsigned Line, StringRef Name, Metadata *NS, unsigned Line, StringRef Name,
SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) { SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) {
unsigned EntitiesCount = C.pImpl->DIImportedEntitys.size();
auto *M = DIImportedEntity::get(C, Tag, Context, DINodeRef(NS), Line, Name); auto *M = DIImportedEntity::get(C, Tag, Context, DINodeRef(NS), Line, Name);
AllImportedModules.emplace_back(M); if (EntitiesCount < C.pImpl->DIImportedEntitys.size())
// A new Imported Entity was just added to the context.
// Add it to the Imported Modules list.
AllImportedModules.emplace_back(M);
return M; return M;
} }

View File

@ -418,4 +418,19 @@ TEST_F(IRBuilderTest, DebugLoc) {
DIB.finalize(); DIB.finalize();
} }
TEST_F(IRBuilderTest, DIImportedEntity) {
IRBuilder<> Builder(BB);
DIBuilder DIB(*M);
auto File = DIB.createFile("F.CBL", "/");
auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74, "F.CBL", "/",
"llvm-cobol74", true, "", 0);
auto IE1 = DIB.createImportedDeclaration(CU, nullptr, 1);
auto IE2 = DIB.createImportedDeclaration(CU, nullptr, 1);
auto IE3 = DIB.createImportedModule(CU, (DIImportedEntity*)nullptr, 2);
auto IE4 = DIB.createImportedModule(CU, (DIImportedEntity*)nullptr, 2);
DIB.finalize();
EXPECT_TRUE(verifyModule(*M));
EXPECT_TRUE(CU->getImportedEntities().size() == 2);
}
} }