Skip to content

Commit 11daa8e

Browse files
author
George Rimar
committed
[ELF] - Make SymbolTable::addDefined return Defined.
Now it returns Symbol. This should be NFC that avoids doing cast at the caller's sides. Differential revision: https://reviews.llvm.org/D54627 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@347455 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 29249c5 commit 11daa8e

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

ELF/SymbolTable.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,9 @@ static void reportDuplicate(Symbol *Sym, InputFile *NewFile,
459459
error(Msg);
460460
}
461461

462-
Symbol *SymbolTable::addDefined(StringRef Name, uint8_t StOther, uint8_t Type,
463-
uint64_t Value, uint64_t Size, uint8_t Binding,
464-
SectionBase *Section, InputFile *File) {
462+
Defined *SymbolTable::addDefined(StringRef Name, uint8_t StOther, uint8_t Type,
463+
uint64_t Value, uint64_t Size, uint8_t Binding,
464+
SectionBase *Section, InputFile *File) {
465465
Symbol *S;
466466
bool WasInserted;
467467
std::tie(S, WasInserted) = insert(Name, getVisibility(StOther),
@@ -474,7 +474,7 @@ Symbol *SymbolTable::addDefined(StringRef Name, uint8_t StOther, uint8_t Type,
474474
else if (Cmp == 0)
475475
reportDuplicate(S, File, dyn_cast_or_null<InputSectionBase>(Section),
476476
Value);
477-
return S;
477+
return cast<Defined>(S);
478478
}
479479

480480
template <typename ELFT>

ELF/SymbolTable.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ class SymbolTable {
4545
Symbol *addUndefined(StringRef Name, uint8_t Binding, uint8_t StOther,
4646
uint8_t Type, bool CanOmitFromDynSym, InputFile *File);
4747

48-
Symbol *addDefined(StringRef Name, uint8_t StOther, uint8_t Type,
49-
uint64_t Value, uint64_t Size, uint8_t Binding,
50-
SectionBase *Section, InputFile *File);
48+
Defined *addDefined(StringRef Name, uint8_t StOther, uint8_t Type,
49+
uint64_t Value, uint64_t Size, uint8_t Binding,
50+
SectionBase *Section, InputFile *File);
5151

5252
template <class ELFT>
5353
void addShared(StringRef Name, SharedFile<ELFT> &F,

ELF/Writer.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,14 @@ static Defined *addOptionalRegular(StringRef Name, SectionBase *Sec,
172172
Symbol *S = Symtab->find(Name);
173173
if (!S || S->isDefined())
174174
return nullptr;
175-
Symbol *Sym = Symtab->addDefined(Name, StOther, STT_NOTYPE, Val,
176-
/*Size=*/0, Binding, Sec,
177-
/*File=*/nullptr);
178-
return cast<Defined>(Sym);
175+
return Symtab->addDefined(Name, StOther, STT_NOTYPE, Val,
176+
/*Size=*/0, Binding, Sec,
177+
/*File=*/nullptr);
179178
}
180179

181180
static Defined *addAbsolute(StringRef Name) {
182-
return cast<Defined>(Symtab->addDefined(Name, STV_HIDDEN, STT_NOTYPE, 0, 0,
183-
STB_GLOBAL, nullptr, nullptr));
181+
return Symtab->addDefined(Name, STV_HIDDEN, STT_NOTYPE, 0, 0, STB_GLOBAL,
182+
nullptr, nullptr);
184183
}
185184

186185
// The linker is expected to define some symbols depending on

0 commit comments

Comments
 (0)