Author: mprobst Date: Tue Apr 19 13:19:06 2016 New Revision: 266790 URL: http://llvm.org/viewvc/llvm-project?rev=266790&view=rev Log: reuse mustBeJSIdent for interface detection
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=266790&r1=266789&r2=266790&view=diff ============================================================================== --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Apr 19 13:19:06 2016 @@ -663,10 +663,8 @@ static bool tokenCanStartNewLine(const c Tok.isNot(tok::kw_noexcept); } -static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords, - const FormatToken *FormatTok) { - if (FormatTok->Tok.isLiteral()) - return true; +static bool mustBeJSIdent(const AdditionalKeywords &Keywords, + const FormatToken *FormatTok) { // FIXME: This returns true for C/C++ keywords like 'struct'. return FormatTok->is(tok::identifier) && (FormatTok->Tok.getIdentifierInfo() == nullptr || @@ -679,6 +677,11 @@ static bool mustBeJSIdentOrValue(const A Keywords.kw_interface, Keywords.kw_throws)); } +static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords, + const FormatToken *FormatTok) { + return FormatTok->Tok.isLiteral() || mustBeJSIdent(Keywords, FormatTok); +} + // isJSDeclOrStmt returns true if |FormatTok| starts a declaration or statement // when encountered after a value (see mustBeJSIdentOrValue). static bool isJSDeclOrStmt(const AdditionalKeywords &Keywords, @@ -1015,9 +1018,7 @@ void UnwrappedLineParser::parseStructura unsigned StoredPosition = Tokens->getPosition(); FormatToken *Next = Tokens->getNextToken(); FormatTok = Tokens->setPosition(StoredPosition); - if (Next && (Next->isNot(tok::identifier) || - Next->isOneOf(Keywords.kw_instanceof, Keywords.kw_of, - Keywords.kw_in))) { + if (Next && !mustBeJSIdent(Keywords, Next)) { nextToken(); break; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits