[clangd][NFC] Use the existing ASTContext from scope

This commit is contained in:
Kadir Cetinkaya 2022-06-15 16:10:19 +02:00
parent 7212977fbb
commit 0473530281
No known key found for this signature in database
GPG key ID: E39E36B8D2057ED6

View file

@ -578,7 +578,7 @@ HoverInfo getHoverContents(const NamedDecl *D, const PrintingPolicy &PP,
const SymbolIndex *Index,
const syntax::TokenBuffer &TB) {
HoverInfo HI;
const ASTContext &Ctx = D->getASTContext();
auto &Ctx = D->getASTContext();
HI.AccessSpecifier = getAccessSpelling(D->getAccess()).str();
HI.NamespaceScope = getNamespaceScope(D);
@ -614,20 +614,17 @@ HoverInfo getHoverContents(const NamedDecl *D, const PrintingPolicy &PP,
if (const FunctionDecl *FD = getUnderlyingFunction(D))
fillFunctionTypeAndParams(HI, D, FD, PP);
else if (const auto *VD = dyn_cast<ValueDecl>(D))
HI.Type = printType(VD->getType(), VD->getASTContext(), PP);
HI.Type = printType(VD->getType(), Ctx, PP);
else if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D))
HI.Type = TTP->wasDeclaredWithTypename() ? "typename" : "class";
else if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(D))
HI.Type = printType(TTP, PP);
else if (const auto *VT = dyn_cast<VarTemplateDecl>(D))
HI.Type =
printType(VT->getTemplatedDecl()->getType(), VT->getASTContext(), PP);
HI.Type = printType(VT->getTemplatedDecl()->getType(), Ctx, PP);
else if (const auto *TN = dyn_cast<TypedefNameDecl>(D))
HI.Type = printType(TN->getUnderlyingType().getDesugaredType(Ctx),
TN->getASTContext(), PP);
HI.Type = printType(TN->getUnderlyingType().getDesugaredType(Ctx), Ctx, PP);
else if (const auto *TAT = dyn_cast<TypeAliasTemplateDecl>(D))
HI.Type = printType(TAT->getTemplatedDecl()->getUnderlyingType(),
TAT->getASTContext(), PP);
HI.Type = printType(TAT->getTemplatedDecl()->getUnderlyingType(), Ctx, PP);
// Fill in value with evaluated initializer if possible.
if (const auto *Var = dyn_cast<VarDecl>(D)) {