Mangle enum constant expressions. Fixes rdar://problem/8204122
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109315 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index f408849..b5f629a 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -1873,6 +1873,12 @@
Out << 'E';
break;
+ case Decl::EnumConstant: {
+ const EnumConstantDecl *ED = cast<EnumConstantDecl>(D);
+ mangleIntegerLiteral(ED->getType(), ED->getInitVal());
+ break;
+ }
+
case Decl::NonTypeTemplateParm: {
const NonTypeTemplateParmDecl *PD = cast<NonTypeTemplateParmDecl>(D);
mangleTemplateParameter(PD->getIndex());
diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp
index 37af79b..3a2e112 100644
--- a/test/CodeGenCXX/mangle.cpp
+++ b/test/CodeGenCXX/mangle.cpp
@@ -518,3 +518,14 @@
int S::a() { return S::x; }
}
}
+
+// rdar://problem/8204122
+namespace test15 {
+ enum E { e = 3 };
+ template <int I> struct S {};
+
+ template <int I> void f(S<I + e>) {}
+
+ // CHECK: define weak_odr void @_ZN6test151fILi7EEEvNS_1SIXplT_LNS_1EE3EEEE(
+ template void f<7>(S<7 + e>);
+}