[cfe-commits] r82193 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle.cpp
Anders Carlsson
andersca at mac.com
Thu Sep 17 21:29:09 PDT 2009
Author: andersca
Date: Thu Sep 17 23:29:09 2009
New Revision: 82193
URL: http://llvm.org/viewvc/llvm-project?rev=82193&view=rev
Log:
More mangling goodness.
Modified:
cfe/trunk/lib/CodeGen/Mangle.cpp
cfe/trunk/test/CodeGenCXX/mangle.cpp
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=82193&r1=82192&r2=82193&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Thu Sep 17 23:29:09 2009
@@ -82,6 +82,7 @@
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs);
void manglePrefix(const DeclContext *DC);
+ void mangleTemplatePrefix(const DeclContext *DC);
void mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity);
void mangleCVQualifiers(unsigned Quals);
void mangleType(QualType T);
@@ -265,17 +266,27 @@
}
if (DC->isTranslationUnit() || isStdNamespace(DC)) {
- const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND);
- if (FD && FD->getPrimaryTemplate())
- mangleUnscopedTemplateName(FD);
- else
- mangleUnscopedName(ND);
- } else if (isa<FunctionDecl>(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;
+ }
+ }
+
+ // FIXME: Check if we have a class template.
+ mangleUnscopedName(ND);
+ return;
+ }
+
+ if (isa<FunctionDecl>(DC)) {
mangleLocalName(ND);
- else
- mangleNestedName(ND);
+ return;
+ }
+
+ mangleNestedName(ND);
}
-
void CXXNameMangler::mangleName(const TemplateDecl *TD,
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs) {
@@ -418,12 +429,6 @@
assert(false && "Can't mangle a using directive name!");
break;
}
-
- if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(ND)) {
- if (const TemplateArgumentList *TemplateArgs
- = Function->getTemplateSpecializationArgs())
- mangleTemplateArgumentList(*TemplateArgs);
- }
}
void CXXNameMangler::mangleSourceName(const IdentifierInfo *II) {
@@ -436,15 +441,24 @@
void CXXNameMangler::mangleNestedName(const NamedDecl *ND) {
// <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E
// ::= N [<CV-qualifiers>] <template-prefix> <template-args> E
- // FIXME: no template support
+ // FIXME: no class template support
Out << 'N';
if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND))
mangleCVQualifiers(Method->getTypeQualifiers());
- manglePrefix(ND->getDeclContext());
- mangleUnqualifiedName(ND);
+
+ const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND);
+ if (FD && FD->getPrimaryTemplate()) {
+ // FIXME: Call mangleTemplatePrefix.
+ manglePrefix(FD->getDeclContext());
+ mangleUnqualifiedName(FD);
+ mangleTemplateArgumentList(*FD->getTemplateSpecializationArgs());
+ } else {
+ manglePrefix(ND->getDeclContext());
+ mangleUnqualifiedName(ND);
+ }
+
Out << 'E';
}
-
void CXXNameMangler::mangleNestedName(const TemplateDecl *TD,
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs) {
@@ -476,7 +490,7 @@
if (mangleSubstitution(cast<NamedDecl>(DC)))
return;
-
+
if (!DC->getParent()->isTranslationUnit())
manglePrefix(DC->getParent());
@@ -493,6 +507,14 @@
addSubstitution(cast<NamedDecl>(DC));
}
+void CXXNameMangler::mangleTemplatePrefix(const DeclContext *DC) {
+ // <template-prefix> ::= <prefix> <template unqualified-name>
+ // ::= <template-param>
+ // ::= <substitution>
+
+ // FIXME: Implement!
+}
+
void
CXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity) {
switch (OO) {
Modified: cfe/trunk/test/CodeGenCXX/mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle.cpp?rev=82193&r1=82192&r2=82193&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle.cpp Thu Sep 17 23:29:09 2009
@@ -95,9 +95,8 @@
template<typename T, typename U = S1<T> > struct S4 { };
template<typename T> void ft3(S4<T>*) { }
-extern "C++" {
- // CHECK: @_Z1hv
- void h() { }
+namespace NS {
+ template<typename T> void ft1(T) { }
}
void g() {
@@ -109,4 +108,13 @@
// CHECK: @_Z3ft3IiEvP2S4IT_2S1IS1_EE
ft3<int>(0);
+
+ // CHECK: @_ZN2NS3ft1IiEEvT_
+ NS::ft1<int>(1);
+}
+
+extern "C++" {
+ // CHECK: @_Z1hv
+ void h() { }
}
+
More information about the cfe-commits
mailing list