[clang-tools-extra] 0473530 - [clangd][NFC] Use the existing ASTContext from scope

Kadir Cetinkaya via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 15 07:12:54 PDT 2022


Author: Kadir Cetinkaya
Date: 2022-06-15T16:10:49+02:00
New Revision: 04735302814e4df1cf37caeff3406fa5523901eb

URL: https://github.com/llvm/llvm-project/commit/04735302814e4df1cf37caeff3406fa5523901eb
DIFF: https://github.com/llvm/llvm-project/commit/04735302814e4df1cf37caeff3406fa5523901eb.diff

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

Added: 
    

Modified: 
    clang-tools-extra/clangd/Hover.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp
index 07552c5869fa..26eb2574195d 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -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)) {


        


More information about the cfe-commits mailing list