summaryrefslogtreecommitdiffstats
path: root/clang/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
commit26a6dd087753612d05e17c132e78daf71fb7d45a (patch)
tree6338a301c3f9ec0b4c68237ffc88e601a63fedac /clang/CodeGen/CodeGenTypes.cpp
parent86e7166522edbecdf8db328f200e0a330cef841e (diff)
downloadbcm5719-llvm-26a6dd087753612d05e17c132e78daf71fb7d45a.tar.gz
bcm5719-llvm-26a6dd087753612d05e17c132e78daf71fb7d45a.zip
Fix memory corruption from the type map being modified while a reference
to a cell is being held. llvm-svn: 46735
Diffstat (limited to 'clang/CodeGen/CodeGenTypes.cpp')
-rw-r--r--clang/CodeGen/CodeGenTypes.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/CodeGen/CodeGenTypes.cpp b/clang/CodeGen/CodeGenTypes.cpp
index 25354eb945a..f3510d45951 100644
--- a/clang/CodeGen/CodeGenTypes.cpp
+++ b/clang/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!");
OpenPOWER on IntegriCloud