Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit a98a25f

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:1db2d571b501 into amd-gfx:e2fc454576ad
Local branch amd-gfx e2fc454 Merged main:e0ea9fd6dc36 into amd-gfx:1e7037e979ae Remote branch main 1db2d57 [llvm][TableGen] Fix misleading error for invalid use of let (llvm#118616)
2 parents e2fc454 + 1db2d57 commit a98a25f

File tree

83 files changed

+2186
-723
lines changed

Some content is hidden

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

83 files changed

+2186
-723
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ Bug Fixes to C++ Support
799799
- Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205)
800800
- Fixed an incorrect lambda scope of generic lambdas that caused Clang to crash when computing potential lambda
801801
captures at the end of a full expression. (#GH115931)
802+
- Clang no longer rejects deleting a pointer of incomplete enumeration type. (#GH99278)
802803

803804
Bug Fixes to AST Handling
804805
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/tools/dump_format_style.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# documentation in ../ClangFormatStyleOptions.rst automatically.
44
# Run from the directory in which this file is located to update the docs.
55

6+
import argparse
67
import inspect
78
import os
89
import re
@@ -474,6 +475,10 @@ class State:
474475
return options
475476

476477

478+
p = argparse.ArgumentParser()
479+
p.add_argument("-o", "--output", help="path of output file")
480+
args = p.parse_args()
481+
477482
with open(FORMAT_STYLE_FILE) as f:
478483
opts = OptionsReader(f).read_options()
479484
with open(INCLUDE_STYLE_FILE) as f:
@@ -487,6 +492,5 @@ class State:
487492

488493
contents = substitute(contents, "FORMAT_STYLE_OPTIONS", options_text)
489494

490-
output_file_path = sys.argv[1] if len(sys.argv) == 2 else DOC_FILE
491-
with open(output_file_path, "wb") as output:
495+
with open(args.output if args.output else DOC_FILE, "wb") as output:
492496
output.write(contents.encode())

clang/include/clang/Basic/arm_sme.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,4 +824,14 @@ let SMETargetGuard = "sme-lutv2" in {
824824
def SVLUTI4_ZT_X4 : SInst<"svluti4_zt_{d}_x4", "4i2.u", "cUc", MergeNone, "aarch64_sme_luti4_zt_x4", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>]>;
825825
}
826826

827+
let SMETargetGuard = "sme-f8f32" in {
828+
def SVMOPA_FP8_ZA32 : Inst<"svmopa_za32[_mf8]_m_fpm", "viPPdd>", "m", MergeNone, "aarch64_sme_fp8_fmopa_za32",
829+
[IsStreaming, IsInOutZA, SetsFPMR, IsOverloadNone], [ImmCheck<0, ImmCheck0_3>]>;
830+
}
831+
832+
let SMETargetGuard = "sme-f8f16" in {
833+
def SVMOPA_FP8_ZA16 : Inst<"svmopa_za16[_mf8]_m_fpm", "viPPdd>", "m", MergeNone, "aarch64_sme_fp8_fmopa_za16",
834+
[IsStreaming, IsInOutZA, SetsFPMR, IsOverloadNone], [ImmCheck<0, ImmCheck0_1>]>;
835+
}
836+
827837
} // let SVETargetGuard = InvalidMode

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ def m_riscv_Features_Group : OptionGroup<"<riscv features group>">,
240240
def m_ve_Features_Group : OptionGroup<"<ve features group>">,
241241
Group<m_Group>, DocName<"VE">;
242242
def m_loongarch_Features_Group : OptionGroup<"<loongarch features group>">,
243-
Group<m_Group>, DocName<"LoongArch">;
243+
Group<m_Group>, DocName<"LoongArch">,
244+
Visibility<[ClangOption, CLOption, FlangOption]>;
244245

245246
def m_libc_Group : OptionGroup<"<m libc group>">, Group<m_mips_Features_Group>,
246247
Flags<[HelpHidden]>;

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr OpPC,
243243
unsigned ID = Func->getBuiltinID();
244244
const Pointer &StrPtr = getParam<Pointer>(Frame, 0);
245245

246-
if (ID == Builtin::BIstrlen)
246+
if (ID == Builtin::BIstrlen || ID == Builtin::BIwcslen)
247247
diagnoseNonConstexprBuiltin(S, OpPC, ID);
248248

