/// CheckProtocolMethodDefs - This routine checks unimpletented methods
/// Declared in protocol, and those referenced by it.
void CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl,
+ bool& IncompleteImpl,
const llvm::DenseMap<void *, char>& InsMap,
const llvm::DenseMap<void *, char>& ClsMap);
/// ImplCategoryMethodsVsIntfMethods - Checks that methods declared in the
/// category interface is implemented in the category @implementation.
void ImplCategoryMethodsVsIntfMethods(ObjcCategoryImplDecl *CatImplDecl,
- ObjcCategoryDecl *CatClassDecl);
+ ObjcCategoryDecl *CatClassDecl);
//===--------------------------------------------------------------------===//
// Statement Parsing Callbacks: SemaStmt.cpp.
/// CheckProtocolMethodDefs - This routine checks unimpletented methods
/// Declared in protocol, and those referenced by it.
void Sema::CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl,
+ bool& IncompleteImpl,
const llvm::DenseMap<void *, char>& InsMap,
const llvm::DenseMap<void *, char>& ClsMap) {
// check unimplemented instance methods.
llvm::SmallString<128> buf;
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName(buf));
+ IncompleteImpl = true;
}
// check unimplemented class methods
methods = PDecl->getClsMethods();
llvm::SmallString<128> buf;
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName(buf));
+ IncompleteImpl = true;
}
// Check on this protocols's referenced protocols, recursively
ObjcProtocolDecl** RefPDecl = PDecl->getReferencedProtocols();
for (int i = 0; i < PDecl->getNumReferencedProtocols(); i++)
- CheckProtocolMethodDefs(RefPDecl[i], InsMap, ClsMap);
+ CheckProtocolMethodDefs(RefPDecl[i], IncompleteImpl, InsMap, ClsMap);
}
void Sema::ImplMethodsVsClassMethods(ObjcImplementationDecl* IMPDecl,
InsMap[methods[i]->getSelector().getAsOpaquePtr()] = 'a';
}
+ bool IncompleteImpl = false;
methods = IDecl->getInsMethods();
for (int j = 0; j < IDecl->getNumInsMethods(); j++)
if (!InsMap.count(methods[j]->getSelector().getAsOpaquePtr())) {
llvm::SmallString<128> buf;
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName(buf));
+ IncompleteImpl = true;
}
llvm::DenseMap<void *, char> ClsMap;
// Check and see if class methods in class interface have been
llvm::SmallString<128> buf;
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName(buf));
+ IncompleteImpl = true;
}
// Check the protocol list for unimplemented methods in the @implementation
ObjcProtocolDecl** protocols = IDecl->getIntfRefProtocols();
for (int i = 0; i < IDecl->getNumIntfRefProtocols(); i++) {
ObjcProtocolDecl* PDecl = protocols[i];
- CheckProtocolMethodDefs(PDecl, InsMap, ClsMap);
+ CheckProtocolMethodDefs(PDecl, IncompleteImpl, InsMap, ClsMap);
}
+ if (IncompleteImpl)
+ Diag(IDecl->getLocation(), diag::warn_incomplete_impl_class,
+ IDecl->getName());
}
/// ImplCategoryMethodsVsIntfMethods - Checks that methods declared in the
InsMap[methods[i]->getSelector().getAsOpaquePtr()] = 'a';
}
+ bool IncompleteImpl = false;
methods = CatClassDecl->getCatInsMethods();
for (int j = 0; j < CatClassDecl->getNumCatInsMethods(); j++)
if (!InsMap.count(methods[j]->getSelector().getAsOpaquePtr())) {
llvm::SmallString<128> buf;
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName(buf));
+ IncompleteImpl = true;
}
llvm::DenseMap<void *, char> ClsMap;
// Check and see if class methods in category interface have been
llvm::SmallString<128> buf;
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName(buf));
+ IncompleteImpl = true;
}
// Check the protocol list for unimplemented methods in the @implementation
ObjcProtocolDecl** protocols = CatClassDecl->getCatReferencedProtocols();
for (int i = 0; i < CatClassDecl->getNumCatReferencedProtocols(); i++) {
ObjcProtocolDecl* PDecl = protocols[i];
- CheckProtocolMethodDefs(PDecl, InsMap, ClsMap);
+ CheckProtocolMethodDefs(PDecl, IncompleteImpl, InsMap, ClsMap);
}
-
+ if (IncompleteImpl)
+ Diag(CatClassDecl->getCatLoc(), diag::warn_incomplete_impl_category,
+ CatClassDecl->getCatName()->getName());
}
/// ObjcClassDeclaration -
/// Next category belonging to this class
ObjcCategoryDecl *NextClassCategory;
+
+ /// Location of cetagory declaration
+ SourceLocation CatLoc;
public:
ObjcCategoryDecl(SourceLocation L, unsigned numRefProtocol)
CatReferencedProtocols(0), NumCatReferencedProtocols(-1),
CatInsMethods(0), NumCatInsMethods(-1),
CatClsMethods(0), NumCatClsMethods(-1),
- NextClassCategory(0) {
+ NextClassCategory(0), CatLoc(L) {
if (numRefProtocol) {
CatReferencedProtocols = new ObjcProtocolDecl*[numRefProtocol];
memset(CatReferencedProtocols, '\0',
NextClassCategory = ClassInterface->getListCategories();
ClassInterface->setListCategories(this);
}
-
+
+ SourceLocation getCatLoc() const { return CatLoc; }
+
static bool classof(const Decl *D) {
return D->getKind() == ObjcCategory;
}
ObjcMethodDecl **getCatClsMethods() const { return CatClsMethods; }
int getNumCatClsMethods() const { return NumCatClsMethods; }
-
void ObjcAddCatImplMethods(
ObjcMethodDecl **insMethods, unsigned numInsMembers,
ObjcMethodDecl **clsMethods, unsigned numClsMembers);