summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2012-12-04 17:27:50 +0000
committerAlexander Kornienko <alexfh@google.com>2012-12-04 17:27:50 +0000
commit870f9eb9cc5e9605ee03383dd5e7336e5cf3aced (patch)
treec991ff3382de196c76b4469bed4c609b67eb20e5 /clang/lib/Format/UnwrappedLineParser.cpp
parent4cf177e238bea0d79d98a7d18e70ab07a6f07525 (diff)
downloadbcm5719-llvm-870f9eb9cc5e9605ee03383dd5e7336e5cf3aced.tar.gz
bcm5719-llvm-870f9eb9cc5e9605ee03383dd5e7336e5cf3aced.zip
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 llvm-svn: 169286
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 888f1c9eeb9..e1972e9dd85 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/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() {
OpenPOWER on IntegriCloud