summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-08-26 11:41:14 +0000
committerDaniel Jasper <djasper@google.com>2014-08-26 11:41:14 +0000
commitad981f888ad7e9375393dd7d0d486e6e6f3c6bbc (patch)
tree6dcac0cbda65d29d16981f23199426cd39488ddd /clang/unittests/Format/FormatTest.cpp
parent81885731a819afd4ca6b40a50012456df6fe66fb (diff)
downloadbcm5719-llvm-ad981f888ad7e9375393dd7d0d486e6e6f3c6bbc.tar.gz
bcm5719-llvm-ad981f888ad7e9375393dd7d0d486e6e6f3c6bbc.zip
clang-format: New option SpacesInSquareBrackets.
Before: int a[5]; a[3] += 42; After: int a[ 5 ]; a[ 3 ] += 42; Fixes LLVM bug #17887 (http://llvm.org/bugs/show_bug.cgi?id=17887). Patch by Marek Kurdej, thank you! llvm-svn: 216449
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index f88bdafb395..411282a69da 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7705,6 +7705,28 @@ TEST_F(FormatTest, ConfigurableSpacesInParentheses) {
"}", Spaces);
}
+TEST_F(FormatTest, ConfigurableSpacesInSquareBrackets) {
+ verifyFormat("int a[5];");
+ verifyFormat("a[3] += 42;");
+
+ FormatStyle Spaces = getLLVMStyle();
+ Spaces.SpacesInSquareBrackets = true;
+ // Lambdas unchanged.
+ verifyFormat("int c = []() -> int { return 2; }();\n", Spaces);
+ verifyFormat("return [i, args...] {};", Spaces);
+
+ // Not lambdas.
+ verifyFormat("int a[ 5 ];", Spaces);
+ verifyFormat("a[ 3 ] += 42;", Spaces);
+ verifyFormat("constexpr char hello[]{\"hello\"};", Spaces);
+ verifyFormat("double &operator[](int i) { return 0; }\n"
+ "int i;",
+ Spaces);
+ verifyFormat("std::unique_ptr<int[]> foo() {}", Spaces);
+ verifyFormat("int i = a[ a ][ a ]->f();", Spaces);
+ verifyFormat("int i = (*b)[ a ]->f();", Spaces);
+}
+
TEST_F(FormatTest, ConfigurableSpaceBeforeAssignmentOperators) {
verifyFormat("int a = 5;");
verifyFormat("a += 42;");
@@ -8261,6 +8283,7 @@ TEST_F(FormatTest, ParsesConfigurationBools) {
CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
CHECK_PARSE_BOOL(Cpp11BracedListStyle);
CHECK_PARSE_BOOL(SpacesInParentheses);
+ CHECK_PARSE_BOOL(SpacesInSquareBrackets);
CHECK_PARSE_BOOL(SpacesInAngles);
CHECK_PARSE_BOOL(SpaceInEmptyParentheses);
CHECK_PARSE_BOOL(SpacesInContainerLiterals);
OpenPOWER on IntegriCloud