Remove Action::ActOnImpleIvarVsClassIvars(), it is only called by Sema (not Parser).

Add Sema::CheckImplementationIvars() to replace the previous action.

llvm-svn: 42553
This commit is contained in:
Steve Naroff 2007-10-02 21:43:37 +00:00
parent f214ff8701
commit d174155204
4 changed files with 19 additions and 21 deletions

View File

@ -51,6 +51,7 @@ namespace clang {
class ObjcImplementationDecl; class ObjcImplementationDecl;
class ObjcCategoryImplDecl; class ObjcCategoryImplDecl;
class ObjcCategoryDecl; class ObjcCategoryDecl;
class ObjcIvarDecl;
/// Sema - This implements semantic analysis and AST building for C. /// Sema - This implements semantic analysis and AST building for C.
class Sema : public Action { class Sema : public Action {
@ -216,6 +217,11 @@ private:
const llvm::DenseMap<void *, char>& InsMap, const llvm::DenseMap<void *, char>& InsMap,
const llvm::DenseMap<void *, char>& ClsMap); const llvm::DenseMap<void *, char>& ClsMap);
/// CheckImplementationIvars - This routine checks if the instance variables
/// listed in the implelementation match those listed in the interface.
void CheckImplementationIvars(ObjcImplementationDecl *ImpDecl,
ObjcIvarDecl **Fields, unsigned nIvars);
/// ImplMethodsVsClassMethods - This is main routine to warn if any method /// ImplMethodsVsClassMethods - This is main routine to warn if any method
/// remains unimplemented in the @implementation class. /// remains unimplemented in the @implementation class.
void ImplMethodsVsClassMethods(ObjcImplementationDecl* IMPDecl, void ImplMethodsVsClassMethods(ObjcImplementationDecl* IMPDecl,
@ -421,9 +427,6 @@ public:
virtual void ObjcAddMethodsToClass(Scope* S, DeclTy *ClassDecl, virtual void ObjcAddMethodsToClass(Scope* S, DeclTy *ClassDecl,
DeclTy **allMethods, unsigned allNum); DeclTy **allMethods, unsigned allNum);
virtual void ActOnImpleIvarVsClassIvars(DeclTy *ClassDecl,
DeclTy **Fields, unsigned NumFields);
virtual DeclTy *ObjcBuildMethodDeclaration(SourceLocation MethodLoc, virtual DeclTy *ObjcBuildMethodDeclaration(SourceLocation MethodLoc,
tok::TokenKind MethodType, TypeTy *ReturnType, Selector Sel, tok::TokenKind MethodType, TypeTy *ReturnType, Selector Sel,
// optional arguments. The number of types/arguments is obtained // optional arguments. The number of types/arguments is obtained

View File

@ -1168,17 +1168,18 @@ Sema::DeclTy *Sema::ObjcStartClassImplementation(Scope *S,
return IMPDecl; return IMPDecl;
} }
void Sema::ActOnImpleIvarVsClassIvars(DeclTy *ClassDecl, void Sema::CheckImplementationIvars(ObjcImplementationDecl *ImpDecl,
DeclTy **Fields, unsigned numIvars) { ObjcIvarDecl **ivars, unsigned numIvars) {
ObjcInterfaceDecl* IDecl = assert(ImpDecl && "missing implementation decl");
cast<ObjcInterfaceDecl>(static_cast<Decl*>(ClassDecl)); ObjcInterfaceDecl* IDecl = getObjCInterfaceDecl(ImpDecl->getIdentifier());
assert(IDecl && "missing named interface class decl");
ObjcIvarDecl** ivars = reinterpret_cast<ObjcIvarDecl**>(Fields); if (!IDecl)
return;
assert(ivars && "missing @implementation ivars"); assert(ivars && "missing @implementation ivars");
// Check interface's Ivar list against those in the implementation. // Check interface's Ivar list against those in the implementation.
// names and types must match. // names and types must match.
// //
ObjcIvarDecl** IntfIvars = IDecl->getIntfDeclIvars(); ObjcIvarDecl** IntfIvars = IDecl->getIntfDeclIvars();
int IntfNumIvars = IDecl->getIntfDeclNumIvars(); int IntfNumIvars = IDecl->getIntfDeclNumIvars();
unsigned j = 0; unsigned j = 0;
@ -1676,10 +1677,7 @@ void Sema::ActOnFields(Scope* S,
cast<ObjcImplementationDecl>(static_cast<Decl*>(RecDecl)); cast<ObjcImplementationDecl>(static_cast<Decl*>(RecDecl));
assert(IMPDecl && "ActOnFields - missing ObjcImplementationDecl"); assert(IMPDecl && "ActOnFields - missing ObjcImplementationDecl");
IMPDecl->ObjcAddInstanceVariablesToClassImpl(ClsFields, RecFields.size()); IMPDecl->ObjcAddInstanceVariablesToClassImpl(ClsFields, RecFields.size());
ObjcInterfaceDecl* IDecl = getObjCInterfaceDecl(IMPDecl->getIdentifier()); CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size());
if (IDecl)
ActOnImpleIvarVsClassIvars(static_cast<DeclTy*>(IDecl),
reinterpret_cast<DeclTy**>(&RecFields[0]), RecFields.size());
} }
} }
} }

View File

@ -82,6 +82,7 @@ public:
AllocIntfRefProtocols(numRefProtos); AllocIntfRefProtocols(numRefProtos);
} }
// This is necessary when converting a forward declaration to a definition.
void AllocIntfRefProtocols(unsigned numRefProtos) { void AllocIntfRefProtocols(unsigned numRefProtos) {
if (numRefProtos) { if (numRefProtos) {
IntfRefProtocols = new ObjcProtocolDecl*[numRefProtos]; IntfRefProtocols = new ObjcProtocolDecl*[numRefProtos];

View File

@ -448,10 +448,6 @@ public:
DeclTy **allMethods, unsigned allNum) { DeclTy **allMethods, unsigned allNum) {
return; return;
} }
virtual void ActOnImpleIvarVsClassIvars(DeclTy *ClassDecl,
DeclTy **Fields, unsigned NumFields) {
return;
}
virtual DeclTy *ObjcStartProtoInterface(Scope* S, virtual DeclTy *ObjcStartProtoInterface(Scope* S,
SourceLocation AtProtoInterfaceLoc, SourceLocation AtProtoInterfaceLoc,
IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,