@@ -4769,31 +4769,32 @@ ExprResult Sema::CheckOSLogFormatStringArg(Expr *Arg) {
47694769/// Check that the user is calling the appropriate va_start builtin for the
47704770/// target and calling convention.
47714771static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) {
4772- const llvm::Triple &TT = S.Context.getTargetInfo().getTriple();
4772+ const TargetInfo &TI = S.Context.getTargetInfo();
4773+ bool IsMicrosoftABI = TI.getCXXABI().isMicrosoft();
4774+ const llvm::Triple &TT = TI.getTriple();
47734775 bool IsX64 = TT.getArch() == llvm::Triple::x86_64;
47744776 bool IsAArch64 = (TT.getArch() == llvm::Triple::aarch64 ||
47754777 TT.getArch() == llvm::Triple::aarch64_32);
4776- bool IsWindows = TT.isOSWindows();
47774778 bool IsMSVAStart = BuiltinID == Builtin::BI__builtin_ms_va_start;
47784779 if (IsX64 || IsAArch64) {
47794780 CallingConv CC = CC_C;
47804781 if (const FunctionDecl *FD = S.getCurFunctionDecl())
47814782 CC = FD->getType()->castAs<FunctionType>()->getCallConv();
47824783 if (IsMSVAStart) {
47834784 // Don't allow this in System V ABI functions.
4784- if (CC == CC_X86_64SysV || (!IsWindows && CC != CC_Win64))
4785+ if (CC == CC_X86_64SysV || (!IsMicrosoftABI && CC != CC_Win64))
47854786 return S.Diag(Fn->getBeginLoc(),
47864787 diag::err_ms_va_start_used_in_sysv_function);
47874788 } else {
47884789 // On x86-64/AArch64 Unix, don't allow this in Win64 ABI functions.
47894790 // On x64 Windows, don't allow this in System V ABI functions.
47904791 // (Yes, that means there's no corresponding way to support variadic
47914792 // System V ABI functions on Windows.)
4792- if ((IsWindows && CC == CC_X86_64SysV) ||
4793- (!IsWindows && CC == CC_Win64))
4793+ if ((IsMicrosoftABI && CC == CC_X86_64SysV) ||
4794+ (!IsMicrosoftABI && CC == CC_Win64))
47944795 return S.Diag(Fn->getBeginLoc(),
47954796 diag::err_va_start_used_in_wrong_abi_function)
4796- << !IsWindows ;
4797+ << !IsMicrosoftABI ;
47974798 }
47984799 return false;
47994800 }
0 commit comments