diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-02-18 05:09:49 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-02-18 05:09:49 +0000 |
commit | d33d9c0cc0cfdcd0b10f35a6acdfb25da4a64f19 (patch) | |
tree | 62ddec380281fd5d7584b9ad958acdf4df241f5d /include/clang/AST | |
parent | 00dbfde0d7d0ef003a5a6bf7de0116636d0c1278 (diff) |
Representation of objc gc's attribute using ExtQualType.
Note that one test attr-objc-gc.m fails. I will fix this
after removing these attributes from the Decl nodes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64889 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST')
-rw-r--r-- | include/clang/AST/ASTContext.h | 5 | ||||
-rw-r--r-- | include/clang/AST/Type.h | 36 |
2 files changed, 29 insertions, 12 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 349b6e3f83..76bb01ebe5 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -190,6 +190,11 @@ public: /// replaced. QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace); + /// getObjCGCQualType - Returns the uniqued reference to the type for an + /// objc gc qualified type. The retulting type has a union of the qualifiers + /// from T and the gc attribute. + QualType getObjCGCQualType(QualType T, QualType::GCAttrTypes gcAttr); + /// getComplexType - Return the uniqued reference to the type for a complex /// number with the specified element type. QualType getComplexType(QualType T); diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index ebbc5504a5..909f395791 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -93,6 +93,12 @@ public: CVRFlags = Const|Restrict|Volatile }; + enum GCAttrTypes { + GCNone = 0, + Weak, + Strong + }; + QualType() {} QualType(const Type *Ptr, unsigned Quals) @@ -188,6 +194,9 @@ public: /// getAddressSpace - Return the address space of this type. inline unsigned getAddressSpace() const; + /// GCAttrTypesAttr - Returns gc attribute of this type. + inline QualType::GCAttrTypes getObjCGCAttr() const; + /// Emit - Serialize a QualType to Bitcode. void Emit(llvm::Serializer& S) const; @@ -255,6 +264,7 @@ public: BlockPointer, // C extension FixedWidthInt }; + private: QualType CanonicalType; @@ -461,14 +471,6 @@ protected: /// __strong attributes. /// class ExtQualType : public Type, public llvm::FoldingSetNode { -public: - 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. @@ -477,16 +479,16 @@ private: /// Address Space ID - The address space ID this type is qualified with. unsigned AddressSpace; /// GC __weak/__strong attributes - GCAttrTypes GCAttrType; + QualType::GCAttrTypes GCAttrType; ExtQualType(Type *Base, QualType CanonicalPtr, unsigned AddrSpace, - GCAttrTypes gcAttr) : + QualType::GCAttrTypes gcAttr) : Type(ExtQual, CanonicalPtr, Base->isDependentType()), BaseType(Base), AddressSpace(AddrSpace), GCAttrType(gcAttr) { } friend class ASTContext; // ASTContext creates these. public: Type *getBaseType() const { return BaseType; } - GCAttrTypes getType() const { return GCAttrType; } + QualType::GCAttrTypes getObjCGCAttr() const { return GCAttrType; } unsigned getAddressSpace() const { return AddressSpace; } virtual void getAsStringInternal(std::string &InnerString) const; @@ -495,7 +497,7 @@ public: Profile(ID, getBaseType(), AddressSpace, GCAttrType); } static void Profile(llvm::FoldingSetNodeID &ID, Type *Base, - unsigned AddrSpace, GCAttrTypes gcAttr) { + unsigned AddrSpace, QualType::GCAttrTypes gcAttr) { ID.AddPointer(Base); ID.AddInteger(AddrSpace); ID.AddInteger(gcAttr); @@ -1741,6 +1743,16 @@ inline unsigned QualType::getAddressSpace() const { return 0; } +/// getObjCGCAttr - Return the gc attribute of this type. +inline QualType::GCAttrTypes QualType::getObjCGCAttr() const { + QualType CT = getTypePtr()->getCanonicalTypeInternal(); + if (const ArrayType *AT = dyn_cast<ArrayType>(CT)) + return AT->getElementType().getObjCGCAttr(); + if (const ExtQualType *EXTQT = dyn_cast<ExtQualType>(CT)) + return EXTQT->getObjCGCAttr(); + return GCNone; +} + /// isMoreQualifiedThan - Determine whether this type is more /// qualified than the Other type. For example, "const volatile int" /// is more qualified than "const int", "volatile int", and |