Skip to content

Commit 4abcbb0

Browse files
authored
[Clang][Cygwin] Use correct mangling rule (#158404)
In 45ca613, whether to mangle names based on calling conventions according to Microsoft conventions was refactored to a bool in the TargetInfo. Cygwin targets also require this mangling, but were missed, presumably due to lack of test coverage of these targets. This commit enables the name mangling for Cygwin, and also enables test coverage of this mangling on Cygwin targets.
1 parent bf156a2 commit 4abcbb0

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

clang/lib/Basic/Targets/X86.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_32TargetInfo : public X86_32TargetInfo {
646646
: X86_32TargetInfo(Triple, Opts) {
647647
this->WCharType = TargetInfo::UnsignedShort;
648648
this->WIntType = TargetInfo::UnsignedInt;
649+
this->UseMicrosoftManglingForC = true;
649650
DoubleAlign = LongLongAlign = 64;
650651
resetDataLayout("e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-"
651652
"i128:128-f80:32-n8:16:32-a:0:32-S32",
@@ -983,6 +984,7 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : public X86_64TargetInfo {
983984
: X86_64TargetInfo(Triple, Opts) {
984985
this->WCharType = TargetInfo::UnsignedShort;
985986
this->WIntType = TargetInfo::UnsignedInt;
987+
this->UseMicrosoftManglingForC = true;
986988
}
987989

988990
void getTargetDefines(const LangOptions &Opts,

clang/test/CodeGen/mangle-windows.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s
2-
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-mingw32 | FileCheck %s
2+
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-mingw32 | FileCheck %s
3+
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-cygwin | FileCheck %s
34
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-windows-msvc-elf | FileCheck %s --check-prefix=ELF32
45
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-win32 | FileCheck %s --check-prefix=X64
5-
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-mingw32 | FileCheck %s --check-prefix=X64
6+
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-mingw32 | FileCheck %s --check-prefix=X64
7+
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-cygwin | FileCheck %s --check-prefix=X64
68
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-windows-msvc-elf | FileCheck %s --check-prefix=ELF64
79

810
// CHECK: target datalayout = "e-m:x-{{.*}}"

clang/test/CodeGenCXX/mangle-windows.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-mingw32 | \
55
// RUN: FileCheck --check-prefix=ITANIUM %s
66

7+
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-cygwin | \
8+
// RUN: FileCheck --check-prefix=ITANIUM %s
9+
710
void __stdcall f1(void) {}
811
// WIN: define dso_local x86_stdcallcc void @"?f1@@YGXXZ"
912
// ITANIUM: define dso_local x86_stdcallcc void @"\01__Z2f1v@0"

0 commit comments

Comments
 (0)