[PATCH] D115168: [clang-format] [PR49298] Sort includes pass will sort inside raw strings

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 8 02:27:51 PST 2021


MyDeveloperDay added inline comments.


================
Comment at: clang/lib/Format/Format.cpp:2605-2607
+      if (!CharSequence.empty()) {
+        RawStringTermination = ")" + CharSequence + "\"";
+      }
----------------
curdeius wrote:
> Since `CharSequence` is empty, you might want to remove the if altogether and create `RawStringTermination` unconditionally.
> 
> Oh, actually, as it's used in the for loop, you *have to* reassign `RawStringTermination`, otherwise the code like:
> ```
> R"x(...
> ...)x"; // RawStringTermination is "x"
> R"(...
> ...); // RawStringTermination would still be "x"
> #include <b.h> // not sorted but it should
> #include <a.h> // not sorted but it should
> ```
> will misbehave.
> Please create a test case for this.
Correct I need to remove the `if`


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

https://reviews.llvm.org/D115168



More information about the cfe-commits mailing list