зеркало из https://github.com/microsoft/clang-1.git
Simplified ExtQualType per Chris's feedback.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64820 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
afcc7b425b
Коммит
4886a4204f
|
@ -462,55 +462,43 @@ protected:
|
||||||
///
|
///
|
||||||
class ExtQualType : public Type, public llvm::FoldingSetNode {
|
class ExtQualType : public Type, public llvm::FoldingSetNode {
|
||||||
public:
|
public:
|
||||||
enum EQT {
|
enum GCAttrTypes {
|
||||||
EXTNONE = 0x0,
|
GCNone = 0,
|
||||||
ASQUAL = 0x01,
|
Weak,
|
||||||
GCQUAL = 0x10
|
Strong
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// BaseType - This is the underlying type that this qualifies. All CVR
|
/// BaseType - This is the underlying type that this qualifies. All CVR
|
||||||
/// qualifiers are stored on the QualType that references this type, so we
|
/// qualifiers are stored on the QualType that references this type, so we
|
||||||
/// can't have any here.
|
/// can't have any here.
|
||||||
Type *BaseType;
|
Type *BaseType;
|
||||||
unsigned ExtQualTypeKind : 2;
|
|
||||||
|
|
||||||
/// Address Space ID - The address space ID this type is qualified with.
|
/// Address Space ID - The address space ID this type is qualified with.
|
||||||
unsigned AddressSpace;
|
unsigned AddressSpace;
|
||||||
/// GC __weak/__strong attributes
|
/// GC __weak/__strong attributes
|
||||||
ObjCGCAttr *GCAttr;
|
GCAttrTypes GCAttrType;
|
||||||
|
|
||||||
ExtQualType(Type *Base, QualType CanonicalPtr, unsigned AddrSpace,
|
ExtQualType(Type *Base, QualType CanonicalPtr, unsigned AddrSpace,
|
||||||
ObjCGCAttr *gcAttr,
|
GCAttrTypes gcAttr) :
|
||||||
unsigned ExtKind) :
|
|
||||||
Type(ExtQual, CanonicalPtr, Base->isDependentType()), BaseType(Base),
|
Type(ExtQual, CanonicalPtr, Base->isDependentType()), BaseType(Base),
|
||||||
ExtQualTypeKind(ExtKind), AddressSpace(0), GCAttr(0) {
|
AddressSpace(AddrSpace), GCAttrType(gcAttr) { }
|
||||||
if (ExtKind & ASQUAL)
|
|
||||||
AddressSpace = AddrSpace;
|
|
||||||
if (ExtKind & GCQUAL)
|
|
||||||
GCAttr = gcAttr;
|
|
||||||
}
|
|
||||||
friend class ASTContext; // ASTContext creates these.
|
friend class ASTContext; // ASTContext creates these.
|
||||||
public:
|
public:
|
||||||
Type *getBaseType() const { return BaseType; }
|
Type *getBaseType() const { return BaseType; }
|
||||||
ObjCGCAttr *getGCAttr() const {
|
GCAttrTypes getType() const { return GCAttrType; }
|
||||||
assert((ExtQualTypeKind & GCQUAL) && "Bad ExtQualType Kind - not GCQUAL");
|
unsigned getAddressSpace() const { return AddressSpace; }
|
||||||
return GCAttr;
|
|
||||||
}
|
|
||||||
unsigned getAddressSpace() const {
|
|
||||||
assert((ExtQualTypeKind & ASQUAL) && "Bad ExtQualType Kind - not ASQUAL");
|
|
||||||
return AddressSpace;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void getAsStringInternal(std::string &InnerString) const;
|
virtual void getAsStringInternal(std::string &InnerString) const;
|
||||||
|
|
||||||
void Profile(llvm::FoldingSetNodeID &ID) {
|
void Profile(llvm::FoldingSetNodeID &ID) {
|
||||||
Profile(ID, getBaseType(), AddressSpace, GCAttr);
|
Profile(ID, getBaseType(), AddressSpace, GCAttrType);
|
||||||
}
|
}
|
||||||
static void Profile(llvm::FoldingSetNodeID &ID, Type *Base,
|
static void Profile(llvm::FoldingSetNodeID &ID, Type *Base,
|
||||||
unsigned AddrSpace, ObjCGCAttr *gcAttr) {
|
unsigned AddrSpace, GCAttrTypes gcAttr) {
|
||||||
ID.AddPointer(Base);
|
ID.AddPointer(Base);
|
||||||
ID.AddPointer(gcAttr);
|
|
||||||
ID.AddInteger(AddrSpace);
|
ID.AddInteger(AddrSpace);
|
||||||
|
ID.AddInteger(gcAttr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool classof(const Type *T) { return T->getTypeClass() == ExtQual; }
|
static bool classof(const Type *T) { return T->getTypeClass() == ExtQual; }
|
||||||
|
|
|
@ -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
|
// Check if we've already instantiated an address space qual'd type of this
|
||||||
// type.
|
// type.
|
||||||
llvm::FoldingSetNodeID ID;
|
llvm::FoldingSetNodeID ID;
|
||||||
ExtQualType::Profile(ID, T.getTypePtr(), AddressSpace, 0);
|
ExtQualType::Profile(ID, T.getTypePtr(), AddressSpace, ExtQualType::GCNone);
|
||||||
void *InsertPos = 0;
|
void *InsertPos = 0;
|
||||||
if (ExtQualType *EXTQy = ExtQualTypes.FindNodeOrInsertPos(ID, InsertPos))
|
if (ExtQualType *EXTQy = ExtQualTypes.FindNodeOrInsertPos(ID, InsertPos))
|
||||||
return QualType(EXTQy, 0);
|
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;
|
assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
|
||||||
}
|
}
|
||||||
ExtQualType *New = new (*this, 8) ExtQualType(T.getTypePtr(), Canonical,
|
ExtQualType *New = new (*this, 8) ExtQualType(T.getTypePtr(), Canonical,
|
||||||
AddressSpace, 0,
|
AddressSpace, ExtQualType::GCNone);
|
||||||
ExtQualType::ASQUAL);
|
|
||||||
ExtQualTypes.InsertNode(New, InsertPos);
|
ExtQualTypes.InsertNode(New, InsertPos);
|
||||||
Types.push_back(New);
|
Types.push_back(New);
|
||||||
return QualType(New, T.getCVRQualifiers());
|
return QualType(New, T.getCVRQualifiers());
|
||||||
|
|
|
@ -1054,17 +1054,15 @@ void ComplexType::getAsStringInternal(std::string &S) const {
|
||||||
|
|
||||||
void ExtQualType::getAsStringInternal(std::string &S) const {
|
void ExtQualType::getAsStringInternal(std::string &S) const {
|
||||||
bool space = false;
|
bool space = false;
|
||||||
if (ExtQualTypeKind & ASQUAL) {
|
if (AddressSpace) {
|
||||||
S = "__attribute__((address_space("+llvm::utostr_32(AddressSpace)+")))" + S;
|
S = "__attribute__((address_space("+llvm::utostr_32(AddressSpace)+")))" + S;
|
||||||
space = true;
|
space = true;
|
||||||
}
|
}
|
||||||
if (ExtQualTypeKind & GCQUAL) {
|
if (GCAttrType != GCNone) {
|
||||||
if (space)
|
if (space)
|
||||||
S += ' ';
|
S += ' ';
|
||||||
S += "__attribute__((objc_gc(";
|
S += "__attribute__((objc_gc(";
|
||||||
ObjCGCAttr *gcattr = getGCAttr();
|
if (GCAttrType == Weak)
|
||||||
ObjCGCAttr::GCAttrTypes attr = gcattr->getType();
|
|
||||||
if (attr & ObjCGCAttr::Weak)
|
|
||||||
S += "weak";
|
S += "weak";
|
||||||
else
|
else
|
||||||
S += "strong";
|
S += "strong";
|
||||||
|
|
Загрузка…
Ссылка в новой задаче