aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2013-02-10 20:35:35 +0000
committerNico Weber <nicolasweber@gmx.de>2013-02-10 20:35:35 +0000
commitd74fcdb630dad817f5d462edd6d12bb95e3f27f1 (patch)
tree539c2ea1d77eb71e1b4d0942b2fb4a78ed2392ee /lib/Format/UnwrappedLineParser.cpp
parentf0c5456d7d6a9f74281011297d86cb3b1fa53cc1 (diff)
Formatter: Initial support for ObjC dictionary literals.
Before: @{ foo: bar } ; Now: @{ foo : bar }; parseBracedList() already does the right thing from an UnwrappedLineParser perspective, so check for "@{" in all loops that process constructs that can contain expressions and call parseBracedList() if found. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174840 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--lib/Format/UnwrappedLineParser.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 36307e0487..cb956084e0 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -188,7 +188,8 @@ bool UnwrappedLineParser::parseLevel(bool HasOpeningBrace) {
return Error;
}
-bool UnwrappedLineParser::parseBlock(bool MustBeDeclaration, unsigned AddLevels) {
+bool UnwrappedLineParser::parseBlock(bool MustBeDeclaration,
+ unsigned AddLevels) {
assert(FormatTok.Tok.is(tok::l_brace) && "'{' expected");
nextToken();
@@ -265,6 +266,10 @@ void UnwrappedLineParser::parseStructuralElement() {
switch (FormatTok.Tok.getKind()) {
case tok::at:
nextToken();
+ if (FormatTok.Tok.is(tok::l_brace)) {
+ parseBracedList();
+ break;
+ }
switch (FormatTok.Tok.getObjCKeywordID()) {
case tok::objc_public:
case tok::objc_protected:
@@ -344,6 +349,11 @@ void UnwrappedLineParser::parseStructuralElement() {
do {
++TokenNumber;
switch (FormatTok.Tok.getKind()) {
+ case tok::at:
+ nextToken();
+ if (FormatTok.Tok.is(tok::l_brace))
+ parseBracedList();
+ break;
case tok::kw_enum:
parseEnum();
break;
@@ -457,6 +467,11 @@ void UnwrappedLineParser::parseParens() {
Line->Level -= 1;
break;
}
+ case tok::at:
+ nextToken();
+ if (FormatTok.Tok.is(tok::l_brace))
+ parseBracedList();
+ break;
default:
nextToken();
break;