[PATCH] D124238: [AST] QualifiedTemplateName::getTemplateDecl cleanup.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 22 05:28:36 PDT 2022


hokein updated this revision to Diff 424446.
hokein marked 2 inline comments as done.
hokein added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124238/new/

https://reviews.llvm.org/D124238

Files:
  clang/include/clang/AST/TemplateName.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/TemplateName.cpp
  clang/lib/Sema/TreeTransform.h
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===================================================================
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1443,6 +1443,7 @@
   switch (Name.getKind()) {
   case TemplateName::Template:
   case TemplateName::UsingTemplate:
+  case TemplateName::QualifiedTemplate: // FIXME: Visit nested-name-specifier.
     return Visit(MakeCursorTemplateRef(Name.getAsTemplateDecl(), Loc, TU));
 
   case TemplateName::OverloadedTemplate:
@@ -1460,11 +1461,6 @@
     // FIXME: Visit nested-name-specifier.
     return false;
 
-  case TemplateName::QualifiedTemplate:
-    // FIXME: Visit nested-name-specifier.
-    return Visit(MakeCursorTemplateRef(
-        Name.getAsQualifiedTemplateName()->getTemplateDecl(), Loc, TU));
-
   case TemplateName::SubstTemplateTemplateParm:
     return Visit(MakeCursorTemplateRef(
         Name.getAsSubstTemplateTemplateParm()->getParameter(), Loc, TU));
Index: clang/lib/Sema/TreeTransform.h
===================================================================
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -4280,7 +4280,7 @@
                                               NamedDecl *FirstQualifierInScope,
                                               bool AllowInjectedClassName) {
   if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) {
-    TemplateDecl *Template = QTN->getTemplateDecl();
+    TemplateDecl *Template = QTN->getUnderlyingTemplate().getAsTemplateDecl();
     assert(Template && "qualified template name must refer to a template");
 
     TemplateDecl *TransTemplate
Index: clang/lib/AST/TemplateName.cpp
===================================================================
--- clang/lib/AST/TemplateName.cpp
+++ clang/lib/AST/TemplateName.cpp
@@ -115,7 +115,7 @@
   }
 
   if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName())
-    return QTN->getTemplateDecl();
+    return QTN->getUnderlyingTemplate().getAsTemplateDecl();
 
   if (SubstTemplateTemplateParmStorage *sub = getAsSubstTemplateTemplateParm())
     return sub->getReplacement().getAsTemplateDecl();
@@ -273,14 +273,15 @@
     if (Qual == Qualified::Fully &&
         getDependence() !=
             TemplateNameDependenceScope::DependentInstantiation) {
-      QTN->getTemplateDecl()->printQualifiedName(OS, Policy);
+      QTN->getUnderlyingTemplate().getAsTemplateDecl()->printQualifiedName(
+          OS, Policy);
       return;
     }
     if (Qual == Qualified::AsWritten)
       QTN->getQualifier()->print(OS, Policy);
     if (QTN->hasTemplateKeyword())
       OS << "template ";
-    OS << *QTN->getTemplateDecl();
+    OS << *QTN->getUnderlyingTemplate().getAsTemplateDecl();
   } else if (DependentTemplateName *DTN = getAsDependentTemplateName()) {
     if (Qual == Qualified::AsWritten && DTN->getQualifier())
       DTN->getQualifier()->print(OS, Policy);
Index: clang/lib/AST/ItaniumMangle.cpp
===================================================================
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -2204,9 +2204,6 @@
 
   switch (TN.getKind()) {
   case TemplateName::QualifiedTemplate:
-    TD = TN.getAsQualifiedTemplateName()->getTemplateDecl();
-    goto HaveDecl;
-
   case TemplateName::UsingTemplate:
   case TemplateName::Template:
     TD = TN.getAsTemplateDecl();
Index: clang/include/clang/AST/TemplateName.h
===================================================================
--- clang/include/clang/AST/TemplateName.h
+++ clang/include/clang/AST/TemplateName.h
@@ -439,13 +439,6 @@
   /// Return the underlying template name.
   TemplateName getUnderlyingTemplate() const { return UnderlyingTemplate; }
 
-  /// The template declaration to which this qualified name
-  /// refers.
-  /// FIXME: remove this and use getUnderlyingTemplate() instead.
-  TemplateDecl *getTemplateDecl() const {
-    return UnderlyingTemplate.getAsTemplateDecl();
-  }
-
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, getQualifier(), hasTemplateKeyword(), UnderlyingTemplate);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124238.424446.patch
Type: text/x-patch
Size: 4081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220422/145b4642/attachment-0001.bin>


More information about the cfe-commits mailing list