diff options
author | Reuben Thomas <reuben.thomas@me.com> | 2019-04-08 12:54:48 +0000 |
---|---|---|
committer | Reuben Thomas <reuben.thomas@me.com> | 2019-04-08 12:54:48 +0000 |
commit | 91f60b44958fbcaf6450e82ef40965e92aedda5f (patch) | |
tree | f56eb0ee89c5c4ff7d62a2b1fbbab17959ba29bf /clang/lib/Format | |
parent | b743b45ebf1bc0b62cde614e334ef44cfbc9926e (diff) | |
download | bcm5719-llvm-91f60b44958fbcaf6450e82ef40965e92aedda5f.tar.gz bcm5719-llvm-91f60b44958fbcaf6450e82ef40965e92aedda5f.zip |
[clang-format] Optionally insert a space after unary ! operator
llvm-svn: 357908
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/Format.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index e2326423a7a..2d8596a42aa 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -478,6 +478,7 @@ template <> struct MappingTraits<FormatStyle> { IO.mapOptional("SortIncludes", Style.SortIncludes); IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations); IO.mapOptional("SpaceAfterCStyleCast", Style.SpaceAfterCStyleCast); + IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot); IO.mapOptional("SpaceAfterTemplateKeyword", Style.SpaceAfterTemplateKeyword); IO.mapOptional("SpaceBeforeAssignmentOperators", @@ -730,6 +731,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.SpacesInContainerLiterals = true; LLVMStyle.SpacesInCStyleCastParentheses = false; LLVMStyle.SpaceAfterCStyleCast = false; + LLVMStyle.SpaceAfterLogicalNot = false; LLVMStyle.SpaceAfterTemplateKeyword = true; LLVMStyle.SpaceBeforeCtorInitializerColon = true; LLVMStyle.SpaceBeforeInheritanceColon = true; diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 8f64e3cf985..032be722b28 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2832,7 +2832,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, return true; } if (Left.is(TT_UnaryOperator)) - return Right.is(TT_BinaryOperator); + return (Style.SpaceAfterLogicalNot && Left.is(tok::exclaim)) || + Right.is(TT_BinaryOperator); // If the next token is a binary operator or a selector name, we have // incorrectly classified the parenthesis as a cast. FIXME: Detect correctly. |