diff options
author | Daniel Jasper <djasper@google.com> | 2014-09-03 07:37:29 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-09-03 07:37:29 +0000 |
commit | db986eb6bbc98edcebbfa60aa47bf7efe6ea80d3 (patch) | |
tree | dabf2a8de3cde259c570995089b8b93ee37da1ff /clang/lib | |
parent | c578567b079a4d13a0dd9efb55ef3983642584fc (diff) | |
download | bcm5719-llvm-db986eb6bbc98edcebbfa60aa47bf7efe6ea80d3.tar.gz bcm5719-llvm-db986eb6bbc98edcebbfa60aa47bf7efe6ea80d3.zip |
clang-format: Add an option 'SpaceAfterCStyleCast'.
This permits to add a space after closing parenthesis of a C-style cast.
Defaults to false to preserve old behavior.
Fixes llvm.org/PR19982.
Before:
(int)i;
After:
(int) i;
Patch by Marek Kurdej.
llvm-svn: 217022
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/Format.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 432da61d85a..a623ae1c716 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -228,6 +228,7 @@ template <> struct MappingTraits<FormatStyle> { IO.mapOptional("SpaceInEmptyParentheses", Style.SpaceInEmptyParentheses); IO.mapOptional("SpacesInCStyleCastParentheses", Style.SpacesInCStyleCastParentheses); + IO.mapOptional("SpaceAfterCStyleCast", Style.SpaceAfterCStyleCast); IO.mapOptional("SpacesInContainerLiterals", Style.SpacesInContainerLiterals); IO.mapOptional("SpaceBeforeAssignmentOperators", @@ -351,6 +352,7 @@ FormatStyle getLLVMStyle() { LLVMStyle.SpaceInEmptyParentheses = false; LLVMStyle.SpacesInContainerLiterals = true; LLVMStyle.SpacesInCStyleCastParentheses = false; + LLVMStyle.SpaceAfterCStyleCast = false; LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements; LLVMStyle.SpaceBeforeAssignmentOperators = true; LLVMStyle.SpacesInAngles = false; diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 8b62c97a9d5..3b92c10fd8f 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1641,9 +1641,10 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, Tok.getNextNonComment() && Tok.Type != TT_ObjCMethodExpr && !Tok.Previous->is(tok::question) && (Tok.Type != TT_DictLiteral || Style.SpacesInContainerLiterals); - if (Tok.Previous->Type == TT_UnaryOperator || - Tok.Previous->Type == TT_CastRParen) + if (Tok.Previous->Type == TT_UnaryOperator) return Tok.Type == TT_BinaryOperator; + if (Tok.Previous->Type == TT_CastRParen) + return Style.SpaceAfterCStyleCast || Tok.Type == TT_BinaryOperator; if (Tok.Previous->is(tok::greater) && Tok.is(tok::greater)) { return Tok.Type == TT_TemplateCloser && Tok.Previous->Type == TT_TemplateCloser && |