clang-format: Option to control spacing in template argument lists.
Same as SpacesInParentheses, this option allows adding a space inside
the '<' and '>' of a template parameter list.
Patch by Christopher Olsen.
This fixes llvm.org/PR17301.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193614 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 83035f7..991763c 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -6592,6 +6592,7 @@
CHECK_PARSE_BOOL(Cpp11BracedListStyle);
CHECK_PARSE_BOOL(IndentFunctionDeclarationAfterType);
CHECK_PARSE_BOOL(SpacesInParentheses);
+ CHECK_PARSE_BOOL(SpacesInAngles);
CHECK_PARSE_BOOL(SpaceInEmptyParentheses);
CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
CHECK_PARSE_BOOL(SpaceAfterControlStatementKeyword);
@@ -7010,5 +7011,30 @@
format("int i = longFunction(arg);", SixIndent));
}
+TEST_F(FormatTest, SpacesInAngles) {
+ FormatStyle Spaces = getLLVMStyle();
+ Spaces.SpacesInAngles = true;
+
+ verifyFormat("static_cast< int >(arg);", Spaces);
+ verifyFormat("template < typename T0, typename T1 > void f() {}", Spaces);
+ verifyFormat("f< int, float >();", Spaces);
+ verifyFormat("template <> g() {}", Spaces);
+ verifyFormat("template < std::vector< int > > f() {}", Spaces);
+
+ Spaces.Standard = FormatStyle::LS_Cpp03;
+ Spaces.SpacesInAngles = true;
+ verifyFormat("A< A< int > >();", Spaces);
+
+ Spaces.SpacesInAngles = false;
+ verifyFormat("A<A<int> >();", Spaces);
+
+ Spaces.Standard = FormatStyle::LS_Cpp11;
+ Spaces.SpacesInAngles = true;
+ verifyFormat("A< A< int > >();", Spaces);
+
+ Spaces.SpacesInAngles = false;
+ verifyFormat("A<A<int>>();", Spaces);
+}
+
} // end namespace tooling
} // end namespace clang