diff options
| author | Martin Probst <martin@probst.io> | 2016-04-19 18:19:06 +0000 |
|---|---|---|
| committer | Martin Probst <martin@probst.io> | 2016-04-19 18:19:06 +0000 |
| commit | 533965c195173714a8a000a465a075672d2c8a8b (patch) | |
| tree | ee4cc781d613fd1536a0722efe93810bbd70f62b | |
| parent | 1e8261ea0430ecc0bed0ace31e0ec724a5a69270 (diff) | |
| download | bcm5719-llvm-533965c195173714a8a000a465a075672d2c8a8b.tar.gz bcm5719-llvm-533965c195173714a8a000a465a075672d2c8a8b.zip | |
reuse mustBeJSIdent for interface detection
llvm-svn: 266790
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 6d2d2cb44c0..55eecf64e22 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -663,10 +663,8 @@ static bool tokenCanStartNewLine(const clang::Token &Tok) { 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 AdditionalKeywords &Keywords, 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::parseStructuralElement() { 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; } |

