diff options
| author | Manuel Klimek <klimek@google.com> | 2013-01-21 10:07:49 +0000 |
|---|---|---|
| committer | Manuel Klimek <klimek@google.com> | 2013-01-21 10:07:49 +0000 |
| commit | 762dd189a4c1c7db7b826d0e057edf980d7fe3ca (patch) | |
| tree | c4f11e8c3f51524b316e3d21c7bd0db9569762c2 /clang/lib | |
| parent | 3fd1260155750203f9cb6029ec1f5fa8fc4e4673 (diff) | |
| download | bcm5719-llvm-762dd189a4c1c7db7b826d0e057edf980d7fe3ca.tar.gz bcm5719-llvm-762dd189a4c1c7db7b826d0e057edf980d7fe3ca.zip | |
Fix parsing of return statements.
Previously, we would not detect brace initializer lists in return
statements, thus:
return (a)(b) { 1, 2, 3 };
would put the semicolon onto the next line.
llvm-svn: 173017
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 29 | ||||
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.h | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 393416de029..3fd1ff9024e 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -308,6 +308,9 @@ void UnwrappedLineParser::parseStructuralElement() { case tok::kw_case: parseCaseLabel(); return; + case tok::kw_return: + parseReturn(); + return; default: break; } @@ -380,6 +383,32 @@ void UnwrappedLineParser::parseBracedList() { } while (!eof()); } +void UnwrappedLineParser::parseReturn() { + nextToken(); + + do { + switch (FormatTok.Tok.getKind()) { + case tok::l_brace: + parseBracedList(); + break; + case tok::l_paren: + parseParens(); + break; + case tok::r_brace: + // Assume missing ';'. + addUnwrappedLine(); + return; + case tok::semi: + nextToken(); + addUnwrappedLine(); + return; + default: + nextToken(); + break; + } + } while (!eof()); +} + void UnwrappedLineParser::parseParens() { assert(FormatTok.Tok.is(tok::l_paren) && "'(' expected."); nextToken(); diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h index 010569af7b3..47148ef66d7 100644 --- a/clang/lib/Format/UnwrappedLineParser.h +++ b/clang/lib/Format/UnwrappedLineParser.h @@ -131,6 +131,7 @@ private: void parseComments(); void parseStructuralElement(); void parseBracedList(); + void parseReturn(); void parseParens(); void parseIfThenElse(); void parseForOrWhileLoop(); |

