[cfe-commits] r76741 - in /cfe/trunk: include/clang/AST/Type.h include/clang/Basic/DiagnosticSemaKinds.td lib/AST/ASTContext.cpp lib/AST/Type.cpp lib/Sema/SemaExprObjC.cpp lib/Sema/SemaType.cpp test/SemaObjC/call-super-2.m test/SemaObjC/protocol-archane.m test/SemaObjC/protocol-attribute.m test/SemaObjC/protocol-qualified-class-unsupported.m
Steve Naroff
snaroff at apple.com
Wed Jul 22 09:07:05 PDT 2009
Author: snaroff
Date: Wed Jul 22 11:07:01 2009
New Revision: 76741
URL: http://llvm.org/viewvc/llvm-project?rev=76741&view=rev
Log:
Fix <rdar://problem/6770276> Support Class<Proto> syntax.
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaObjC/call-super-2.m
cfe/trunk/test/SemaObjC/protocol-archane.m
cfe/trunk/test/SemaObjC/protocol-attribute.m
cfe/trunk/test/SemaObjC/protocol-qualified-class-unsupported.m
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=76741&r1=76740&r2=76741&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Jul 22 11:07:01 2009
@@ -402,6 +402,7 @@
bool isObjCInterfaceType() const; // NSString or NSString<foo>
bool isObjCQualifiedInterfaceType() const; // NSString<foo>
bool isObjCQualifiedIdType() const; // id<foo>
+ bool isObjCQualifiedClassType() const; // Class<foo>
bool isObjCIdType() const; // id
bool isObjCClassType() const; // Class
bool isObjCBuiltinType() const; // 'id' or 'Class'
@@ -1950,7 +1951,7 @@
Protocols.size();
}
/// isObjCQualifiedClassType - true for "Class <p>".
- bool isQualifiedClassType() const {
+ bool isObjCQualifiedClassType() const {
return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCClass) &&
Protocols.size();
}
@@ -2137,6 +2138,11 @@
return OPT->isObjCQualifiedIdType();
return false;
}
+inline bool Type::isObjCQualifiedClassType() const {
+ if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType())
+ return OPT->isObjCQualifiedClassType();
+ return false;
+}
inline bool Type::isObjCIdType() const {
if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType())
return OPT->isObjCIdType();
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=76741&r1=76740&r2=76741&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jul 22 11:07:01 2009
@@ -1961,8 +1961,6 @@
"use of C99-specific array features, accepted as an extension">;
def err_invalid_protocol_qualifiers : Error<
"invalid protocol qualifiers on non-ObjC type">;
-def err_qualified_class_unsupported : Error<
- "protocol qualified 'Class' is unsupported">;
def warn_ivar_use_hidden : Warning<
"local declaration of %0 hides instance variable">;
def error_ivar_use_in_class_method : Error<
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=76741&r1=76740&r2=76741&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Jul 22 11:07:01 2009
@@ -1742,9 +1742,6 @@
QualType ASTContext::getObjCObjectPointerType(QualType InterfaceT,
ObjCProtocolDecl **Protocols,
unsigned NumProtocols) {
- if (InterfaceT.isNull())
- InterfaceT = ObjCBuiltinIdTy;
-
// Sort the protocol list alphabetically to canonicalize it.
if (NumProtocols)
SortAndUniqueProtocols(Protocols, NumProtocols);
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=76741&r1=76740&r2=76741&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Wed Jul 22 11:07:01 2009
@@ -1603,7 +1603,7 @@
if (isObjCIdType() || isObjCQualifiedIdType())
ObjCQIString = "id";
- else if (isObjCClassType())
+ else if (isObjCClassType() || isObjCQualifiedClassType())
ObjCQIString = "Class";
else
ObjCQIString = getInterfaceDecl()->getNameAsString();
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=76741&r1=76740&r2=76741&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Jul 22 11:07:01 2009
@@ -512,8 +512,7 @@
}
// Handle messages to id.
- if (ReceiverCType == Context.getCanonicalType(Context.getObjCIdType()) ||
- ReceiverCType->isBlockPointerType() ||
+ if (ReceiverCType->isObjCIdType() || ReceiverCType->isBlockPointerType() ||
Context.isObjCNSObjectType(RExpr->getType())) {
ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool(
Sel, SourceRange(lbrac,rbrac));
@@ -528,7 +527,8 @@
}
// Handle messages to Class.
- if (ReceiverCType == Context.getCanonicalType(Context.getObjCClassType())) {
+ if (ReceiverCType->isObjCClassType() ||
+ ReceiverCType->isObjCQualifiedClassType()) {
ObjCMethodDecl *Method = 0;
if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) {
@@ -538,6 +538,9 @@
if (!Method)
Method = LookupPrivateClassMethod(Sel, ClassDecl);
+
+ // FIXME: if we still haven't found a method, we need to look in
+ // protocols (if we have qualifiers).
}
if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
return true;
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=76741&r1=76740&r2=76741&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Jul 22 11:07:01 2009
@@ -101,7 +101,7 @@
case DeclSpec::TST_unspecified:
// "<proto1,proto2>" is an objc qualified ID with a missing id.
if (DeclSpec::ProtocolQualifierListTy PQ = DS.getProtocolQualifiers()) {
- Result = Context.getObjCObjectPointerType(QualType(),
+ Result = Context.getObjCObjectPointerType(Context.ObjCBuiltinIdTy,
(ObjCProtocolDecl**)PQ,
DS.getNumProtocolQualifiers());
break;
@@ -220,14 +220,14 @@
DS.getNumProtocolQualifiers());
else if (Result->isObjCIdType())
// id<protocol-list>
- Result = Context.getObjCObjectPointerType(QualType(),
+ Result = Context.getObjCObjectPointerType(Context.ObjCBuiltinIdTy,
(ObjCProtocolDecl**)PQ, DS.getNumProtocolQualifiers());
else if (Result->isObjCClassType()) {
if (DeclLoc.isInvalid())
DeclLoc = DS.getSourceRange().getBegin();
// Class<protocol-list>
- Diag(DeclLoc, diag::err_qualified_class_unsupported)
- << DS.getSourceRange();
+ Result = Context.getObjCObjectPointerType(Context.ObjCBuiltinClassTy,
+ (ObjCProtocolDecl**)PQ, DS.getNumProtocolQualifiers());
} else {
if (DeclLoc.isInvalid())
DeclLoc = DS.getSourceRange().getBegin();
Modified: cfe/trunk/test/SemaObjC/call-super-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/call-super-2.m?rev=76741&r1=76740&r2=76741&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/call-super-2.m (original)
+++ cfe/trunk/test/SemaObjC/call-super-2.m Wed Jul 22 11:07:01 2009
@@ -40,8 +40,8 @@
{
int i = [(id <Func>)self class_func0];
i += [(id <Func>)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
- i += [(Class <Func>)self class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}}
- return i + [(Class <Func>)super class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}} // expected-error {{cannot cast 'super' (it isn't an expression)}}
+ i += [(Class <Func>)self class_func0]; //
+ return i + [(Class <Func>)super class_func0]; // // expected-error {{cannot cast 'super' (it isn't an expression)}}
}
+ (int) class_func3
{
Modified: cfe/trunk/test/SemaObjC/protocol-archane.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/protocol-archane.m?rev=76741&r1=76740&r2=76741&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/protocol-archane.m (original)
+++ cfe/trunk/test/SemaObjC/protocol-archane.m Wed Jul 22 11:07:01 2009
@@ -28,8 +28,7 @@
// GCC doesn't diagnose this.
NotAnObjCObjectType <SomeProtocol> *obj; // expected-error {{invalid protocol qualifiers on non-ObjC type}}
-// Decided not to support the following GCC extension. Found while researching rdar://6497631
typedef struct objc_class *Class;
-Class <SomeProtocol> UnfortunateGCCExtension; // expected-error {{protocol qualified 'Class' is unsupported}}
+Class <SomeProtocol> UnfortunateGCCExtension;
Modified: cfe/trunk/test/SemaObjC/protocol-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/protocol-attribute.m?rev=76741&r1=76740&r2=76741&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/protocol-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/protocol-attribute.m Wed Jul 22 11:07:01 2009
@@ -3,7 +3,7 @@
__attribute ((unavailable))
@protocol FwProto; // expected-note{{marked unavailable}}
-Class <FwProto> cFw = 0; // expected-warning {{'FwProto' is unavailable}} expected-error{{protocol qualified 'Class' is unsupported}}
+Class <FwProto> cFw = 0; // expected-warning {{'FwProto' is unavailable}}
__attribute ((deprecated)) @protocol MyProto1
@@ -31,7 +31,7 @@
-Class <MyProto1> clsP1 = 0; // expected-warning {{'MyProto1' is deprecated}} expected-error{{protocol qualified 'Class' is unsupported}}
+Class <MyProto1> clsP1 = 0; // expected-warning {{'MyProto1' is deprecated}}
@protocol FwProto @end // expected-note{{marked unavailable}}
Modified: cfe/trunk/test/SemaObjC/protocol-qualified-class-unsupported.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/protocol-qualified-class-unsupported.m?rev=76741&r1=76740&r2=76741&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/protocol-qualified-class-unsupported.m (original)
+++ cfe/trunk/test/SemaObjC/protocol-qualified-class-unsupported.m Wed Jul 22 11:07:01 2009
@@ -23,7 +23,7 @@
@interface Derived2: Object <Func>
@end
-static void doSomething(Class <Func> unsupportedObjectType) { // expected-error {{protocol qualified 'Class' is unsupported}}
+static void doSomething(Class <Func> unsupportedObjectType) {
[unsupportedObjectType class_func0];
}
More information about the cfe-commits
mailing list