}
CodeGenTypes::~CodeGenTypes() {
- for(llvm::DenseMap<const TagDecl *, CGRecordLayout *>::iterator
+ for(llvm::DenseMap<const Type *, CGRecordLayout *>::iterator
I = CGRecordLayouts.begin(), E = CGRecordLayouts.end();
I != E; ++I)
delete I->second;
/// UpdateCompletedType - When we find the full definition for a TagDecl,
/// replace the 'opaque' type we previously made for it if applicable.
void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) {
- llvm::DenseMap<const TagDecl*, llvm::PATypeHolder>::iterator TDTI =
- TagDeclTypes.find(TD);
+ const Type *Key =
+ Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
+ llvm::DenseMap<const Type*, llvm::PATypeHolder>::iterator TDTI =
+ TagDeclTypes.find(Key);
if (TDTI == TagDeclTypes.end()) return;
// Remember the opaque LLVM type for this tagdecl.
/// ConvertTagDeclType - Lay out a tagged decl type like struct or union or
/// enum.
const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
- llvm::DenseMap<const TagDecl*, llvm::PATypeHolder>::iterator TDTI =
- TagDeclTypes.find(TD);
+ // TagDecl's are not necessarily unique, instead use the (clang)
+ // type connected to the decl.
+ const Type *Key =
+ Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
+ llvm::DenseMap<const Type*, llvm::PATypeHolder>::iterator TDTI =
+ TagDeclTypes.find(Key);
// If we've already compiled this tag type, use the previous definition.
if (TDTI != TagDeclTypes.end())
// for this tagged decl.
if (!TD->isDefinition()) {
llvm::Type *ResultType = llvm::OpaqueType::get();
- TagDeclTypes.insert(std::make_pair(TD, ResultType));
+ TagDeclTypes.insert(std::make_pair(Key, ResultType));
return ResultType;
}
// Create new OpaqueType now for later use in case this is a recursive
// type. This will later be refined to the actual type.
llvm::PATypeHolder ResultHolder = llvm::OpaqueType::get();
- TagDeclTypes.insert(std::make_pair(TD, ResultHolder));
+ TagDeclTypes.insert(std::make_pair(Key, ResultHolder));
const llvm::Type *ResultType;
const RecordDecl *RD = cast<const RecordDecl>(TD);
RO.layoutStructFields(Context.getASTRecordLayout(RD));
// Get llvm::StructType.
- CGRecordLayouts[TD] = new CGRecordLayout(RO.getLLVMType(),
- RO.getPaddingFields());
+ const Type *Key =
+ Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
+ CGRecordLayouts[Key] = new CGRecordLayout(RO.getLLVMType(),
+ RO.getPaddingFields());
ResultType = RO.getLLVMType();
} else if (TD->isUnion()) {
RO.layoutUnionFields(Context.getASTRecordLayout(RD));
// Get llvm::StructType.
- CGRecordLayouts[TD] = new CGRecordLayout(RO.getLLVMType(),
- RO.getPaddingFields());
+ const Type *Key =
+ Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
+ CGRecordLayouts[Key] = new CGRecordLayout(RO.getLLVMType(),
+ RO.getPaddingFields());
ResultType = RO.getLLVMType();
} else {
ResultType = llvm::StructType::get(std::vector<const llvm::Type*>());
/// getCGRecordLayout - Return record layout info for the given llvm::Type.
const CGRecordLayout *
CodeGenTypes::getCGRecordLayout(const TagDecl *TD) const {
- llvm::DenseMap<const TagDecl*, CGRecordLayout *>::iterator I
- = CGRecordLayouts.find(TD);
+ const Type *Key =
+ Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
+ llvm::DenseMap<const Type*, CGRecordLayout *>::iterator I
+ = CGRecordLayouts.find(Key);
assert (I != CGRecordLayouts.end()
&& "Unable to find record layout information for type");
return I->second;
llvm::SmallVector<std::pair<const PointerLikeType *,
llvm::OpaqueType *>, 8> PointersToResolve;
- llvm::DenseMap<const TagDecl*, llvm::PATypeHolder> TagDeclTypes;
+ llvm::DenseMap<const Type*, llvm::PATypeHolder> TagDeclTypes;
/// CGRecordLayouts - This maps llvm struct type with corresponding
/// record layout info.
/// FIXME : If CGRecordLayout is less than 16 bytes then use
/// inline it in the map.
- llvm::DenseMap<const TagDecl*, CGRecordLayout *> CGRecordLayouts;
+ llvm::DenseMap<const Type*, CGRecordLayout *> CGRecordLayouts;
/// FieldInfo - This maps struct field with corresponding llvm struct type
/// field no. This info is populated by record organizer.