diff options
| author | Daniel Jasper <djasper@google.com> | 2013-10-29 14:52:02 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-10-29 14:52:02 +0000 |
| commit | dd978ae0e118ebd99d18df518cf8d03ea115af07 (patch) | |
| tree | 7bbb6b836d37e8325a015cb0579ec94df4792bae /clang/lib/Format | |
| parent | f34ac3ed2c9badee39b3efc72d4c34f922cf3b39 (diff) | |
| download | bcm5719-llvm-dd978ae0e118ebd99d18df518cf8d03ea115af07.tar.gz bcm5719-llvm-dd978ae0e118ebd99d18df518cf8d03ea115af07.zip | |
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.
llvm-svn: 193614
Diffstat (limited to 'clang/lib/Format')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 54d0b1f5e2a..c75684b3b5a 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -158,6 +158,7 @@ template <> struct MappingTraits<clang::format::FormatStyle> { IO.mapOptional("IndentFunctionDeclarationAfterType", Style.IndentFunctionDeclarationAfterType); IO.mapOptional("SpacesInParentheses", Style.SpacesInParentheses); + IO.mapOptional("SpacesInAngles", Style.SpacesInAngles); IO.mapOptional("SpaceInEmptyParentheses", Style.SpaceInEmptyParentheses); IO.mapOptional("SpacesInCStyleCastParentheses", Style.SpacesInCStyleCastParentheses); @@ -218,6 +219,7 @@ FormatStyle getLLVMStyle() { LLVMStyle.SpaceAfterControlStatementKeyword = true; LLVMStyle.SpaceBeforeAssignmentOperators = true; LLVMStyle.ContinuationIndentWidth = 4; + LLVMStyle.SpacesInAngles = false; setDefaultPenalties(LLVMStyle); LLVMStyle.PenaltyReturnTypeOnItsOwnLine = 60; @@ -263,6 +265,7 @@ FormatStyle getGoogleStyle() { GoogleStyle.SpaceAfterControlStatementKeyword = true; GoogleStyle.SpaceBeforeAssignmentOperators = true; GoogleStyle.ContinuationIndentWidth = 4; + GoogleStyle.SpacesInAngles = false; setDefaultPenalties(GoogleStyle); GoogleStyle.PenaltyReturnTypeOnItsOwnLine = 200; diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index eeecdceb849..799e4c11a5c 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1221,6 +1221,9 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, (Left.MatchingParen && Left.MatchingParen->Type == TT_CastRParen)) ? Style.SpacesInCStyleCastParentheses : Style.SpacesInParentheses; + if (Style.SpacesInAngles && + ((Left.Type == TT_TemplateOpener) != (Right.Type == TT_TemplateCloser))) + return true; if (Right.isOneOf(tok::semi, tok::comma)) return false; if (Right.is(tok::less) && @@ -1350,7 +1353,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, if (Tok.Previous->is(tok::greater) && Tok.is(tok::greater)) { return Tok.Type == TT_TemplateCloser && Tok.Previous->Type == TT_TemplateCloser && - Style.Standard != FormatStyle::LS_Cpp11; + (Style.Standard != FormatStyle::LS_Cpp11 || Style.SpacesInAngles); } if (Tok.isOneOf(tok::arrowstar, tok::periodstar) || Tok.Previous->isOneOf(tok::arrowstar, tok::periodstar)) |

