summaryrefslogtreecommitdiffstats
path: root/lib/AST/ItaniumMangle.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-07-16 05:42:25 +0000
committerMartin Storsjo <martin@martin.st>2018-07-16 05:42:25 +0000
commite3f43c2ae1bd915046fe173d8ac32389672cad83 (patch)
treeac92fff98c52105e825279d14a048525d063eade /lib/AST/ItaniumMangle.cpp
parent27d1a66dffa9424bcdadc7cd52cf2ae019e49889 (diff)
[MinGW] Automatically mangle Windows-specific entry points as C
This mangles entry points wmain, WinMain, wWinMain or DllMain as C functions, to match the ABI for these functions. We already did the same for these functions in MSVC mode, but we also should do the same in the Itanium ABI. This fixes PR38124. Differential Revision: https://reviews.llvm.org/D49354 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337146 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ItaniumMangle.cpp')
-rw-r--r--lib/AST/ItaniumMangle.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp
index 6f7efcbe1b..3b99a3d9af 100644
--- a/lib/AST/ItaniumMangle.cpp
+++ b/lib/AST/ItaniumMangle.cpp
@@ -592,6 +592,18 @@ bool ItaniumMangleContextImpl::shouldMangleCXXName(const NamedDecl *D) {
if (FD->isMain())
return false;
+ // The Windows ABI expects that we would never mangle "typical"
+ // user-defined entry points regardless of visibility or freestanding-ness.
+ //
+ // N.B. This is distinct from asking about "main". "main" has a lot of
+ // special rules associated with it in the standard while these
+ // user-defined entry points are outside of the purview of the standard.
+ // For example, there can be only one definition for "main" in a standards
+ // compliant program; however nothing forbids the existence of wmain and
+ // WinMain in the same translation unit.
+ if (FD->isMSVCRTEntryPoint())
+ return false;
+
// C++ functions and those whose names are not a simple identifier need
// mangling.
if (!FD->getDeclName().isIdentifier() || L == CXXLanguageLinkage)