[clang] 864752c - [AST] QualifiedTemplateName::getTemplateDecl cleanup.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 22 05:29:08 PDT 2022
Author: Haojian Wu
Date: 2022-04-22T14:28:48+02:00
New Revision: 864752cfeba445652b6ee0e040da366894a86c88
URL: https://github.com/llvm/llvm-project/commit/864752cfeba445652b6ee0e040da366894a86c88
DIFF: https://github.com/llvm/llvm-project/commit/864752cfeba445652b6ee0e040da366894a86c88.diff
LOG: [AST] QualifiedTemplateName::getTemplateDecl cleanup.
This is a followup cleanup of 1234b1c6d8113d50beef5801be607ad1d502b2f7
Differential Revision: https://reviews.llvm.org/D124238
Added:
Modified:
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
Removed:
################################################################################
diff --git a/clang/include/clang/AST/TemplateName.h b/clang/include/clang/AST/TemplateName.h
index b6f4332830c8f..ca85adac648b5 100644
--- a/clang/include/clang/AST/TemplateName.h
+++ b/clang/include/clang/AST/TemplateName.h
@@ -439,13 +439,6 @@ class QualifiedTemplateName : public llvm::FoldingSetNode {
/// 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);
}
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index adab764487c7b..75f072168858b 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2204,9 +2204,6 @@ void CXXNameMangler::mangleType(TemplateName TN) {
switch (TN.getKind()) {
case TemplateName::QualifiedTemplate:
- TD = TN.getAsQualifiedTemplateName()->getTemplateDecl();
- goto HaveDecl;
-
case TemplateName::UsingTemplate:
case TemplateName::Template:
TD = TN.getAsTemplateDecl();
diff --git a/clang/lib/AST/TemplateName.cpp b/clang/lib/AST/TemplateName.cpp
index 8e32c9c6a6ad7..f0f64cd5a5168 100644
--- a/clang/lib/AST/TemplateName.cpp
+++ b/clang/lib/AST/TemplateName.cpp
@@ -115,7 +115,7 @@ TemplateDecl *TemplateName::getAsTemplateDecl() const {
}
if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName())
- return QTN->getTemplateDecl();
+ return QTN->getUnderlyingTemplate().getAsTemplateDecl();
if (SubstTemplateTemplateParmStorage *sub = getAsSubstTemplateTemplateParm())
return sub->getReplacement().getAsTemplateDecl();
@@ -273,14 +273,15 @@ void TemplateName::print(raw_ostream &OS, const PrintingPolicy &Policy,
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);
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 282163cf4c923..aef757efc9e71 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -4280,7 +4280,7 @@ TreeTransform<Derived>::TransformTemplateName(CXXScopeSpec &SS,
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
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index fc6177036b08a..6df673fec4ada 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -1443,6 +1443,7 @@ bool CursorVisitor::VisitTemplateName(TemplateName Name, SourceLocation Loc) {
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 @@ bool CursorVisitor::VisitTemplateName(TemplateName Name, SourceLocation Loc) {
// 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));
More information about the cfe-commits
mailing list