]> granicus.if.org Git - clang/commitdiff
Add Microsoft mangling of constructors and destructors. Patch by Dmitry!
authorMichael J. Spencer <bigcheesegs@gmail.com>
Thu, 1 Dec 2011 09:55:00 +0000 (09:55 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Thu, 1 Dec 2011 09:55:00 +0000 (09:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145581 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/MicrosoftMangle.cpp
test/CodeGenCXX/mangle-ms.cpp

index 1a18ef1dc060bc716c0e166cb9dc5b18e2e899c6..42e6c9322db894019d9030dc7ce24ce9893c6a83 100644 (file)
@@ -335,10 +335,12 @@ MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
       llvm_unreachable("Can't mangle Objective-C selector names here!");
       
     case DeclarationName::CXXConstructorName:
-      llvm_unreachable("Can't mangle constructors yet!");
+      Out << "?0";
+      break;
       
     case DeclarationName::CXXDestructorName:
-      llvm_unreachable("Can't mangle destructors yet!");
+      Out << "?1";
+      break;
       
     case DeclarationName::CXXConversionFunctionName:
       // <operator-name> ::= ?B # (cast)
@@ -1168,13 +1170,15 @@ void MicrosoftMangleContext::mangleCXXRTTIName(QualType T,
 }
 void MicrosoftMangleContext::mangleCXXCtor(const CXXConstructorDecl *D,
                                            CXXCtorType Type,
-                                           raw_ostream &) {
-  llvm_unreachable("Can't yet mangle constructors!");
+                                           raw_ostream & Out) {
+  MicrosoftCXXNameMangler mangler(*this, Out);
+  mangler.mangle(D);
 }
 void MicrosoftMangleContext::mangleCXXDtor(const CXXDestructorDecl *D,
                                            CXXDtorType Type,
-                                           raw_ostream &) {
-  llvm_unreachable("Can't yet mangle destructors!");
+                                           raw_ostream & Out) {
+  MicrosoftCXXNameMangler mangler(*this, Out);
+  mangler.mangle(D);
 }
 void MicrosoftMangleContext::mangleReferenceTemporary(const clang::VarDecl *,
                                                       raw_ostream &) {
index d8d75b7d0f0e7ee71bb5bcdff984e8c0b3f209f4..fe5fde1a1b3bfc72d4182165219e49b660612ef9 100644 (file)
@@ -28,7 +28,18 @@ protected:
 public:
   static const volatile char f;
   int operator+(int a);
-};
+  foo(){}
+//CHECK: @"\01??0foo@@QAE@XZ"
+
+  ~foo(){}
+//CHECK: @"\01??1foo@@QAE@XZ"
+
+  foo(int i){}
+//CHECK: @"\01??0foo@@QAE@H@Z"
+
+  foo(char *q){}
+//CHECK: @"\01??0foo@@QAE@PAD@Z"
+}f,s1(1),s2((char*)0);
 
 struct bar {
   static int g;