summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-05-18 14:49:19 +0000
committerDaniel Jasper <djasper@google.com>2015-05-18 14:49:19 +0000
commit3c883d1dccd9e81fd28b7cffd7c4dc29b4685910 (patch)
tree3c6cc4ef1a135dc3222529d2c2a429d882e430c1 /clang/lib/Format
parentcec9ffd2a244d0001768f529da797bd141e9f214 (diff)
downloadbcm5719-llvm-3c883d1dccd9e81fd28b7cffd7c4dc29b4685910.tar.gz
bcm5719-llvm-3c883d1dccd9e81fd28b7cffd7c4dc29b4685910.zip
clang-format: Fix another regression caused by r237565.
Before: class C : test { class D : test{void f(){int i{2}; } } ; } ; After: class C : test { class D : test { void f() { int i{2}; } }; }; llvm-svn: 237569
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp13
-rw-r--r--clang/lib/Format/UnwrappedLineParser.h4
2 files changed, 10 insertions, 7 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 2331305cc53..5b1a4485673 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -325,6 +325,7 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
switch (Tok->Tok.getKind()) {
case tok::l_brace:
+ Tok->BlockKind = BK_Unknown;
LBraceStack.push_back(Tok);
break;
case tok::r_brace:
@@ -1017,9 +1018,9 @@ void UnwrappedLineParser::tryToParseJSFunction() {
parseChildBlock();
}
-bool UnwrappedLineParser::tryToParseBracedList(bool ExpectClassBody) {
+bool UnwrappedLineParser::tryToParseBracedList() {
if (FormatTok->BlockKind == BK_Unknown)
- calculateBraceTypes(ExpectClassBody);
+ calculateBraceTypes();
assert(FormatTok->BlockKind != BK_Unknown);
if (FormatTok->BlockKind == BK_Block)
return false;
@@ -1573,9 +1574,11 @@ void UnwrappedLineParser::parseRecord() {
// and class declarations).
if (FormatTok->isOneOf(tok::colon, tok::less)) {
while (!eof()) {
- if (FormatTok->is(tok::l_brace) &&
- !tryToParseBracedList(/*ExpectClassBody=*/true))
- break;
+ if (FormatTok->is(tok::l_brace)) {
+ calculateBraceTypes(/*ExpectClassBody=*/true);
+ if (!tryToParseBracedList())
+ break;
+ }
if (FormatTok->Tok.is(tok::semi))
return;
nextToken();
diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h
index a75845f5d83..c2fa0295768 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -82,7 +82,7 @@ private:
void parsePPEndIf();
void parsePPUnknown();
void parseStructuralElement();
- bool tryToParseBracedList(bool ExpectClassBody = false);
+ bool tryToParseBracedList();
bool parseBracedList(bool ContinueOnSemicolons = false);
void parseParens();
void parseSquare();
@@ -113,7 +113,7 @@ private:
void readToken();
void flushComments(bool NewlineBeforeNext);
void pushToken(FormatToken *Tok);
- void calculateBraceTypes(bool ExpectClassBody);
+ void calculateBraceTypes(bool ExpectClassBody = false);
// Marks a conditional compilation edge (for example, an '#if', '#ifdef',
// '#else' or merge conflict marker). If 'Unreachable' is true, assumes
OpenPOWER on IntegriCloud