summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorFrancois Ferrand <thetypz@gmail.com>2018-06-11 14:41:26 +0000
committerFrancois Ferrand <thetypz@gmail.com>2018-06-11 14:41:26 +0000
commit6bb103f9facf48253b3a29c37d8870e7abaa7ff5 (patch)
tree50f10c5216e474a55ddbd1b6cb6d51ba477856ef /clang/lib/Format/Format.cpp
parent7db69cc08aef49192ea86d4fc0fe7210ad2b5e50 (diff)
downloadbcm5719-llvm-6bb103f9facf48253b3a29c37d8870e7abaa7ff5.tar.gz
bcm5719-llvm-6bb103f9facf48253b3a29c37d8870e7abaa7ff5.zip
clang-format: Introduce BreakInheritanceList option
Summary: This option replaces the BreakBeforeInheritanceComma option with an enum, thus introducing a mode where the colon stays on the same line as constructor declaration: // When it fits on line: class A : public B, public C { ... }; // When it does not fit: class A : public B, public C { ... }; This matches the behavior of the `BreakConstructorInitializers` option, introduced in https://reviews.llvm.org/D32479. Reviewers: djasper, klimek Reviewed By: djasper Subscribers: mzeren-vmw, cfe-commits Differential Revision: https://reviews.llvm.org/D43015 llvm-svn: 334408
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index d1a5dc8e6c6..7e62d1596c8 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -149,6 +149,16 @@ struct ScalarEnumerationTraits<FormatStyle::BreakConstructorInitializersStyle> {
};
template <>
+struct ScalarEnumerationTraits<FormatStyle::BreakInheritanceListStyle> {
+ static void
+ enumeration(IO &IO, FormatStyle::BreakInheritanceListStyle &Value) {
+ IO.enumCase(Value, "BeforeColon", FormatStyle::BILS_BeforeColon);
+ IO.enumCase(Value, "BeforeComma", FormatStyle::BILS_BeforeComma);
+ IO.enumCase(Value, "AfterColon", FormatStyle::BILS_AfterColon);
+ }
+};
+
+template <>
struct ScalarEnumerationTraits<FormatStyle::PPDirectiveIndentStyle> {
static void enumeration(IO &IO, FormatStyle::PPDirectiveIndentStyle &Value) {
IO.enumCase(Value, "None", FormatStyle::PPDIS_None);
@@ -350,8 +360,19 @@ template <> struct MappingTraits<FormatStyle> {
IO.mapOptional("BreakBeforeBinaryOperators",
Style.BreakBeforeBinaryOperators);
IO.mapOptional("BreakBeforeBraces", Style.BreakBeforeBraces);
+
+ bool BreakBeforeInheritanceComma = false;
IO.mapOptional("BreakBeforeInheritanceComma",
- Style.BreakBeforeInheritanceComma);
+ BreakBeforeInheritanceComma);
+ IO.mapOptional("BreakInheritanceList",
+ Style.BreakInheritanceList);
+ // If BreakBeforeInheritanceComma was specified but
+ // BreakInheritance was not, initialize the latter from the
+ // former for backwards compatibility.
+ if (BreakBeforeInheritanceComma &&
+ Style.BreakInheritanceList == FormatStyle::BILS_BeforeColon)
+ Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
+
IO.mapOptional("BreakBeforeTernaryOperators",
Style.BreakBeforeTernaryOperators);
@@ -624,7 +645,7 @@ FormatStyle getLLVMStyle() {
false, false, true, true, true};
LLVMStyle.BreakAfterJavaFieldAnnotations = false;
LLVMStyle.BreakConstructorInitializers = FormatStyle::BCIS_BeforeColon;
- LLVMStyle.BreakBeforeInheritanceComma = false;
+ LLVMStyle.BreakInheritanceList = FormatStyle::BILS_BeforeColon;
LLVMStyle.BreakStringLiterals = true;
LLVMStyle.ColumnLimit = 80;
LLVMStyle.CommentPragmas = "^ IWYU pragma:";
@@ -840,7 +861,7 @@ FormatStyle getMozillaStyle() {
MozillaStyle.BinPackArguments = false;
MozillaStyle.BreakBeforeBraces = FormatStyle::BS_Mozilla;
MozillaStyle.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
- MozillaStyle.BreakBeforeInheritanceComma = true;
+ MozillaStyle.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
MozillaStyle.ConstructorInitializerIndentWidth = 2;
MozillaStyle.ContinuationIndentWidth = 2;
MozillaStyle.Cpp11BracedListStyle = false;
OpenPOWER on IntegriCloud