Skip to content

Commit

Permalink
[clangd][NFC] Use the existing ASTContext from scope
Browse files Browse the repository at this point in the history
  • Loading branch information
kadircet committed Jun 15, 2022
1 parent 7212977 commit 0473530
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions clang-tools-extra/clangd/Hover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 0473530

Please sign in to comment.