Skip to content

Commit 8f71650

Browse files
[clang] Use a new constructor of ArrayRef (NFC) (llvm#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)
1 parent 786ccb2 commit 8f71650

File tree

5 files changed

+12
-16
lines changed

5 files changed

+12
-16
lines changed

clang/lib/APINotes/APINotesWriter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,10 +1118,9 @@ void emitFunctionInfo(raw_ostream &OS, const FunctionInfo &FI) {
11181118
emitParamInfo(OS, PI);
11191119

11201120
writer.write<uint16_t>(FI.ResultType.size());
1121-
writer.write(ArrayRef<char>{FI.ResultType.data(), FI.ResultType.size()});
1121+
writer.write(ArrayRef<char>{FI.ResultType});
11221122
writer.write<uint16_t>(FI.SwiftReturnOwnership.size());
1123-
writer.write(ArrayRef<char>{FI.SwiftReturnOwnership.data(),
1124-
FI.SwiftReturnOwnership.size()});
1123+
writer.write(ArrayRef<char>{FI.SwiftReturnOwnership});
11251124
}
11261125

11271126
/// Used to serialize the on-disk global function table.

clang/lib/AST/ASTImporter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,7 @@ ASTNodeImporter::VisitCountAttributedType(const CountAttributedType *T) {
16051605

16061606
return Importer.getToContext().getCountAttributedType(
16071607
*ToWrappedTypeOrErr, CountExpr, T->isCountInBytes(), T->isOrNull(),
1608-
ArrayRef(CoupledDecls.data(), CoupledDecls.size()));
1608+
ArrayRef(CoupledDecls));
16091609
}
16101610

16111611
ExpectedType ASTNodeImporter::VisitTemplateTypeParmType(
@@ -6337,8 +6337,8 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl(
63376337

63386338
if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>(
63396339
D2, D, Importer.getToContext(), D->getTagKind(), DC, *BeginLocOrErr,
6340-
*IdLocOrErr, ToTPList, ClassTemplate,
6341-
ArrayRef(TemplateArgs.data(), TemplateArgs.size()), CanonInjType,
6340+
*IdLocOrErr, ToTPList, ClassTemplate, ArrayRef(TemplateArgs),
6341+
CanonInjType,
63426342
cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
63436343
return D2;
63446344

clang/lib/Driver/OffloadBundler.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,7 @@ class ObjectFileHandler final : public FileHandler {
744744
// Input is the same as the content of the original input file, therefore
745745
// temporary file is not needed.
746746
if (StringRef(BundlerConfig.FilesType).starts_with("a")) {
747-
auto InputFileOrErr =
748-
TempFiles.Create(ArrayRef<char>(Input.data(), Input.size()));
747+
auto InputFileOrErr = TempFiles.Create(ArrayRef<char>(Input));
749748
if (!InputFileOrErr)
750749
return InputFileOrErr.takeError();
751750
ObjcopyInputFileName = *InputFileOrErr;
@@ -1289,8 +1288,7 @@ CompressedOffloadBundle::decompress(const llvm::MemoryBuffer &Input,
12891288
HashRecalcTimer.startTimer();
12901289
llvm::MD5 Hash;
12911290
llvm::MD5::MD5Result Result;
1292-
Hash.update(llvm::ArrayRef<uint8_t>(DecompressedData.data(),
1293-
DecompressedData.size()));
1291+
Hash.update(llvm::ArrayRef<uint8_t>(DecompressedData));
12941292
Hash.final(Result);
12951293
uint64_t RecalculatedHash = Result.low();
12961294
HashRecalcTimer.stopTimer();

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16427,9 +16427,8 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor,
1642716427

1642816428
DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
1642916429

16430-
CheckConstructorCall(Constructor, DeclInitType,
16431-
llvm::ArrayRef(AllArgs.data(), AllArgs.size()), Proto,
16432-
Loc);
16430+
CheckConstructorCall(Constructor, DeclInitType, llvm::ArrayRef(AllArgs),
16431+
Proto, Loc);
1643316432

1643416433
return Invalid;
1643516434
}

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,9 +1773,9 @@ Sema::ActOnTemplateParameterList(unsigned Depth,
17731773
for (NamedDecl *P : Params)
17741774
warnOnReservedIdentifier(P);
17751775

1776-
return TemplateParameterList::Create(
1777-
Context, TemplateLoc, LAngleLoc,
1778-
llvm::ArrayRef(Params.data(), Params.size()), RAngleLoc, RequiresClause);
1776+
return TemplateParameterList::Create(Context, TemplateLoc, LAngleLoc,
1777+
llvm::ArrayRef(Params), RAngleLoc,
1778+
RequiresClause);
17791779
}
17801780

17811781
static void SetNestedNameSpecifier(Sema &S, TagDecl *T,

0 commit comments

Comments
 (0)