[cfe-commits] r89782 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp

John McCall rjmccall at apple.com
Tue Nov 24 10:42:40 PST 2009


Author: rjmccall
Date: Tue Nov 24 12:42:40 2009
New Revision: 89782

URL: http://llvm.org/viewvc/llvm-project?rev=89782&view=rev
Log:
Helper function for turning a TemplateName into a DeclarationName.


Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=89782&r1=89781&r2=89782&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Nov 24 12:42:40 2009
@@ -733,6 +733,8 @@
     return getExtQualType(T, Qs);
   }
 
+  DeclarationName getNameForTemplate(TemplateName Name);
+
   TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS,
                                         bool TemplateKeyword,
                                         TemplateDecl *Template);

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=89782&r1=89781&r2=89782&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Nov 24 12:42:40 2009
@@ -2342,6 +2342,22 @@
                                                      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.





More information about the cfe-commits mailing list