From 4b2ccfc302d7eebe9380211e6e2d4f7b4a6d0eba Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sun, 28 Feb 2010 22:05:49 +0000 Subject: [PATCH] Improve name mangling for dependently-scoped declaration references. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97422 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/Mangle.cpp | 13 ++++++++++++- test/CodeGenCXX/mangle-template.cpp | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 55185cb92d..fd9a1bab7f 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -1369,7 +1369,18 @@ void CXXNameMangler::mangleExpression(const Expr *E) { case Expr::DependentScopeDeclRefExprClass: { const DependentScopeDeclRefExpr *DRE = cast(E); - const Type *QTy = DRE->getQualifier()->getAsType(); + NestedNameSpecifier *NNS = DRE->getQualifier(); + const Type *QTy = NNS->getAsType(); + + // When we're dealing with a nested-name-specifier that has just a + // dependent identifier in it, mangle that as a typename. FIXME: + // It isn't clear that we ever actually want to have such a + // nested-name-specifier; why not just represent it as a typename type? + if (!QTy && NNS->getAsIdentifier() && NNS->getPrefix()) { + QTy = getASTContext().getTypenameType(NNS->getPrefix(), + NNS->getAsIdentifier()) + .getTypePtr(); + } assert(QTy && "Qualifier was not type!"); // ::= sr # dependent name diff --git a/test/CodeGenCXX/mangle-template.cpp b/test/CodeGenCXX/mangle-template.cpp index 38b4bfa38a..57f30a762e 100644 --- a/test/CodeGenCXX/mangle-template.cpp +++ b/test/CodeGenCXX/mangle-template.cpp @@ -85,3 +85,22 @@ namespace test7 { // CHECK: define void @_ZN5test71XIiEC1IdEEPT_PNS_5int_cIXplL_ZNS_4metaIiE5valueEEsrNS6_IS3_EE5valueEE4typeE template X::X(double*, float*); } + +namespace test8 { + template + struct meta { + struct type { + static const unsigned value = sizeof(T); + }; + }; + + template struct int_c { + typedef float type; + }; + + template + void f(int_c::type::value>) { } + + // CHECK: define void @_ZN5test81fIiEEvNS_5int_cIXsrNS_4metaIT_E4typeE5valueEEE + template void f(int_c); +} -- 2.40.0