Parse: Just a small tidy-up in ParseLexedMethodDeclaration
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 12 Jan 2015 06:51:15 +0000 (06:51 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 12 Jan 2015 06:51:15 +0000 (06:51 +0000)
No functional change intended, just tidy up the parse flow.

llvm-svn: 225620

clang/lib/Parse/ParseCXXInlineMethods.cpp

index 375041e..0d5bb2e 100644 (file)
@@ -337,14 +337,16 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
         DefArgResult = ParseBraceInitializer();
       } else
         DefArgResult = ParseAssignmentExpression();
+      bool DefArgTokenFound =
+          Tok.is(tok::eof) && Tok.getEofData() == LM.DefaultArgs[I].Param;
+      if (DefArgTokenFound)
+        ConsumeAnyToken();
       DefArgResult = Actions.CorrectDelayedTyposInExpr(DefArgResult);
-      if (DefArgResult.isInvalid())
+      if (DefArgResult.isInvalid()) {
         Actions.ActOnParamDefaultArgumentError(LM.DefaultArgs[I].Param,
                                                EqualLoc);
-      else {
-        if (Tok.is(tok::eof) && Tok.getEofData() == LM.DefaultArgs[I].Param) {
-          ConsumeAnyToken();
-        } else {
+      } else {
+        if (!DefArgTokenFound) {
           // 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.