summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-06-30 11:32:22 +0000
committerDaniel Jasper <djasper@google.com>2015-06-30 11:32:22 +0000
commita87af7a32645e606b961e013d81f9152d059196f (patch)
tree35581a0ce78df4ea249cdffd745b4027da15dd9d
parent5b119091a130c2a09e9128b9e874efabb7c9c69f (diff)
downloadbcm5719-llvm-a87af7a32645e606b961e013d81f9152d059196f.tar.gz
bcm5719-llvm-a87af7a32645e606b961e013d81f9152d059196f.zip
clang-format: Properly parse parenthesis in braced lists.
Among other things, this makes clang-format understand arbitrary blocks embedded in them, such as: SomeFunction({MACRO({ return output; }), b}); where MACRO could e.g. expand to a lambda. llvm-svn: 241059
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp5
-rw-r--r--clang/unittests/Format/FormatTest.cpp2
2 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 72652a7d0d1..c58e6bccd9b 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1111,16 +1111,15 @@ bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons) {
FormatTok->BlockKind = BK_BracedInit;
parseBracedList();
break;
- case tok::r_paren:
+ case tok::l_paren:
+ parseParens();
// JavaScript can just have free standing methods and getters/setters in
// object literals. Detect them by a "{" following ")".
if (Style.Language == FormatStyle::LK_JavaScript) {
- nextToken();
if (FormatTok->is(tok::l_brace))
parseChildBlock();
break;
}
- nextToken();
break;
case tok::r_brace:
nextToken();
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 743171fb003..ef5299aada7 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3184,6 +3184,8 @@ TEST_F(FormatTest, LayoutNestedBlocks) {
"}, a);",
Style);
+ verifyFormat("SomeFunction({MACRO({ return output; }), b});");
+
verifyNoCrash("^{v^{a}}");
}
OpenPOWER on IntegriCloud