diff options
author | Owen Pan <owenpiano@gmail.com> | 2019-08-10 07:51:21 +0000 |
---|---|---|
committer | Owen Pan <owenpiano@gmail.com> | 2019-08-10 07:51:21 +0000 |
commit | db4ad3603ac9bc2f118aa5f176dc04979f836c25 (patch) | |
tree | e487930ebc79e4dcbe7d7fa0040a150c30c29dde /clang/lib/Format | |
parent | 74c43a2277f6327a65d4b237473ac7be4f0585dd (diff) | |
download | bcm5719-llvm-db4ad3603ac9bc2f118aa5f176dc04979f836c25.tar.gz bcm5719-llvm-db4ad3603ac9bc2f118aa5f176dc04979f836c25.zip |
[clang-format] Add SpaceInEmptyBlock option for WebKit
See PR40840
Differential Revision: https://reviews.llvm.org/D65925
llvm-svn: 368507
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/Format.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Format/UnwrappedLineFormatter.cpp | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 589cf96b206..6c4fedbdbf2 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -494,6 +494,7 @@ template <> struct MappingTraits<FormatStyle> { IO.mapOptional("SpaceBeforeParens", Style.SpaceBeforeParens); IO.mapOptional("SpaceBeforeRangeBasedForLoopColon", Style.SpaceBeforeRangeBasedForLoopColon); + IO.mapOptional("SpaceInEmptyBlock", Style.SpaceInEmptyBlock); IO.mapOptional("SpaceInEmptyParentheses", Style.SpaceInEmptyParentheses); IO.mapOptional("SpacesBeforeTrailingComments", Style.SpacesBeforeTrailingComments); @@ -734,6 +735,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.ReflowComments = true; LLVMStyle.SpacesInParentheses = false; LLVMStyle.SpacesInSquareBrackets = false; + LLVMStyle.SpaceInEmptyBlock = false; LLVMStyle.SpaceInEmptyParentheses = false; LLVMStyle.SpacesInContainerLiterals = true; LLVMStyle.SpacesInCStyleCastParentheses = false; @@ -979,6 +981,7 @@ FormatStyle getWebKitStyle() { Style.ObjCSpaceAfterProperty = true; Style.PointerAlignment = FormatStyle::PAS_Left; Style.SpaceBeforeCpp11BracedList = true; + Style.SpaceInEmptyBlock = true; return Style; } diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp index 3f3c80bc1cc..f41c77e405c 100644 --- a/clang/lib/Format/UnwrappedLineFormatter.cpp +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp @@ -551,7 +551,7 @@ private: (Tok->getNextNonComment() == nullptr || Tok->getNextNonComment()->is(tok::semi))) { // We merge empty blocks even if the line exceeds the column limit. - Tok->SpacesRequiredBefore = 0; + Tok->SpacesRequiredBefore = Style.SpaceInEmptyBlock ? 1 : 0; Tok->CanBreakBefore = true; return 1; } else if (Limit != 0 && !Line.startsWithNamespace() && |