[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 8 05:42:57 PDT 2022


aaron.ballman accepted this revision.
aaron.ballman added a comment.

I only spotted one thing I think is actually an issue, the rest is style related. LGTM with the one issue fixed.



================
Comment at: clang/lib/Lex/Lexer.cpp:2707-2709
+        if (!isASCII(C)) {
+          goto MultiByteUTF8;
+        }
----------------



================
Comment at: clang/lib/Lex/Lexer.cpp:2754
 #else
-      // Scan for '/' quickly.  Many block comments are very large.
-      while (CurPtr[0] != '/' &&
-             CurPtr[1] != '/' &&
-             CurPtr[2] != '/' &&
-             CurPtr[3] != '/' &&
-             CurPtr+4 < BufferEnd) {
-        CurPtr += 4;
+      while (CurPtr + 16 <= BufferEnd) {
+        bool HasNonASCII = false;
----------------
`<` instead of `<=`?


================
Comment at: clang/lib/Lex/Lexer.cpp:2756-2758
+        for (unsigned I = 0; I < 16; ++I) {
+          HasNonASCII |= !isASCII(CurPtr[I]);
+        }
----------------



================
Comment at: clang/lib/Lex/Lexer.cpp:2764-2766
+        for (unsigned I = 0; I < 16; ++I) {
+          HasSlash |= CurPtr[I] == '/';
+        }
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059



More information about the cfe-commits mailing list