summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-08-30 10:10:19 +0000
committerDaniel Jasper <djasper@google.com>2013-08-30 10:10:19 +0000
commitb71508727859e1aef49c8f08e85cb3865a51a417 (patch)
tree6a6014095fe1ff6fd9a11bb10cfb4a9f6e182d34 /clang/lib/Format
parent1cc6cce9a625764f17c061b68e6092089e30e1f0 (diff)
downloadbcm5719-llvm-b71508727859e1aef49c8f08e85cb3865a51a417.tar.gz
bcm5719-llvm-b71508727859e1aef49c8f08e85cb3865a51a417.zip
clang-format: Improve recovery from enums with errors.
Before: namespace n { enum Type { One, Two, // missing }; int i; } void g() { } After: namespace n { enum Type { One, Two, // missing }; int i; } void g() {} llvm-svn: 189662
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 9e4600b430d..fb63899f471 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -937,6 +937,7 @@ void UnwrappedLineParser::parseEnum() {
if (FormatTok->Tok.is(tok::identifier))
nextToken();
}
+ bool HasError = false;
if (FormatTok->Tok.is(tok::l_brace)) {
if (Style.BreakBeforeBraces == FormatStyle::BS_Allman)
addUnwrappedLine();
@@ -952,7 +953,17 @@ void UnwrappedLineParser::parseEnum() {
addUnwrappedLine();
nextToken();
--Line->Level;
+ if (HasError) {
+ if (FormatTok->is(tok::semi))
+ nextToken();
+ addUnwrappedLine();
+ }
return;
+ case tok::semi:
+ HasError = true;
+ nextToken();
+ addUnwrappedLine();
+ break;
case tok::comma:
nextToken();
addUnwrappedLine();
OpenPOWER on IntegriCloud