[cfe-commits] r107567 - in /cfe/trunk: lib/CodeGen/MicrosoftCXXABI.cpp test/CodeGenCXX/mangle-ms.cpp

Charles Davis cdavis at mines.edu
Sat Jul 3 01:01:40 PDT 2010


Author: cdavis
Date: Sat Jul  3 03:01:32 2010
New Revision: 107567

URL: http://llvm.org/viewvc/llvm-project?rev=107567&view=rev
Log:
Mangle member pointer types in the Microsoft C++ Mangler.

Modified:
    cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
    cfe/trunk/test/CodeGenCXX/mangle-ms.cpp

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=107567&r1=107566&r2=107567&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Sat Jul  3 03:01:32 2010
@@ -645,7 +645,7 @@
     //                          ::= Q # const pointer
     //                          ::= R # volatile pointer
     //                          ::= S # const volatile pointer
-    if (T->isPointerType()) {
+    if (T->isAnyPointerType() || T->isMemberPointerType()) {
       if (!Quals.hasVolatile()) {
         Out << 'Q';
       } else {
@@ -661,7 +661,7 @@
       // in there.
       mangleQualifiers(Quals, false);
   }
-  else if (T->isPointerType()) {
+  else if (T->isAnyPointerType() || T->isMemberPointerType()) {
     Out << 'P';
   }
   switch (T->getTypeClass()) {
@@ -1000,8 +1000,20 @@
   mangleType(ElementTy.getLocalUnqualifiedType());
 }
 
+// <type>                   ::= <pointer-to-member-type>
+// <pointer-to-member-type> ::= <pointer-cvr-qualifiers> <cvr-qualifiers>
+//                                                          <class name> <type>
 void MicrosoftCXXNameMangler::mangleType(const MemberPointerType *T) {
-  assert(false && "Don't know how to mangle MemberPointerTypes yet!");
+  QualType PointeeType = T->getPointeeType();
+  if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(PointeeType)) {
+    Out << '8';
+    mangleName(cast<RecordType>(T->getClass())->getDecl());
+    mangleType(FPT, NULL, false, true);
+  } else {
+    mangleQualifiers(PointeeType.getQualifiers(), true);
+    mangleName(cast<RecordType>(T->getClass())->getDecl());
+    mangleType(PointeeType.getLocalUnqualifiedType());
+  }
 }
 
 void MicrosoftCXXNameMangler::mangleType(const TemplateTypeParmType *T) {

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=107567&r1=107566&r2=107567&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Sat Jul  3 03:01:32 2010
@@ -10,6 +10,8 @@
 // CHECK: @"\01?h@@3QAHA"
 // CHECK: @"\01?i@@3PAY0BD at HA"
 // CHECK: @"\01?j@@3P6GHCE at ZA"
+// CHECK: @"\01?k@@3PTfoo@@DA"
+// CHECK: @"\01?l@@3P8foo@@AAHH at ZA"
 
 int a;
 
@@ -61,6 +63,10 @@
 
 int (__stdcall *j)(signed char, unsigned char);
 
+const volatile char foo::*k;
+
+int (foo::*l)(int);
+
 // Static functions are mangled, too.
 // Also make sure calling conventions, arglists, and throw specs work.
 static void __stdcall alpha(float a, double b) throw() {}





More information about the cfe-commits mailing list