[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);
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(ArrayRef<char>{FI.SwiftReturnOwnership.data(),
FI.SwiftReturnOwnership.size()});
writer.write(ArrayRef<char>{FI.SwiftReturnOwnership});
}
/// Used to serialize the on-disk global function table.

View File

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

View File

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

View File

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

View File

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