summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseObjc.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-09-17 19:15:26 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-09-17 19:15:26 +0000
commitf4ffdf357c98e30fd8a67d41ab51e55932f8d2d4 (patch)
tree69301404a4e37a67f4877489dcd4b1d064f76942 /clang/lib/Parse/ParseObjc.cpp
parent42782343606a4c50fb5f237bbda37823b67e845b (diff)
downloadbcm5719-llvm-f4ffdf357c98e30fd8a67d41ab51e55932f8d2d4.tar.gz
bcm5719-llvm-f4ffdf357c98e30fd8a67d41ab51e55932f8d2d4.zip
objective-C: issue warning when there is no whitespace
between objc method parameter name and colon. // rdar://12263549 llvm-svn: 164047
Diffstat (limited to 'clang/lib/Parse/ParseObjc.cpp')
-rw-r--r--clang/lib/Parse/ParseObjc.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp
index 1465a730e44..48c5efac6ba 100644
--- a/clang/lib/Parse/ParseObjc.cpp
+++ b/clang/lib/Parse/ParseObjc.cpp
@@ -18,6 +18,7 @@
#include "clang/Sema/PrettyDeclStackTrace.h"
#include "clang/Sema/Scope.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
using namespace clang;
@@ -1031,7 +1032,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
Scope::FunctionPrototypeScope|Scope::DeclScope);
AttributePool allParamAttrs(AttrFactory);
-
+ bool warnSelectorName = false;
while (1) {
ParsedAttributes paramAttrs(AttrFactory);
Sema::ObjCArgInfo ArgInfo;
@@ -1102,6 +1103,13 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
SelIdent = ParseObjCSelectorPiece(selLoc);
if (!SelIdent && Tok.isNot(tok::colon))
break;
+ if (MethodDefinition && !SelIdent) {
+ SourceLocation ColonLoc = Tok.getLocation();
+ if (PP.getLocForEndOfToken(ArgInfo.NameLoc) == ColonLoc) {
+ warnSelectorName = true;
+ Diag(ArgInfo.NameLoc, diag::missing_selector_name);
+ }
+ }
// We have a selector or a colon, continue parsing.
}
@@ -1142,6 +1150,22 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
Selector Sel = PP.getSelectorTable().getSelector(KeyIdents.size(),
&KeyIdents[0]);
+ if (warnSelectorName) {
+ SmallVector<IdentifierInfo *, 12> DiagKeyIdents;
+ for (unsigned i = 0, size = KeyIdents.size(); i < size; i++)
+ if (KeyIdents[i])
+ DiagKeyIdents.push_back(KeyIdents[i]);
+ else {
+ std::string name = "Name";
+ name += llvm::utostr(i+1);
+ IdentifierInfo *NamedMissingId = &PP.getIdentifierTable().get(name);
+ DiagKeyIdents.push_back(NamedMissingId);
+ }
+ Selector NewSel =
+ PP.getSelectorTable().getSelector(DiagKeyIdents.size(), &DiagKeyIdents[0]);
+ Diag(mLoc, diag::note_missing_argument_name)
+ << NewSel.getAsString() << Sel.getAsString();
+ }
Decl *Result
= Actions.ActOnMethodDeclaration(getCurScope(), mLoc, Tok.getLocation(),
mType, DSRet, ReturnType,
OpenPOWER on IntegriCloud