From 5ed1bc351f36ca1086d7836baee546c39ce90dd7 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sun, 28 Feb 2010 21:40:32 +0000 Subject: [PATCH] Add name mangling for DeclRefExprs that refer to external names git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97418 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/Mangle.cpp | 10 ++++++++-- test/CodeGenCXX/mangle-template.cpp | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 22dbd91259..55185cb92d 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -1346,10 +1346,16 @@ void CXXNameMangler::mangleExpression(const Expr *E) { break; case Expr::DeclRefExprClass: { - const Decl *D = cast(E)->getDecl(); + const NamedDecl *D = cast(E)->getDecl(); switch (D->getKind()) { - default: assert(false && "Unhandled decl kind!"); + default: + // ::= L E # external name + Out << 'L'; + mangle(D, "_Z"); + Out << 'E'; + break; + case Decl::NonTypeTemplateParm: { const NonTypeTemplateParmDecl *PD = cast(D); mangleTemplateParameter(PD->getIndex()); diff --git a/test/CodeGenCXX/mangle-template.cpp b/test/CodeGenCXX/mangle-template.cpp index c8296f3c4b..38b4bfa38a 100644 --- a/test/CodeGenCXX/mangle-template.cpp +++ b/test/CodeGenCXX/mangle-template.cpp @@ -1,5 +1,4 @@ // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s - namespace test1 { int x; template class T { }; @@ -66,3 +65,23 @@ template class T { }; // CHECK-FAIL: void @_ZN5test62f0ENS_1TIXadL_ZNS_1A3im0EfEEEE( void f0(T<&A::im0> a0) {} } + +namespace test7 { + template + struct meta { + static const unsigned value = sizeof(T); + }; + + template struct int_c { + typedef float type; + }; + + template + struct X { + template + X(U*, typename int_c<(meta::value + meta::value)>::type *) { } + }; + + // CHECK: define void @_ZN5test71XIiEC1IdEEPT_PNS_5int_cIXplL_ZNS_4metaIiE5valueEEsrNS6_IS3_EE5valueEE4typeE + template X::X(double*, float*); +} -- 2.40.0