Commit 0e83d687 authored by Hans Wennborg's avatar Hans Wennborg
Browse files

Merging r324439:

------------------------------------------------------------------------
r324439 | compnerd | 2018-02-07 02:55:08 +0100 (Wed, 07 Feb 2018) | 5 lines

AST: support SwiftCC on MS ABI

Microsoft has reserved the identifier 'S' as the swift calling
convention.  Decorate the symbols appropriately.  This enables swift on
Windows.
------------------------------------------------------------------------

llvm-svn: 324460
parent 34c856a8
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -950,11 +950,10 @@ void MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
  }
}

void MicrosoftCXXNameMangler::mangleNestedName(const NamedDecl *ND) {
// <postfix> ::= <unqualified-name> [<postfix>]
//           ::= <substitution> [<postfix>]
void MicrosoftCXXNameMangler::mangleNestedName(const NamedDecl *ND) {
  const DeclContext *DC = getEffectiveDeclContext(ND);

  while (!DC->isTranslationUnit()) {
    if (isa<TagDecl>(ND) || isa<VarDecl>(ND)) {
      unsigned Disc;
@@ -2140,6 +2139,7 @@ void MicrosoftCXXNameMangler::mangleCallingConvention(CallingConv CC) {
    case CC_X86StdCall: Out << 'G'; break;
    case CC_X86FastCall: Out << 'I'; break;
    case CC_X86VectorCall: Out << 'Q'; break;
    case CC_Swift: Out << 'S'; break;
    case CC_X86RegCall: Out << 'w'; break;
  }
}
+28 −0
Original line number Diff line number Diff line
// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fdeclspec -emit-llvm %s -o - | FileCheck %s

void __attribute__((__swiftcall__)) f() {}
// CHECK-DAG: @"\01?f@@YSXXZ"

void (__attribute__((__swiftcall__)) *p)();
// CHECK-DAG: @"\01?p@@3P6SXXZA"

namespace {
void __attribute__((__swiftcall__)) __attribute__((__used__)) f() { }
// CHECK-DAG: "\01?f@?A@@YSXXZ"
}

namespace n {
void __attribute__((__swiftcall__)) f() {}
// CHECK-DAG: "\01?f@n@@YSXXZ"
}

struct __declspec(dllexport) S {
  S(const S &) = delete;
  S & operator=(const S &) = delete;
  void __attribute__((__swiftcall__)) m() { }
  // CHECK-DAG: "\01?m@S@@QASXXZ"
};

void f(void (__attribute__((__swiftcall__))())) {}
// CHECK-DAG: "\01?f@@YAXP6SXXZ@Z"