Skip to content
Snippets Groups Projects
Commit a3a2b3a1 authored by Alexander Kornienko's avatar Alexander Kornienko
Browse files

Clang-format: detect unbalanced braces.

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits, silvas

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169518 91177308-0d34-0410-b5e6-96231b3b80d8
parent 33c95f11
No related branches found
No related tags found
No related merge requests found
...@@ -52,8 +52,8 @@ bool UnwrappedLineParser::parseLevel() { ...@@ -52,8 +52,8 @@ bool UnwrappedLineParser::parseLevel() {
addUnwrappedLine(); addUnwrappedLine();
break; break;
case tok::r_brace: case tok::r_brace:
// FIXME: We need a test when it has to be "return Error;" // Stray '}' is an error.
return false; return true;
default: default:
parseStatement(); parseStatement();
break; break;
...@@ -63,6 +63,7 @@ bool UnwrappedLineParser::parseLevel() { ...@@ -63,6 +63,7 @@ bool UnwrappedLineParser::parseLevel() {
} }
bool UnwrappedLineParser::parseBlock() { bool UnwrappedLineParser::parseBlock() {
assert(FormatTok.Tok.is(tok::l_brace) && "'{' expected");
nextToken(); nextToken();
// FIXME: Remove this hack to handle namespaces. // FIXME: Remove this hack to handle namespaces.
......
...@@ -428,6 +428,7 @@ TEST_F(FormatTest, IncorrectCodeErrorDetection) { ...@@ -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", 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(); FormatStyle Style = getLLVMStyle();
Style.ColumnLimit = 10; Style.ColumnLimit = 10;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment