krasimir updated this revision to Diff 272966. krasimir added a comment. - try to update Phabricator diff
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82199/new/ https://reviews.llvm.org/D82199 Files: clang/lib/Format/ContinuationIndenter.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -6281,6 +6281,17 @@ " : bbbbbbbbbbbbbbbbbbbbbbb ? 2222222222222222\n" " : 3333333333333333;", Style); + + Style.AlignOperands = FormatStyle::OAS_DontAlign; + Style.BreakBeforeTernaryOperators = false; + // FIXME: Aligning the question marks is weird given DontAlign. + // Consider disabling this alignment in this case. Also check whether this + // will render the adjustment from https://reviews.llvm.org/D82199 + // unnecessary. + verifyFormat("int x = aaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaa :\n" + " bbbb ? cccccccccccccccccc :\n" + " ddddd;\n", + Style); } TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) { Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -1041,8 +1041,10 @@ // * not remove the 'lead' ContinuationIndentWidth // * always un-indent by the operator when // BreakBeforeTernaryOperators=true - unsigned Indent = - State.Stack.back().Indent - Style.ContinuationIndentWidth; + unsigned Indent = State.Stack.back().Indent; + if (Style.AlignOperands != FormatStyle::OAS_DontAlign) { + Indent -= Style.ContinuationIndentWidth; + } if (Style.BreakBeforeTernaryOperators && State.Stack.back().UnindentOperator) Indent -= 2;
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -6281,6 +6281,17 @@ " : bbbbbbbbbbbbbbbbbbbbbbb ? 2222222222222222\n" " : 3333333333333333;", Style); + + Style.AlignOperands = FormatStyle::OAS_DontAlign; + Style.BreakBeforeTernaryOperators = false; + // FIXME: Aligning the question marks is weird given DontAlign. + // Consider disabling this alignment in this case. Also check whether this + // will render the adjustment from https://reviews.llvm.org/D82199 + // unnecessary. + verifyFormat("int x = aaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaa :\n" + " bbbb ? cccccccccccccccccc :\n" + " ddddd;\n", + Style); } TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) { Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -1041,8 +1041,10 @@ // * not remove the 'lead' ContinuationIndentWidth // * always un-indent by the operator when // BreakBeforeTernaryOperators=true - unsigned Indent = - State.Stack.back().Indent - Style.ContinuationIndentWidth; + unsigned Indent = State.Stack.back().Indent; + if (Style.AlignOperands != FormatStyle::OAS_DontAlign) { + Indent -= Style.ContinuationIndentWidth; + } if (Style.BreakBeforeTernaryOperators && State.Stack.back().UnindentOperator) Indent -= 2;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits