diff options
author | Daniel Jasper <djasper@google.com> | 2015-05-31 08:51:54 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-05-31 08:51:54 +0000 |
commit | be520bd1a609778bcadd1adecd22ee2f3cb16c07 (patch) | |
tree | ab096228864f895a1f0640480942e520aaca99f2 /clang/lib/Format | |
parent | cd8d4ff98598b3234181e826a7a900eecf9bd455 (diff) | |
download | bcm5719-llvm-be520bd1a609778bcadd1adecd22ee2f3cb16c07.tar.gz bcm5719-llvm-be520bd1a609778bcadd1adecd22ee2f3cb16c07.zip |
clang-format: NFC. Cleanup after r237895.
Specifically adhere to LLVM Coding Standards (no 'else' after
return/break/continue) and remove yet another implementation of
paren counting. We already have enough of those in the
UnwrappedLineParser.
No functional changes intended.
llvm-svn: 238672
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 34 | ||||
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.h | 5 |
2 files changed, 8 insertions, 31 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 939528fbffe..662606cf4cc 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -887,9 +887,8 @@ void UnwrappedLineParser::parseStructuralElement() { // followed by a curly. if (FormatTok->is(TT_JsFatArrow)) { nextToken(); - if (FormatTok->is(tok::l_brace)) { + if (FormatTok->is(tok::l_brace)) parseChildBlock(); - } break; } @@ -1019,7 +1018,7 @@ void UnwrappedLineParser::tryToParseJSFunction() { return; // Parse formal parameter list. - parseBalanced(tok::l_paren, tok::r_paren); + parseParens(); if (FormatTok->is(tok::colon)) { // Parse a type definition. @@ -1027,34 +1026,16 @@ void UnwrappedLineParser::tryToParseJSFunction() { // Eat the type declaration. For braced inline object types, balance braces, // otherwise just parse until finding an l_brace for the function body. - if (FormatTok->is(tok::l_brace)) { - parseBalanced(tok::l_brace, tok::r_brace); - } else { - while(FormatTok->isNot(tok::l_brace) && !eof()) { + if (FormatTok->is(tok::l_brace)) + tryToParseBracedList(); + else + while(FormatTok->isNot(tok::l_brace) && !eof()) nextToken(); - } - } } parseChildBlock(); } -void UnwrappedLineParser::parseBalanced(tok::TokenKind OpenKind, - tok::TokenKind CloseKind) { - assert(FormatTok->is(OpenKind)); - nextToken(); - int Depth = 1; - while (Depth > 0 && !eof()) { - // Parse the formal parameter list. - if (FormatTok->is(OpenKind)) { - ++Depth; - } else if (FormatTok->is(CloseKind)) { - --Depth; - } - nextToken(); - } -} - bool UnwrappedLineParser::tryToParseBracedList() { if (FormatTok->BlockKind == BK_Unknown) calculateBraceTypes(); @@ -1076,7 +1057,8 @@ bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons) { if (FormatTok->is(Keywords.kw_function)) { tryToParseJSFunction(); continue; - } else if (FormatTok->is(TT_JsFatArrow)) { + } + if (FormatTok->is(TT_JsFatArrow)) { nextToken(); // Fat arrows can be followed by simple expressions or by child blocks // in curly braces. diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h index 6a6e56fea02..c2fa0295768 100644 --- a/clang/lib/Format/UnwrappedLineParser.h +++ b/clang/lib/Format/UnwrappedLineParser.h @@ -107,11 +107,6 @@ private: bool tryToParseLambda(); bool tryToParseLambdaIntroducer(); void tryToParseJSFunction(); - /// \brief Parses tokens until encountering the CloseKind token, but balances - /// tokens when encountering more OpenKind tokens. Useful for e.g. parsing a - /// curly brace delimited block that can contain nested blocks. - /// The parser must be positioned on a token of OpenKind. - void parseBalanced(tok::TokenKind OpenKind, tok::TokenKind CloseKind); void addUnwrappedLine(); bool eof() const; void nextToken(); |