[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 10:31:09 PST 2020


AnakinZheng created this revision.
AnakinZheng added reviewers: kadircet, sammccall.
AnakinZheng added a project: clang.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov.

Previously this piece of code asserts when processing extended ASCII. Proposing a fix to extend the ascii handling code to take extended ascii as well.


Repository:
  rG LLVM Github Monorepo

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
@@ -59,7 +59,7 @@
   // 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 & 0x80))) { // ASCII character.
+    if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
       if (CB(1, 1))
         return true;
       ++I;


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


More information about the cfe-commits mailing list