[clang] [clang] Remove isOSWindows() checks (PR #129909)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 5 10:23:56 PST 2025
https://github.com/Prabhuk created https://github.com/llvm/llvm-project/pull/129909
The logic to decide which va_start builtin should be used must rely on
the ABI information. The target triple based check is rigid. It makes
the support for new triples such as x86_64-uefi to add more triple based
checks across the codebase.
>From a41ed14a5520c9d3f284ef8c71140d11d7478887 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Wed, 5 Mar 2025 18:19:26 +0000
Subject: [PATCH] [clang] Remove isOSWindows() checks
The logic to decide which va_start builtin should be used must rely on
the ABI information. The target triple based check is rigid. It makes
the support for new triples such as x86_64-uefi to add more triple based
checks across the codebase.
---
clang/lib/Sema/SemaChecking.cpp | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index f9926c6b4adab..2af02c337b6e1 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4769,11 +4769,12 @@ ExprResult Sema::CheckOSLogFormatStringArg(Expr *Arg) {
/// Check that the user is calling the appropriate va_start builtin for the
/// target and calling convention.
static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) {
- const llvm::Triple &TT = S.Context.getTargetInfo().getTriple();
+ const TargetInfo &TI = S.Context.getTargetInfo();
+ bool IsMicrosoftABI = TI.getCXXABI().isMicrosoft();
+ const llvm::Triple &TT = TI.getTriple();
bool IsX64 = TT.getArch() == llvm::Triple::x86_64;
bool IsAArch64 = (TT.getArch() == llvm::Triple::aarch64 ||
TT.getArch() == llvm::Triple::aarch64_32);
- bool IsWindows = TT.isOSWindows();
bool IsMSVAStart = BuiltinID == Builtin::BI__builtin_ms_va_start;
if (IsX64 || IsAArch64) {
CallingConv CC = CC_C;
@@ -4781,7 +4782,7 @@ static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) {
CC = FD->getType()->castAs<FunctionType>()->getCallConv();
if (IsMSVAStart) {
// Don't allow this in System V ABI functions.
- if (CC == CC_X86_64SysV || (!IsWindows && CC != CC_Win64))
+ if (CC == CC_X86_64SysV || (!IsMicrosoftABI && CC != CC_Win64))
return S.Diag(Fn->getBeginLoc(),
diag::err_ms_va_start_used_in_sysv_function);
} else {
@@ -4789,11 +4790,11 @@ static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) {
// On x64 Windows, don't allow this in System V ABI functions.
// (Yes, that means there's no corresponding way to support variadic
// System V ABI functions on Windows.)
- if ((IsWindows && CC == CC_X86_64SysV) ||
- (!IsWindows && CC == CC_Win64))
+ if ((IsMicrosoftABI && CC == CC_X86_64SysV) ||
+ (!IsMicrosoftABI && CC == CC_Win64))
return S.Diag(Fn->getBeginLoc(),
diag::err_va_start_used_in_wrong_abi_function)
- << !IsWindows;
+ << !IsMicrosoftABI;
}
return false;
}
More information about the cfe-commits
mailing list