Skip to content

Commit f52496e

Browse files
committed
Rename SymbolBody -> Symbol
Now that we have only SymbolBody as the symbol class. So, "SymbolBody" is a bit strange name now. This is a mechanical change generated by perl -i -pe s/SymbolBody/Symbol/g $(git grep -l SymbolBody lld/ELF lld/COFF) nd clang-format-diff. Differential Revision: https://reviews.llvm.org/D39459 llvm-svn: 317370
1 parent e6b53da commit f52496e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+536
-567
lines changed

lld/COFF/Chunks.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void SectionChunk::writeTo(uint8_t *Buf) const {
251251
// Get the output section of the symbol for this relocation. The output
252252
// section is needed to compute SECREL and SECTION relocations used in debug
253253
// info.
254-
SymbolBody *Body = File->getSymbolBody(Rel.SymbolTableIndex);
254+
Symbol *Body = File->getSymbol(Rel.SymbolTableIndex);
255255
Defined *Sym = cast<Defined>(Body);
256256
Chunk *C = Sym->getChunk();
257257
OutputSection *OS = C ? C->getOutputSection() : nullptr;
@@ -328,7 +328,7 @@ void SectionChunk::getBaserels(std::vector<Baserel> *Res) {
328328
uint8_t Ty = getBaserelType(Rel);
329329
if (Ty == IMAGE_REL_BASED_ABSOLUTE)
330330
continue;
331-
SymbolBody *Body = File->getSymbolBody(Rel.SymbolTableIndex);
331+
Symbol *Body = File->getSymbol(Rel.SymbolTableIndex);
332332
if (isa<DefinedAbsolute>(Body))
333333
continue;
334334
Res->emplace_back(RVA + Rel.VirtualAddress, Ty);

lld/COFF/Chunks.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DefinedImportData;
3535
class DefinedRegular;
3636
class ObjFile;
3737
class OutputSection;
38-
class SymbolBody;
38+
class Symbol;
3939

4040
// Mask for section types (code, data, bss, disacardable, etc.)
4141
// and permissions (writable, readable or executable).
@@ -117,7 +117,7 @@ class SectionChunk final : public Chunk {
117117
public:
118118
class symbol_iterator : public llvm::iterator_adaptor_base<
119119
symbol_iterator, const coff_relocation *,
120-
std::random_access_iterator_tag, SymbolBody *> {
120+
std::random_access_iterator_tag, Symbol *> {
121121
friend SectionChunk;
122122

123123
ObjFile *File;
@@ -128,9 +128,7 @@ class SectionChunk final : public Chunk {
128128
public:
129129
symbol_iterator() = default;
130130

131-
SymbolBody *operator*() const {
132-
return File->getSymbolBody(I->SymbolTableIndex);
133-
}
131+
Symbol *operator*() const { return File->getSymbol(I->SymbolTableIndex); }
134132
};
135133

136134
SectionChunk(ObjFile *File, const coff_section *Header);

lld/COFF/Config.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ using llvm::StringRef;
2727
class DefinedAbsolute;
2828
class DefinedRelative;
2929
class StringChunk;
30-
class SymbolBody;
30+
class Symbol;
3131

3232
// Short aliases.
3333
static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
@@ -39,7 +39,7 @@ static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386;
3939
struct Export {
4040
StringRef Name; // N in /export:N or /export:E=N
4141
StringRef ExtName; // E in /export:E=N
42-
SymbolBody *Sym = nullptr;
42+
Symbol *Sym = nullptr;
4343
uint16_t Ordinal = 0;
4444
bool Noname = false;
4545
bool Data = false;
@@ -79,7 +79,7 @@ struct Configuration {
7979
llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
8080
bool Verbose = false;
8181
WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
82-
SymbolBody *Entry = nullptr;
82+
Symbol *Entry = nullptr;
8383
bool NoEntry = false;
8484
std::string OutputFile;
8585
std::string ImportName;
@@ -94,7 +94,7 @@ struct Configuration {
9494
std::vector<llvm::StringRef> Argv;
9595

9696
// Symbols in this set are considered as live by the garbage collector.
97-
std::set<SymbolBody *> GCRoot;
97+
std::set<Symbol *> GCRoot;
9898

9999
std::set<StringRef> NoDefaultLibs;
100100
bool NoDefaultLibAll = false;
@@ -105,13 +105,13 @@ struct Configuration {
105105
std::vector<Export> Exports;
106106
std::set<std::string> DelayLoads;
107107
std::map<std::string, int> DLLOrder;
108-
SymbolBody *DelayLoadHelper = nullptr;
108+
Symbol *DelayLoadHelper = nullptr;
109109

110110
bool SaveTemps = false;
111111

112112
// Used for SafeSEH.
113-
SymbolBody *SEHTable = nullptr;
114-
SymbolBody *SEHCount = nullptr;
113+
Symbol *SEHTable = nullptr;
114+
Symbol *SEHCount = nullptr;
115115

116116
// Used for /opt:lldlto=N
117117
unsigned LTOOptLevel = 2;

lld/COFF/Driver.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ void LinkerDriver::addLibSearchPaths() {
353353
}
354354
}
355355

356-
SymbolBody *LinkerDriver::addUndefined(StringRef Name) {
357-
SymbolBody *B = Symtab->addUndefined(Name);
356+
Symbol *LinkerDriver::addUndefined(StringRef Name) {
357+
Symbol *B = Symtab->addUndefined(Name);
358358
Config->GCRoot.insert(B);
359359
return B;
360360
}
@@ -1181,7 +1181,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
11811181
for (auto Pair : Config->AlternateNames) {
11821182
StringRef From = Pair.first;
11831183
StringRef To = Pair.second;
1184-
SymbolBody *Sym = Symtab->find(From);
1184+
Symbol *Sym = Symtab->find(From);
11851185
if (!Sym)
11861186
continue;
11871187
if (auto *U = dyn_cast<Undefined>(Sym))
@@ -1237,7 +1237,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
12371237
Args.hasArg(OPT_export_all_symbols))) {
12381238
AutoExporter Exporter;
12391239

1240-
Symtab->forEachSymbol([=](SymbolBody *S) {
1240+
Symtab->forEachSymbol([=](Symbol *S) {
12411241
auto *Def = dyn_cast<Defined>(S);
12421242
if (!Exporter.shouldExport(Def))
12431243
return;
@@ -1268,7 +1268,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
12681268
StringRef Name = Pair.first;
12691269
uint32_t Alignment = Pair.second;
12701270

1271-
SymbolBody *Sym = Symtab->find(Name);
1271+
Symbol *Sym = Symtab->find(Name);
12721272
if (!Sym) {
12731273
warn("/aligncomm symbol " + Name + " not found");
12741274
continue;

lld/COFF/Driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class LinkerDriver {
9696
std::set<std::string> VisitedFiles;
9797
std::set<std::string> VisitedLibs;
9898

99-
SymbolBody *addUndefined(StringRef Sym);
99+
Symbol *addUndefined(StringRef Sym);
100100
StringRef mangle(StringRef Sym);
101101

102102
// Windows specific -- "main" is not the only main function in Windows.

lld/COFF/DriverUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ void fixupExports() {
574574
}
575575

576576
for (Export &E : Config->Exports) {
577-
SymbolBody *Sym = E.Sym;
577+
Symbol *Sym = E.Sym;
578578
if (!E.ForwardTo.empty() || !Sym) {
579579
E.SymbolName = E.Name;
580580
} else {

lld/COFF/ICF.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ bool ICF::equalsConstant(const SectionChunk *A, const SectionChunk *B) {
119119
R1.VirtualAddress != R2.VirtualAddress) {
120120
return false;
121121
}
122-
SymbolBody *B1 = A->File->getSymbolBody(R1.SymbolTableIndex);
123-
SymbolBody *B2 = B->File->getSymbolBody(R2.SymbolTableIndex);
122+
Symbol *B1 = A->File->getSymbol(R1.SymbolTableIndex);
123+
Symbol *B2 = B->File->getSymbol(R2.SymbolTableIndex);
124124
if (B1 == B2)
125125
return true;
126126
if (auto *D1 = dyn_cast<DefinedRegular>(B1))
@@ -143,8 +143,8 @@ bool ICF::equalsConstant(const SectionChunk *A, const SectionChunk *B) {
143143
bool ICF::equalsVariable(const SectionChunk *A, const SectionChunk *B) {
144144
// Compare relocations.
145145
auto Eq = [&](const coff_relocation &R1, const coff_relocation &R2) {
146-
SymbolBody *B1 = A->File->getSymbolBody(R1.SymbolTableIndex);
147-
SymbolBody *B2 = B->File->getSymbolBody(R2.SymbolTableIndex);
146+
Symbol *B1 = A->File->getSymbol(R1.SymbolTableIndex);
147+
Symbol *B2 = B->File->getSymbol(R2.SymbolTableIndex);
148148
if (B1 == B2)
149149
return true;
150150
if (auto *D1 = dyn_cast<DefinedRegular>(B1))

lld/COFF/InputFiles.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ std::vector<BitcodeFile *> BitcodeFile::Instances;
5151
/// If Source is Undefined and has no weak alias set, makes it a weak
5252
/// alias to Target.
5353
static void checkAndSetWeakAlias(SymbolTable *Symtab, InputFile *F,
54-
SymbolBody *Source, SymbolBody *Target) {
54+
Symbol *Source, Symbol *Target) {
5555
if (auto *U = dyn_cast<Undefined>(Source)) {
5656
if (U->WeakAlias && U->WeakAlias != Target)
5757
Symtab->reportDuplicate(Source, F);
@@ -175,7 +175,7 @@ void ObjFile::initializeSymbols() {
175175
SymbolBodies.reserve(NumSymbols);
176176
SparseSymbolBodies.resize(NumSymbols);
177177

178-
SmallVector<std::pair<SymbolBody *, uint32_t>, 8> WeakAliases;
178+
SmallVector<std::pair<Symbol *, uint32_t>, 8> WeakAliases;
179179
int32_t LastSectionNumber = 0;
180180

181181
for (uint32_t I = 0; I < NumSymbols; ++I) {
@@ -186,7 +186,7 @@ void ObjFile::initializeSymbols() {
186186
AuxP = check(COFFObj->getSymbol(I + 1)).getRawPtr();
187187
bool IsFirst = (LastSectionNumber != Sym.getSectionNumber());
188188

189-
SymbolBody *Body = nullptr;
189+
Symbol *Body = nullptr;
190190
if (Sym.isUndefined()) {
191191
Body = createUndefined(Sym);
192192
} else if (Sym.isWeakExternal()) {
@@ -206,26 +206,26 @@ void ObjFile::initializeSymbols() {
206206
}
207207

208208
for (auto &KV : WeakAliases) {
209-
SymbolBody *Sym = KV.first;
209+
Symbol *Sym = KV.first;
210210
uint32_t Idx = KV.second;
211211
checkAndSetWeakAlias(Symtab, this, Sym, SparseSymbolBodies[Idx]);
212212
}
213213
}
214214

215-
SymbolBody *ObjFile::createUndefined(COFFSymbolRef Sym) {
215+
Symbol *ObjFile::createUndefined(COFFSymbolRef Sym) {
216216
StringRef Name;
217217
COFFObj->getSymbolName(Sym, Name);
218218
return Symtab->addUndefined(Name, this, Sym.isWeakExternal());
219219
}
220220

221-
SymbolBody *ObjFile::createDefined(COFFSymbolRef Sym, const void *AuxP,
222-
bool IsFirst) {
221+
Symbol *ObjFile::createDefined(COFFSymbolRef Sym, const void *AuxP,
222+
bool IsFirst) {
223223
StringRef Name;
224224
if (Sym.isCommon()) {
225225
auto *C = make<CommonChunk>(Sym);
226226
Chunks.push_back(C);
227227
COFFObj->getSymbolName(Sym, Name);
228-
SymbolBody *S =
228+
Symbol *S =
229229
Symtab->addCommon(this, Name, Sym.getValue(), Sym.getGeneric(), C);
230230
return S;
231231
}
@@ -280,7 +280,7 @@ SymbolBody *ObjFile::createDefined(COFFSymbolRef Sym, const void *AuxP,
280280
DefinedRegular *B;
281281
if (Sym.isExternal()) {
282282
COFFObj->getSymbolName(Sym, Name);
283-
SymbolBody *S =
283+
Symbol *S =
284284
Symtab->addRegular(this, Name, SC->isCOMDAT(), Sym.getGeneric(), SC);
285285
B = cast<DefinedRegular>(S);
286286
} else
@@ -368,7 +368,7 @@ void BitcodeFile::parse() {
368368
MB.getBuffer(), Saver.save(ParentName + MB.getBufferIdentifier()))));
369369
for (const lto::InputFile::Symbol &ObjSym : Obj->symbols()) {
370370
StringRef SymName = Saver.save(ObjSym.getName());
371-
SymbolBody *Sym;
371+
Symbol *Sym;
372372
if (ObjSym.isUndefined()) {
373373
Sym = Symtab->addUndefined(SymName, this, false);
374374
} else if (ObjSym.isCommon()) {
@@ -377,7 +377,7 @@ void BitcodeFile::parse() {
377377
// Weak external.
378378
Sym = Symtab->addUndefined(SymName, this, true);
379379
std::string Fallback = ObjSym.getCOFFWeakExternalFallback();
380-
SymbolBody *Alias = Symtab->addUndefined(Saver.save(Fallback));
380+
Symbol *Alias = Symtab->addUndefined(Saver.save(Fallback));
381381
checkAndSetWeakAlias(Symtab, this, Sym, Alias);
382382
} else {
383383
bool IsCOMDAT = ObjSym.getComdatIndex() != -1;

lld/COFF/InputFiles.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class DefinedImportData;
4747
class DefinedImportThunk;
4848
class Lazy;
4949
class SectionChunk;
50-
class SymbolBody;
50+
class Symbol;
5151
class Undefined;
5252

5353
// The root class of input files.
@@ -110,11 +110,11 @@ class ObjFile : public InputFile {
110110
MachineTypes getMachineType() override;
111111
std::vector<Chunk *> &getChunks() { return Chunks; }
112112
std::vector<SectionChunk *> &getDebugChunks() { return DebugChunks; }
113-
std::vector<SymbolBody *> &getSymbols() { return SymbolBodies; }
113+
std::vector<Symbol *> &getSymbols() { return SymbolBodies; }
114114

115-
// Returns a SymbolBody object for the SymbolIndex'th symbol in the
115+
// Returns a Symbol object for the SymbolIndex'th symbol in the
116116
// underlying object file.
117-
SymbolBody *getSymbolBody(uint32_t SymbolIndex) {
117+
Symbol *getSymbol(uint32_t SymbolIndex) {
118118
return SparseSymbolBodies[SymbolIndex];
119119
}
120120

@@ -129,7 +129,7 @@ class ObjFile : public InputFile {
129129

130130
// The list of safe exception handlers listed in .sxdata section.
131131
// COFF-specific and x86-only.
132-
std::set<SymbolBody *> SEHandlers;
132+
std::set<Symbol *> SEHandlers;
133133

134134
// Pointer to the PDB module descriptor builder. Various debug info records
135135
// will reference object files by "module index", which is here. Things like
@@ -142,8 +142,8 @@ class ObjFile : public InputFile {
142142
void initializeSymbols();
143143
void initializeSEH();
144144

145-
SymbolBody *createDefined(COFFSymbolRef Sym, const void *Aux, bool IsFirst);
146-
SymbolBody *createUndefined(COFFSymbolRef Sym);
145+
Symbol *createDefined(COFFSymbolRef Sym, const void *Aux, bool IsFirst);
146+
Symbol *createUndefined(COFFSymbolRef Sym);
147147

148148
std::unique_ptr<COFFObjectFile> COFFObj;
149149
const coff_section *SXData = nullptr;
@@ -163,13 +163,13 @@ class ObjFile : public InputFile {
163163
std::vector<Chunk *> SparseChunks;
164164

165165
// List of all symbols referenced or defined by this file.
166-
std::vector<SymbolBody *> SymbolBodies;
166+
std::vector<Symbol *> SymbolBodies;
167167

168168
// This vector contains the same symbols as SymbolBodies, but they
169-
// are indexed such that you can get a SymbolBody by symbol
169+
// are indexed such that you can get a Symbol by symbol
170170
// index. Nonexistent indices (which are occupied by auxiliary
171171
// symbols in the real symbol table) are filled with null pointers.
172-
std::vector<SymbolBody *> SparseSymbolBodies;
172+
std::vector<Symbol *> SparseSymbolBodies;
173173
};
174174

175175
// This type represents import library members that contain DLL names
@@ -210,15 +210,15 @@ class BitcodeFile : public InputFile {
210210
public:
211211
explicit BitcodeFile(MemoryBufferRef M) : InputFile(BitcodeKind, M) {}
212212
static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; }
213-
std::vector<SymbolBody *> &getSymbols() { return SymbolBodies; }
213+
std::vector<Symbol *> &getSymbols() { return SymbolBodies; }
214214
MachineTypes getMachineType() override;
215215
static std::vector<BitcodeFile *> Instances;
216216
std::unique_ptr<llvm::lto::InputFile> Obj;
217217

218218
private:
219219
void parse() override;
220220

221-
std::vector<SymbolBody *> SymbolBodies;
221+
std::vector<Symbol *> SymbolBodies;
222222
};
223223
} // namespace coff
224224

lld/COFF/LTO.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@ BitcodeCompiler::BitcodeCompiler() : LTOObj(createLTO()) {}
8888

8989
BitcodeCompiler::~BitcodeCompiler() = default;
9090

91-
static void undefine(SymbolBody *S) { replaceBody<Undefined>(S, S->getName()); }
91+
static void undefine(Symbol *S) { replaceBody<Undefined>(S, S->getName()); }
9292

9393
void BitcodeCompiler::add(BitcodeFile &F) {
9494
lto::InputFile &Obj = *F.Obj;
9595
unsigned SymNum = 0;
96-
std::vector<SymbolBody *> SymBodies = F.getSymbols();
96+
std::vector<Symbol *> SymBodies = F.getSymbols();
9797
std::vector<lto::SymbolResolution> Resols(SymBodies.size());
9898

9999
// Provide a resolution to the LTO API for each symbol.
100100
for (const lto::InputFile::Symbol &ObjSym : Obj.symbols()) {
101-
SymbolBody *Sym = SymBodies[SymNum];
101+
Symbol *Sym = SymBodies[SymNum];
102102
lto::SymbolResolution &R = Resols[SymNum];
103103
++SymNum;
104104

0 commit comments

Comments
 (0)