249249
if (!CheckArray(S, OpPC, StrPtr))
@@ -256,6 +256,12 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr OpPC,
256256
return false;
257257

258258
assert(StrPtr.getFieldDesc()->isPrimitiveArray());
259+
unsigned ElemSize = StrPtr.getFieldDesc()->getElemSize();
260+
261+
if (ID == Builtin::BI__builtin_wcslen || ID == Builtin::BIwcslen) {
262+
const ASTContext &AC = S.getASTContext();
263+
assert(ElemSize == AC.getTypeSizeInChars(AC.getWCharType()).getQuantity());
264+
}
259265

260266
size_t Len = 0;
261267
for (size_t I = StrPtr.getIndex();; ++I, ++Len) {
@@ -264,7 +270,20 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr OpPC,
264270
if (!CheckRange(S, OpPC, ElemPtr, AK_Read))
265271
return false;
266272

267-
uint8_t Val = ElemPtr.deref<uint8_t>();
273+
uint32_t Val;
274+
switch (ElemSize) {
275+
case 1:
276+
Val = ElemPtr.deref<uint8_t>();
277+
break;
278+
case 2:
279+
Val = ElemPtr.deref<uint16_t>();
280+
break;
281+
case 4:
282+
Val = ElemPtr.deref<uint32_t>();
283+
break;
284+
default:
285+
llvm_unreachable("Unsupported char size");
286+
}
268287
if (Val == 0)
269288
break;
270289
}
@@ -1859,6 +1878,8 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F,
18591878
break;
18601879
case Builtin::BI__builtin_strlen:
18611880
case Builtin::BIstrlen:
1881+
case Builtin::BI__builtin_wcslen:
1882+
case Builtin::BIwcslen:
18621883
if (!interp__builtin_strlen(S, OpPC, Frame, F, Call))
18631884
return false;
18641885
break;

clang/lib/AST/CXXInheritance.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ bool CXXRecordDecl::FindBaseClass(const CXXBaseSpecifier *Specifier,
368368
const CXXRecordDecl *BaseRecord) {
369369
assert(BaseRecord->getCanonicalDecl() == BaseRecord &&
370370
"User data for FindBaseClass is not canonical!");
371-
return Specifier->getType()->castAs<RecordType>()->getDecl()
372-
->getCanonicalDecl() == BaseRecord;
371+
return cast<CXXRecordDecl>(Specifier->getType()->getAsRecordDecl())
372+
->getCanonicalDecl() == BaseRecord;
373373
}
374374

