summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2015-01-25 00:25:44 +0000
committerNathan Sidwell <nathan@acm.org>2015-01-25 00:25:44 +0000
commitd5b9a1d78ad722b010f85530ce6442cd246073be (patch)
tree8682a11d73da06dfc1d312337bbd968c9689b4cf
parent2d321fb79d86482792958341f9d6376cbcc38d97 (diff)
downloadbcm5719-llvm-d5b9a1d78ad722b010f85530ce6442cd246073be.tar.gz
bcm5719-llvm-d5b9a1d78ad722b010f85530ce6442cd246073be.zip
Remove duplicate code
llvm-svn: 227024
-rw-r--r--clang/lib/Parse/ParseDeclCXX.cpp50
1 files changed, 18 insertions, 32 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 0d988312d8b..63baaefc2fc 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));
}
}
OpenPOWER on IntegriCloud