-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[llvm] Use llvm::iterator_range::empty (NFC) #151905
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_20250803_iterator_range_empty_llvm
Aug 4, 2025
Merged
[llvm] Use llvm::iterator_range::empty (NFC) #151905
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20250803_iterator_range_empty_llvm
Aug 4, 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
@llvm/pr-subscribers-backend-directx @llvm/pr-subscribers-backend-hexagon Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/151905.diff 9 Files Affected:
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 6d0a94d8a3367..73df62abaf023 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -2260,7 +2260,7 @@ class DWARFObjInMemory final : public DWARFObject {
continue;
}
- if (Section.relocation_begin() == Section.relocation_end())
+ if (Section.relocations().empty())
continue;
// Symbol to [address, section index] cache mapping.
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
index 308dac48cbf7a..09ac0f19a7b07 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
@@ -261,7 +261,7 @@ class MachOLinkGraphBuilder_arm64 : public MachOLinkGraphBuilder {
// Skip relocations virtual sections.
if (S.isVirtual()) {
- if (S.relocation_begin() != S.relocation_end())
+ if (!S.relocations().empty())
return make_error<JITLinkError>("Virtual section contains "
"relocations");
continue;
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
index bb5f3ab7ed43c..27209a82eb5f4 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
@@ -236,7 +236,7 @@ class MachOLinkGraphBuilder_x86_64 : public MachOLinkGraphBuilder {
// Skip relocations virtual sections.
if (S.isVirtual()) {
- if (S.relocation_begin() != S.relocation_end())
+ if (!S.relocations().empty())
return make_error<JITLinkError>("Virtual section contains "
"relocations");
continue;
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
index ffc7696c3fd50..08d6c78bd1eb1 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -2822,7 +2822,7 @@ Error RuntimeDyldELF::finalizeLoad(const ObjectFile &Obj,
// object's sections to GOTs.
for (section_iterator SI = Obj.section_begin(), SE = Obj.section_end();
SI != SE; ++SI) {
- if (SI->relocation_begin() != SI->relocation_end()) {
+ if (!SI->relocations().empty()) {
Expected<section_iterator> RelSecOrErr = SI->getRelocatedSection();
if (!RelSecOrErr)
return make_error<RuntimeDyldError>(
diff --git a/llvm/lib/SandboxIR/Value.cpp b/llvm/lib/SandboxIR/Value.cpp
index e39bbc44bca00..94b4a4c9a406f 100644
--- a/llvm/lib/SandboxIR/Value.cpp
+++ b/llvm/lib/SandboxIR/Value.cpp
@@ -22,7 +22,7 @@ Value::Value(ClassID SubclassID, llvm::Value *Val, Context &Ctx)
Value::use_iterator Value::use_begin() {
llvm::Use *LLVMUse = nullptr;
- if (Val->use_begin() != Val->use_end())
+ if (!Val->uses().empty())
LLVMUse = &*Val->use_begin();
User *User = LLVMUse != nullptr ? cast_or_null<sandboxir::User>(Ctx.getValue(
Val->use_begin()->getUser()))
diff --git a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
index b6e8ce7d78b23..26a113d2d5260 100644
--- a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
+++ b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
@@ -103,7 +103,7 @@ GlobalVariable *DXContainerGlobals::computeShaderHash(Module &M) {
dxbc::ShaderHash HashData = {0, {0}};
// The Hash's IncludesSource flag gets set whenever the hashed shader includes
// debug information.
- if (M.debug_compile_units_begin() != M.debug_compile_units_end())
+ if (!M.debug_compile_units().empty())
HashData.Flags = static_cast<uint32_t>(dxbc::HashFlags::IncludesSource);
memcpy(reinterpret_cast<void *>(&HashData.Digest), Result.data(), 16);
diff --git a/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp b/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
index 102f1c65e16c6..14b6bb318e3b2 100644
--- a/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
@@ -330,7 +330,7 @@ bool HexagonCommonGEP::isHandledGepForm(GetElementPtrInst *GepI) {
if (!GepI->getType()->isPointerTy())
return false;
// No GEPs without any indices. (Is this possible?)
- if (GepI->idx_begin() == GepI->idx_end())
+ if (GepI->indices().empty())
return false;
return true;
}
diff --git a/llvm/lib/Transforms/Utils/PredicateInfo.cpp b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
index de9deab28750f..b22ecbc33e4ff 100644
--- a/llvm/lib/Transforms/Utils/PredicateInfo.cpp
+++ b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
@@ -721,7 +721,7 @@ PredicateInfo::~PredicateInfo() {
CreatedDeclarations.clear();
for (Function *F : FunctionPtrs) {
- assert(F->user_begin() == F->user_end() &&
+ assert(F->users().empty() &&
"PredicateInfo consumer did not remove all SSA copies.");
F->eraseFromParent();
}
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 0316c4ba51da6..6ce23e80d1a3d 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -2736,7 +2736,7 @@ void Dumper::printRelocations() {
for (const SectionRef &Section : ToolSectionFilter(O, &Ndx)) {
if (O.isELF() && (ELFSectionRef(Section).getFlags() & ELF::SHF_ALLOC))
continue;
- if (Section.relocation_begin() == Section.relocation_end())
+ if (Section.relocations().empty())
continue;
Expected<section_iterator> SecOrErr = Section.getRelocatedSection();
if (!SecOrErr)
|
arsenm
approved these changes
Aug 4, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
No description provided.