From: John McCall Date: Tue, 24 Nov 2009 18:42:40 +0000 (+0000) Subject: Helper function for turning a TemplateName into a DeclarationName. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80ad16f4b2b350ddbaae21a52975e63df5aafc2c;p=clang Helper function for turning a TemplateName into a DeclarationName. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89782 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 2e2e298ec4..e265245782 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -733,6 +733,8 @@ public: return getExtQualType(T, Qs); } + DeclarationName getNameForTemplate(TemplateName Name); + TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template); diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index dd9fce90e0..639e8f8b9e 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -2342,6 +2342,22 @@ CanQualType ASTContext::getCanonicalType(QualType T) { VAT->getBracketsRange())); } +DeclarationName ASTContext::getNameForTemplate(TemplateName Name) { + if (TemplateDecl *TD = Name.getAsTemplateDecl()) + return TD->getDeclName(); + + if (DependentTemplateName *DTN = Name.getAsDependentTemplateName()) { + if (DTN->isIdentifier()) { + return DeclarationNames.getIdentifier(DTN->getIdentifier()); + } else { + return DeclarationNames.getCXXOperatorName(DTN->getOperator()); + } + } + + assert(Name.getAsOverloadedFunctionDecl()); + return Name.getAsOverloadedFunctionDecl()->getDeclName(); +} + TemplateName ASTContext::getCanonicalTemplateName(TemplateName Name) { // If this template name refers to a template, the canonical // template name merely stores the template itself.