[cfe-commits] r163650 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseObjc.cpp test/SemaObjC/warn-missing-selector-arg-name.m
Fariborz Jahanian
fjahanian at apple.com
Tue Sep 11 14:27:45 PDT 2012
Author: fjahanian
Date: Tue Sep 11 16:27:45 2012
New Revision: 163650
URL: http://llvm.org/viewvc/llvm-project?rev=163650&view=rev
Log:
objective-C: warn if selector has nothing but bare
':' in its name. // rdar://8366823
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/test/SemaObjC/warn-missing-selector-arg-name.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=163650&r1=163649&r2=163650&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Tue Sep 11 16:27:45 2012
@@ -361,6 +361,9 @@
"no parameter name in the middle of a selector"
" may result in incomplete selector name">,
InGroup<DiagGroup<"missing-argument-name-in-selector">>, DefaultIgnore;
+def warn_selector_with_bare_colon : Warning<
+ "selector has only bare colons in its name">,
+ InGroup<DiagGroup<"selector-with-bare-colons">>, DefaultIgnore;
def note_missing_argument_name : Note<
"did you mean %0 as the selector name">;
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=163650&r1=163649&r2=163650&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Sep 11 16:27:45 2012
@@ -1032,6 +1032,7 @@
AttributePool allParamAttrs(AttrFactory);
bool warnSelectorName = false;
+ bool warnHasNoName = true;
while (1) {
ParsedAttributes paramAttrs(AttrFactory);
Sema::ObjCArgInfo ArgInfo;
@@ -1109,7 +1110,8 @@
Diag(Tok, diag::warn_missing_argument_name); // missing argument name.
warnSelectorName = true;
}
-
+ else
+ warnHasNoName = false;
// We have a selector or a colon, continue parsing.
}
@@ -1150,8 +1152,11 @@
Selector Sel = PP.getSelectorTable().getSelector(KeyIdents.size(),
&KeyIdents[0]);
- if (warnSelectorName)
+ if (warnSelectorName) {
+ if (warnHasNoName)
+ Diag(mLoc, diag::warn_selector_with_bare_colon);
Diag(mLoc, diag::note_missing_argument_name) << Sel.getAsString();
+ }
Decl *Result
= Actions.ActOnMethodDeclaration(getCurScope(), mLoc, Tok.getLocation(),
Modified: cfe/trunk/test/SemaObjC/warn-missing-selector-arg-name.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/warn-missing-selector-arg-name.m?rev=163650&r1=163649&r2=163650&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/warn-missing-selector-arg-name.m (original)
+++ cfe/trunk/test/SemaObjC/warn-missing-selector-arg-name.m Tue Sep 11 16:27:45 2012
@@ -1,11 +1,15 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -Wmissing-argument-name-in-selector %s
-// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class -Wmissing-argument-name-in-selector %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wselector-with-bare-colons -Wmissing-argument-name-in-selector %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wselector-with-bare-colons -Wmissing-argument-name-in-selector %s
+// rdar://8366823
// rdar://12263549
@interface Super @end
@interface INTF : Super
+- (void) MMM;
+- (void)bar:(id)b;
-(void) Name1:(id)Arg1 Name2:(id)Arg2; // Name1:Name2:
-(void) Name1:(id) Name2:(id)Arg2; // expected-warning {{no parameter name in the middle of a selector may result in incomplete selector name}} \
+ // expected-warning {{selector has only bare colons in its name}} \
// expected-note {{did you mean Name1:: as the selector name}}
-(void) Name1:(id)Arg1 Name2:(id)Arg2 Name3:(id)Arg3; // Name1:Name2:Name3:
-(void) Name1:(id)Arg1 Name2:(id) Name3:(id)Arg3; // expected-warning {{no parameter name in the middle of a selector may result in incomplete selector name}} \
@@ -13,8 +17,11 @@
@end
@implementation INTF
+- (void) MMM{}
+- (void)bar:(id)b{}
-(void) Name1:(id)Arg1 Name2:(id)Arg2{}
-(void) Name1:(id) Name2:(id)Arg2 {} // expected-warning {{no parameter name in the middle of a selector may result in incomplete selector name}} \
+ // expected-warning {{selector has only bare colons in its name}} \
// expected-note {{did you mean Name1:: as the selector name}}
-(void) Name1:(id)Arg1 Name2:(id)Arg2 Name3:(id)Arg3 {}
-(void) Name1:(id)Arg1 Name2:(id) Name3:(id)Arg3 {} // expected-warning {{no parameter name in the middle of a selector may result in incomplete selector name}} \
More information about the cfe-commits
mailing list