aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseObjc.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-02-09 22:20:01 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-02-09 22:20:01 +0000
commit7f53253223b29d77f1e9c5c0ce93a19932761b77 (patch)
tree241f0561678ba7020b09d3088260ca62e378b2e5 /lib/Parse/ParseObjc.cpp
parentbf36e25224b959595af84337339103ebc542ff8c (diff)
Fix scoping of method declarations and issue
warning when same parameter name used multiple times. // rdar://8877730 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125229 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseObjc.cpp')
-rw-r--r--lib/Parse/ParseObjc.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index af53d7d592..0aae43adb8 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -868,7 +868,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
Selector Sel = PP.getSelectorTable().getNullarySelector(SelIdent);
Decl *Result
- = Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(),
+ = Actions.ActOnMethodDeclaration(getCurScope(), mLoc, Tok.getLocation(),
mType, IDecl, DSRet, ReturnType, Sel,
0,
CParamInfo.data(), CParamInfo.size(),
@@ -879,7 +879,9 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
llvm::SmallVector<IdentifierInfo *, 12> KeyIdents;
llvm::SmallVector<Sema::ObjCArgInfo, 12> ArgInfos;
-
+ ParseScope PrototypeScope(this,
+ Scope::FunctionPrototypeScope|Scope::DeclScope);
+
while (1) {
Sema::ObjCArgInfo ArgInfo;
@@ -976,18 +978,25 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
// If attributes exist after the method, parse them.
if (getLang().ObjC2)
MaybeParseGNUAttributes(attrs);
-
- if (KeyIdents.size() == 0)
+
+ if (KeyIdents.size() == 0) {
+ // Leave prototype scope.
+ PrototypeScope.Exit();
return 0;
+ }
+
Selector Sel = PP.getSelectorTable().getSelector(KeyIdents.size(),
&KeyIdents[0]);
Decl *Result
- = Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(),
+ = Actions.ActOnMethodDeclaration(getCurScope(), mLoc, Tok.getLocation(),
mType, IDecl, DSRet, ReturnType, Sel,
&ArgInfos[0],
CParamInfo.data(), CParamInfo.size(),
attrs.getList(),
MethodImplKind, isVariadic);
+ // Leave prototype scope.
+ PrototypeScope.Exit();
+
PD.complete(Result);
return Result;
}