Substitute unscoped template names.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82119 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index 6429bd7..9b5fd74 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -276,7 +276,11 @@
void CXXNameMangler::mangleUnscopedTemplateName(const FunctionDecl *FD) {
// <unscoped-template-name> ::= <unscoped-name>
// ::= <substitution>
+ if (mangleSubstitution(FD))
+ return;
+
mangleUnscopedName(FD);
+ addSubstitution(FD);
}
void CXXNameMangler::mangleCalloffset(int64_t nv, int64_t v) {
diff --git a/test/CodeGenCXX/function-template-specialization.cpp b/test/CodeGenCXX/function-template-specialization.cpp
index 8dbaf2f..677be4c 100644
--- a/test/CodeGenCXX/function-template-specialization.cpp
+++ b/test/CodeGenCXX/function-template-specialization.cpp
@@ -8,12 +8,10 @@
}
void test(int *iptr, float *fptr, int diff) {
- // FIXME: should be "_Z4nextIiiEPT_S1_RKT0_"
- // CHECK: _Z4nextIiiEPT_S0_RKT0_
+ // CHECK: _Z4nextIiiEPT_S1_RKT0_
iptr = next(iptr, diff);
- // FIXME: should be "_Z4nextIfiEPT_S1_RKT0_"
- // CHECK: _Z4nextIfiEPT_S0_RKT0_
-
+
+ // CHECK: _Z4nextIfiEPT_S1_RKT0_
fptr = next(fptr, diff);
}
@@ -22,7 +20,7 @@
void test2(int *iptr, double *dptr, int diff) {
iptr = next(iptr, diff);
- // FIXME: should be "_Z4nextIdiEPT_S1_RKT0_"
- // CHECK: _Z4nextIiiEPT_S0_RKT0_
+
+ // CHECK: _Z4nextIdiEPT_S1_RKT0_
dptr = next(dptr, diff);
}
diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp
index a4c223e..65ef008 100644
--- a/test/CodeGenCXX/mangle.cpp
+++ b/test/CodeGenCXX/mangle.cpp
@@ -88,9 +88,14 @@
// CHECK: define void @_Z1fi
void f(const int) { }
-// CHECK: define linkonce_odr void @_Z2tfIidEvT0_T_
-template<typename T, typename U> void tf(U u, T t) { }
+template<typename T, typename U> void ft1(U u, T t) { }
+
+template<typename T> void ft2(T t, void (*)(T), void (*)(T)) { }
void g() {
- tf<int, double>(1, 0);
+ // CHECK: @_Z3ft1IidEvT0_T_
+ ft1<int, double>(1, 0);
+
+ // CHECK: @_Z3ft2IcEvT_PFvS0_ES2_
+ ft2<char>(1, 0, 0);
}