[PATCH] D46258: [clangd] Also use UTF-16 in index position.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 30 03:13:21 PDT 2018


hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: jkorous, MaskRay, ioeric, ilya-biryukov, klimek.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46258

Files:
  clangd/index/SymbolCollector.cpp


Index: clangd/index/SymbolCollector.cpp
===================================================================
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -195,14 +195,10 @@
   auto TokenLength = clang::Lexer::MeasureTokenLength(NameLoc, SM, LangOpts);
 
   auto CreatePosition = [&SM](SourceLocation Loc) {
-    auto FileIdAndOffset = SM.getDecomposedLoc(Loc);
-    auto FileId = FileIdAndOffset.first;
-    auto Offset = FileIdAndOffset.second;
+    auto LSPLoc = sourceLocToPosition(SM, Loc);
     SymbolLocation::Position Pos;
-    // Position is 0-based while SourceManager is 1-based.
-    Pos.Line = SM.getLineNumber(FileId, Offset) - 1;
-    // FIXME: Use UTF-16 code units, not UTF-8 bytes.
-    Pos.Column = SM.getColumnNumber(FileId, Offset) - 1;
+    Pos.Line = LSPLoc.line;
+    Pos.Column = LSPLoc.character;
     return Pos;
   };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46258.144526.patch
Type: text/x-patch
Size: 878 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180430/841c17ed/attachment.bin>


More information about the cfe-commits mailing list