[cfe-commits] r55870 - in /cfe/trunk/lib/CodeGen: CodeGenTypes.cpp CodeGenTypes.h
Daniel Dunbar
daniel at zuster.org
Fri Sep 5 19:26:43 PDT 2008
Author: ddunbar
Date: Fri Sep 5 21:26:43 2008
New Revision: 55870
URL: http://llvm.org/viewvc/llvm-project?rev=55870&view=rev
Log:
Key LLVM types for TagDecl's off of the clang Type, since there is now
a many-to-one relationship between TagDecl's and types.
Modified:
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.h
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=55870&r1=55869&r2=55870&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Fri Sep 5 21:26:43 2008
@@ -66,7 +66,7 @@
}
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;
@@ -131,8 +131,10 @@
/// 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.
@@ -377,8 +379,12 @@
/// 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())
@@ -388,7 +394,7 @@
// 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;
}
@@ -406,7 +412,7 @@
// 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);
@@ -417,8 +423,10 @@
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()) {
@@ -430,8 +438,10 @@
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*>());
@@ -485,8 +495,10 @@
/// 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;
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=55870&r1=55869&r2=55870&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Fri Sep 5 21:26:43 2008
@@ -84,13 +84,13 @@
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.
More information about the cfe-commits
mailing list