diff options
| author | Alexander Kornienko <alexfh@google.com> | 2013-12-12 09:49:52 +0000 |
|---|---|---|
| committer | Alexander Kornienko <alexfh@google.com> | 2013-12-12 09:49:52 +0000 |
| commit | 293cb1217b7950fb4f073bb6eca0dc7ac72c7baf (patch) | |
| tree | aab8e16a93947046be1e3f5c887fd215f4362e65 /lib/Format/Format.cpp | |
| parent | 1204f96cdb605d5ed575cfb472f66036d6e32cd6 (diff) | |
| download | clang-293cb1217b7950fb4f073bb6eca0dc7ac72c7baf.tar.gz clang-293cb1217b7950fb4f073bb6eca0dc7ac72c7baf.tar.bz2 clang-293cb1217b7950fb4f073bb6eca0dc7ac72c7baf.tar.xz | |
Implemented GNU-style formatting for compound statements.
Summary:
Added BraceBreakingStyle::BS_GNU. I'm not sure about the correctness of
static initializer formatting, but compound statements should be fine.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D2372
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197138 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
| -rw-r--r-- | lib/Format/Format.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 808e64db91..87c2fd70ae 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -68,6 +68,7 @@ template <> struct ScalarEnumerationTraits<FormatStyle::BraceBreakingStyle> { IO.enumCase(Value, "Linux", FormatStyle::BS_Linux); IO.enumCase(Value, "Stroustrup", FormatStyle::BS_Stroustrup); IO.enumCase(Value, "Allman", FormatStyle::BS_Allman); + IO.enumCase(Value, "GNU", FormatStyle::BS_GNU); } }; @@ -359,7 +360,7 @@ FormatStyle getWebKitStyle() { FormatStyle getGNUStyle() { FormatStyle Style = getLLVMStyle(); Style.BreakBeforeBinaryOperators = true; - Style.BreakBeforeBraces = FormatStyle::BS_Allman; + Style.BreakBeforeBraces = FormatStyle::BS_GNU; Style.BreakBeforeTernaryOperators = true; Style.ColumnLimit = 79; Style.SpaceBeforeParens = FormatStyle::SBPO_Always; @@ -561,7 +562,8 @@ private: SmallVectorImpl<AnnotatedLine *>::const_iterator E, unsigned Limit) { if (Limit == 0) return 0; - if (Style.BreakBeforeBraces == FormatStyle::BS_Allman && + if ((Style.BreakBeforeBraces == FormatStyle::BS_Allman || + Style.BreakBeforeBraces == FormatStyle::BS_GNU) && I[1]->First->is(tok::l_brace)) return 0; if (I[1]->InPPDirective != (*I)->InPPDirective || |
