[PATCH] D13765: clang-format: [JS] Handle string literals spanning character classes.

Martin Probst via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 16 16:29:24 PDT 2015


mprobst added inline comments.

================
Comment at: lib/Format/Format.cpp:858
@@ +857,3 @@
+    }
+    if (Prev) {
+      if (Prev->isOneOf(tok::plus, tok::plusplus, tok::minus,
----------------
djasper wrote:
> I'd probably put this into the other two conditions to reduce indentation. More specifically, I'd do:
> 
>   if (PrecedesOperand(Prev)) // sink the nullptr check into the function.
>     return;
> 
>   if (Prev->isOneOf(...)) {
>   }
Not having a `Prev` is actually part of the `true` case (no token/start of file precedes an operand), i.e. if nothing precedes the slash, it must be a regexp, too. Given that, both of the nested checks only run `if (Prev)`, so I think the nesting makes sense.

However it turns out my unary check was slightly off and untested (whoops). Added a test and fixed the code.


http://reviews.llvm.org/D13765





More information about the cfe-commits mailing list