mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 19:07:53 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user