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

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 6 11:48:03 PST 2021


HazardyKnusperkeks added inline comments.


================
Comment at: clang/lib/Format/Format.cpp:2598
+    // Skip past until we think we we the rawstring literal close.
+    if (Trimmed.contains("R\"(")) {
+      FormattingOff = true;
----------------
curdeius wrote:
> HazardyKnusperkeks wrote:
> > curdeius wrote:
> > > This won't be enough for raw literals with custom delimiter e.g. `R"xyz(...)xyz"`.
> > > But well, without any code parsing, this function will always be easily outsmarted I guess.
> > > Maybe we can use regexp here and save the delimiter? (And then check it below)
> > And then we need to check first for closing, since we can close and reopen on the same line, or not?
> It's done below anyway (i.e. `Trimmed` is still the same line), nope?
Yes but if we save the delimiter we will save the new one, before checking for the old one to close.
I was just thinking we must close the old one correctly before "opening" the new one. But after rethinking about it, that shouldn't matter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115168



More information about the cfe-commits mailing list