[lld] 26cc651 - [ELF] Improve comment of InputSection::file and update getFile. NFC (#79550)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 26 10:43:06 PST 2024
Author: Fangrui Song
Date: 2024-01-26T10:43:02-08:00
New Revision: 26cc651f1b2a9c74ce332a14f0e35c03db34876b
URL: https://github.com/llvm/llvm-project/commit/26cc651f1b2a9c74ce332a14f0e35c03db34876b
DIFF: https://github.com/llvm/llvm-project/commit/26cc651f1b2a9c74ce332a14f0e35c03db34876b.diff
LOG: [ELF] Improve comment of InputSection::file and update getFile. NFC (#79550)
Clarify a comment after #78944.
All uses of `getFile()` assert `file` is non-null. `getFile` is not used
with a
synthetic section. Replace `cast_or_null` with `cast`.
Added:
Modified:
lld/ELF/InputSection.h
Removed:
################################################################################
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index dda4242d8be1c1f..bb9dff38ae02995 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -118,9 +118,9 @@ class InputSectionBase : public SectionBase {
static bool classof(const SectionBase *s) { return s->kind() != Output; }
- // The file which contains this section. Its dynamic type is always
- // ObjFile<ELFT>, but in order to avoid ELFT, we use InputFile as
- // its static type.
+ // The file which contains this section. Its dynamic type is usually
+ // ObjFile<ELFT>, but may be an InputFile of InternalKind (for a synthetic
+ // section).
InputFile *file;
// Input sections are part of an output section. Special sections
@@ -132,8 +132,9 @@ class InputSectionBase : public SectionBase {
// Section index of the relocation section if exists.
uint32_t relSecIdx = 0;
+ // Getter when the dynamic type is ObjFile<ELFT>.
template <class ELFT> ObjFile<ELFT> *getFile() const {
- return cast_or_null<ObjFile<ELFT>>(file);
+ return cast<ObjFile<ELFT>>(file);
}
// Used by --optimize-bb-jumps and RISC-V linker relaxation temporarily to
More information about the llvm-commits
mailing list