aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclObjC.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-05-15 11:32:37 +0000
committerJohn McCall <rjmccall@apple.com>2010-05-15 11:32:37 +0000
commitc12c5bba6ceb6acd4e51e7a0fc03257da9cfd44e (patch)
treef6b386f56c0925da061036cb04ba79a0bff05d91 /lib/Sema/SemaDeclObjC.cpp
parentd86c477fb5d3fc34864afecbbb5443da9355e8fb (diff)
Substantially alter the design of the Objective C type AST by introducing
ObjCObjectType, which is basically just a pair of one of {primitive-id, primitive-Class, user-defined @class} with a list of protocols. An ObjCObjectPointerType is therefore just a pointer which always points to one of these types (possibly sugared). ObjCInterfaceType is now just a kind of ObjCObjectType which happens to not carry any protocols. Alter a rather large number of use sites to use ObjCObjectType instead of ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather than hashing them in a FoldingSet. Remove some number of methods that are no longer used, at least after this patch. By simplifying ObjCObjectPointerType, we are now able to easily remove and apply pointers to Objective-C types, which is crucial for a certain kind of ObjC++ metaprogramming common in WebKit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103870 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclObjC.cpp')
-rw-r--r--lib/Sema/SemaDeclObjC.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 9ed9692114..b166d87340 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -142,8 +142,8 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
// typedef. If we do, get the underlying class type.
if (const TypedefDecl *TDecl = dyn_cast_or_null<TypedefDecl>(PrevDecl)) {
QualType T = TDecl->getUnderlyingType();
- if (T->isObjCInterfaceType()) {
- if (NamedDecl *IDecl = T->getAs<ObjCInterfaceType>()->getDecl())
+ if (T->isObjCObjectType()) {
+ if (NamedDecl *IDecl = T->getAs<ObjCObjectType>()->getInterface())
SuperClassDecl = dyn_cast<ObjCInterfaceDecl>(IDecl);
}
}
@@ -210,8 +210,8 @@ Sema::DeclPtrTy Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
LookupOrdinaryName, ForRedeclaration);
if (const TypedefDecl *TDecl = dyn_cast_or_null<TypedefDecl>(CDeclU)) {
QualType T = TDecl->getUnderlyingType();
- if (T->isObjCInterfaceType()) {
- if (NamedDecl *IDecl = T->getAs<ObjCInterfaceType>()->getDecl()) {
+ if (T->isObjCObjectType()) {
+ if (NamedDecl *IDecl = T->getAs<ObjCObjectType>()->getInterface()) {
ClassName = IDecl->getIdentifier();
CDeclU = LookupSingleName(TUScope, ClassName, ClassLocation,
LookupOrdinaryName, ForRedeclaration);
@@ -1024,15 +1024,15 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
//
// FIXME: Make an extension?
TypedefDecl *TDD = dyn_cast<TypedefDecl>(PrevDecl);
- if (!TDD || !isa<ObjCInterfaceType>(TDD->getUnderlyingType())) {
+ if (!TDD || !TDD->getUnderlyingType()->isObjCObjectType()) {
Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
Diag(PrevDecl->getLocation(), diag::note_previous_definition);
- } else if (TDD) {
+ } else {
// a forward class declaration matching a typedef name of a class refers
// to the underlying class.
- if (ObjCInterfaceType * OI =
- dyn_cast<ObjCInterfaceType>(TDD->getUnderlyingType()))
- PrevDecl = OI->getDecl();
+ if (const ObjCObjectType *OI =
+ TDD->getUnderlyingType()->getAs<ObjCObjectType>())
+ PrevDecl = OI->getInterface();
}
}
ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
@@ -1532,7 +1532,7 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
// Methods cannot return interface types. All ObjC objects are
// passed by reference.
- if (resultDeclType->isObjCInterfaceType()) {
+ if (resultDeclType->isObjCObjectType()) {
Diag(MethodLoc, diag::err_object_cannot_be_passed_returned_by_value)
<< 0 << resultDeclType;
return DeclPtrTy();
@@ -1570,7 +1570,7 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
ArgInfo[i].Name, ArgType, DI,
VarDecl::None, VarDecl::None, 0);
- if (ArgType->isObjCInterfaceType()) {
+ if (ArgType->isObjCObjectType()) {
Diag(ArgInfo[i].NameLoc,
diag::err_object_cannot_be_passed_returned_by_value)
<< 1 << ArgType;
@@ -1594,7 +1594,7 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
else
// Perform the default array/function conversions (C99 6.7.5.3p[7,8]).
ArgType = adjustParameterType(ArgType);
- if (ArgType->isObjCInterfaceType()) {
+ if (ArgType->isObjCObjectType()) {
Diag(Param->getLocation(),
diag::err_object_cannot_be_passed_returned_by_value)
<< 1 << ArgType;