/// TagDecl
/// ObjCMethodDecl
/// ObjCContainerDecl
-/// ObjCImpl
/// LinkageSpecDecl
/// BlockDecl
///
DECL(ObjCCategory, ObjCContainerDecl)
DECL(ObjCProtocol, ObjCContainerDecl)
DECL(ObjCInterface, ObjCContainerDecl)
+ ABSTRACT_DECL(ObjCImpl, ObjCContainerDecl)
+ DECL(ObjCCategoryImpl, ObjCImplDecl)
+ DECL(ObjCImplementation, ObjCImplDecl)
DECL(ObjCProperty, NamedDecl)
DECL(ObjCCompatibleAlias, NamedDecl)
- ABSTRACT_DECL(ObjCImpl, NamedDecl)
- DECL(ObjCCategoryImpl, ObjCImplDecl)
- DECL(ObjCImplementation, ObjCImplDecl)
DECL(LinkageSpec, Decl)
DECL(ObjCPropertyImpl, Decl)
DECL(ObjCForwardProtocol, Decl)
DECL_CONTEXT(Namespace)
DECL_CONTEXT(LinkageSpec)
DECL_CONTEXT(ObjCMethod)
-DECL_CONTEXT_BASE(ObjCImpl)
DECL_CONTEXT_BASE(Tag)
DECL_CONTEXT_BASE(Function)
DECL_CONTEXT_BASE(ObjCContainer)
LAST_DECL_CONTEXT(Block)
// Declaration ranges
-DECL_RANGE(Named, OverloadedFunction, ObjCImplementation)
-DECL_RANGE(ObjCContainer, ObjCContainer, ObjCInterface)
+DECL_RANGE(Named, OverloadedFunction, ObjCCompatibleAlias)
+DECL_RANGE(ObjCContainer, ObjCContainer, ObjCImplementation)
DECL_RANGE(Field, Field, ObjCAtDefsField)
DECL_RANGE(Type, Typedef, TemplateTypeParm)
DECL_RANGE(Tag, Enum, ClassTemplatePartialSpecialization)
};
/// ObjCContainerDecl - Represents a container for method declarations.
-/// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl, and
-/// ObjCProtocolDecl.
-/// FIXME: Use for ObjC implementation decls.
+/// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl,
+/// ObjCProtocolDecl, and ObjCImplDecl.
///
class ObjCContainerDecl : public NamedDecl, public DeclContext {
SourceLocation AtEndLoc; // marks the end of the method container.
static bool classof(const ObjCCategoryDecl *D) { return true; }
};
-class ObjCImplDecl : public NamedDecl, public DeclContext {
+class ObjCImplDecl : public ObjCContainerDecl {
/// Class interface for this category implementation
ObjCInterfaceDecl *ClassInterface;
- SourceLocation EndLoc;
-
protected:
ObjCImplDecl(Kind DK, DeclContext *DC, SourceLocation L,
ObjCInterfaceDecl *classInterface)
- : NamedDecl(DK, DC, L,
- classInterface? classInterface->getDeclName()
- : DeclarationName()),
- DeclContext(DK), ClassInterface(classInterface) {}
+ : ObjCContainerDecl(DK, DC, L,
+ classInterface? classInterface->getIdentifier() : 0),
+ ClassInterface(classInterface) {}
public:
virtual ~ObjCImplDecl() {}
addDecl(method);
}
- // Get the local instance/class method declared in this interface.
- ObjCMethodDecl *getMethod(Selector Sel, bool isInstance) const;
- ObjCMethodDecl *getInstanceMethod(Selector Sel) const {
- return getMethod(Sel, true/*isInstance*/);
- }
- ObjCMethodDecl *getClassMethod(Selector Sel) const {
- return getMethod(Sel, false/*isInstance*/);
- }
-
void addPropertyImplementation(ObjCPropertyImplDecl *property);
ObjCPropertyImplDecl *FindPropertyImplDecl(IdentifierInfo *propertyId) const;
return propimpl_iterator(decls_end());
}
- typedef filtered_decl_iterator<ObjCMethodDecl,
- &ObjCMethodDecl::isInstanceMethod>
- instmeth_iterator;
- instmeth_iterator instmeth_begin() const {
- return instmeth_iterator(decls_begin());
- }
- instmeth_iterator instmeth_end() const {
- return instmeth_iterator(decls_end());
- }
-
- typedef filtered_decl_iterator<ObjCMethodDecl,
- &ObjCMethodDecl::isClassMethod>
- classmeth_iterator;
- classmeth_iterator classmeth_begin() const {
- return classmeth_iterator(decls_begin());
- }
- classmeth_iterator classmeth_end() const {
- return classmeth_iterator(decls_end());
- }
-
- // Location information, modeled after the Stmt API.
- virtual SourceRange getSourceRange() const {
- return SourceRange(getLocation(), EndLoc);
- }
- SourceLocation getLocStart() const { return getLocation(); }
- SourceLocation getLocEnd() const { return EndLoc; }
- void setLocEnd(SourceLocation LE) { EndLoc = LE; };
-
static bool classof(const Decl *D) {
return D->getKind() >= ObjCImplFirst && D->getKind() <= ObjCImplLast;
}
static bool classof(const ObjCImplDecl *D) { return true; }
- static DeclContext *castToDeclContext(const ObjCImplDecl *D) {
- return static_cast<DeclContext *>(const_cast<ObjCImplDecl*>(D));
- }
- static ObjCImplDecl *castFromDeclContext(const DeclContext *DC) {
- return static_cast<ObjCImplDecl *>(const_cast<DeclContext*>(DC));
- }
};
/// ObjCCategoryImplDecl - An object of this class encapsulates a category
return 0;
}
-// getMethod - This method returns an instance/class method by looking in
-// the class implementation. Unlike interfaces, we don't look outside the
-// implementation.
-ObjCMethodDecl *ObjCImplDecl::getMethod(Selector Sel, bool isInstance) const {
- // Since instance & class methods can have the same name, the loop below
- // ensures we get the correct method.
- //
- // @interface Whatever
- // - (int) class_method;
- // + (float) class_method;
- // @end
- //
- lookup_const_iterator Meth, MethEnd;
- for (llvm::tie(Meth, MethEnd) = lookup(Sel);
- Meth != MethEnd; ++Meth) {
- ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth);
- if (MD && MD->isInstanceMethod() == isInstance)
- return MD;
- }
- return 0;
-}
-
//===----------------------------------------------------------------------===//
// ObjCImplementationDecl
//===----------------------------------------------------------------------===//
}
void PCHDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) {
- VisitNamedDecl(D);
+ VisitObjCContainerDecl(D);
D->setClassInterface(
cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
- D->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
void PCHDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
}
void PCHDeclWriter::VisitObjCImplDecl(ObjCImplDecl *D) {
- VisitNamedDecl(D);
+ VisitObjCContainerDecl(D);
Writer.AddDeclRef(D->getClassInterface(), Record);
- Writer.AddSourceLocation(D->getLocEnd(), Record);
// Abstract class (no need to define a stable pch::DECL code).
}
CDecl->setAtEndLoc(AtEndLoc);
}
if (ObjCImplementationDecl *IC=dyn_cast<ObjCImplementationDecl>(ClassDecl)) {
- IC->setLocEnd(AtEndLoc);
+ IC->setAtEndLoc(AtEndLoc);
if (ObjCInterfaceDecl* IDecl = IC->getClassInterface())
ImplMethodsVsClassMethods(IC, IDecl);
} else if (ObjCCategoryImplDecl* CatImplClass =
dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
- CatImplClass->setLocEnd(AtEndLoc);
+ CatImplClass->setAtEndLoc(AtEndLoc);
// Find category interface decl and then check that all methods declared
// in this interface are implemented in the category @implementation.