[lld] r275673 - Rename Version VersionDefinition.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 15 21:02:00 PDT 2016
Author: ruiu
Date: Fri Jul 15 23:02:00 2016
New Revision: 275673
URL: http://llvm.org/viewvc/llvm-project?rev=275673&view=rev
Log:
Rename Version VersionDefinition.
The identifier `Version` was used too often in the code to handle
symbol versions. The struct that contains version definitions is
named `Version`. Local variables for version ID are named `Version`.
Local varaible for version string are named `Version`.
This patch give them different names.
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
lld/trunk/ELF/SymbolListFile.cpp
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/ELF/Symbols.h
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=275673&r1=275672&r2=275673&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Fri Jul 15 23:02:00 2016
@@ -37,8 +37,8 @@ enum class UnresolvedPolicy { NoUndef, E
// This struct contains symbols version definition that
// can be found in version script if it is used for link.
-struct Version {
- Version(llvm::StringRef Name, size_t Id) : Name(Name), Id(Id) {}
+struct VersionDefinition {
+ VersionDefinition(llvm::StringRef Name, size_t Id) : Name(Name), Id(Id) {}
llvm::StringRef Name;
size_t Id;
std::vector<llvm::StringRef> Globals;
@@ -64,7 +64,7 @@ struct Configuration {
llvm::StringRef Sysroot;
llvm::StringSet<> TraceSymbol;
std::string RPath;
- std::vector<Version> SymbolVersions;
+ std::vector<VersionDefinition> SymbolVersions;
std::vector<llvm::StringRef> DynamicList;
std::vector<llvm::StringRef> SearchPaths;
std::vector<llvm::StringRef> Undefined;
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=275673&r1=275672&r2=275673&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Jul 15 23:02:00 2016
@@ -1485,7 +1485,7 @@ static StringRef getFileDefName() {
template <class ELFT> void VersionDefinitionSection<ELFT>::finalize() {
FileDefNameOff = Out<ELFT>::DynStrTab->addString(getFileDefName());
- for (Version &V : Config->SymbolVersions)
+ for (VersionDefinition &V : Config->SymbolVersions)
V.NameOff = Out<ELFT>::DynStrTab->addString(V.Name);
this->Header.sh_size =
@@ -1519,7 +1519,7 @@ template <class ELFT>
void VersionDefinitionSection<ELFT>::writeTo(uint8_t *Buf) {
writeOne(Buf, 1, getFileDefName(), FileDefNameOff);
- for (Version &V : Config->SymbolVersions) {
+ for (VersionDefinition &V : Config->SymbolVersions) {
Buf += sizeof(Elf_Verdef) + sizeof(Elf_Verdaux);
writeOne(Buf, V.Id, V.Name, V.NameOff);
}
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=275673&r1=275672&r2=275673&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Fri Jul 15 23:02:00 2016
@@ -25,7 +25,6 @@ namespace elf {
class SymbolBody;
struct SectionPiece;
-struct Version;
template <class ELFT> class SymbolTable;
template <class ELFT> class SymbolTableSection;
template <class ELFT> class StringTableSection;
Modified: lld/trunk/ELF/SymbolListFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolListFile.cpp?rev=275673&r1=275672&r2=275673&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolListFile.cpp (original)
+++ lld/trunk/ELF/SymbolListFile.cpp Fri Jul 15 23:02:00 2016
@@ -69,24 +69,24 @@ public:
void run();
private:
- void parseVersion(StringRef Version);
- void parseGlobal(StringRef Version);
+ void parseVersion(StringRef VerStr);
+ void parseGlobal(StringRef VerStr);
void parseLocal();
};
-size_t elf::defineSymbolVersion(StringRef Version) {
+size_t elf::defineSymbolVersion(StringRef VerStr) {
// Identifiers start at 2 because 0 and 1 are reserved
// for VER_NDX_LOCAL and VER_NDX_GLOBAL constants.
size_t VersionId = Config->SymbolVersions.size() + 2;
- Config->SymbolVersions.push_back(elf::Version(Version, VersionId));
+ Config->SymbolVersions.push_back({VerStr, VersionId});
return VersionId;
}
-void VersionScriptParser::parseVersion(StringRef Version) {
- defineSymbolVersion(Version);
+void VersionScriptParser::parseVersion(StringRef VerStr) {
+ defineSymbolVersion(VerStr);
if (skip("global:") || peek() != "local:")
- parseGlobal(Version);
+ parseGlobal(VerStr);
if (skip("local:"))
parseLocal();
expect("}");
@@ -95,7 +95,7 @@ void VersionScriptParser::parseVersion(S
// "Ver2 { global: foo; local: *; } Ver1;" has "Ver1" as a parent. This
// version hierarchy is, probably against your instinct, purely for human; the
// runtime doesn't care about them at all. In LLD, we simply skip the token.
- if (!Version.empty() && peek() != ";")
+ if (!VerStr.empty() && peek() != ";")
next();
expect(";");
}
@@ -106,9 +106,9 @@ void VersionScriptParser::parseLocal() {
expect(";");
}
-void VersionScriptParser::parseGlobal(StringRef Version) {
+void VersionScriptParser::parseGlobal(StringRef VerStr) {
std::vector<StringRef> *Globals;
- if (Version.empty())
+ if (VerStr.empty())
Globals = &Config->VersionScriptGlobals;
else
Globals = &Config->SymbolVersions.back().Globals;
@@ -136,13 +136,13 @@ void VersionScriptParser::run() {
}
while (!atEOF() && !Error) {
- StringRef Version = next();
- if (Version == "{") {
+ StringRef VerStr = next();
+ if (VerStr == "{") {
setError(Msg);
return;
}
expect("{");
- parseVersion(Version);
+ parseVersion(VerStr);
}
}
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=275673&r1=275672&r2=275673&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Fri Jul 15 23:02:00 2016
@@ -180,7 +180,7 @@ static uint16_t getVersionId(Symbol *Sym
if (Default)
Version = Version.drop_front();
- for (elf::Version &V : Config->SymbolVersions)
+ for (VersionDefinition &V : Config->SymbolVersions)
if (V.Name == Version)
return Default ? V.Id : (V.Id | VERSYM_HIDDEN);
@@ -590,7 +590,7 @@ template <class ELFT> void SymbolTable<E
// version tags in reverse order. We use the first match we find (the last
// matching version tag in the file).
for (size_t I = 0, E = Config->SymbolVersions.size(); I < E; ++I) {
- Version &V = Config->SymbolVersions[I];
+ VersionDefinition &V = Config->SymbolVersions[I];
for (StringRef Name : V.Globals) {
if (hasWildcard(Name))
continue;
@@ -610,7 +610,7 @@ template <class ELFT> void SymbolTable<E
}
for (size_t I = Config->SymbolVersions.size() - 1; I != (size_t)-1; --I) {
- Version &V = Config->SymbolVersions[I];
+ VersionDefinition &V = Config->SymbolVersions[I];
for (StringRef Name : V.Globals)
if (hasWildcard(Name))
for (SymbolBody *B : findAll(Name))
Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=275673&r1=275672&r2=275673&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Fri Jul 15 23:02:00 2016
@@ -30,7 +30,6 @@ class BitcodeFile;
class InputFile;
class LazyObjectFile;
class SymbolBody;
-struct Version;
template <class ELFT> class ObjectFile;
template <class ELFT> class OutputSection;
template <class ELFT> class OutputSectionBase;
More information about the llvm-commits
mailing list