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
This commit is contained in:
Rui Ueyama
2017-10-11 04:34:34 +00:00
parent f5733500c9
commit 722221f5a7
3 changed files with 8 additions and 8 deletions

View File

@@ -852,18 +852,18 @@ bool LinkerScript::needsInterpSection() {
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;
}

View File

@@ -231,7 +231,7 @@ public:
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);

View File

@@ -756,7 +756,7 @@ SymbolAssignment *ScriptParser::readAssignment(StringRef Name) {
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 @@ Expr ScriptParser::readPrimary() {
// 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 @@ Expr ScriptParser::readPrimary() {
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) {