diff options
author | Manuel Klimek <klimek@google.com> | 2013-06-21 17:25:42 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2013-06-21 17:25:42 +0000 |
commit | 836c2868f9bc4536203655e7d88769b199f96ade (patch) | |
tree | 68066ba028709412e5590b05a068d53010bbcfa1 /clang/lib/Format/Format.cpp | |
parent | 72a54eab3504fc703bc90b32ccf505f26631a31b (diff) | |
download | bcm5719-llvm-836c2868f9bc4536203655e7d88769b199f96ade.tar.gz bcm5719-llvm-836c2868f9bc4536203655e7d88769b199f96ade.zip |
Add an option to not indent declarations when breaking after the type.
Make that option the default for LLVM style.
llvm-svn: 184563
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r-- | clang/lib/Format/Format.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 86437d4c18e..a81f9d05330 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -109,6 +109,8 @@ template <> struct MappingTraits<clang::format::FormatStyle> { IO.mapOptional("IndentWidth", Style.IndentWidth); IO.mapOptional("UseTab", Style.UseTab); IO.mapOptional("BreakBeforeBraces", Style.BreakBeforeBraces); + IO.mapOptional("IndentFunctionDeclarationAfterType", + Style.IndentFunctionDeclarationAfterType); } }; } @@ -143,6 +145,7 @@ FormatStyle getLLVMStyle() { LLVMStyle.IndentWidth = 2; LLVMStyle.UseTab = false; LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach; + LLVMStyle.IndentFunctionDeclarationAfterType = false; return LLVMStyle; } @@ -172,6 +175,7 @@ FormatStyle getGoogleStyle() { GoogleStyle.IndentWidth = 2; GoogleStyle.UseTab = false; GoogleStyle.BreakBeforeBraces = FormatStyle::BS_Attach; + GoogleStyle.IndentFunctionDeclarationAfterType = true; return GoogleStyle; } @@ -524,7 +528,8 @@ private: State.Column = State.Stack.back().VariablePos; } else if (Previous.ClosesTemplateDeclaration || (Current.Type == TT_StartOfName && State.ParenLevel == 0 && - Line.StartsDefinition)) { + (!Style.IndentFunctionDeclarationAfterType || + Line.StartsDefinition))) { State.Column = State.Stack.back().Indent; } else if (Current.Type == TT_ObjCSelectorName) { if (State.Stack.back().ColonPos > Current.CodePointCount) { |