forked from OSchip/llvm-project
parent
adb08de4d9
commit
2b5e1dda69
|
@ -82,6 +82,7 @@ namespace {
|
||||||
const TemplateArgument *TemplateArgs,
|
const TemplateArgument *TemplateArgs,
|
||||||
unsigned NumTemplateArgs);
|
unsigned NumTemplateArgs);
|
||||||
void manglePrefix(const DeclContext *DC);
|
void manglePrefix(const DeclContext *DC);
|
||||||
|
void mangleTemplatePrefix(const DeclContext *DC);
|
||||||
void mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity);
|
void mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity);
|
||||||
void mangleCVQualifiers(unsigned Quals);
|
void mangleCVQualifiers(unsigned Quals);
|
||||||
void mangleType(QualType T);
|
void mangleType(QualType T);
|
||||||
|
@ -265,17 +266,27 @@ void CXXNameMangler::mangleName(const NamedDecl *ND) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DC->isTranslationUnit() || isStdNamespace(DC)) {
|
if (DC->isTranslationUnit() || isStdNamespace(DC)) {
|
||||||
const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND);
|
// Check if we have a function template.
|
||||||
if (FD && FD->getPrimaryTemplate())
|
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)){
|
||||||
mangleUnscopedTemplateName(FD);
|
if (FD->getPrimaryTemplate()) {
|
||||||
else
|
mangleUnscopedTemplateName(FD);
|
||||||
mangleUnscopedName(ND);
|
mangleTemplateArgumentList(*FD->getTemplateSpecializationArgs());
|
||||||
} else if (isa<FunctionDecl>(DC))
|
return;
|
||||||
mangleLocalName(ND);
|
}
|
||||||
else
|
}
|
||||||
mangleNestedName(ND);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// FIXME: Check if we have a class template.
|
||||||
|
mangleUnscopedName(ND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isa<FunctionDecl>(DC)) {
|
||||||
|
mangleLocalName(ND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mangleNestedName(ND);
|
||||||
|
}
|
||||||
void CXXNameMangler::mangleName(const TemplateDecl *TD,
|
void CXXNameMangler::mangleName(const TemplateDecl *TD,
|
||||||
const TemplateArgument *TemplateArgs,
|
const TemplateArgument *TemplateArgs,
|
||||||
unsigned NumTemplateArgs) {
|
unsigned NumTemplateArgs) {
|
||||||
|
@ -418,12 +429,6 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND) {
|
||||||
assert(false && "Can't mangle a using directive name!");
|
assert(false && "Can't mangle a using directive name!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(ND)) {
|
|
||||||
if (const TemplateArgumentList *TemplateArgs
|
|
||||||
= Function->getTemplateSpecializationArgs())
|
|
||||||
mangleTemplateArgumentList(*TemplateArgs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CXXNameMangler::mangleSourceName(const IdentifierInfo *II) {
|
void CXXNameMangler::mangleSourceName(const IdentifierInfo *II) {
|
||||||
|
@ -436,15 +441,24 @@ void CXXNameMangler::mangleSourceName(const IdentifierInfo *II) {
|
||||||
void CXXNameMangler::mangleNestedName(const NamedDecl *ND) {
|
void CXXNameMangler::mangleNestedName(const NamedDecl *ND) {
|
||||||
// <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E
|
// <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E
|
||||||
// ::= N [<CV-qualifiers>] <template-prefix> <template-args> E
|
// ::= N [<CV-qualifiers>] <template-prefix> <template-args> E
|
||||||
// FIXME: no template support
|
// FIXME: no class template support
|
||||||
Out << 'N';
|
Out << 'N';
|
||||||
if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND))
|
if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(ND))
|
||||||
mangleCVQualifiers(Method->getTypeQualifiers());
|
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';
|
Out << 'E';
|
||||||
}
|
}
|
||||||
|
|
||||||
void CXXNameMangler::mangleNestedName(const TemplateDecl *TD,
|
void CXXNameMangler::mangleNestedName(const TemplateDecl *TD,
|
||||||
const TemplateArgument *TemplateArgs,
|
const TemplateArgument *TemplateArgs,
|
||||||
unsigned NumTemplateArgs) {
|
unsigned NumTemplateArgs) {
|
||||||
|
@ -476,7 +490,7 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC) {
|
||||||
|
|
||||||
if (mangleSubstitution(cast<NamedDecl>(DC)))
|
if (mangleSubstitution(cast<NamedDecl>(DC)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!DC->getParent()->isTranslationUnit())
|
if (!DC->getParent()->isTranslationUnit())
|
||||||
manglePrefix(DC->getParent());
|
manglePrefix(DC->getParent());
|
||||||
|
|
||||||
|
@ -493,6 +507,14 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC) {
|
||||||
addSubstitution(cast<NamedDecl>(DC));
|
addSubstitution(cast<NamedDecl>(DC));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CXXNameMangler::mangleTemplatePrefix(const DeclContext *DC) {
|
||||||
|
// <template-prefix> ::= <prefix> <template unqualified-name>
|
||||||
|
// ::= <template-param>
|
||||||
|
// ::= <substitution>
|
||||||
|
|
||||||
|
// FIXME: Implement!
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity) {
|
CXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity) {
|
||||||
switch (OO) {
|
switch (OO) {
|
||||||
|
|
|
@ -95,9 +95,8 @@ template<typename T> void ft2(T t, void (*)(T), void (*)(T)) { }
|
||||||
template<typename T, typename U = S1<T> > struct S4 { };
|
template<typename T, typename U = S1<T> > struct S4 { };
|
||||||
template<typename T> void ft3(S4<T>*) { }
|
template<typename T> void ft3(S4<T>*) { }
|
||||||
|
|
||||||
extern "C++" {
|
namespace NS {
|
||||||
// CHECK: @_Z1hv
|
template<typename T> void ft1(T) { }
|
||||||
void h() { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void g() {
|
void g() {
|
||||||
|
@ -109,4 +108,13 @@ void g() {
|
||||||
|
|
||||||
// CHECK: @_Z3ft3IiEvP2S4IT_2S1IS1_EE
|
// CHECK: @_Z3ft3IiEvP2S4IT_2S1IS1_EE
|
||||||
ft3<int>(0);
|
ft3<int>(0);
|
||||||
|
|
||||||
|
// CHECK: @_ZN2NS3ft1IiEEvT_
|
||||||
|
NS::ft1<int>(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C++" {
|
||||||
|
// CHECK: @_Z1hv
|
||||||
|
void h() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue