-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang] Remove isOSWindows() checks #129909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Member
|
@llvm/pr-subscribers-clang Author: Prabhuk (Prabhuk) ChangesThe logic to decide which va_start builtin should be used must rely on Full diff: https://github.com/llvm/llvm-project/pull/129909.diff 1 Files Affected:
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;
}
|
rnk
reviewed
Mar 5, 2025
Contributor
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.