r260497 - clang-format: Make it more expensive to break template parameters.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 10 22:43:01 PST 2016
Author: djasper
Date: Thu Feb 11 00:43:01 2016
New Revision: 260497
URL: http://llvm.org/viewvc/llvm-project?rev=260497&view=rev
Log:
clang-format: Make it more expensive to break template parameters.
In particular, make it more expensive than breaking after the return
type of a function definition/declaration.
Before:
template <typename T>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa<
T>::aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa);
After:
template <typename T>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa);
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=260497&r1=260496&r2=260497&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Feb 11 00:43:01 2016
@@ -59,7 +59,7 @@ private:
FormatToken *Left = CurrentToken->Previous;
Left->ParentBracket = Contexts.back().ContextKind;
- ScopedContextCreator ContextCreator(*this, tok::less, 10);
+ ScopedContextCreator ContextCreator(*this, tok::less, 12);
// If this angle is in the context of an expression, we need to be more
// hesitant to detect it as opening template parameters.
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=260497&r1=260496&r2=260497&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Feb 11 00:43:01 2016
@@ -3850,6 +3850,11 @@ TEST_F(FormatTest, BreaksFunctionDeclara
"typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa\n"
"aaaaaaaaaa<aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" bool *aaaaaaaaaaaaaaaaaa, bool *aa) {}");
+ verifyGoogleFormat(
+ "template <typename T>\n"
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+ "aaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa);");
FormatStyle Style = getLLVMStyle();
Style.PointerAlignment = FormatStyle::PAS_Left;
More information about the cfe-commits
mailing list