[clang] Use a new constructor of ArrayRef (NFC) (#146007)

ArrayRef now has a new constructor that takes a parameter whose type
has data() and size().  This patch migrates:

  ArrayRef<T>(X.data(), X.size()

to:

  ArrayRef<T>(X)
This commit is contained in:
Kazu Hirata 2025-06-26 23:38:05 -07:00 committed by GitHub
parent 786ccb2c0e
commit 8f71650baa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 12 additions and 16 deletions

View File

@ -1118,10 +1118,9 @@ void emitFunctionInfo(raw_ostream &OS, const FunctionInfo &FI) {
emitParamInfo(OS, PI); emitParamInfo(OS, PI);
writer.write<uint16_t>(FI.ResultType.size()); writer.write<uint16_t>(FI.ResultType.size());
writer.write(ArrayRef<char>{FI.ResultType.data(), FI.ResultType.size()}); writer.write(ArrayRef<char>{FI.ResultType});
writer.write<uint16_t>(FI.SwiftReturnOwnership.size()); writer.write<uint16_t>(FI.SwiftReturnOwnership.size());
writer.write(ArrayRef<char>{FI.SwiftReturnOwnership.data(), writer.write(ArrayRef<char>{FI.SwiftReturnOwnership});
FI.SwiftReturnOwnership.size()});
} }
/// Used to serialize the on-disk global function table. /// Used to serialize the on-disk global function table.

View File

@ -1605,7 +1605,7 @@ ASTNodeImporter::VisitCountAttributedType(const CountAttributedType *T) {
return Importer.getToContext().getCountAttributedType( return Importer.getToContext().getCountAttributedType(
*ToWrappedTypeOrErr, CountExpr, T->isCountInBytes(), T->isOrNull(), *ToWrappedTypeOrErr, CountExpr, T->isCountInBytes(), T->isOrNull(),
ArrayRef(CoupledDecls.data(), CoupledDecls.size())); ArrayRef(CoupledDecls));
} }
ExpectedType ASTNodeImporter::VisitTemplateTypeParmType( ExpectedType ASTNodeImporter::VisitTemplateTypeParmType(
@ -6337,8 +6337,8 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl(
if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>( if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>(
D2, D, Importer.getToContext(), D->getTagKind(), DC, *BeginLocOrErr, D2, D, Importer.getToContext(), D->getTagKind(), DC, *BeginLocOrErr,
*IdLocOrErr, ToTPList, ClassTemplate, *IdLocOrErr, ToTPList, ClassTemplate, ArrayRef(TemplateArgs),
ArrayRef(TemplateArgs.data(), TemplateArgs.size()), CanonInjType, CanonInjType,
cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl))) cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
return D2; return D2;

View File

@ -744,8 +744,7 @@ private:
// Input is the same as the content of the original input file, therefore // Input is the same as the content of the original input file, therefore
// temporary file is not needed. // temporary file is not needed.
if (StringRef(BundlerConfig.FilesType).starts_with("a")) { if (StringRef(BundlerConfig.FilesType).starts_with("a")) {
auto InputFileOrErr = auto InputFileOrErr = TempFiles.Create(ArrayRef<char>(Input));
TempFiles.Create(ArrayRef<char>(Input.data(), Input.size()));
if (!InputFileOrErr) if (!InputFileOrErr)
return InputFileOrErr.takeError(); return InputFileOrErr.takeError();
ObjcopyInputFileName = *InputFileOrErr; ObjcopyInputFileName = *InputFileOrErr;
@ -1289,8 +1288,7 @@ CompressedOffloadBundle::decompress(const llvm::MemoryBuffer &Input,
HashRecalcTimer.startTimer(); HashRecalcTimer.startTimer();
llvm::MD5 Hash; llvm::MD5 Hash;
llvm::MD5::MD5Result Result; llvm::MD5::MD5Result Result;
Hash.update(llvm::ArrayRef<uint8_t>(DecompressedData.data(), Hash.update(llvm::ArrayRef<uint8_t>(DecompressedData));
DecompressedData.size()));
Hash.final(Result); Hash.final(Result);
uint64_t RecalculatedHash = Result.low(); uint64_t RecalculatedHash = Result.low();
HashRecalcTimer.stopTimer(); HashRecalcTimer.stopTimer();

View File

@ -16427,9 +16427,8 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor,
DiagnoseSentinelCalls(Constructor, Loc, AllArgs); DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
CheckConstructorCall(Constructor, DeclInitType, CheckConstructorCall(Constructor, DeclInitType, llvm::ArrayRef(AllArgs),
llvm::ArrayRef(AllArgs.data(), AllArgs.size()), Proto, Proto, Loc);
Loc);
return Invalid; return Invalid;
} }

View File

@ -1773,9 +1773,9 @@ Sema::ActOnTemplateParameterList(unsigned Depth,
for (NamedDecl *P : Params) for (NamedDecl *P : Params)
warnOnReservedIdentifier(P); warnOnReservedIdentifier(P);
return TemplateParameterList::Create( return TemplateParameterList::Create(Context, TemplateLoc, LAngleLoc,
Context, TemplateLoc, LAngleLoc, llvm::ArrayRef(Params), RAngleLoc,
llvm::ArrayRef(Params.data(), Params.size()), RAngleLoc, RequiresClause); RequiresClause);
} }
static void SetNestedNameSpecifier(Sema &S, TagDecl *T, static void SetNestedNameSpecifier(Sema &S, TagDecl *T,