Swap parameters of getSymbolValue.
Usually, a function that does symbol lookup takes symbol name as
its first argument. Also, if a function takes a source location hint,
it is usually the last parameter. So the previous parameter order
was counter-intuitive.
llvm-svn: 315433
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index da76568..25774b6 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -852,18 +852,18 @@
return false;
}
-ExprValue LinkerScript::getSymbolValue(const Twine &Loc, StringRef S) {
- if (S == ".") {
+ExprValue LinkerScript::getSymbolValue(StringRef Name, const Twine &Loc) {
+ if (Name == ".") {
if (Ctx)
return {Ctx->OutSec, false, Dot - Ctx->OutSec->Addr, Loc};
error(Loc + ": unable to get location counter value");
return 0;
}
- if (auto *Sym = dyn_cast_or_null<DefinedRegular>(Symtab->find(S)))
+ if (auto *Sym = dyn_cast_or_null<DefinedRegular>(Symtab->find(Name)))
return {Sym->Section, false, Sym->Value, Loc};
- error(Loc + ": symbol not found: " + S);
+ error(Loc + ": symbol not found: " + Name);
return 0;
}
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index 291981b..4362edf 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -231,7 +231,7 @@
uint64_t getDot() { return Dot; }
void discard(ArrayRef<InputSection *> V);
- ExprValue getSymbolValue(const Twine &Loc, StringRef S);
+ ExprValue getSymbolValue(StringRef Name, const Twine &Loc);
void fabricateDefaultCommands();
void addOrphanSections(OutputSectionFactory &Factory);
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index acbe0a9..7c8e260 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -756,7 +756,7 @@
Expr E = readExpr();
if (Op == "+=") {
std::string Loc = getCurrentLocation();
- E = [=] { return add(Script->getSymbolValue(Loc, Name), E()); };
+ E = [=] { return add(Script->getSymbolValue(Name, Loc), E()); };
}
return make<SymbolAssignment>(Name, E, getCurrentLocation());
}
@@ -1051,7 +1051,7 @@
// Tok is the dot.
if (Tok == ".")
- return [=] { return Script->getSymbolValue(Location, Tok); };
+ return [=] { return Script->getSymbolValue(Tok, Location); };
// Tok is a literal number.
if (Optional<uint64_t> Val = parseInt(Tok))
@@ -1061,7 +1061,7 @@
if (!isValidCIdentifier(Tok))
setError("malformed number: " + Tok);
Script->ReferencedSymbols.push_back(Tok);
- return [=] { return Script->getSymbolValue(Location, Tok); };
+ return [=] { return Script->getSymbolValue(Tok, Location); };
}
Expr ScriptParser::readTernary(Expr Cond) {