Use
+ llvm::DenseMap<Type *, llvm::PATypeHolder> TypeHolderMap;
instead of
- llvm::DenseMap<Type *, llvm::PATypeHolder *> TypeHolderMap;
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43514 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CodeGenTypes.cpp b/CodeGen/CodeGenTypes.cpp
index 06d9609..1fd09e9 100644
--- a/CodeGen/CodeGenTypes.cpp
+++ b/CodeGen/CodeGenTypes.cpp
@@ -75,16 +75,16 @@
/// ConvertType - Convert the specified type to its LLVM form.
const llvm::Type *CodeGenTypes::ConvertType(QualType T) {
// See if type is already cached.
- llvm::DenseMap<Type *, llvm::PATypeHolder *>::iterator
+ llvm::DenseMap<Type *, llvm::PATypeHolder>::iterator
I = TypeHolderMap.find(T.getTypePtr());
if (I != TypeHolderMap.end()) {
- llvm::PATypeHolder *PAT = I->second;
- return PAT->get();
+ llvm::PATypeHolder PAT = I->second;
+ return PAT.get();
}
const llvm::Type *ResultType = ConvertNewType(T);
- llvm::PATypeHolder *PAT = new llvm::PATypeHolder(ResultType);
- TypeHolderMap[T.getTypePtr()] = PAT;
+ TypeHolderMap.insert(std::make_pair(T.getTypePtr(),
+ llvm::PATypeHolder(ResultType)));
return ResultType;
}
@@ -187,7 +187,9 @@
if (!ResultType->isFirstClassType() && ResultType != llvm::Type::VoidTy) {
const llvm::Type *RType = llvm::PointerType::get(ResultType);
QualType RTy = Context.getPointerType(FP.getResultType());
- TypeHolderMap[RTy.getTypePtr()] = new llvm::PATypeHolder(RType);
+ TypeHolderMap.insert(std::make_pair(RTy.getTypePtr(),
+ llvm::PATypeHolder(RType)));
+
ArgTys.push_back(RType);
ResultType = llvm::Type::VoidTy;
}
@@ -237,8 +239,8 @@
// Reevaluate this when performance analyis finds tons of opaque types.
llvm::OpaqueType *OpaqueTy = llvm::OpaqueType::get();
RecordTypesToResolve[RD] = OpaqueTy;
- QualType Opq;
- TypeHolderMap[Opq.getTypePtr()] = new llvm::PATypeHolder(OpaqueTy);
+ TypeHolderMap.insert(std::make_pair(T.getTypePtr(),
+ llvm::PATypeHolder(OpaqueTy)));
// Layout fields.
RecordOrganizer RO;
@@ -304,7 +306,9 @@
else {
QualType PTy = Context.getPointerType(FTP.getArgType(i));
const llvm::Type *PtrTy = llvm::PointerType::get(Ty);
- TypeHolderMap[PTy.getTypePtr()] = new llvm::PATypeHolder(PtrTy);
+ TypeHolderMap.insert(std::make_pair(PTy.getTypePtr(),
+ llvm::PATypeHolder(PtrTy)));
+
ArgTys.push_back(PtrTy);
}
}
diff --git a/CodeGen/CodeGenTypes.h b/CodeGen/CodeGenTypes.h
index a6e13c4..95aea85 100644
--- a/CodeGen/CodeGenTypes.h
+++ b/CodeGen/CodeGenTypes.h
@@ -83,7 +83,7 @@
/// and maps llvm::Types to corresponding clang::Type. llvm::PATypeHolder is
/// used instead of llvm::Type because it allows us to bypass potential
/// dangling type pointers due to type refinement on llvm side.
- llvm::DenseMap<Type *, llvm::PATypeHolder *> TypeHolderMap;
+ llvm::DenseMap<Type *, llvm::PATypeHolder> TypeHolderMap;
/// ConvertNewType - Convert type T into a llvm::Type. Do not use this
/// method directly because it does not do any type caching. This method