375375
bool CXXRecordDecl::FindVirtualBaseClass(const CXXBaseSpecifier *Specifier,
@@ -378,8 +378,8 @@ bool CXXRecordDecl::FindVirtualBaseClass(const CXXBaseSpecifier *Specifier,
378378
assert(BaseRecord->getCanonicalDecl() == BaseRecord &&
379379
"User data for FindBaseClass is not canonical!");
380380
return Specifier->isVirtual() &&
381-
Specifier->getType()->castAs<RecordType>()->getDecl()
382-
->getCanonicalDecl() == BaseRecord;
381+
cast<CXXRecordDecl>(Specifier->getType()->getAsRecordDecl())
382+
->getCanonicalDecl() == BaseRecord;
383383
}
384384

385385
static bool isOrdinaryMember(const NamedDecl *ND) {
@@ -692,7 +692,7 @@ AddIndirectPrimaryBases(const CXXRecordDecl *RD, ASTContext &Context,
692692
"Cannot get indirect primary bases for class with dependent bases.");
693693

694694
const CXXRecordDecl *BaseDecl =
695-
cast<CXXRecordDecl>(I.getType()->castAs<RecordType>()->getDecl());
695+
cast<CXXRecordDecl>(I.getType()->getAsRecordDecl());
696696

697697
// Only bases with virtual bases participate in computing the
698698
// indirect primary virtual base classes.
@@ -714,7 +714,7 @@ CXXRecordDecl::getIndirectPrimaryBases(CXXIndirectPrimaryBaseSet& Bases) const {
714714
"Cannot get indirect primary bases for class with dependent bases.");
715715

716716
const CXXRecordDecl *BaseDecl =
717-
cast<CXXRecordDecl>(I.getType()->castAs<RecordType>()->getDecl());
717+
cast<CXXRecordDecl>(I.getType()->getAsRecordDecl());
718718

719719
// Only bases with virtual bases participate in computing the
720720
// indirect primary virtual base classes.

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10201,6 +10201,8 @@ CodeGenFunction::getSVEType(const SVETypeFlags &TypeFlags) {
1020110201
case SVETypeFlags::EltTyInt64:
1020210202
return llvm::ScalableVectorType::get(Builder.getInt64Ty(), 2);
1020310203

10204+
case SVETypeFlags::EltTyMFloat8:
10205+
return llvm::ScalableVectorType::get(Builder.getInt8Ty(), 16);
1020410206
case SVETypeFlags::EltTyFloat16:
1020510207
return llvm::ScalableVectorType::get(Builder.getHalfTy(), 8);
1020610208
case SVETypeFlags::EltTyBFloat16:
@@ -11255,6 +11257,10 @@ Value *CodeGenFunction::EmitAArch64SMEBuiltinExpr(unsigned BuiltinID,
1125511257
BuiltinID == SME::BI__builtin_sme_svstr_za)
1125611258
return EmitSMELdrStr(TypeFlags, Ops, Builtin->LLVMIntrinsic);
1125711259

11260+
// Emit set FPMR for intrinsics that require it
11261+
if (TypeFlags.setsFPMR())
11262+
Builder.CreateCall(CGM.getIntrinsic(Intrinsic::aarch64_set_fpmr),
11263+
Ops.pop_back_val());
1125811264
// Handle builtins which require their multi-vector operands to be swapped
1125911265
swapCommutativeSMEOperands(BuiltinID, Ops);
1126011266

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ void Flang::AddLoongArch64TargetArgs(const ArgList &Args,
213213
D.Diag(diag::err_drv_argument_not_allowed_with) << "-mabi" << V;
214214
}
215215
}
216+
217+
if (const Arg *A = Args.getLastArg(options::OPT_mannotate_tablejump,
218+
options::OPT_mno_annotate_tablejump)) {
219+
if (A->getOption().matches(options::OPT_mannotate_tablejump)) {
220+
CmdArgs.push_back("-mllvm");
221+
CmdArgs.push_back("-loongarch-annotate-tablejump");
222+
}
223+
}
216224
}
217225

218226
void Flang::AddPPCTargetArgs(const ArgList &Args,

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3747,7 +3747,8 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
37473747
} else if (!Pointee->isDependentType()) {
37483748
// FIXME: This can result in errors if the definition was imported from a
37493749
// module but is hidden.
3750-
if (!RequireCompleteType(StartLoc, Pointee,
3750+
if (Pointee->isEnumeralType() ||
3751+
!RequireCompleteType(StartLoc, Pointee,
37513752
LangOpts.CPlusPlus26
37523753
? diag::err_delete_incomplete
37533754
: diag::warn_delete_incomplete,

clang/test/AST/ByteCode/builtin-functions.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#error "huh?"
1616
#endif
1717

18+
extern "C" {
19+
typedef decltype(sizeof(int)) size_t;
20+
extern size_t wcslen(const wchar_t *p);
21+
}
1822

1923
namespace strcmp {
2024
constexpr char kFoobar[6] = {'f','o','o','b','a','r'};
@@ -93,6 +97,14 @@ constexpr const char *a = "foo\0quux";
9397
constexpr char d[] = { 'f', 'o', 'o' }; // no nul terminator.
9498
constexpr int bad = __builtin_strlen(d); // both-error {{constant expression}} \
9599
// both-note {{one-past-the-end}}
100+
101+
constexpr int wn = __builtin_wcslen(L"hello");
102+
static_assert(wn == 5);
103+
constexpr int wm = wcslen(L"hello"); // both-error {{constant expression}} \
104+
// both-note {{non-constexpr function 'wcslen' cannot be used in a constant expression}}
105+
106+
int arr[3]; // both-note {{here}}
107+
int wk = arr[wcslen(L"hello")]; // both-warning {{array index 5}}
96108
}
97109

98110
namespace nan {

0 commit comments

Comments
 (0)