[cfe-commits] r97418 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle-template.cpp

Douglas Gregor dgregor at apple.com
Sun Feb 28 13:40:32 PST 2010


Author: dgregor
Date: Sun Feb 28 15:40:32 2010
New Revision: 97418

URL: http://llvm.org/viewvc/llvm-project?rev=97418&view=rev
Log:
Add name mangling for DeclRefExprs that refer to external names

Modified:
    cfe/trunk/lib/CodeGen/Mangle.cpp
    cfe/trunk/test/CodeGenCXX/mangle-template.cpp

Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=97418&r1=97417&r2=97418&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Sun Feb 28 15:40:32 2010
@@ -1346,10 +1346,16 @@
     break;
 
   case Expr::DeclRefExprClass: {
-    const Decl *D = cast<DeclRefExpr>(E)->getDecl();
+    const NamedDecl *D = cast<DeclRefExpr>(E)->getDecl();
 
     switch (D->getKind()) {
-    default: assert(false && "Unhandled decl kind!");
+    default: 
+      //  <expr-primary> ::= L <mangled-name> E # external name
+      Out << 'L';
+      mangle(D, "_Z");
+      Out << 'E';
+      break;
+
     case Decl::NonTypeTemplateParm: {
       const NonTypeTemplateParmDecl *PD = cast<NonTypeTemplateParmDecl>(D);
       mangleTemplateParameter(PD->getIndex());

Modified: cfe/trunk/test/CodeGenCXX/mangle-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-template.cpp?rev=97418&r1=97417&r2=97418&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-template.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-template.cpp Sun Feb 28 15:40:32 2010
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
-
 namespace test1 {
 int x;
 template <int& D> class T { };
@@ -66,3 +65,23 @@
 // CHECK-FAIL: void @_ZN5test62f0ENS_1TIXadL_ZNS_1A3im0EfEEEE(
 void f0(T<&A::im0> a0) {}
 }
+
+namespace test7 {
+  template<typename T>
+  struct meta {
+    static const unsigned value = sizeof(T);
+  };
+
+  template<unsigned> struct int_c { 
+    typedef float type;
+  };
+
+  template<typename T>
+  struct X {
+    template<typename U>
+    X(U*, typename int_c<(meta<T>::value + meta<U>::value)>::type *) { }
+  };
+
+  // CHECK: define void @_ZN5test71XIiEC1IdEEPT_PNS_5int_cIXplL_ZNS_4metaIiE5valueEEsrNS6_IS3_EE5valueEE4typeE
+  template X<int>::X(double*, float*);
+}





More information about the cfe-commits mailing list