]> granicus.if.org Git - clang/commitdiff
Helper function for turning a TemplateName into a DeclarationName.
authorJohn McCall <rjmccall@apple.com>
Tue, 24 Nov 2009 18:42:40 +0000 (18:42 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 24 Nov 2009 18:42:40 +0000 (18:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89782 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h
lib/AST/ASTContext.cpp

index 2e2e298ec421f6ff9f9e3d70f014907e46fa0e1b..e265245782937beb112d79eea7b100cd03a93edb 100644 (file)
@@ -733,6 +733,8 @@ public:
     return getExtQualType(T, Qs);
   }
 
+  DeclarationName getNameForTemplate(TemplateName Name);
+
   TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS,
                                         bool TemplateKeyword,
                                         TemplateDecl *Template);
index dd9fce90e03313308c0d73e85bfd6b828d6fbc75..639e8f8b9eb89fcaceef7dafcb547d33716b81ad 100644 (file)
@@ -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.