[PATCH] D74844: [clangd] Get rid of Lexer usage in CodeComplete

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 19 09:03:04 PST 2020


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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74844

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


Index: clang-tools-extra/clangd/CodeComplete.cpp
===================================================================
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -52,6 +52,7 @@
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/Sema.h"
+#include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
@@ -588,9 +589,10 @@
 
   // Case 4: There was a qualifier, and Sema didn't resolve it.
   Scopes.AccessibleScopes.push_back(""); // Make sure global scope is included.
-  llvm::StringRef SpelledSpecifier = Lexer::getSourceText(
-      CharSourceRange::getCharRange(SemaSpecifier->getRange()),
-      CCSema.SourceMgr, clang::LangOptions());
+  llvm::StringRef SpelledSpecifier =
+      syntax::FileRange(CCSema.SourceMgr, SemaSpecifier->getBeginLoc(),
+                        SemaSpecifier->getEndLoc())
+          .text(CCSema.SourceMgr);
   if (SpelledSpecifier.consume_front("::"))
     Scopes.AccessibleScopes = {""};
   Scopes.UnresolvedQualifier = std::string(SpelledSpecifier);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74844.245432.patch
Type: text/x-patch
Size: 1158 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200219/1d239e88/attachment.bin>


More information about the cfe-commits mailing list