[PATCH] D90949: [clang-format] avoid introducing multiline comments

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 9 02:20:29 PST 2020


krasimir added inline comments.


================
Comment at: clang/lib/Format/BreakableToken.cpp:109
+    // after '\'.
+    if (Style.isCpp()) {
+      StringRef::size_type LastNonBlank =
----------------
sammccall wrote:
> Do we really want to predicate this on isCpp()? `//` comments are allowed by C99.
> Even if the warning only applies to C++ for some reason, the reasons for confusion do not.
I think in Java and other non-C++-y languages, an `\` at the end of a line-comment line does not have any special meaning, hence I didn't want it to trigger in those cases.


================
Comment at: clang/lib/Format/BreakableToken.cpp:125
     else
       break;
   }
----------------
sammccall wrote:
> doesn't this mean that we won't loop? if Text ends with "blah \ \" then you'll split between "blah" and the first "\"?
> 
> I guess this could be structured:
> 
> ```
> while () {
>   if (special case 1) {
>     // adjust pos
>     continue;
>   }
>   if (special case 2) {
>     // adjust pos
>     continue;
>   }
>   break;
> }
> ```
> 
> (This is equivalent to the old if/elseif/break which is too hard to add complex conditions to)
Thank you! Updated this block and added a test case for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90949



More information about the cfe-commits mailing list