[clangd] Get rid of lexer usage in AST.cpp

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75193
This commit is contained in:
Kadir Cetinkaya 2020-02-26 18:22:27 +01:00
parent 1aab055dd8
commit f31fc1043d
No known key found for this signature in database
GPG Key ID: E39E36B8D2057ED6
2 changed files with 1 additions and 11 deletions

View File

@ -25,7 +25,6 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Specifiers.h"
#include "clang/Index/USRGeneration.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
@ -417,16 +416,8 @@ public:
llvm::Optional<QualType> getDeducedType(ASTContext &ASTCtx,
SourceLocation Loc) {
Token Tok;
// Only try to find a deduced type if the token is auto or decltype.
if (!Loc.isValid() ||
Lexer::getRawToken(Loc, Tok, ASTCtx.getSourceManager(),
ASTCtx.getLangOpts(), false) ||
!Tok.is(tok::raw_identifier) ||
!(Tok.getRawIdentifier() == "auto" ||
Tok.getRawIdentifier() == "decltype")) {
if (!Loc.isValid())
return {};
}
DeducedTypeVisitor V(Loc);
V.TraverseAST(ASTCtx);
if (V.DeducedType.isNull())

View File

@ -109,7 +109,6 @@ NestedNameSpecifierLoc getQualifierLoc(const NamedDecl &ND);
QualType declaredType(const TypeDecl *D);
/// Retrieves the deduced type at a given location (auto, decltype).
/// Retuns None unless Loc starts an auto/decltype token.
/// It will return the underlying type.
llvm::Optional<QualType> getDeducedType(ASTContext &, SourceLocation Loc);