diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-11 19:58:42 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-11 19:58:42 +0000 |
commit | 67f35b051b608206459879ee19f831519010b5bd (patch) | |
tree | 981cab55bb95e81bc6f5dca71d9cfb4a967ab88b /clang/lib/Sema/SemaDeclObjC.cpp | |
parent | 03a6cbbd91e6491f315a3627f1f5f03337d9c67f (diff) | |
download | bcm5719-llvm-67f35b051b608206459879ee19f831519010b5bd.tar.gz bcm5719-llvm-67f35b051b608206459879ee19f831519010b5bd.zip |
improve the 'conflicting types' diagnostics to include correct location info, now
that it is plumbed through Sema. On a file from growl, we used to emit:
t.mi:107059:1: warning: conflicting types for 'removePluginHandler:forPluginTypes:'
- (void) removePluginHandler:(id <GrowlPluginHandler>)handler forPluginTypes:(NSSet *)extensions {
^
t.mi:105280:1: note: previous definition is here
- (void) removePluginHandler:(id <NSObject>)handler forPluginTypes:(NSSet *)types;
^
now we produce:
t.mi:107059:55: warning: conflicting parameter types in implementation of 'removePluginHandler:forPluginTypes:': 'id<NSObject>' vs 'id<GrowlPluginHandler>'
- (void) removePluginHandler:(id <GrowlPluginHandler>)handler forPluginTypes:(NSSet *)extensions {
^
t.mi:105280:45: note: previous definition is here
- (void) removePluginHandler:(id <NSObject>)handler forPluginTypes:(NSSet *)types;
^
We still don't have proper loc info for properties, hence the FIXME.
rdar://6782494
llvm-svn: 68879
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 52b6db59f38..6048901e7a2 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -763,25 +763,28 @@ void Sema::WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method, void Sema::WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethodDecl, ObjCMethodDecl *IntfMethodDecl) { - bool err = false; if (!Context.typesAreCompatible(IntfMethodDecl->getResultType(), - ImpMethodDecl->getResultType())) - err = true; - else - for (ObjCMethodDecl::param_iterator IM=ImpMethodDecl->param_begin(), - IF = IntfMethodDecl->param_begin(), EM = ImpMethodDecl->param_end(); - IM != EM; ++IM, ++IF) { - if (!Context.typesAreCompatible((*IF)->getType(), (*IM)->getType())) { - err = true; - break; - } - } - - if (err) { - Diag(ImpMethodDecl->getLocation(), diag::warn_conflicting_types) - << ImpMethodDecl->getDeclName(); + ImpMethodDecl->getResultType())) { + Diag(ImpMethodDecl->getLocation(), diag::warn_conflicting_ret_types) + << ImpMethodDecl->getDeclName() << IntfMethodDecl->getResultType() + << ImpMethodDecl->getResultType(); Diag(IntfMethodDecl->getLocation(), diag::note_previous_definition); } + + for (ObjCMethodDecl::param_iterator IM = ImpMethodDecl->param_begin(), + IF = IntfMethodDecl->param_begin(), EM = ImpMethodDecl->param_end(); + IM != EM; ++IM, ++IF) { + if (Context.typesAreCompatible((*IF)->getType(), (*IM)->getType())) + continue; + + Diag((*IM)->getLocation(), diag::warn_conflicting_param_types) + << ImpMethodDecl->getDeclName() << (*IF)->getType() + << (*IM)->getType(); + SourceLocation Loc = (*IF)->getLocation(); + // FIXME + if (Loc == SourceLocation()) Loc = IntfMethodDecl->getLocation(); + Diag(Loc, diag::note_previous_definition); + } } /// isPropertyReadonly - Return true if property is readonly, by searching |