Skip to content

Commit 26cc651

Browse files
authored
[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`.
1 parent 02d3a79 commit 26cc651

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lld/ELF/InputSection.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ class InputSectionBase : public SectionBase {
118118

119119
static bool classof(const SectionBase *s) { return s->kind() != Output; }
120120

121-
// The file which contains this section. Its dynamic type is always
122-
// ObjFile<ELFT>, but in order to avoid ELFT, we use InputFile as
123-
// its static type.
121+
// The file which contains this section. Its dynamic type is usually
122+
// ObjFile<ELFT>, but may be an InputFile of InternalKind (for a synthetic
123+
// section).
124124
InputFile *file;
125125

126126
// Input sections are part of an output section. Special sections
@@ -132,8 +132,9 @@ class InputSectionBase : public SectionBase {
132132
// Section index of the relocation section if exists.
133133
uint32_t relSecIdx = 0;
134134

135+
// Getter when the dynamic type is ObjFile<ELFT>.
135136
template <class ELFT> ObjFile<ELFT> *getFile() const {
136-
return cast_or_null<ObjFile<ELFT>>(file);
137+
return cast<ObjFile<ELFT>>(file);
137138
}
138139

139140
// Used by --optimize-bb-jumps and RISC-V linker relaxation temporarily to

0 commit comments

Comments
 (0)