[PATCH] D50078: clang-format: support aligned nested conditionals formatting

Francois Ferrand via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 24 06:39:05 PDT 2019


Typz added inline comments.


================
Comment at: clang/unittests/Format/FormatTest.cpp:5739
+               "                  ? ccccccccccccccc\n"
+               "                  : ddddddddddddddd;");
   verifyFormat("bool aaaaaa = aaaaaaaaaaaaa //\n"
----------------
MyDeveloperDay wrote:
> Nit: I'm just slightly confused as to what is happening here.. I assume this is the case where they are not aligned in the style. 
Ternary operator do indeed get aligned, thus :
* the "tests" (on first and third lines) get aligned
* the "results" do not fit on the line, thus get further wrapped


================
Comment at: clang/unittests/Format/FormatTest.cpp:5998
+               "                  ddddddddddddddd;",
                Style);
   verifyFormat("bool aaaaaa = aaaaaaaaaaaaa ? //\n"
----------------
MyDeveloperDay wrote:
> as above how does one get back to the original case?
I tried this quite a bit, but could not find a reliable way to "skip" the ternary operator alignment when result operand get wrapped.
If you have an idea/hint how to do this, I'd be glad to give a try...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50078/new/

https://reviews.llvm.org/D50078





More information about the cfe-commits mailing list