diff options
| -rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 2 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 5 |
3 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index ff1f1aa8534..3714088306c 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -278,9 +278,10 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, // simple assignment without binary expression on the RHS. Also indent // relative to unary operators and the colons of constructor initializers. State.Stack.back().LastSpace = State.Column; - else if (Previous.Type == TT_InheritanceColon) + else if (Previous.Type == TT_InheritanceColon) { State.Stack.back().Indent = State.Column; - else if (Previous.opensScope()) { + State.Stack.back().LastSpace = State.Column; + } else if (Previous.opensScope()) { // If a function has a trailing call, indent all parameters from the // opening parenthesis. This avoids confusing indents like: // OuterFunction(InnerFunctionCall( // break diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 0e06d3b651c..823235e602c 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -335,7 +335,7 @@ private: Contexts.back().FirstObjCSelectorName = Tok->Previous; } else if (Contexts.back().ColonIsForRangeExpr) { Tok->Type = TT_RangeBasedForLoopColon; - } else if (Contexts.size() == 1) { + } else if (Contexts.size() == 1 && Line.First->isNot(tok::kw_enum)) { Tok->Type = TT_InheritanceColon; } else if (Contexts.back().ContextKind == tok::l_paren) { Tok->Type = TT_InlineASMColon; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 1916076ca08..4a51448f335 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1530,6 +1530,11 @@ TEST_F(FormatTest, FormatsClasses) { " int i;\n" "};", getLLVMStyleWithColumns(32)); + verifyFormat("struct aaaaaaaaaaaaa : public aaaaaaaaaaaaaaaaaaa< // break\n" + " aaaaaaaaaaaaaaaa> {};"); + verifyFormat("struct aaaaaaaaaaaaaaaaaaaa\n" + " : public aaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaa,\n" + " aaaaaaaaaaaaaaaaaaaaaa> {};"); } TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) { |

