summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authormydeveloperday <mydeveloperday@gmail.com>2019-11-16 11:54:21 +0000
committerpaulhoad <mydeveloperday@gmail.com>2019-11-16 11:54:21 +0000
commita4a7c1259e8a8f2d11fa29686a6c2834948c1358 (patch)
treeab315a8d692d9765a93b2a2347774241779fbca2 /clang/lib/Format/Format.cpp
parent42effc106966d45053abdd4e3d03ecfe256869b5 (diff)
downloadbcm5719-llvm-a4a7c1259e8a8f2d11fa29686a6c2834948c1358.tar.gz
bcm5719-llvm-a4a7c1259e8a8f2d11fa29686a6c2834948c1358.zip
[clang-format] Add SpaceBeforeBrackets
Summary: Adds a new option SpaceBeforeBrackets to add spaces before brackets (i.e. int a[23]; -> int a [23];) This is present as an option in the Visual Studio C++ code formatting settings, but there was no matching setting in clang-format. Reviewers: djasper, MyDeveloperDay, mitchell-stellar Reviewed By: MyDeveloperDay Subscribers: llvm-commits, cfe-commits, klimek Patch by: Anteru Tags: #clang, #clang-format, #llvm Differential Revision: https://reviews.llvm.org/D6920
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rwxr-xr-x[-rw-r--r--]clang/lib/Format/Format.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 083c3a8f02f..4e42bab5618 100644..100755
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -543,6 +543,8 @@ template <> struct MappingTraits<FormatStyle> {
Style.SpacesInCStyleCastParentheses);
IO.mapOptional("SpacesInParentheses", Style.SpacesInParentheses);
IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
+ IO.mapOptional("SpaceBeforeSquareBrackets",
+ Style.SpaceBeforeSquareBrackets);
IO.mapOptional("Standard", Style.Standard);
IO.mapOptional("StatementMacros", Style.StatementMacros);
IO.mapOptional("TabWidth", Style.TabWidth);
@@ -813,6 +815,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true;
LLVMStyle.SpaceBeforeAssignmentOperators = true;
LLVMStyle.SpaceBeforeCpp11BracedList = false;
+ LLVMStyle.SpaceBeforeSquareBrackets = false;
LLVMStyle.SpacesInAngles = false;
LLVMStyle.PenaltyBreakAssignment = prec::Assignment;
@@ -1354,10 +1357,11 @@ public:
WhitespaceManager Whitespaces(
Env.getSourceManager(), Style,
- Style.DeriveLineEnding ?
- inputUsesCRLF(Env.getSourceManager().getBufferData(Env.getFileID()),
- Style.UseCRLF) :
- Style.UseCRLF);
+ Style.DeriveLineEnding
+ ? inputUsesCRLF(
+ Env.getSourceManager().getBufferData(Env.getFileID()),
+ Style.UseCRLF)
+ : Style.UseCRLF);
ContinuationIndenter Indenter(Style, Tokens.getKeywords(),
Env.getSourceManager(), Whitespaces, Encoding,
BinPackInconclusiveFunctions);
OpenPOWER on IntegriCloud