diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-13 20:33:44 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-13 20:33:44 +0000 |
commit | a03ab10f0e4d888139b3b694dd55d176982f72a4 (patch) | |
tree | b6430a75f6b55f092469562b1e84c44698c8e057 /lib/Format/Format.cpp | |
parent | 778749aa7c2ed73ffeb60065dc015ed62127c8e1 (diff) |
Allow breaking after the return type in function declarations.
This has so far been disabled for Google style, but should be done
before breaking at nested name specifiers or in template parameters.
Before (in Google style):
template <typename T>
aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaa<
T>::aaaaaaa() {}
After:
template <typename T>
aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa>
aaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaa() {}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175074 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r-- | lib/Format/Format.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index d8c02e2e18..8c2128eb01 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -43,11 +43,11 @@ FormatStyle getLLVMStyle() { LLVMStyle.SpacesBeforeTrailingComments = 1; LLVMStyle.BinPackParameters = true; LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true; - LLVMStyle.AllowReturnTypeOnItsOwnLine = true; LLVMStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = false; LLVMStyle.AllowShortIfStatementsOnASingleLine = false; LLVMStyle.ObjCSpaceBeforeProtocolList = true; LLVMStyle.PenaltyExcessCharacter = 1000000; + LLVMStyle.PenaltyReturnTypeOnItsOwnLine = 5; return LLVMStyle; } @@ -63,11 +63,11 @@ FormatStyle getGoogleStyle() { GoogleStyle.SpacesBeforeTrailingComments = 2; GoogleStyle.BinPackParameters = false; GoogleStyle.AllowAllParametersOfDeclarationOnNextLine = true; - GoogleStyle.AllowReturnTypeOnItsOwnLine = false; GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true; GoogleStyle.AllowShortIfStatementsOnASingleLine = false; GoogleStyle.ObjCSpaceBeforeProtocolList = false; GoogleStyle.PenaltyExcessCharacter = 1000000; + GoogleStyle.PenaltyReturnTypeOnItsOwnLine = 100; return GoogleStyle; } @@ -717,9 +717,10 @@ private: reconstructPath(State, Current->Previous); DEBUG({ if (Current->NewLine) { - llvm::errs() << "Penalty for splitting before " - << Current->State.NextToken->FormatTok.Tok.getName() - << ": " << Current->State.NextToken->SplitPenalty << "\n"; + llvm::errs() + << "Penalty for splitting before " + << Current->Previous->State.NextToken->FormatTok.Tok.getName() + << ": " << Current->Previous->State.NextToken->SplitPenalty << "\n"; } }); addTokenToState(Current->NewLine, false, State); |