Fix parsing of initializer lists with elaborated type specifier.
Now we correctly parse and format:
verifyFormat("struct foo a = { bar };
int n;
llvm-svn: 172229
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index f7332ee..758f819 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -319,7 +319,7 @@
return;
case tok::kw_struct: // fallthrough
case tok::kw_class:
- parseStructOrClass();
+ parseStructClassOrBracedList();
return;
case tok::semi:
nextToken();
@@ -565,7 +565,7 @@
} while (!eof());
}
-void UnwrappedLineParser::parseStructOrClass() {
+void UnwrappedLineParser::parseStructClassOrBracedList() {
nextToken();
do {
switch (FormatTok.Tok.getKind()) {
@@ -578,6 +578,12 @@
nextToken();
addUnwrappedLine();
return;
+ case tok::equal:
+ nextToken();
+ if (FormatTok.Tok.is(tok::l_brace)) {
+ parseBracedList();
+ }
+ break;
default:
nextToken();
break;
diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h
index 837b539..cfd0608 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -146,7 +146,7 @@
void parseNamespace();
void parseAccessSpecifier();
void parseEnum();
- void parseStructOrClass();
+ void parseStructClassOrBracedList();
void parseObjCProtocolList();
void parseObjCUntilAtEnd();
void parseObjCInterfaceOrImplementation();