[PATCH] D124748: [clang-format] Fix whitespace counting stuff

sstwcw via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun May 15 06:00:52 PDT 2022


sstwcw marked 8 inline comments as done.
sstwcw added a comment.

This patch is not NFC.  But there would not be change in behavior if the
input is valid C as far as I know.

  input:
  #define LIST \
  `ENTRY \
  `ENTRY
  output before, note extra line:
  #define LIST                                                                   \
                                                                                 \
    `ENTRY \
  `ENTRY
  output after:
  #define LIST \
  `ENTRY \
  `ENTRY

I don't know how I would add a test for this.

The tests in D124749 <https://reviews.llvm.org/D124749> depend on this though.



================
Comment at: clang/lib/Format/FormatTokenLexer.cpp:839
 
+void FormatTokenLexer::resizeToken(size_t NewLen) {
+  resetLexer(SourceMgr.getFileOffset(Lex->getSourceLocation(
----------------
HazardyKnusperkeks wrote:
> Can you add some documentation?
Is this comment enough?


================
Comment at: clang/lib/Format/FormatTokenLexer.cpp:923-924
+      case '\r':
+        if (i + 1 < e && Text[i + 1] == '\n')
+          break;
+        LLVM_FALLTHROUGH;
----------------
owenpan wrote:
> `\r\n` is a newline on Windows.
I added a comment to make it clear the code is correct.


================
Comment at: clang/lib/Format/FormatTokenLexer.cpp:946-948
+      case '?':
+      case '/':
+        InEscape = true;
----------------
owenpan wrote:
> Don't you need to look ahead for a `??/`?
It has to be `??/`.  Now there's an assertion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124748



More information about the cfe-commits mailing list