[cfe-commits] r45014 - in /cfe/trunk: AST/ASTContext.cpp AST/Type.cpp Sema/SemaExpr.cpp include/clang/AST/Type.h
Fariborz Jahanian
fjahanian at apple.com
Thu Dec 13 12:47:43 PST 2007
Author: fjahanian
Date: Thu Dec 13 14:47:42 2007
New Revision: 45014
URL: http://llvm.org/viewvc/llvm-project?rev=45014&view=rev
Log:
Patch to make ObjcQualifiedInterfaceType inherit ObjcInterfaceType
Modified:
cfe/trunk/AST/ASTContext.cpp
cfe/trunk/AST/Type.cpp
cfe/trunk/Sema/SemaExpr.cpp
cfe/trunk/include/clang/AST/Type.h
Modified: cfe/trunk/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/ASTContext.cpp?rev=45014&r1=45013&r2=45014&view=diff
==============================================================================
--- cfe/trunk/AST/ASTContext.cpp (original)
+++ cfe/trunk/AST/ASTContext.cpp Thu Dec 13 14:47:42 2007
@@ -687,7 +687,7 @@
QualType ASTContext::getObjcInterfaceType(ObjcInterfaceDecl *Decl) {
if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
- Decl->TypeForDecl = new ObjcInterfaceType(Decl);
+ Decl->TypeForDecl = new ObjcInterfaceType(Type::ObjcInterface, Decl);
Types.push_back(Decl->TypeForDecl);
return QualType(Decl->TypeForDecl, 0);
}
@@ -697,11 +697,8 @@
/// the conforming protocol list.
QualType ASTContext::getObjcQualifiedInterfaceType(ObjcInterfaceDecl *Decl,
ObjcProtocolDecl **Protocols, unsigned NumProtocols) {
- ObjcInterfaceType *IType =
- cast<ObjcInterfaceType>(getObjcInterfaceType(Decl));
-
llvm::FoldingSetNodeID ID;
- ObjcQualifiedInterfaceType::Profile(ID, IType, Protocols, NumProtocols);
+ ObjcQualifiedInterfaceType::Profile(ID, Protocols, NumProtocols);
void *InsertPos = 0;
if (ObjcQualifiedInterfaceType *QT =
@@ -710,7 +707,7 @@
// No Match;
ObjcQualifiedInterfaceType *QType =
- new ObjcQualifiedInterfaceType(IType, Protocols, NumProtocols);
+ new ObjcQualifiedInterfaceType(Decl, Protocols, NumProtocols);
Types.push_back(QType);
ObjcQualifiedInterfaceTypes.InsertNode(QType, InsertPos);
return QualType(QType, 0);
@@ -1204,8 +1201,8 @@
ObjcQualifiedInterfaceType *rhsQI =
dyn_cast<ObjcQualifiedInterfaceType>(rhs.getCanonicalType().getTypePtr());
assert(rhsQI && "QualifiedInterfaceTypesAreCompatible - bad rhs type");
- if (!interfaceTypesAreCompatible(QualType(lhsQI->getInterfaceType(), 0),
- QualType(rhsQI->getInterfaceType(), 0)))
+ if (!interfaceTypesAreCompatible(getObjcInterfaceType(lhsQI->getDecl()),
+ getObjcInterfaceType(rhsQI->getDecl())))
return false;
/* All protocols in lhs must have a presense in rhs. */
for (unsigned i =0; i < lhsQI->getNumProtocols(); i++) {
Modified: cfe/trunk/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Type.cpp?rev=45014&r1=45013&r2=45014&view=diff
==============================================================================
--- cfe/trunk/AST/Type.cpp (original)
+++ cfe/trunk/AST/Type.cpp Thu Dec 13 14:47:42 2007
@@ -529,16 +529,14 @@
}
void ObjcQualifiedInterfaceType::Profile(llvm::FoldingSetNodeID &ID,
- ObjcInterfaceType *interfaceType,
ObjcProtocolDecl **protocols,
unsigned NumProtocols) {
- ID.AddPointer(interfaceType);
for (unsigned i = 0; i != NumProtocols; i++)
ID.AddPointer(protocols[i]);
}
void ObjcQualifiedInterfaceType::Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, getInterfaceType(), &Protocols[0], getNumProtocols());
+ Profile(ID, &Protocols[0], getNumProtocols());
}
/// LookThroughTypedefs - Return the ultimate type this typedef corresponds to
@@ -770,7 +768,7 @@
std::string &InnerString) const {
if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'.
InnerString = ' ' + InnerString;
- std::string ObjcQIString = getInterfaceType()->getDecl()->getName();
+ std::string ObjcQIString = getDecl()->getName();
ObjcQIString += '<';
int num = getNumProtocols();
for (int i = 0; i < num; i++) {
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=45014&r1=45013&r2=45014&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Thu Dec 13 14:47:42 2007
@@ -540,8 +540,7 @@
if (isa<ObjcInterfaceType>(BaseType.getCanonicalType()))
IFace = dyn_cast<ObjcInterfaceType>(BaseType)->getDecl();
else
- IFace = dyn_cast<ObjcQualifiedInterfaceType>(BaseType)
- ->getInterfaceType()->getDecl();
+ IFace = dyn_cast<ObjcQualifiedInterfaceType>(BaseType)->getDecl();
ObjcInterfaceDecl *clsDeclared;
if (ObjcIvarDecl *IV = IFace->lookupInstanceVariable(&Member, clsDeclared))
return new ObjCIvarRefExpr(IV, IV->getType(), MemberLoc, BaseExpr,
@@ -2300,9 +2299,7 @@
ObjcInterfaceDecl* ClassDecl;
if (ObjcQualifiedInterfaceType *QIT =
dyn_cast<ObjcQualifiedInterfaceType>(receiverType)) {
- ObjcInterfaceType * OITypePtr = QIT->getInterfaceType();
-
- ClassDecl = OITypePtr->getDecl();
+ ClassDecl = QIT->getDecl();
Method = ClassDecl->lookupInstanceMethod(Sel);
if (!Method) {
// search protocols
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=45014&r1=45013&r2=45014&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Dec 13 14:47:42 2007
@@ -899,9 +899,9 @@
class ObjcInterfaceType : public Type {
ObjcInterfaceDecl *Decl;
-
- ObjcInterfaceType(ObjcInterfaceDecl *D) :
- Type(ObjcInterface, QualType()), Decl(D) { }
+protected:
+ ObjcInterfaceType(TypeClass tc, ObjcInterfaceDecl *D) :
+ Type(tc, QualType()), Decl(D) { }
friend class ASTContext; // ASTContext creates these.
public:
@@ -919,23 +919,20 @@
/// conforming to a list of protocols; such as, INTF<Proto1, Proto2, Proto1>.
/// Duplicate protocols are removed and protocol list is canonicalized to be in
/// alphabetical order.
-class ObjcQualifiedInterfaceType : public Type, public llvm::FoldingSetNode {
- // Interface type for this protocol conforming object type
- ObjcInterfaceType *InterfaceType;
-
+class ObjcQualifiedInterfaceType : public ObjcInterfaceType,
+ public llvm::FoldingSetNode {
+
// List of protocols for this protocol conforming object type
// List is sorted on protocol name. No protocol is enterred more than once.
llvm::SmallVector<ObjcProtocolDecl*, 8> Protocols;
- ObjcQualifiedInterfaceType(ObjcInterfaceType *T,
+ ObjcQualifiedInterfaceType(ObjcInterfaceDecl *D,
ObjcProtocolDecl **Protos, unsigned NumP) :
- Type(ObjcQualifiedInterface, QualType()), InterfaceType(T),
+ ObjcInterfaceType(ObjcQualifiedInterface, D),
Protocols(Protos, Protos+NumP) { }
friend class ASTContext; // ASTContext creates these.
public:
- ObjcInterfaceType *getInterfaceType() const { return InterfaceType; }
-
ObjcProtocolDecl *getProtocols(unsigned i) const {
return Protocols[i];
}
@@ -947,7 +944,6 @@
void Profile(llvm::FoldingSetNodeID &ID);
static void Profile(llvm::FoldingSetNodeID &ID,
- ObjcInterfaceType *interfaceType,
ObjcProtocolDecl **protocols, unsigned NumProtocols);
static bool classof(const Type *T) {
More information about the cfe-commits
mailing list