diff options
Diffstat (limited to 'lib/Format/UnwrappedLineParser.cpp')
-rw-r--r-- | lib/Format/UnwrappedLineParser.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 00ca3a5334..d7220259b7 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -129,13 +129,10 @@ bool UnwrappedLineParser::parseBlock(unsigned AddLevels) { parseLevel(/*HasOpeningBrace=*/true); Line.Level -= AddLevels; - // FIXME: Add error handling. if (!FormatTok.Tok.is(tok::r_brace)) return true; - nextToken(); - if (FormatTok.Tok.is(tok::semi)) - nextToken(); + nextToken(); // Munch the closing brace. return false; } @@ -246,6 +243,10 @@ void UnwrappedLineParser::parseStructuralElement() { case tok::kw_enum: parseEnum(); return; + case tok::kw_struct: // fallthrough + case tok::kw_class: + parseStructOrClass(); + return; case tok::semi: nextToken(); addUnwrappedLine(); @@ -459,6 +460,26 @@ void UnwrappedLineParser::parseEnum() { } while (!eof()); } +void UnwrappedLineParser::parseStructOrClass() { + nextToken(); + do { + switch (FormatTok.Tok.getKind()) { + case tok::l_brace: + // FIXME: Think about how to resolve the error handling here. + parseBlock(); + parseStructuralElement(); + return; + case tok::semi: + nextToken(); + addUnwrappedLine(); + return; + default: + nextToken(); + break; + } + } while (!eof()); +} + void UnwrappedLineParser::addUnwrappedLine() { // Consume trailing comments. while (!eof() && FormatTok.NewlinesBefore == 0 && |