compnerd updated this revision to Diff 132324. compnerd added a comment. Handle pointers as well
Repository: rC Clang https://reviews.llvm.org/D42768 Files: lib/AST/MicrosoftMangle.cpp test/CodeGenCXX/msabi-swiftcall-cc.cpp Index: test/CodeGenCXX/msabi-swiftcall-cc.cpp =================================================================== --- /dev/null +++ test/CodeGenCXX/msabi-swiftcall-cc.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -emit-llvm %s -o - | FileCheck %s + +void __attribute__((__swiftcall__)) f(void) {} +// CHECK-DAG: @"\01?f@__swift_cc@__Swift@@YAXXZ" + +void (__attribute__((__swiftcall__)) *p)(void); +// CHECK-DAG: @"\01?p@__swift_cc@__Swift@@3P6AXXZA" Index: lib/AST/MicrosoftMangle.cpp =================================================================== --- lib/AST/MicrosoftMangle.cpp +++ lib/AST/MicrosoftMangle.cpp @@ -1050,6 +1050,20 @@ } DC = DC->getParent(); } + + const Type *Ty = nullptr; + + if (const auto *FD = dyn_cast<FunctionDecl>(ND)) + Ty = FD->getType()->getAs<FunctionType>(); + + if (const auto *VD = dyn_cast<VarDecl>(ND)) + if (VD->getType()->isPointerType()) + Ty = VD->getType()->getPointeeType()->getAs<FunctionType>(); + + if (Ty) + if (Ty->getAs<FunctionType>()->getCallConv() == CC_Swift) + for (const char *NS : {"__swift_cc", "__Swift"}) + mangleSourceName(NS); } void MicrosoftCXXNameMangler::mangleCXXDtorType(CXXDtorType T) { @@ -1959,6 +1973,11 @@ mangleQualifiers(Quals, /*IsMember=*/false); } + // We currently mangle the SwiftCC as `__Swift::__swift_cc` namespace on the + // decl in mangleNestedName. + if (CC == CC_Swift) + CC = CC_C; + mangleCallingConvention(CC); // <return-type> ::= <type>
Index: test/CodeGenCXX/msabi-swiftcall-cc.cpp =================================================================== --- /dev/null +++ test/CodeGenCXX/msabi-swiftcall-cc.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -emit-llvm %s -o - | FileCheck %s + +void __attribute__((__swiftcall__)) f(void) {} +// CHECK-DAG: @"\01?f@__swift_cc@__Swift@@YAXXZ" + +void (__attribute__((__swiftcall__)) *p)(void); +// CHECK-DAG: @"\01?p@__swift_cc@__Swift@@3P6AXXZA" Index: lib/AST/MicrosoftMangle.cpp =================================================================== --- lib/AST/MicrosoftMangle.cpp +++ lib/AST/MicrosoftMangle.cpp @@ -1050,6 +1050,20 @@ } DC = DC->getParent(); } + + const Type *Ty = nullptr; + + if (const auto *FD = dyn_cast<FunctionDecl>(ND)) + Ty = FD->getType()->getAs<FunctionType>(); + + if (const auto *VD = dyn_cast<VarDecl>(ND)) + if (VD->getType()->isPointerType()) + Ty = VD->getType()->getPointeeType()->getAs<FunctionType>(); + + if (Ty) + if (Ty->getAs<FunctionType>()->getCallConv() == CC_Swift) + for (const char *NS : {"__swift_cc", "__Swift"}) + mangleSourceName(NS); } void MicrosoftCXXNameMangler::mangleCXXDtorType(CXXDtorType T) { @@ -1959,6 +1973,11 @@ mangleQualifiers(Quals, /*IsMember=*/false); } + // We currently mangle the SwiftCC as `__Swift::__swift_cc` namespace on the + // decl in mangleNestedName. + if (CC == CC_Swift) + CC = CC_C; + mangleCallingConvention(CC); // <return-type> ::= <type>
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits