[cfe-commits] r65248 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/ASTContext.cpp lib/AST/Type.cpp lib/CodeGen/CodeGenTypes.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprObjC.cpp
Steve Naroff
snaroff at apple.com
Sat Feb 21 13:17:02 PST 2009
Author: snaroff
Date: Sat Feb 21 15:17:01 2009
New Revision: 65248
URL: http://llvm.org/viewvc/llvm-project?rev=65248&view=rev
Log:
More work to integrate newly added ObjCQualifiedClassType into the type system.
This is necessary 'plumbing' to fix <rdar://problem/6497631> Message lookup is sometimes different than gcc's.
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=65248&r1=65247&r2=65248&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sat Feb 21 15:17:01 2009
@@ -270,7 +270,7 @@
TypeName, Tagged, ExtQual,
TemplateTypeParm, ClassTemplateSpecialization,
ObjCInterface, ObjCQualifiedInterface,
- ObjCQualifiedId,
+ ObjCQualifiedId, ObjCQualifiedClass,
TypeOfExp, TypeOfTyp, // GNU typeof extension.
BlockPointer, // C extension
FixedWidthInt
@@ -1758,7 +1758,7 @@
llvm::SmallVector<ObjCProtocolDecl*, 8> Protocols;
ObjCQualifiedClassType(ObjCProtocolDecl **Protos, unsigned NumP)
- : Type(ObjCQualifiedId, QualType()/*these are always canonical*/,
+ : Type(ObjCQualifiedClass, QualType()/*these are always canonical*/,
/*Dependent=*/false),
Protocols(Protos, Protos+NumP) { }
friend class ASTContext; // ASTContext creates these.
@@ -1785,7 +1785,7 @@
ObjCProtocolDecl **protocols, unsigned NumProtocols);
static bool classof(const Type *T) {
- return T->getTypeClass() == ObjCQualifiedId;
+ return T->getTypeClass() == ObjCQualifiedClass;
}
static bool classof(const ObjCQualifiedClassType *) { return true; }
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=65248&r1=65247&r2=65248&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Feb 21 15:17:01 2009
@@ -2408,7 +2408,7 @@
/// to struct), Interface* (pointer to ObjCInterfaceType) and id<P> (qualified
/// ID type).
bool ASTContext::isObjCObjectPointerType(QualType Ty) const {
- if (Ty->isObjCQualifiedIdType())
+ if (Ty->isObjCQualifiedIdType() || Ty->isObjCQualifiedClassType())
return true;
// Blocks are objects.
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=65248&r1=65247&r2=65248&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sat Feb 21 15:17:01 2009
@@ -693,7 +693,8 @@
isa<BlockPointerType>(CanonicalType) ||
isa<MemberPointerType>(CanonicalType) ||
isa<ComplexType>(CanonicalType) ||
- isa<ObjCQualifiedIdType>(CanonicalType);
+ isa<ObjCQualifiedIdType>(CanonicalType) ||
+ isa<ObjCQualifiedClassType>(CanonicalType);
}
/// \brief Determines whether the type is a C++ aggregate type or C
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=65248&r1=65247&r2=65248&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Sat Feb 21 15:17:01 2009
@@ -290,6 +290,7 @@
}
case Type::ObjCQualifiedId:
+ case Type::ObjCQualifiedClass:
// Protocols don't influence the LLVM type.
return ConvertTypeRecursive(Context.getObjCIdType());
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=65248&r1=65247&r2=65248&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Feb 21 15:17:01 2009
@@ -2734,7 +2734,9 @@
// C99 6.5.16.1p1: the left operand is a pointer and the right is
// a null pointer constant.
- if ((lhsType->isPointerType() || lhsType->isObjCQualifiedIdType() ||
+ if ((lhsType->isPointerType() ||
+ lhsType->isObjCQualifiedIdType() ||
+ lhsType->isObjCQualifiedClassType() ||
lhsType->isBlockPointerType())
&& rExpr->isNullPointerConstant(Context)) {
ImpCastExprToType(rExpr, lhsType);
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=65248&r1=65247&r2=65248&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Sat Feb 21 15:17:01 2009
@@ -391,7 +391,8 @@
// We allow sending a message to a qualified ID ("id<foo>"), which is ok as
// long as one of the protocols implements the selector (if not, warn).
if (ObjCQualifiedIdType *QIT = dyn_cast<ObjCQualifiedIdType>(ReceiverCType)) {
- // Search protocols
+ // Search protocols for instance methods.
+ ReceiverCType.dump();
for (unsigned i = 0; i < QIT->getNumProtocols(); i++) {
ObjCProtocolDecl *PDecl = QIT->getProtocols(i);
if (PDecl && (Method = PDecl->lookupInstanceMethod(Sel)))
@@ -400,6 +401,18 @@
if (!Method)
Diag(lbrac, diag::warn_method_not_found_in_protocol)
<< Sel << RExpr->getSourceRange();
+ // Check for GCC extension "Class<foo>".
+ } else if (ObjCQualifiedClassType *QIT =
+ dyn_cast<ObjCQualifiedClassType>(ReceiverCType)) {
+ // Search protocols for class methods.
+ for (unsigned i = 0; i < QIT->getNumProtocols(); i++) {
+ ObjCProtocolDecl *PDecl = QIT->getProtocols(i);
+ if (PDecl && (Method = PDecl->lookupClassMethod(Sel)))
+ break;
+ }
+ if (!Method)
+ Diag(lbrac, diag::warn_method_not_found_in_protocol)
+ << Sel << RExpr->getSourceRange();
} else if (const ObjCInterfaceType *OCIReceiver =
ReceiverCType->getAsPointerToObjCInterfaceType()) {
// We allow sending a message to a pointer to an interface (an object).
More information about the cfe-commits
mailing list