summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-12-05 01:35:25 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-12-05 01:35:25 +0000
commit521b3a363efb30ac51d62d340446645bb860bad9 (patch)
tree87d9bb36b13f989c05d87be4226e69dd1d6cb977 /clang/lib/Sema/SemaDeclObjC.cpp
parent8e942123cbe9e7263ab580eecefe42eea3dcba67 (diff)
downloadbcm5719-llvm-521b3a363efb30ac51d62d340446645bb860bad9.tar.gz
bcm5719-llvm-521b3a363efb30ac51d62d340446645bb860bad9.zip
Patch for diagnosing type mismatch between
methods in class and its implementation. This is work in progress. llvm-svn: 60573
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index b3afd78fc7a..9da662e4766 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -643,6 +643,34 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplementationDecl* IMPDecl,
E = IDecl->instmeth_end(); I != E; ++I)
if (!(*I)->isSynthesized() && !InsMap.count((*I)->getSelector()))
WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
+ else if (!(*I)->isSynthesized()){
+ bool err = false;
+ ObjCMethodDecl *ImpMethodDecl =
+ IMPDecl->getInstanceMethod((*I)->getSelector());
+ ObjCMethodDecl *IntfMethodDecl =
+ IDecl->getInstanceMethod((*I)->getSelector());
+ QualType ImpMethodQType =
+ Context.getCanonicalType(ImpMethodDecl->getResultType());
+ QualType IntfMethodQType =
+ Context.getCanonicalType(IntfMethodDecl->getResultType());
+ if (!Context.typesAreCompatible(IntfMethodQType, ImpMethodQType))
+ err = true;
+ else for (ObjCMethodDecl::param_iterator IM=ImpMethodDecl->param_begin(),
+ IF=IntfMethodDecl->param_begin(),
+ EM=ImpMethodDecl->param_end(); IM!=EM; ++IM, IF++) {
+ ImpMethodQType = Context.getCanonicalType((*IM)->getType());
+ IntfMethodQType = Context.getCanonicalType((*IF)->getType());
+ if (!Context.typesAreCompatible(IntfMethodQType, ImpMethodQType)) {
+ err = true;
+ break;
+ }
+ }
+ if (err) {
+ Diag(ImpMethodDecl->getLocation(), diag::err_conflicting_types)
+ << ImpMethodDecl->getDeclName();
+ Diag(IntfMethodDecl->getLocation(), diag::note_previous_definition);
+ }
+ }
llvm::DenseSet<Selector> ClsMap;
// Check and see if class methods in class interface have been
OpenPOWER on IntegriCloud