diff options
author | Alexander Kornienko <alexfh@google.com> | 2012-12-04 17:27:50 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2012-12-04 17:27:50 +0000 |
commit | cff563c0123bbb8d959c93ed371d27cbc6bc4a29 (patch) | |
tree | 9aacc432b98df1f22275726c196a421a78fa4216 /lib/Format/UnwrappedLineParser.cpp | |
parent | ff685c562c8fd5dfc6effec17377fde9dad6f271 (diff) |
Error recovery part 2
Summary: Adds recovery for structural errors in clang-format.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, silvas
Differential Revision: http://llvm-reviews.chandlerc.com/D164
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169286 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/UnwrappedLineParser.cpp')
-rw-r--r-- | lib/Format/UnwrappedLineParser.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 888f1c9eeb..e1972e9dd8 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -32,12 +32,13 @@ UnwrappedLineParser::UnwrappedLineParser(Lexer &Lex, SourceManager &SourceMgr, Lex.SetKeepWhitespaceMode(true); } -void UnwrappedLineParser::parse() { +bool UnwrappedLineParser::parse() { parseToken(); - parseLevel(); + return parseLevel(); } -void UnwrappedLineParser::parseLevel() { +bool UnwrappedLineParser::parseLevel() { + bool Error = false; do { switch (FormatTok.Tok.getKind()) { case tok::hash: @@ -47,19 +48,20 @@ void UnwrappedLineParser::parseLevel() { parseComment(); break; case tok::l_brace: - parseBlock(); + Error |= parseBlock(); addUnwrappedLine(); break; case tok::r_brace: - return; + return false; default: parseStatement(); break; } } while (!eof()); + return Error; } -void UnwrappedLineParser::parseBlock() { +bool UnwrappedLineParser::parseBlock() { nextToken(); // FIXME: Remove this hack to handle namespaces. @@ -74,11 +76,12 @@ void UnwrappedLineParser::parseBlock() { --Line.Level; // FIXME: Add error handling. if (!FormatTok.Tok.is(tok::r_brace)) - return; + return true; nextToken(); if (FormatTok.Tok.is(tok::semi)) nextToken(); + return false; } void UnwrappedLineParser::parsePPDirective() { |