diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-09-11 17:24:26 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-09-11 17:24:26 +0000 |
commit | 92faee71f4fa01565c1c1eab617e936a01d56276 (patch) | |
tree | f4df3a22331803252a9e3d05c13958f57a084fd8 /lib/Parse/ParseObjc.cpp | |
parent | c6baadceec1d5148c20ee6c902a102233c547f62 (diff) | |
download | clang-92faee71f4fa01565c1c1eab617e936a01d56276.tar.gz clang-92faee71f4fa01565c1c1eab617e936a01d56276.tar.bz2 clang-92faee71f4fa01565c1c1eab617e936a01d56276.tar.xz |
objective-C: warn under a flag if missing argument
name results in unintended selector name.
// rdar://12263549
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163634 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseObjc.cpp')
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 977d4d9734..6d5f35a799 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -1031,7 +1031,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, Scope::FunctionPrototypeScope|Scope::DeclScope); AttributePool allParamAttrs(AttrFactory); - + bool warnSelectorName = false; while (1) { ParsedAttributes paramAttrs(AttrFactory); Sema::ObjCArgInfo ArgInfo; @@ -1100,8 +1100,16 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, // Check for another keyword selector. SelIdent = ParseObjCSelectorPiece(selLoc); - if (!SelIdent && Tok.isNot(tok::colon)) - break; + if (!SelIdent) { + if (Tok.isNot(tok::colon)) + break; + // parameter name was not followed with selector name; as in: + // - (void) Meth: (id) Name:(id)Arg2; Issue a warning as user + // might have meant: - (void) Meth: (id)Arg1 Name:(id)Arg2; + Diag(Tok, diag::warn_missing_argument_name); // missing argument name. + warnSelectorName = true; + } + // We have a selector or a colon, continue parsing. } @@ -1142,6 +1150,9 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, Selector Sel = PP.getSelectorTable().getSelector(KeyIdents.size(), &KeyIdents[0]); + if (warnSelectorName) + Diag(mLoc, diag::note_missing_argument_name) << Sel.getAsString(); + Decl *Result = Actions.ActOnMethodDeclaration(getCurScope(), mLoc, Tok.getLocation(), mType, DSRet, ReturnType, |