[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

Yancheng Zheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 17 11:53:24 PST 2020


AnakinZheng updated this revision to Diff 245021.
AnakinZheng added a comment.

Fix the previous stupid mistake.


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

https://reviews.llvm.org/D74731

Files:
  clang-tools-extra/clangd/SourceCode.cpp


Index: clang-tools-extra/clangd/SourceCode.cpp
===================================================================
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -58,8 +58,8 @@
   // A codepoint takes two UTF-16 code unit if it's astral (outside BMP).
   // Astral codepoints are encoded as 4 bytes in UTF-8, starting with 11110xxx.
   for (size_t I = 0; I < U8.size();) {
-    unsigned char C = static_cast<unsigned char>(U8[I]);
-    if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
+    unsigned short C = static_cast<unsigned short>(U8[I]);
+    if (LLVM_LIKELY(C <= 255)) { // ASCII or extended ASCII character.
       if (CB(1, 1))
         return true;
       ++I;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74731.245021.patch
Type: text/x-patch
Size: 738 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200217/d6036bb5/attachment.bin>


More information about the cfe-commits mailing list