From: Nathan Sidwell Date: Sun, 25 Jan 2015 00:25:44 +0000 (+0000) Subject: Remove duplicate code X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d5b9a1d78ad722b010f85530ce6442cd246073be;p=platform%2Fupstream%2Fllvm.git Remove duplicate code llvm-svn: 227024 --- diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 0d98831..63baaef 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -1882,51 +1882,37 @@ AccessSpecifier Parser::getAccessSpecifierIfPresent() const { /// the class definition. void Parser::HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo, Decl *ThisDecl) { - // We just declared a member function. If this member function - // has any default arguments or an exception-specification, we'll need to - // parse them later. - LateParsedMethodDeclaration *LateMethod = nullptr; DeclaratorChunk::FunctionTypeInfo &FTI = DeclaratorInfo.getFunctionTypeInfo(); + // If there was a late-parsed exception-specification, we'll need a + // late parse + bool NeedLateParse = FTI.getExceptionSpecType() == EST_Unparsed; + + if (!NeedLateParse) + // Look ahead to see if there are any default args + for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx) + if (FTI.Params[ParamIdx].DefaultArgTokens) { + NeedLateParse = true; + break; + } - // If there was a late-parsed exception-specification, hold onto its tokens. - if (FTI.getExceptionSpecType() == EST_Unparsed) { + if (NeedLateParse) { // Push this method onto the stack of late-parsed method // declarations. - LateMethod = new LateParsedMethodDeclaration(this, ThisDecl); + auto LateMethod = new LateParsedMethodDeclaration(this, ThisDecl); getCurrentClass().LateParsedDeclarations.push_back(LateMethod); LateMethod->TemplateScope = getCurScope()->isTemplateParamScope(); - // Stash the exception-specification tokens in the late-pased mthod. + // Stash the exception-specification tokens in the late-pased method. LateMethod->ExceptionSpecTokens = FTI.ExceptionSpecTokens; FTI.ExceptionSpecTokens = 0; - // Reserve space for the parameters. + // Push tokens for each parameter. Those that do not have + // defaults will be NULL. LateMethod->DefaultArgs.reserve(FTI.NumParams); - } - - for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx) { - if (LateMethod || FTI.Params[ParamIdx].DefaultArgTokens) { - if (!LateMethod) { - // Push this method onto the stack of late-parsed method - // declarations. - LateMethod = new LateParsedMethodDeclaration(this, ThisDecl); - getCurrentClass().LateParsedDeclarations.push_back(LateMethod); - LateMethod->TemplateScope = getCurScope()->isTemplateParamScope(); - - // Add all of the parameters prior to this one (they don't - // have default arguments). - LateMethod->DefaultArgs.reserve(FTI.NumParams); - for (unsigned I = 0; I < ParamIdx; ++I) - LateMethod->DefaultArgs.push_back( - LateParsedDefaultArgument(FTI.Params[I].Param)); - } - - // Add this parameter to the list of parameters (it may or may - // not have a default argument). + for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx) LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument( - FTI.Params[ParamIdx].Param, FTI.Params[ParamIdx].DefaultArgTokens)); - } + FTI.Params[ParamIdx].Param, FTI.Params[ParamIdx].DefaultArgTokens)); } }