[cfe-commits] r159234 - in /cfe/trunk: lib/AST/MicrosoftMangle.cpp test/CodeGenCXX/mangle-ms-back-references.cpp

Timur Iskhodzhanov timurrrr at google.com
Tue Jun 26 15:29:51 PDT 2012


Author: timurrrr
Date: Tue Jun 26 17:29:50 2012
New Revision: 159234

URL: http://llvm.org/viewvc/llvm-project?rev=159234&view=rev
Log:
[Windows] Improve mangling of templates when back references are present

Modified:
    cfe/trunk/lib/AST/MicrosoftMangle.cpp
    cfe/trunk/test/CodeGenCXX/mangle-ms-back-references.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=159234&r1=159233&r2=159234&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Jun 26 17:29:50 2012
@@ -706,8 +706,15 @@
   // <template-name> ::= <unscoped-template-name> <template-args>
   //                 ::= <substitution>
   // Always start with the unqualified name.
+
+  // Templates have their own context for back references.
+  BackRefMap TemplateContext;
+  NameBackReferences.swap(TemplateContext);
+
   mangleUnscopedTemplateName(TD);
   mangleTemplateArgs(TemplateArgs);
+  
+  NameBackReferences.swap(TemplateContext);
 }
 
 void

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-back-references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-back-references.cpp?rev=159234&r1=159233&r2=159234&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-ms-back-references.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-back-references.cpp Tue Jun 26 17:29:50 2012
@@ -9,7 +9,7 @@
 void f3(int a, const char* b, const char* c) {}
 // CHECK: "\01?f3@@YAXHPBD0 at Z"
 
-const char *f4(const char* a, const char* b) {}
+const char *f4(const char* a, const char* b) { return 0; }
 // CHECK: "\01?f4@@YAPBDPBD0 at Z"
 
 void f5(char const* a, unsigned int b, char c, void const* d, char const* e, unsigned int f) {}
@@ -46,7 +46,7 @@
 // built-ins.
 typedef unsigned int uintptr_t;
 typedef unsigned int size_t;
-void *h(size_t a, uintptr_t b) {}
+void *h(size_t a, uintptr_t b) { return 0; }
 // CHECK: "\01?h@@YAPAXII at Z"
 
 // Function pointers might be mangled in a complex way.
@@ -61,3 +61,64 @@
 
 PInt3Func h3(PInt3Func x, PInt3Func y, int* z) { return 0; }
 // CHECK: "\01?h3@@YAP6APAHPAH0 at ZP6APAH00@Z10 at Z"
+
+namespace PR13207 {
+class A {};
+class B {};
+class C {};
+
+template<class X>
+class I {};
+template<class X, class Y>
+class J {};
+template<class X, class Y, class Z>
+class K {};
+
+class L {
+ public:
+  void foo(I<A> x) {}
+};
+// CHECK: "\01?foo at L@PR13207@@QAEXV?$I at VA@PR13207@@@2@@Z"
+
+void call_l_foo(L* l) { l->foo(I<A>()); }
+
+void foo(I<A> x) {}
+// CHECK: "\01?foo at PR13207@@YAXV?$I at VA@PR13207@@@1@@Z"
+void foo2(I<A> x, I<A> y) { }
+// CHECK "\01?foo2 at PR13207@@YAXV?$I at VA@PR13207@@@1 at 0@Z"
+void bar(J<A,B> x) {}
+// CHECK: "\01?bar at PR13207@@YAXV?$J at VA@PR13207@@VB at 2@@1@@Z"
+void spam(K<A,B,C> x) {}
+// CHECK: "\01?spam at PR13207@@YAXV?$K at VA@PR13207@@VB at 2@VC at 2@@1@@Z"
+
+namespace NA {
+class X {};
+template<class T> class Y {};
+void foo(Y<X> x) {}
+// CHECK: "\01?foo at NA@PR13207@@YAXV?$Y at VX@NA at PR13207@@@12@@Z"
+}
+
+namespace NB {
+class X {};
+template<class T> class Y {};
+void foo(Y<NA::X> x) {}
+// CHECK: "\01?foo at NB@PR13207@@YAXV?$Y at VX@NA at PR13207@@@12@@Z"
+
+void bar(NA::Y<X> x) {}
+// CHECK: "\01?bar at NB@PR13207@@YAXV?$Y at VX@NB at PR13207@@@NA at 2@@Z"
+
+void spam(NA::Y<NA::X> x) {}
+// CHECK: "\01?spam at NB@PR13207@@YAXV?$Y at VX@NA at PR13207@@@NA at 2@@Z"
+}
+
+namespace NC {
+class X {};
+template<class T> class Y {};
+
+void foo(Y<NB::X> x) {}
+// CHECK: "\01?foo at NC@PR13207@@YAXV?$Y at VX@NB at PR13207@@@12@@Z"
+
+void foobar(NC::Y<NB::Y<NA::Y<NA::X> > > x) {}
+// CHECK: "\01?foobar at NC@PR13207@@YAXV?$Y at V?$Y at V?$Y at VX@NA at PR13207@@@NA at PR13207@@@NB at PR13207@@@12@@Z"
+}
+}





More information about the cfe-commits mailing list