Clang-format: detect unbalanced braces.

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits, silvas

Differential Revision: http://llvm-reviews.chandlerc.com/D176

llvm-svn: 169518
This commit is contained in:
Alexander Kornienko 2012-12-06 17:49:17 +00:00
parent e8f80a12bd
commit ecdc7507ab
2 changed files with 4 additions and 2 deletions

View File

@ -52,8 +52,8 @@ bool UnwrappedLineParser::parseLevel() {
addUnwrappedLine();
break;
case tok::r_brace:
// FIXME: We need a test when it has to be "return Error;"
return false;
// Stray '}' is an error.
return true;
default:
parseStatement();
break;
@ -63,6 +63,7 @@ bool UnwrappedLineParser::parseLevel() {
}
bool UnwrappedLineParser::parseBlock() {
assert(FormatTok.Tok.is(tok::l_brace) && "'{' expected");
nextToken();
// FIXME: Remove this hack to handle namespaces.

View File

@ -428,6 +428,7 @@ TEST_F(FormatTest, IncorrectCodeErrorDetection) {
EXPECT_EQ("{\n{\n}\n", format("{\n{\n}\n"));
EXPECT_EQ("{\n {\n}\n", format("{\n {\n}\n"));
EXPECT_EQ("{\n {\n }\n", format("{\n {\n }\n"));
EXPECT_EQ("{\n {\n }\n }\n}\n", format("{\n {\n }\n }\n}\n"));
FormatStyle Style = getLLVMStyle();
Style.ColumnLimit = 10;