[cfe-commits] r82250 - /cfe/trunk/lib/CodeGen/Mangle.cpp

Anders Carlsson andersca at mac.com
Fri Sep 18 12:00:19 PDT 2009


Author: andersca
Date: Fri Sep 18 14:00:18 2009
New Revision: 82250

URL: http://llvm.org/viewvc/llvm-project?rev=82250&view=rev
Log:
More mangler mangling.

Modified:
    cfe/trunk/lib/CodeGen/Mangle.cpp

Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=82250&r1=82249&r2=82250&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Fri Sep 18 14:00:18 2009
@@ -252,6 +252,21 @@
   return NS->getOriginalNamespace()->getIdentifier()->isStr("std");
 }
 
+static const NamedDecl *isTemplate(const NamedDecl *ND, 
+                                   const TemplateArgumentList *&TemplateArgs) {
+  // Check if we have a function template.
+  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)){
+    if (FD->getPrimaryTemplate()) {
+      TemplateArgs = FD->getTemplateSpecializationArgs();
+      return FD;
+    }
+  }
+
+  // FIXME: Check if we have a class template.
+
+  return 0;
+}
+
 void CXXNameMangler::mangleName(const NamedDecl *ND) {
   //  <name> ::= <nested-name>
   //         ::= <unscoped-name>
@@ -266,16 +281,14 @@
   }
   
   if (DC->isTranslationUnit() || isStdNamespace(DC)) {
-    // Check if we have a function template.
-    if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)){
-      if (FD->getPrimaryTemplate()) {
-        mangleUnscopedTemplateName(FD);
-        mangleTemplateArgumentList(*FD->getTemplateSpecializationArgs());
-        return;
-      }
+    // Check if we have a template.
+    const TemplateArgumentList *TemplateArgs = 0;
+    if (const NamedDecl *TD = isTemplate(ND, TemplateArgs)) {
+      mangleUnscopedTemplateName(TD);
+      mangleTemplateArgumentList(*TemplateArgs);
+      return;
     }
 
-    // FIXME: Check if we have a class template.
     mangleUnscopedName(ND);
     return;
   }
@@ -446,10 +459,11 @@
   if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND))
     mangleCVQualifiers(Method->getTypeQualifiers());
   
-  const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND);
-  if (FD && FD->getPrimaryTemplate()) {
-    mangleTemplatePrefix(FD);
-    mangleTemplateArgumentList(*FD->getTemplateSpecializationArgs());
+  // Check if we have a template.
+  const TemplateArgumentList *TemplateArgs = 0;
+  if (const NamedDecl *TD = isTemplate(ND, TemplateArgs)) { 
+    mangleTemplatePrefix(TD);
+    mangleTemplateArgumentList(*TemplateArgs);
   } else {
     manglePrefix(ND->getDeclContext());
     mangleUnqualifiedName(ND);





More information about the cfe-commits mailing list