Skip to content

Commit b37c675

Browse files
authored
merge main into amd-staging (llvm#2061)
2 parents 1f37a9f + 0606f66 commit b37c675

File tree

194 files changed

+4810
-1782
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+4810
-1782
lines changed

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6127,6 +6127,16 @@ the configuration (without a prefix: ``Auto``).
61276127
true: false:
61286128
! someExpression(); vs. !someExpression();
61296129

6130+
.. _SpaceAfterOperatorKeyword:
6131+
6132+
**SpaceAfterOperatorKeyword** (``Boolean``) :versionbadge:`clang-format 21` :ref:`<SpaceAfterOperatorKeyword>`
6133+
If ``true``, a space will be inserted after the ``operator`` keyword.
6134+
6135+
.. code-block:: c++
6136+
6137+
true: false:
6138+
bool operator ==(int a); vs. bool operator==(int a);
6139+
61306140
.. _SpaceAfterTemplateKeyword:
61316141

61326142
**SpaceAfterTemplateKeyword** (``Boolean``) :versionbadge:`clang-format 4` :ref:`<SpaceAfterTemplateKeyword>`

clang/docs/LanguageExtensions.rst

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,18 +1859,12 @@ The following type trait primitives are supported by Clang. Those traits marked
18591859
* ``__is_trivially_constructible`` (C++, GNU, Microsoft)
18601860
* ``__is_trivially_copyable`` (C++, GNU, Microsoft)
18611861
* ``__is_trivially_destructible`` (C++, MSVC 2013)
1862-
* ``__is_trivially_relocatable`` (Clang) (Deprecated,
1863-
use ``__builtin_is_cpp_trivially_relocatable`` instead).
1864-
Returns true if moving an object
1862+
* ``__is_trivially_relocatable`` (Clang): Returns true if moving an object
18651863
of the given type, and then destroying the source object, is known to be
18661864
functionally equivalent to copying the underlying bytes and then dropping the
18671865
source object on the floor. This is true of trivial types,
18681866
C++26 relocatable types, and types which
18691867
were made trivially relocatable via the ``clang::trivial_abi`` attribute.
1870-
This trait is deprecated and should be replaced by
1871-
``__builtin_is_cpp_trivially_relocatable``. Note however that it is generally
1872-
unsafe to relocate a C++-relocatable type with ``memcpy`` or ``memmove``;
1873-
use ``__builtin_trivially_relocate``.
18741868
* ``__builtin_is_cpp_trivially_relocatable`` (C++): Returns true if an object
18751869
is trivially relocatable, as defined by the C++26 standard [meta.unary.prop].
18761870
Note that when relocating the caller code should ensure that if the object is polymorphic,

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ Modified Compiler Flags
319319

320320
- The ``-mexecute-only`` and ``-mpure-code`` flags are now accepted for AArch64 targets. (#GH125688)
321321

322+
- The ``-fchar8_t`` flag is no longer considered in non-C++ languages modes. (#GH55373)
323+
322324
Removed Compiler Flags
323325
-------------------------
324326

@@ -580,6 +582,8 @@ Bug Fixes in This Version
580582
the invalid attribute location appropriately. (#GH137861)
581583
- Fixed a crash when a malformed ``_Pragma`` directive appears as part of an
582584
``#include`` directive. (#GH138094)
585+
- Fixed a crash during constant evaluation involving invalid lambda captures
586+
(#GH138832)
583587

584588
Bug Fixes to Compiler Builtins
585589
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -593,15 +597,6 @@ Bug Fixes to Compiler Builtins
593597
- ``__has_unique_object_representations(Incomplete[])`` is no longer accepted, per
594598
`LWG4113 <https://cplusplus.github.io/LWG/issue4113>`_.
595599

596-
- ``__builtin_is_cpp_trivially_relocatable``, ``__builtin_is_replaceable`` and
597-
``__builtin_trivially_relocate`` have been added to support standard C++26 relocation.
598-
599-
- ``__is_trivially_relocatable`` has been deprecated, and uses should be replaced by
600-
``__builtin_is_cpp_trivially_relocatable``.
601-
Note that, it is generally unsafe to ``memcpy`` non-trivially copyable types that
602-
are ``__builtin_is_cpp_trivially_relocatable``. It is recommended to use
603-
``__builtin_trivially_relocate`` instead.
604-
605600
Bug Fixes to Attribute Support
606601
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
607602
- Fixed crash when a parameter to the ``clang::annotate`` attribute evaluates to ``void``. See #GH119125
@@ -837,6 +832,7 @@ clang-format
837832
- Add ``EnumTrailingComma`` option for inserting/removing commas at the end of
838833
``enum`` enumerator lists.
839834
- Add ``OneLineFormatOffRegex`` option for turning formatting off for one line.
835+
- Add ``SpaceAfterOperatorKeyword`` option.
840836

841837
libclang
842838
--------

clang/include/clang/Basic/TokenKinds.def

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ TYPE_TRAIT_2(__is_pointer_interconvertible_base_of, IsPointerInterconvertibleBas
544544
#include "clang/Basic/TransformTypeTraits.def"
545545

546546
// Clang-only C++ Type Traits
547+
TYPE_TRAIT_1(__is_trivially_relocatable, IsTriviallyRelocatable, KEYCXX)
547548
TYPE_TRAIT_1(__is_trivially_equality_comparable, IsTriviallyEqualityComparable, KEYCXX)
548549
TYPE_TRAIT_1(__is_bounded_array, IsBoundedArray, KEYCXX)
549550
TYPE_TRAIT_1(__is_unbounded_array, IsUnboundedArray, KEYCXX)
@@ -555,11 +556,8 @@ TYPE_TRAIT_2(__reference_converts_from_temporary, ReferenceConvertsFromTemporary
555556
// IsDeducible is only used internally by clang for CTAD implementation and
556557
// is not exposed to users.
557558
TYPE_TRAIT_2(/*EmptySpellingName*/, IsDeducible, KEYCXX)
558-
559-
// __is_trivially_relocatable is deprecated
560-
TYPE_TRAIT_1(__builtin_is_cpp_trivially_relocatable, IsCppTriviallyRelocatable, KEYCXX)
561-
TYPE_TRAIT_1(__is_trivially_relocatable, IsTriviallyRelocatable, KEYCXX)
562559
TYPE_TRAIT_1(__is_bitwise_cloneable, IsBitwiseCloneable, KEYALL)
560+
TYPE_TRAIT_1(__builtin_is_cpp_trivially_relocatable, IsCppTriviallyRelocatable, KEYCXX)
563561
TYPE_TRAIT_1(__builtin_is_replaceable, IsReplaceable, KEYCXX)
564562
TYPE_TRAIT_1(__builtin_structured_binding_size, StructuredBindingSize, KEYCXX)
565563

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4031,7 +4031,8 @@ defm char8__t : BoolFOption<"char8_t",
40314031
LangOpts<"Char8">, Default<cpp20.KeyPath>,
40324032
PosFlag<SetTrue, [], [ClangOption], "Enable">,
40334033
NegFlag<SetFalse, [], [ClangOption], "Disable">,
4034-
BothFlags<[], [ClangOption, CC1Option], " C++ builtin type char8_t">>;
4034+
BothFlags<[], [ClangOption, CC1Option], " C++ builtin type char8_t">>,
4035+
ShouldParseIf<cplusplus.KeyPath>;
40354036
def fshort_wchar : Flag<["-"], "fshort-wchar">, Group<f_Group>,
40364037
HelpText<"Force wchar_t to be a short unsigned int">;
40374038
def fno_short_wchar : Flag<["-"], "fno-short-wchar">, Group<f_Group>,

clang/include/clang/Format/Format.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4484,6 +4484,14 @@ struct FormatStyle {
44844484
/// \version 9
44854485
bool SpaceAfterLogicalNot;
44864486

4487+
/// If ``true``, a space will be inserted after the ``operator`` keyword.
4488+
/// \code
4489+
/// true: false:
4490+
/// bool operator ==(int a); vs. bool operator==(int a);
4491+
/// \endcode
4492+
/// \version 21
4493+
bool SpaceAfterOperatorKeyword;
4494+
44874495
/// If \c true, a space will be inserted after the ``template`` keyword.
44884496
/// \code
44894497
/// true: false:
@@ -5454,6 +5462,7 @@ struct FormatStyle {
54545462
SortJavaStaticImport == R.SortJavaStaticImport &&
54555463
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
54565464
SpaceAfterLogicalNot == R.SpaceAfterLogicalNot &&
5465+
SpaceAfterOperatorKeyword == R.SpaceAfterOperatorKeyword &&
54575466
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
54585467
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators &&
54595468
SpaceBeforeCaseColon == R.SpaceBeforeCaseColon &&

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,10 +2932,9 @@ bool Compiler<Emitter>::VisitLambdaExpr(const LambdaExpr *E) {
29322932
// record with their initializers.
29332933
for (const Record::Field &F : R->fields()) {
29342934
const Expr *Init = *CaptureInitIt;
2935-
++CaptureInitIt;
2936-
2937-
if (!Init)
2935+
if (!Init || Init->containsErrors())
29382936
continue;
2937+
++CaptureInitIt;
29392938

29402939
if (std::optional<PrimType> T = classify(Init)) {
29412940
if (!this->visit(Init))

clang/lib/AST/ExprConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11038,7 +11038,7 @@ bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) {
1103811038

1103911039
// If there is no initializer, either this is a VLA or an error has
1104011040
// occurred.
11041-
if (!CurFieldInit)
11041+
if (!CurFieldInit || CurFieldInit->containsErrors())
1104211042
return Error(E);
1104311043

1104411044
LValue Subobject = This;

clang/lib/Basic/Targets/X86.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
866866
switch (CC) {
867867
case CC_C:
868868
case CC_Win64:
869+
case CC_X86_64SysV:
869870
return CCCR_OK;
870871
default:
871872
return CCCR_Warning;

clang/lib/CodeGen/CGCall.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ CodeGenTypes::arrangeFreeFunctionType(CanQual<FunctionProtoType> FTP) {
254254
}
255255

256256
static CallingConv getCallingConventionForDecl(const ObjCMethodDecl *D,
257-
bool IsWindows) {
257+
bool IsTargetDefaultMSABI) {
258258
// Set the appropriate calling convention for the Function.
259259
if (D->hasAttr<StdCallAttr>())
260260
return CC_X86StdCall;
@@ -290,10 +290,10 @@ static CallingConv getCallingConventionForDecl(const ObjCMethodDecl *D,
290290
return CC_IntelOclBicc;
291291

292292
if (D->hasAttr<MSABIAttr>())
293-
return IsWindows ? CC_C : CC_Win64;
293+
return IsTargetDefaultMSABI ? CC_C : CC_Win64;
294294

295295
if (D->hasAttr<SysVABIAttr>())
296-
return IsWindows ? CC_X86_64SysV : CC_C;
296+
return IsTargetDefaultMSABI ? CC_X86_64SysV : CC_C;
297297

298298
if (D->hasAttr<PreserveMostAttr>())
299299
return CC_PreserveMost;
@@ -581,8 +581,11 @@ CodeGenTypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD,
581581
}
582582

583583
FunctionType::ExtInfo einfo;
584-
bool IsWindows = getContext().getTargetInfo().getTriple().isOSWindows();
585-
einfo = einfo.withCallingConv(getCallingConventionForDecl(MD, IsWindows));
584+
bool IsTargetDefaultMSABI =
585+
getContext().getTargetInfo().getTriple().isOSWindows() ||
586+
getContext().getTargetInfo().getTriple().isUEFI();
587+
einfo = einfo.withCallingConv(
588+
getCallingConventionForDecl(MD, IsTargetDefaultMSABI));
586589

587590
if (getContext().getLangOpts().ObjCAutoRefCount &&
588591
MD->hasAttr<NSReturnsRetainedAttr>())

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
900900

901901
bool Fractional = false;
902902
unsigned LMUL;
903+
unsigned NFIELDS = Info.NumVectors;
903904
unsigned FixedSize = ElementCount * SEW;
904905
if (Info.ElementType == CGM.getContext().BoolTy) {
905906
// Mask type only occupies one vector register.
@@ -912,7 +913,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
912913
LMUL = FixedSize / 64;
913914
}
914915

915-
// Element count = (VLENB / SEW) x LMUL
916+
// Element count = (VLENB / SEW) x LMUL x NFIELDS
916917
SmallVector<uint64_t, 12> Expr(
917918
// The DW_OP_bregx operation has two operands: a register which is
918919
// specified by an unsigned LEB128 number, followed by a signed LEB128
@@ -927,6 +928,9 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
927928
Expr.push_back(llvm::dwarf::DW_OP_div);
928929
else
929930
Expr.push_back(llvm::dwarf::DW_OP_mul);
931+
// NFIELDS multiplier
932+
if (NFIELDS > 1)
933+
Expr.append({llvm::dwarf::DW_OP_constu, NFIELDS, llvm::dwarf::DW_OP_mul});
930934
// Element max index = count - 1
931935
Expr.append({llvm::dwarf::DW_OP_constu, 1, llvm::dwarf::DW_OP_minus});
932936

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,8 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
15941594
// Create the alloca. Note that we set the name separately from
15951595
// building the instruction so that it's there even in no-asserts
15961596
// builds.
1597-
address = CreateTempAlloca(allocaTy, allocaAlignment, D.getName(),
1597+
address = CreateTempAlloca(allocaTy, Ty.getAddressSpace(),
1598+
allocaAlignment, D.getName(),
15981599
/*ArraySize=*/nullptr, &AllocaAddr);
15991600

16001601
// Don't emit lifetime markers for MSVC catch parameters. The lifetime of

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,11 @@ CodeGenFunction::CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits Align,
100100
return RawAddress(Alloca, Ty, Align, KnownNonNull);
101101
}
102102

103-
/// CreateTempAlloca - This creates a alloca and inserts it into the entry
104-
/// block. The alloca is casted to default address space if necessary.
105-
RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align,
106-
const Twine &Name,
103+
RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, LangAS DestLangAS,
104+
CharUnits Align, const Twine &Name,
107105
llvm::Value *ArraySize,
108106
RawAddress *AllocaAddr) {
109-
auto Alloca = CreateTempAllocaWithoutCast(Ty, Align, Name, ArraySize);
107+
RawAddress Alloca = CreateTempAllocaWithoutCast(Ty, Align, Name, ArraySize);
110108
if (AllocaAddr)
111109
*AllocaAddr = Alloca;
112110
llvm::Value *V = Alloca.getPointer();
@@ -118,17 +116,18 @@ RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align,
118116
// be different from the type defined by the language. For example,
119117
// in C++ the auto variables are in the default address space. Therefore
120118
// cast alloca to the default address space when necessary.
121-
if (!getLangOpts().OpenCL && getASTAllocaAddressSpace() != LangAS::Default) {
122-
auto DestAddrSpace = getContext().getTargetAddressSpace(LangAS::Default);
119+
120+
unsigned DestAddrSpace = getContext().getTargetAddressSpace(DestLangAS);
121+
if (DestAddrSpace != Alloca.getAddressSpace()) {
123122
llvm::IRBuilderBase::InsertPointGuard IPG(Builder);
124123
// When ArraySize is nullptr, alloca is inserted at AllocaInsertPt,
125124
// otherwise alloca is inserted at the current insertion point of the
126125
// builder.
127126
if (!ArraySize)
128127
Builder.SetInsertPoint(getPostAllocaInsertPoint());
129128
V = getTargetHooks().performAddrSpaceCast(
130-
*this, V, getASTAllocaAddressSpace(), LangAS::Default,
131-
Builder.getPtrTy(DestAddrSpace), /*non-null*/ true);
129+
*this, V, getASTAllocaAddressSpace(), DestLangAS,
130+
Builder.getPtrTy(DestAddrSpace), /*IsNonNull=*/true);
132131
}
133132

134133
return RawAddress(V, Ty, Align, KnownNonNull);

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2863,10 +2863,28 @@ class CodeGenFunction : public CodeGenTypeCache {
28632863
/// more efficient if the caller knows that the address will not be exposed.
28642864
llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty, const Twine &Name = "tmp",
28652865
llvm::Value *ArraySize = nullptr);
2866+
2867+
/// CreateTempAlloca - This creates a alloca and inserts it into the entry
2868+
/// block. The alloca is casted to the address space of \p UseAddrSpace if
2869+
/// necessary.
2870+
RawAddress CreateTempAlloca(llvm::Type *Ty, LangAS UseAddrSpace,
2871+
CharUnits align, const Twine &Name = "tmp",
2872+
llvm::Value *ArraySize = nullptr,
2873+
RawAddress *Alloca = nullptr);
2874+
2875+
/// CreateTempAlloca - This creates a alloca and inserts it into the entry
2876+
/// block. The alloca is casted to default address space if necessary.
2877+
///
2878+
/// FIXME: This version should be removed, and context should provide the
2879+
/// context use address space used instead of default.
28662880
RawAddress CreateTempAlloca(llvm::Type *Ty, CharUnits align,
28672881
const Twine &Name = "tmp",
28682882
llvm::Value *ArraySize = nullptr,
2869-
RawAddress *Alloca = nullptr);
2883+
RawAddress *Alloca = nullptr) {
2884+
return CreateTempAlloca(Ty, LangAS::Default, align, Name, ArraySize,
2885+
Alloca);
2886+
}
2887+
28702888
RawAddress CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits align,
28712889
const Twine &Name = "tmp",
28722890
llvm::Value *ArraySize = nullptr);

clang/lib/Format/Format.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,8 @@ template <> struct MappingTraits<FormatStyle> {
11521152
IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations);
11531153
IO.mapOptional("SpaceAfterCStyleCast", Style.SpaceAfterCStyleCast);
11541154
IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot);
1155+
IO.mapOptional("SpaceAfterOperatorKeyword",
1156+
Style.SpaceAfterOperatorKeyword);
11551157
IO.mapOptional("SpaceAfterTemplateKeyword",
11561158
Style.SpaceAfterTemplateKeyword);
11571159
IO.mapOptional("SpaceAroundPointerQualifiers",
@@ -1639,6 +1641,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
16391641
LLVMStyle.SortUsingDeclarations = FormatStyle::SUD_LexicographicNumeric;
16401642
LLVMStyle.SpaceAfterCStyleCast = false;
16411643
LLVMStyle.SpaceAfterLogicalNot = false;
1644+
LLVMStyle.SpaceAfterOperatorKeyword = false;
16421645
LLVMStyle.SpaceAfterTemplateKeyword = true;
16431646
LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
16441647
LLVMStyle.SpaceBeforeAssignmentOperators = true;

clang/lib/Format/FormatToken.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,14 @@ struct FormatToken {
711711
tok::objc_package, tok::objc_private);
712712
}
713713

714+
bool isObjCLifetimeQualifier(const FormatStyle &Style) const {
715+
if (Style.Language != FormatStyle::LK_ObjC || !TokenText.starts_with("__"))
716+
return false;
717+
const auto Qualifier = TokenText.substr(2);
718+
return Qualifier == "autoreleasing" || Qualifier == "strong" ||
719+
Qualifier == "weak" || Qualifier == "unsafe_unretained";
720+
}
721+
714722
/// Returns whether \p Tok is ([{ or an opening < of a template or in
715723
/// protos.
716724
bool opensScope() const {

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,7 +3100,8 @@ class AnnotatingParser {
31003100
if (NextNextToken) {
31013101
if (NextNextToken->is(tok::arrow))
31023102
return TT_BinaryOperator;
3103-
if (NextNextToken->isPointerOrReference()) {
3103+
if (NextNextToken->isPointerOrReference() &&
3104+
!NextToken->isObjCLifetimeQualifier(Style)) {
31043105
NextNextToken->setFinalizedType(TT_BinaryOperator);
31053106
return TT_BinaryOperator;
31063107
}
@@ -5032,7 +5033,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
50325033
}
50335034

50345035
if (Left.is(tok::kw_operator))
5035-
return Right.is(tok::coloncolon);
5036+
return Right.is(tok::coloncolon) || Style.SpaceAfterOperatorKeyword;
50365037
if (Right.is(tok::l_brace) && Right.is(BK_BracedInit) &&
50375038
!Left.opensScope() && Style.SpaceBeforeCpp11BracedList) {
50385039
return true;

clang/lib/Sema/SemaChecking.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4868,27 +4868,27 @@ static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) {
48684868
bool IsX64 = TT.getArch() == llvm::Triple::x86_64;
48694869
bool IsAArch64 = (TT.getArch() == llvm::Triple::aarch64 ||
48704870
TT.getArch() == llvm::Triple::aarch64_32);
4871-
bool IsWindows = TT.isOSWindows();
4871+
bool IsWindowsOrUEFI = TT.isOSWindows() || TT.isUEFI();
48724872
bool IsMSVAStart = BuiltinID == Builtin::BI__builtin_ms_va_start;
48734873
if (IsX64 || IsAArch64) {
48744874
CallingConv CC = CC_C;
48754875
if (const FunctionDecl *FD = S.getCurFunctionDecl())
48764876
CC = FD->getType()->castAs<FunctionType>()->getCallConv();
48774877
if (IsMSVAStart) {
48784878
// Don't allow this in System V ABI functions.
4879-
if (CC == CC_X86_64SysV || (!IsWindows && CC != CC_Win64))
4879+
if (CC == CC_X86_64SysV || (!IsWindowsOrUEFI && CC != CC_Win64))
48804880
return S.Diag(Fn->getBeginLoc(),
48814881
diag::err_ms_va_start_used_in_sysv_function);
48824882
} else {
48834883
// On x86-64/AArch64 Unix, don't allow this in Win64 ABI functions.
48844884
// On x64 Windows, don't allow this in System V ABI functions.
48854885
// (Yes, that means there's no corresponding way to support variadic
48864886
// System V ABI functions on Windows.)
4887-
if ((IsWindows && CC == CC_X86_64SysV) ||
4888-
(!IsWindows && CC == CC_Win64))
4887+
if ((IsWindowsOrUEFI && CC == CC_X86_64SysV) ||
4888+
(!IsWindowsOrUEFI && CC == CC_Win64))
48894889
return S.Diag(Fn->getBeginLoc(),
48904890
diag::err_va_start_used_in_wrong_abi_function)
4891-
<< !IsWindows;
4891+
<< !IsWindowsOrUEFI;
48924892
}
48934893
return false;
48944894
}

0 commit comments

Comments
 (0)