[lld] [lld][NFC] Remove unnecessary else statements. (PR #69451)
Jacek Caban via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 18 14:21:55 PDT 2023
https://github.com/cjacek updated https://github.com/llvm/llvm-project/pull/69451
>From 10b50d56a6ad1eab2f67c61ff211dfde3cd45d41 Mon Sep 17 00:00:00 2001
From: Jacek Caban <jacek at codeweavers.com>
Date: Wed, 18 Oct 2023 13:58:47 +0200
Subject: [PATCH 1/2] [lld][NFC] Remove unnecessary else statements.
---
lld/COFF/Chunks.h | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/lld/COFF/Chunks.h b/lld/COFF/Chunks.h
index 4e500cafd3ce4a2..dec395a180fc1df 100644
--- a/lld/COFF/Chunks.h
+++ b/lld/COFF/Chunks.h
@@ -386,51 +386,43 @@ class SectionChunk final : public Chunk {
inline size_t Chunk::getSize() const {
if (isa<SectionChunk>(this))
return static_cast<const SectionChunk *>(this)->getSize();
- else
- return static_cast<const NonSectionChunk *>(this)->getSize();
+ return static_cast<const NonSectionChunk *>(this)->getSize();
}
inline uint32_t Chunk::getOutputCharacteristics() const {
if (isa<SectionChunk>(this))
return static_cast<const SectionChunk *>(this)->getOutputCharacteristics();
- else
- return static_cast<const NonSectionChunk *>(this)
- ->getOutputCharacteristics();
+ return static_cast<const NonSectionChunk *>(this)->getOutputCharacteristics();
}
inline void Chunk::writeTo(uint8_t *buf) const {
if (isa<SectionChunk>(this))
static_cast<const SectionChunk *>(this)->writeTo(buf);
- else
- static_cast<const NonSectionChunk *>(this)->writeTo(buf);
+ static_cast<const NonSectionChunk *>(this)->writeTo(buf);
}
inline StringRef Chunk::getSectionName() const {
if (isa<SectionChunk>(this))
return static_cast<const SectionChunk *>(this)->getSectionName();
- else
- return static_cast<const NonSectionChunk *>(this)->getSectionName();
+ return static_cast<const NonSectionChunk *>(this)->getSectionName();
}
inline void Chunk::getBaserels(std::vector<Baserel> *res) {
if (isa<SectionChunk>(this))
static_cast<SectionChunk *>(this)->getBaserels(res);
- else
- static_cast<NonSectionChunk *>(this)->getBaserels(res);
+ static_cast<NonSectionChunk *>(this)->getBaserels(res);
}
inline StringRef Chunk::getDebugName() const {
if (isa<SectionChunk>(this))
return static_cast<const SectionChunk *>(this)->getDebugName();
- else
- return static_cast<const NonSectionChunk *>(this)->getDebugName();
+ return static_cast<const NonSectionChunk *>(this)->getDebugName();
}
inline MachineTypes Chunk::getMachine() const {
if (isa<SectionChunk>(this))
return static_cast<const SectionChunk *>(this)->getMachine();
- else
- return static_cast<const NonSectionChunk *>(this)->getMachine();
+ return static_cast<const NonSectionChunk *>(this)->getMachine();
}
inline chpe_range_type Chunk::getArm64ECRangeType() const {
>From 3dc6f1f360535775abc9223152a43c25e3b7e66c Mon Sep 17 00:00:00 2001
From: Jacek Caban <jacek at codeweavers.com>
Date: Wed, 18 Oct 2023 23:21:26 +0200
Subject: [PATCH 2/2] Restore actually needed elses.
---
lld/COFF/Chunks.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lld/COFF/Chunks.h b/lld/COFF/Chunks.h
index dec395a180fc1df..cbfeb5c025adbb2 100644
--- a/lld/COFF/Chunks.h
+++ b/lld/COFF/Chunks.h
@@ -398,7 +398,8 @@ inline uint32_t Chunk::getOutputCharacteristics() const {
inline void Chunk::writeTo(uint8_t *buf) const {
if (isa<SectionChunk>(this))
static_cast<const SectionChunk *>(this)->writeTo(buf);
- static_cast<const NonSectionChunk *>(this)->writeTo(buf);
+ else
+ static_cast<const NonSectionChunk *>(this)->writeTo(buf);
}
inline StringRef Chunk::getSectionName() const {
@@ -410,7 +411,8 @@ inline StringRef Chunk::getSectionName() const {
inline void Chunk::getBaserels(std::vector<Baserel> *res) {
if (isa<SectionChunk>(this))
static_cast<SectionChunk *>(this)->getBaserels(res);
- static_cast<NonSectionChunk *>(this)->getBaserels(res);
+ else
+ static_cast<NonSectionChunk *>(this)->getBaserels(res);
}
inline StringRef Chunk::getDebugName() const {
More information about the llvm-commits
mailing list