-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[llvm] Use a new constructor of ArrayRef (NFC) #146008
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
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20250626_ArrayRef_data_size_llvm
Jun 27, 2025
Merged
[llvm] Use a new constructor of ArrayRef (NFC) #146008
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20250626_ArrayRef_data_size_llvm
Jun 27, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)
Member
|
@llvm/pr-subscribers-llvm-binary-utilities @llvm/pr-subscribers-llvm-support 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/146008.diff 10 Files Affected:
diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h
index 8d7545144dfd9..0b362d389c177 100644
--- a/llvm/include/llvm/Object/ELF.h
+++ b/llvm/include/llvm/Object/ELF.h
@@ -931,7 +931,7 @@ Expected<typename ELFT::ShdrRange> ELFFile<ELFT>::sections() const {
const uintX_t SectionTableOffset = getHeader().e_shoff;
if (SectionTableOffset == 0) {
if (!FakeSections.empty())
- return ArrayRef(FakeSections.data(), FakeSections.size());
+ return ArrayRef(FakeSections);
return ArrayRef<Elf_Shdr>();
}
diff --git a/llvm/lib/ExecutionEngine/JITLink/XCOFFLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/XCOFFLinkGraphBuilder.cpp
index 13099295eddeb..f0a14c6b1c24c 100644
--- a/llvm/lib/ExecutionEngine/JITLink/XCOFFLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/XCOFFLinkGraphBuilder.cpp
@@ -296,7 +296,7 @@ Error XCOFFLinkGraphBuilder::processCsectsAndSymbols() {
if (!CsectSymbolAddr)
return CsectSymbolAddr.takeError();
- ArrayRef<char> SectionBuffer{Data->data(), Data->size()};
+ ArrayRef<char> SectionBuffer{*Data};
auto Offset = *CsectSymbolAddr - SectionRef.getAddress();
LLVM_DEBUG(dbgs() << " symbol entry: offset = " << Offset
diff --git a/llvm/lib/ExecutionEngine/Orc/SectCreate.cpp b/llvm/lib/ExecutionEngine/Orc/SectCreate.cpp
index c50654cf47a2f..1e889e141ef96 100644
--- a/llvm/lib/ExecutionEngine/Orc/SectCreate.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/SectCreate.cpp
@@ -23,8 +23,7 @@ void SectCreateMaterializationUnit::materialize(
SubtargetFeatures(), getGenericEdgeKindName);
auto &Sect = G->createSection(SectName, MP);
- auto Content = G->allocateContent(
- ArrayRef<char>(Data->getBuffer().data(), Data->getBuffer().size()));
+ auto Content = G->allocateContent(ArrayRef<char>(Data->getBuffer()));
auto &B = G->createContentBlock(Sect, Content, ExecutorAddr(), Alignment, 0);
for (auto &[Name, Info] : ExtraSymbols) {
diff --git a/llvm/lib/Object/OffloadBundle.cpp b/llvm/lib/Object/OffloadBundle.cpp
index a4c1e0547a5b0..1e1042ce2bc21 100644
--- a/llvm/lib/Object/OffloadBundle.cpp
+++ b/llvm/lib/Object/OffloadBundle.cpp
@@ -339,8 +339,7 @@ CompressedOffloadBundle::decompress(llvm::MemoryBufferRef &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/llvm/lib/XRay/FDRTraceWriter.cpp b/llvm/lib/XRay/FDRTraceWriter.cpp
index 8e67a8f984334..fb591252ffa3e 100644
--- a/llvm/lib/XRay/FDRTraceWriter.cpp
+++ b/llvm/lib/XRay/FDRTraceWriter.cpp
@@ -96,7 +96,7 @@ Error FDRTraceWriter::visit(CustomEventRecord &R) {
if (auto E = writeMetadata<5u>(OS, R.size(), R.tsc(), R.cpu()))
return E;
auto D = R.data();
- ArrayRef<char> Bytes(D.data(), D.size());
+ ArrayRef<char> Bytes(D);
OS.write(Bytes);
return Error::success();
}
@@ -105,7 +105,7 @@ Error FDRTraceWriter::visit(CustomEventRecordV5 &R) {
if (auto E = writeMetadata<5u>(OS, R.size(), R.delta()))
return E;
auto D = R.data();
- ArrayRef<char> Bytes(D.data(), D.size());
+ ArrayRef<char> Bytes(D);
OS.write(Bytes);
return Error::success();
}
@@ -114,7 +114,7 @@ Error FDRTraceWriter::visit(TypedEventRecord &R) {
if (auto E = writeMetadata<8u>(OS, R.size(), R.delta(), R.eventType()))
return E;
auto D = R.data();
- ArrayRef<char> Bytes(D.data(), D.size());
+ ArrayRef<char> Bytes(D);
OS.write(Bytes);
return Error::success();
}
diff --git a/llvm/tools/llvm-mc/Disassembler.cpp b/llvm/tools/llvm-mc/Disassembler.cpp
index 16897054fbea8..607184e3b7247 100644
--- a/llvm/tools/llvm-mc/Disassembler.cpp
+++ b/llvm/tools/llvm-mc/Disassembler.cpp
@@ -35,7 +35,7 @@ typedef std::pair<std::vector<unsigned char>, std::vector<const char *>>
static bool PrintInsts(const MCDisassembler &DisAsm, const ByteArrayTy &Bytes,
SourceMgr &SM, MCStreamer &Streamer, bool InAtomicBlock,
const MCSubtargetInfo &STI) {
- ArrayRef<uint8_t> Data(Bytes.first.data(), Bytes.first.size());
+ ArrayRef<uint8_t> Data(Bytes.first);
// Disassemble it to strings.
uint64_t Size;
diff --git a/llvm/tools/llvm-ml/Disassembler.cpp b/llvm/tools/llvm-ml/Disassembler.cpp
index 71063deeeec46..e55561f3b7f86 100644
--- a/llvm/tools/llvm-ml/Disassembler.cpp
+++ b/llvm/tools/llvm-ml/Disassembler.cpp
@@ -33,7 +33,7 @@ typedef std::pair<std::vector<unsigned char>, std::vector<const char *>>
static bool PrintInsts(const MCDisassembler &DisAsm, const ByteArrayTy &Bytes,
SourceMgr &SM, raw_ostream &Out, MCStreamer &Streamer,
bool InAtomicBlock, const MCSubtargetInfo &STI) {
- ArrayRef<uint8_t> Data(Bytes.first.data(), Bytes.first.size());
+ ArrayRef<uint8_t> Data(Bytes.first);
// Disassemble it to strings.
uint64_t Size;
diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
index 40a7b86078d87..aa44f35a2d9cc 100644
--- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
+++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
@@ -921,7 +921,7 @@ static int linkAndVerify() {
RuntimeDyldChecker::MemoryRegionInfo SecInfo;
SecInfo.setTargetAddress(Dyld.getSectionLoadAddress(*SectionID));
StringRef SecContent = Dyld.getSectionContent(*SectionID);
- SecInfo.setContent(ArrayRef<char>(SecContent.data(), SecContent.size()));
+ SecInfo.setContent(ArrayRef<char>(SecContent));
return SecInfo;
};
@@ -945,8 +945,7 @@ static int linkAndVerify() {
SI.Offset);
StringRef SecContent =
Dyld.getSectionContent(SI.SectionID).substr(SI.Offset);
- StubMemInfo.setContent(
- ArrayRef<char>(SecContent.data(), SecContent.size()));
+ StubMemInfo.setContent(ArrayRef<char>(SecContent));
return StubMemInfo;
};
diff --git a/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
index 908d9aa31c66d..1f7067502b15b 100644
--- a/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/ExecutionSessionWrapperFunctionCallsTest.cpp
@@ -110,7 +110,7 @@ TEST(ExecutionSessionWrapperFunctionCalls, RegisterAsyncHandlerAndRun) {
EXPECT_TRUE(SPSArgList<int32_t>::deserialize(IB, Result));
RP.set_value(Result);
},
- AddAsyncTagAddr, ArrayRef<char>(ArgBuffer.data(), ArgBuffer.size()));
+ AddAsyncTagAddr, ArrayRef<char>(ArgBuffer));
EXPECT_EQ(RF.get(), (int32_t)3);
diff --git a/llvm/unittests/Support/Base64Test.cpp b/llvm/unittests/Support/Base64Test.cpp
index e6e54bb53098d..1c4766f2d3931 100644
--- a/llvm/unittests/Support/Base64Test.cpp
+++ b/llvm/unittests/Support/Base64Test.cpp
@@ -31,7 +31,7 @@ void TestBase64Decode(StringRef Input, StringRef Expected,
if (ExpectedErrorMessage.empty()) {
ASSERT_THAT_ERROR(decodeBase64(Input, DecodedBytes), Succeeded());
EXPECT_EQ(llvm::ArrayRef<char>(DecodedBytes),
- llvm::ArrayRef<char>(Expected.data(), Expected.size()));
+ llvm::ArrayRef<char>(Expected));
} else {
ASSERT_THAT_ERROR(decodeBase64(Input, DecodedBytes),
FailedWithMessage(ExpectedErrorMessage));
|
arsenm
approved these changes
Jun 27, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)