[lld] r315433 - Swap parameters of getSymbolValue.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 10 21:34:34 PDT 2017


Author: ruiu
Date: Tue Oct 10 21:34:34 2017
New Revision: 315433

URL: http://llvm.org/viewvc/llvm-project?rev=315433&view=rev
Log:
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.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/LinkerScript.h
    lld/trunk/ELF/ScriptParser.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=315433&r1=315432&r2=315433&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Oct 10 21:34:34 2017
@@ -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;
 }
 

Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=315433&r1=315432&r2=315433&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Tue Oct 10 21:34:34 2017
@@ -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);

Modified: lld/trunk/ELF/ScriptParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ScriptParser.cpp?rev=315433&r1=315432&r2=315433&view=diff
==============================================================================
--- lld/trunk/ELF/ScriptParser.cpp (original)
+++ lld/trunk/ELF/ScriptParser.cpp Tue Oct 10 21:34:34 2017
@@ -756,7 +756,7 @@ SymbolAssignment *ScriptParser::readAssi
   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) {




More information about the llvm-commits mailing list