aboutsummaryrefslogtreecommitdiff
path: root/CodeGen/CodeGenTypes.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-02-05 02:18:07 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-02-05 02:18:07 +0000
commit0ded75bc88b40607aa5baced6e4729774ed2df56 (patch)
treee8a9a5e17c46582e143a4d4f4d4e1f76240a5019 /CodeGen/CodeGenTypes.cpp
parent5bfc1a7ecb853cf87d10e720a07b9fbcd2a223ee (diff)
Fix memory corruption from the type map being modified while a reference
to a cell is being held. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46735 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CodeGenTypes.cpp')
-rw-r--r--CodeGen/CodeGenTypes.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/CodeGen/CodeGenTypes.cpp b/CodeGen/CodeGenTypes.cpp
index 25354eb945..f3510d4595 100644
--- a/CodeGen/CodeGenTypes.cpp
+++ b/CodeGen/CodeGenTypes.cpp
@@ -290,7 +290,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
case Type::Tagged:
const TagType &TT = cast<TagType>(Ty);
const TagDecl *TD = TT.getDecl();
- llvm::Type *&ResultType = TagDeclTypes[TD];
+ llvm::Type *ResultType = TagDeclTypes[TD];
// If corresponding llvm type is not a opaque struct type
// then use it.
@@ -298,7 +298,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
return ResultType;
if (!TD->isDefinition()) {
- ResultType = llvm::OpaqueType::get();
+ ResultType = TagDeclTypes[TD] = llvm::OpaqueType::get();
} else if (TD->getKind() == Decl::Enum) {
return ConvertType(cast<EnumDecl>(TD)->getIntegerType());
} else if (TD->getKind() == Decl::Struct) {
@@ -335,7 +335,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
// Get llvm::StructType.
CGRecordLayout *RLI = new CGRecordLayout(RO.getLLVMType());
- ResultType = RLI->getLLVMType();
+ ResultType = TagDeclTypes[TD] = RLI->getLLVMType();
CGRecordLayouts[ResultType] = RLI;
// Refine any OpaqueType associated with this RecordDecl.
@@ -358,11 +358,11 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
// Get llvm::StructType.
CGRecordLayout *RLI = new CGRecordLayout(RO.getLLVMType());
- ResultType = RLI->getLLVMType();
+ ResultType = TagDeclTypes[TD] = RLI->getLLVMType();
CGRecordLayouts[ResultType] = RLI;
} else {
std::vector<const llvm::Type*> Fields;
- ResultType = llvm::StructType::get(Fields);
+ ResultType = TagDeclTypes[TD] = llvm::StructType::get(Fields);
}
} else {
assert(0 && "FIXME: Implement tag decl kind!");