[lld] 09db84c - [ELF] Remove unneeded null check in getRelocatedSection. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 19 18:25:27 PDT 2024
Author: Fangrui Song
Date: 2024-03-19T18:25:22-07:00
New Revision: 09db84cc5910a3546ab5b9410c295d93ed3e95cf
URL: https://github.com/llvm/llvm-project/commit/09db84cc5910a3546ab5b9410c295d93ed3e95cf
DIFF: https://github.com/llvm/llvm-project/commit/09db84cc5910a3546ab5b9410c295d93ed3e95cf.diff
LOG: [ELF] Remove unneeded null check in getRelocatedSection. NFC
Added:
Modified:
lld/ELF/InputSection.cpp
Removed:
################################################################################
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 19a6595d10ce7b..082e840adde4ab 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -316,7 +316,9 @@ InputSection::InputSection(InputFile *f, uint64_t flags, uint32_t type,
StringRef name, Kind k)
: InputSectionBase(f, flags, type,
/*Entsize*/ 0, /*Link*/ 0, /*Info*/ 0, addralign, data,
- name, k) {}
+ name, k) {
+ assert(f || this == &InputSection::discarded);
+}
template <class ELFT>
InputSection::InputSection(ObjFile<ELFT> &f, const typename ELFT::Shdr &header,
@@ -346,7 +348,7 @@ template <class ELFT> void InputSection::copyShtGroup(uint8_t *buf) {
}
InputSectionBase *InputSection::getRelocatedSection() const {
- if (!file || file->isInternal() || (type != SHT_RELA && type != SHT_REL))
+ if (file->isInternal() || (type != SHT_RELA && type != SHT_REL))
return nullptr;
ArrayRef<InputSectionBase *> sections = file->getSections();
return sections[info];
More information about the llvm-commits
mailing list