diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index a8e2c5556a8..c83ec604758 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1174,6 +1174,9 @@ private: } void parseConditionalExpr() { + while (Current && Current->isTrailingComment()) { + next(); + } FormatToken *Start = Current; parse(prec::LogicalOr); if (!Current || !Current->is(tok::question)) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index b195df4291c..aebfef6fbea 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4060,6 +4060,12 @@ TEST_F(FormatTest, BreaksConditionalExpressions) { " ?: aaaaaaaaaaaaaaa);\n" "}", NoBinPacking); + + verifyFormat("SomeFunction(aaaaaaaaaaaaaaaaa,\n" + " // comment.\n" + " ccccccccccccccccccccccccccccccccccccccc\n" + " ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + " : bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);"); } TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) { |

