[lld] [LLD][COFF][NFC] Use dyn_cast on section chunks (PR #109701)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 23 11:29:55 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-coff
Author: Jacek Caban (cjacek)
<details>
<summary>Changes</summary>
Instead of dyn_cast_or_null, chunk pointers are never null.
---
Full diff: https://github.com/llvm/llvm-project/pull/109701.diff
1 Files Affected:
- (modified) lld/COFF/Writer.cpp (+4-4)
``````````diff
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index c2765453aa964e..7cf723a8cf103f 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -472,7 +472,7 @@ bool Writer::createThunks(OutputSection *os, int margin) {
// Recheck Chunks.size() each iteration, since we can insert more
// elements into it.
for (size_t i = 0; i != os->chunks.size(); ++i) {
- SectionChunk *sc = dyn_cast_or_null<SectionChunk>(os->chunks[i]);
+ SectionChunk *sc = dyn_cast<SectionChunk>(os->chunks[i]);
if (!sc)
continue;
MachineTypes machine = sc->getMachine();
@@ -606,7 +606,7 @@ void Writer::createECCodeMap() {
// Verify that all relocations are in range, with no extra margin requirements.
bool Writer::verifyRanges(const std::vector<Chunk *> chunks) {
for (Chunk *c : chunks) {
- SectionChunk *sc = dyn_cast_or_null<SectionChunk>(c);
+ SectionChunk *sc = dyn_cast<SectionChunk>(c);
if (!sc)
continue;
MachineTypes machine = sc->getMachine();
@@ -872,8 +872,8 @@ bool Writer::fixGnuImportChunks() {
if (!pSec->chunks.empty())
hasIdata = true;
llvm::stable_sort(pSec->chunks, [&](Chunk *s, Chunk *t) {
- SectionChunk *sc1 = dyn_cast_or_null<SectionChunk>(s);
- SectionChunk *sc2 = dyn_cast_or_null<SectionChunk>(t);
+ SectionChunk *sc1 = dyn_cast<SectionChunk>(s);
+ SectionChunk *sc2 = dyn_cast<SectionChunk>(t);
if (!sc1 || !sc2) {
// if SC1, order them ascending. If SC2 or both null,
// S is not less than T.
``````````
</details>
https://github.com/llvm/llvm-project/pull/109701
More information about the llvm-commits
mailing list