forked from OSchip/llvm-project
Code cleanup
Parser::ParseLexedMethodDeclaration: Use local var for Param Sema::MergeCXXFunctionDecls: Use hasInheritedDefaultArg llvm-svn: 227577
This commit is contained in:
parent
1efa12d6d8
commit
55d53fe79f
|
@ -306,9 +306,9 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
|
|||
ParseScope PrototypeScope(this, Scope::FunctionPrototypeScope |
|
||||
Scope::FunctionDeclarationScope | Scope::DeclScope);
|
||||
for (unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
|
||||
auto Param = LM.DefaultArgs[I].Param;
|
||||
// Introduce the parameter into scope.
|
||||
Actions.ActOnDelayedCXXMethodParameter(getCurScope(),
|
||||
LM.DefaultArgs[I].Param);
|
||||
Actions.ActOnDelayedCXXMethodParameter(getCurScope(), Param);
|
||||
if (CachedTokens *Toks = LM.DefaultArgs[I].Toks) {
|
||||
// Mark the end of the default argument so that we know when to stop when
|
||||
// we parse it later on.
|
||||
|
@ -318,7 +318,7 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
|
|||
DefArgEnd.setKind(tok::eof);
|
||||
DefArgEnd.setLocation(LastDefaultArgToken.getLocation().getLocWithOffset(
|
||||
LastDefaultArgToken.getLength()));
|
||||
DefArgEnd.setEofData(LM.DefaultArgs[I].Param);
|
||||
DefArgEnd.setEofData(Param);
|
||||
Toks->push_back(DefArgEnd);
|
||||
|
||||
// Parse the default argument from its saved token stream.
|
||||
|
@ -336,7 +336,7 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
|
|||
// used.
|
||||
EnterExpressionEvaluationContext Eval(Actions,
|
||||
Sema::PotentiallyEvaluatedIfUsed,
|
||||
LM.DefaultArgs[I].Param);
|
||||
Param);
|
||||
|
||||
ExprResult DefArgResult;
|
||||
if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) {
|
||||
|
@ -346,11 +346,9 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
|
|||
DefArgResult = ParseAssignmentExpression();
|
||||
DefArgResult = Actions.CorrectDelayedTyposInExpr(DefArgResult);
|
||||
if (DefArgResult.isInvalid()) {
|
||||
Actions.ActOnParamDefaultArgumentError(LM.DefaultArgs[I].Param,
|
||||
EqualLoc);
|
||||
Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
|
||||
} else {
|
||||
if (Tok.isNot(tok::eof) ||
|
||||
Tok.getEofData() != LM.DefaultArgs[I].Param) {
|
||||
if (Tok.isNot(tok::eof) || Tok.getEofData() != Param) {
|
||||
// The last two tokens are the terminator and the saved value of
|
||||
// Tok; the last token in the default argument is the one before
|
||||
// those.
|
||||
|
@ -359,7 +357,7 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
|
|||
<< SourceRange(Tok.getLocation(),
|
||||
(*Toks)[Toks->size() - 3].getLocation());
|
||||
}
|
||||
Actions.ActOnParamDefaultArgument(LM.DefaultArgs[I].Param, EqualLoc,
|
||||
Actions.ActOnParamDefaultArgument(Param, EqualLoc,
|
||||
DefArgResult.get());
|
||||
}
|
||||
|
||||
|
@ -368,7 +366,7 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
|
|||
while (Tok.isNot(tok::eof))
|
||||
ConsumeAnyToken();
|
||||
|
||||
if (Tok.is(tok::eof) && Tok.getEofData() == LM.DefaultArgs[I].Param)
|
||||
if (Tok.is(tok::eof) && Tok.getEofData() == Param)
|
||||
ConsumeAnyToken();
|
||||
|
||||
delete Toks;
|
||||
|
|
|
@ -509,14 +509,11 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old,
|
|||
|
||||
// Look for the function declaration where the default argument was
|
||||
// actually written, which may be a declaration prior to Old.
|
||||
for (FunctionDecl *Older = Old->getPreviousDecl();
|
||||
Older; Older = Older->getPreviousDecl()) {
|
||||
if (!Older->getParamDecl(p)->hasDefaultArg())
|
||||
break;
|
||||
|
||||
for (auto Older = Old; OldParam->hasInheritedDefaultArg();) {
|
||||
Older = Older->getPreviousDecl();
|
||||
OldParam = Older->getParamDecl(p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Diag(OldParam->getLocation(), diag::note_previous_definition)
|
||||
<< OldParam->getDefaultArgRange();
|
||||
} else if (OldParamHasDfl) {
|
||||
|
|
|
@ -6,6 +6,7 @@ void f0(int i, int j = 2, int k);
|
|||
void f0(int i, int j, int k);
|
||||
void f0(int i = 1, // expected-note{{previous definition}}
|
||||
int j, int k);
|
||||
void f0(int i, int j, int k); // want 2 decls before next default arg
|
||||
void f0(int i, int j, int k);
|
||||
|
||||
namespace N0 {
|
||||
|
|
Loading…
Reference in New Issue