diff options
| author | Daniel Jasper <djasper@google.com> | 2013-05-29 12:07:31 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-05-29 12:07:31 +0000 |
| commit | 61e6bbf8508a46ad1269c8ea67dc0372b84e9a3b (patch) | |
| tree | 423ad8912b247b756db63a233148cfa3de88dadb /clang/lib/Format | |
| parent | 6ba477aa05a3eb89792bb8532748551e1541974f (diff) | |
| download | bcm5719-llvm-61e6bbf8508a46ad1269c8ea67dc0372b84e9a3b.tar.gz bcm5719-llvm-61e6bbf8508a46ad1269c8ea67dc0372b84e9a3b.zip | |
Add option to always break template declarations.
With option enabled (e.g. in Google-style):
template <typename T>
void f() {}
With option disabled:
template <typename T> void f() {}
Enabling this for Google-style and Chromium-style, not sure which other
styles would prefer that.
llvm-svn: 182849
Diffstat (limited to 'clang/lib/Format')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 5e74ed188dc..797410ab11d 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -85,6 +85,8 @@ template <> struct MappingTraits<clang::format::FormatStyle> { Style.AllowShortIfStatementsOnASingleLine); IO.mapOptional("AllowShortLoopsOnASingleLine", Style.AllowShortLoopsOnASingleLine); + IO.mapOptional("AlwaysBreakTemplateDeclarations", + Style.AlwaysBreakTemplateDeclarations); IO.mapOptional("BinPackParameters", Style.BinPackParameters); IO.mapOptional("ColumnLimit", Style.ColumnLimit); IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine", @@ -120,6 +122,7 @@ FormatStyle getLLVMStyle() { LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true; LLVMStyle.AllowShortIfStatementsOnASingleLine = false; LLVMStyle.AllowShortLoopsOnASingleLine = false; + LLVMStyle.AlwaysBreakTemplateDeclarations = false; LLVMStyle.BinPackParameters = true; LLVMStyle.ColumnLimit = 80; LLVMStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = false; @@ -146,6 +149,7 @@ FormatStyle getGoogleStyle() { GoogleStyle.AllowAllParametersOfDeclarationOnNextLine = true; GoogleStyle.AllowShortIfStatementsOnASingleLine = true; GoogleStyle.AllowShortLoopsOnASingleLine = true; + GoogleStyle.AlwaysBreakTemplateDeclarations = true; GoogleStyle.BinPackParameters = true; GoogleStyle.ColumnLimit = 80; GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true; diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 5a6d2ddef9f..ebbafcd3814 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -922,6 +922,9 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) { Current->Parent->is(tok::string_literal) && Current->Children[0].is(tok::string_literal)) { Current->MustBreakBefore = true; + } else if (Current->Parent->ClosesTemplateDeclaration && + Style.AlwaysBreakTemplateDeclarations) { + Current->MustBreakBefore = true; } else { Current->MustBreakBefore = false; } |

