summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-12-12 09:49:52 +0000
committerAlexander Kornienko <alexfh@google.com>2013-12-12 09:49:52 +0000
commit3a33f0292bcadc2eaf980ec7581dbe260f0e092b (patch)
tree05922d09cc643457235fb3203c2d84f3cd999fc2 /clang/lib/Format/Format.cpp
parenta92e2311bb1345c60f6c90180028b8adf252897c (diff)
downloadbcm5719-llvm-3a33f0292bcadc2eaf980ec7581dbe260f0e092b.tar.gz
bcm5719-llvm-3a33f0292bcadc2eaf980ec7581dbe260f0e092b.zip
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 llvm-svn: 197138
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 808e64db915..87c2fd70aee 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/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 ||
OpenPOWER on IntegriCloud