summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-06-21 14:56:24 +0000
committerReid Kleckner <rnk@google.com>2016-06-21 14:56:24 +0000
commit9ff936cfc19024f9742a31eb0ae3680f6eac7877 (patch)
tree371b44d6a117d6ef9a89311631b76bd9f008f85f /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
parent48933772f7bc8c2fe0a7a6172f85738de564c668 (diff)
downloadbcm5719-llvm-9ff936cfc19024f9742a31eb0ae3680f6eac7877.tar.gz
bcm5719-llvm-9ff936cfc19024f9742a31eb0ae3680f6eac7877.zip
[codeview] Fix DenseMap pointer invalidation bug
When you have a map holding a unique_ptr, hold a reference to the raw pointer instead of the unique pointer. The unique_ptr will be moved on rehash. llvm-svn: 273268
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 704f135208d..62509b6ebb2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1297,8 +1297,7 @@ void CodeViewDebug::collectMemberInfo(ClassInfo &Info,
assert((DDTy->getOffsetInBits() % 8) == 0 && "Unnamed bitfield member!");
unsigned offset = DDTy->getOffsetInBits() / 8;
const DIType *Ty = DDTy->getBaseType().resolve();
- assert(dyn_cast<DICompositeType>(Ty) && "Expects structure or union type");
- const DICompositeType *DCTy = dyn_cast<DICompositeType>(Ty);
+ const DICompositeType *DCTy = cast<DICompositeType>(Ty);
ClassInfo &NestedInfo = collectClassInfo(DCTy);
ClassInfo::MemberList &Members = NestedInfo.Members;
for (unsigned i = 0, e = Members.size(); i != e; ++i)
@@ -1308,10 +1307,14 @@ void CodeViewDebug::collectMemberInfo(ClassInfo &Info,
ClassInfo &CodeViewDebug::collectClassInfo(const DICompositeType *Ty) {
auto Insertion = ClassInfoMap.insert({Ty, std::unique_ptr<ClassInfo>()});
- std::unique_ptr<ClassInfo> &Info = Insertion.first->second;
- if (!Insertion.second)
- return *Info;
- Info.reset(new ClassInfo());
+ ClassInfo *Info = nullptr;
+ {
+ std::unique_ptr<ClassInfo> &InfoEntry = Insertion.first->second;
+ if (!Insertion.second)
+ return *InfoEntry;
+ InfoEntry.reset(new ClassInfo());
+ Info = InfoEntry.get();
+ }
// Add elements to structure type.
DINodeArray Elements = Ty->getElements();
OpenPOWER on IntegriCloud