diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2009-02-17 21:45:36 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-02-17 21:45:36 +0000 |
| commit | 37b43cd89ca016e66639a22f01d37fd97069750f (patch) | |
| tree | 8ed6ce5323145b00690e169493ab2a012c7d3fcd | |
| parent | 528987a1e87be84462fd449495850e077f977130 (diff) | |
| download | bcm5719-llvm-37b43cd89ca016e66639a22f01d37fd97069750f.tar.gz bcm5719-llvm-37b43cd89ca016e66639a22f01d37fd97069750f.zip | |
Simplified ExtQualType per Chris's feedback.
llvm-svn: 64820
| -rw-r--r-- | clang/include/clang/AST/Type.h | 38 | ||||
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/AST/Type.cpp | 8 |
3 files changed, 18 insertions, 33 deletions
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index f5e13c235c6..ebbc5504a5d 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -462,55 +462,43 @@ protected: /// class ExtQualType : public Type, public llvm::FoldingSetNode { public: - enum EQT { - EXTNONE = 0x0, - ASQUAL = 0x01, - GCQUAL = 0x10 + enum GCAttrTypes { + GCNone = 0, + Weak, + Strong }; + private: /// BaseType - This is the underlying type that this qualifies. All CVR /// qualifiers are stored on the QualType that references this type, so we /// can't have any here. Type *BaseType; - unsigned ExtQualTypeKind : 2; /// Address Space ID - The address space ID this type is qualified with. unsigned AddressSpace; /// GC __weak/__strong attributes - ObjCGCAttr *GCAttr; + GCAttrTypes GCAttrType; ExtQualType(Type *Base, QualType CanonicalPtr, unsigned AddrSpace, - ObjCGCAttr *gcAttr, - unsigned ExtKind) : + GCAttrTypes gcAttr) : Type(ExtQual, CanonicalPtr, Base->isDependentType()), BaseType(Base), - ExtQualTypeKind(ExtKind), AddressSpace(0), GCAttr(0) { - if (ExtKind & ASQUAL) - AddressSpace = AddrSpace; - if (ExtKind & GCQUAL) - GCAttr = gcAttr; - } + AddressSpace(AddrSpace), GCAttrType(gcAttr) { } friend class ASTContext; // ASTContext creates these. public: Type *getBaseType() const { return BaseType; } - ObjCGCAttr *getGCAttr() const { - assert((ExtQualTypeKind & GCQUAL) && "Bad ExtQualType Kind - not GCQUAL"); - return GCAttr; - } - unsigned getAddressSpace() const { - assert((ExtQualTypeKind & ASQUAL) && "Bad ExtQualType Kind - not ASQUAL"); - return AddressSpace; - } + GCAttrTypes getType() const { return GCAttrType; } + unsigned getAddressSpace() const { return AddressSpace; } virtual void getAsStringInternal(std::string &InnerString) const; void Profile(llvm::FoldingSetNodeID &ID) { - Profile(ID, getBaseType(), AddressSpace, GCAttr); + Profile(ID, getBaseType(), AddressSpace, GCAttrType); } static void Profile(llvm::FoldingSetNodeID &ID, Type *Base, - unsigned AddrSpace, ObjCGCAttr *gcAttr) { + unsigned AddrSpace, GCAttrTypes gcAttr) { ID.AddPointer(Base); - ID.AddPointer(gcAttr); ID.AddInteger(AddrSpace); + ID.AddInteger(gcAttr); } static bool classof(const Type *T) { return T->getTypeClass() == ExtQual; } diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index dec73182b81..c87b08627dd 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -725,7 +725,7 @@ QualType ASTContext::getAddrSpaceQualType(QualType T, unsigned AddressSpace) { // Check if we've already instantiated an address space qual'd type of this // type. llvm::FoldingSetNodeID ID; - ExtQualType::Profile(ID, T.getTypePtr(), AddressSpace, 0); + ExtQualType::Profile(ID, T.getTypePtr(), AddressSpace, ExtQualType::GCNone); void *InsertPos = 0; if (ExtQualType *EXTQy = ExtQualTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(EXTQy, 0); @@ -741,8 +741,7 @@ QualType ASTContext::getAddrSpaceQualType(QualType T, unsigned AddressSpace) { assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP; } ExtQualType *New = new (*this, 8) ExtQualType(T.getTypePtr(), Canonical, - AddressSpace, 0, - ExtQualType::ASQUAL); + AddressSpace, ExtQualType::GCNone); ExtQualTypes.InsertNode(New, InsertPos); Types.push_back(New); return QualType(New, T.getCVRQualifiers()); diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 6aec24fdddd..bc597072edc 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -1054,17 +1054,15 @@ void ComplexType::getAsStringInternal(std::string &S) const { void ExtQualType::getAsStringInternal(std::string &S) const { bool space = false; - if (ExtQualTypeKind & ASQUAL) { + if (AddressSpace) { S = "__attribute__((address_space("+llvm::utostr_32(AddressSpace)+")))" + S; space = true; } - if (ExtQualTypeKind & GCQUAL) { + if (GCAttrType != GCNone) { if (space) S += ' '; S += "__attribute__((objc_gc("; - ObjCGCAttr *gcattr = getGCAttr(); - ObjCGCAttr::GCAttrTypes attr = gcattr->getType(); - if (attr & ObjCGCAttr::Weak) + if (GCAttrType == Weak) S += "weak"; else S += "strong"; |

