-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] Use a new constructor of ArrayRef (NFC) #146007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang] Use a new constructor of ArrayRef (NFC) #146007
Conversation
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)
@llvm/pr-subscribers-clang-driver Author: Kazu Hirata (kazutakahirata) ChangesArrayRef now has a new constructor that takes a parameter whose type ArrayRef<T>(X.data(), X.size() to: ArrayRef<T>(X) Full diff: https://github.com/llvm/llvm-project/pull/146007.diff 5 Files Affected:
diff --git a/clang/lib/APINotes/APINotesWriter.cpp b/clang/lib/APINotes/APINotesWriter.cpp
index 7578bc37b5c68..ffc5473988735 100644
--- a/clang/lib/APINotes/APINotesWriter.cpp
+++ b/clang/lib/APINotes/APINotesWriter.cpp
@@ -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.
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index c4d20554f09ef..90d309e49b264 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -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;
diff --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp
index 3dfd51ee2365a..e83aee01b75cb 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -744,8 +744,7 @@ class ObjectFileHandler final : public FileHandler {
// 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();
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 16645ecf411e5..c492e5f3f2dba 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -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;
}
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index ccc532e1fd3de..1a98b3583185e 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -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,
|
@llvm/pr-subscribers-clang Author: Kazu Hirata (kazutakahirata) ChangesArrayRef now has a new constructor that takes a parameter whose type ArrayRef<T>(X.data(), X.size() to: ArrayRef<T>(X) Full diff: https://github.com/llvm/llvm-project/pull/146007.diff 5 Files Affected:
diff --git a/clang/lib/APINotes/APINotesWriter.cpp b/clang/lib/APINotes/APINotesWriter.cpp
index 7578bc37b5c68..ffc5473988735 100644
--- a/clang/lib/APINotes/APINotesWriter.cpp
+++ b/clang/lib/APINotes/APINotesWriter.cpp
@@ -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.
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index c4d20554f09ef..90d309e49b264 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -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;
diff --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp
index 3dfd51ee2365a..e83aee01b75cb 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -744,8 +744,7 @@ class ObjectFileHandler final : public FileHandler {
// 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();
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 16645ecf411e5..c492e5f3f2dba 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -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;
}
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index ccc532e1fd3de..1a98b3583185e 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -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,
|
ArrayRef now has a new constructor that takes a parameter whose type
has data() and size(). This patch migrates:
ArrayRef(X.data(), X.size()
to:
ArrayRef(X)