[ELF] De-template Symbol::resolveLazy. NFC
authorFangrui Song <i@maskray.me>
Thu, 24 Feb 2022 20:20:05 +0000 (12:20 -0800)
committerFangrui Song <i@maskray.me>
Thu, 24 Feb 2022 20:20:05 +0000 (12:20 -0800)
lld/ELF/Symbols.cpp
lld/ELF/Symbols.h

index 6bf63c2..e361cce 100644 (file)
@@ -650,20 +650,15 @@ void Symbol::resolveDefined(const Defined &other) {
     replace(other);
 }
 
-template <class LazyT>
-static void replaceCommon(Symbol &oldSym, const LazyT &newSym) {
-  backwardReferences.erase(&oldSym);
-  oldSym.replace(newSym);
-  newSym.extract();
-}
-
-template <class LazyT> void Symbol::resolveLazy(const LazyT &other) {
+void Symbol::resolveLazy(const LazyObject &other) {
   // For common objects, we want to look for global or weak definitions that
   // should be extracted as the canonical definition instead.
   if (isCommon() && elf::config->fortranCommon) {
     if (auto *loSym = dyn_cast<LazyObject>(&other)) {
       if (loSym->file->shouldExtractForCommon(getName())) {
-        replaceCommon(*this, other);
+        backwardReferences.erase(this);
+        replace(other);
+        other.extract();
         return;
       }
     }
index 1a6cc9f..be4eb49 100644 (file)
@@ -36,6 +36,7 @@ class InputSectionBase;
 class SharedSymbol;
 class Symbol;
 class Undefined;
+class LazyObject;
 class InputFile;
 
 // Some index properties of a symbol are stored separately in this auxiliary
@@ -224,7 +225,7 @@ private:
   void resolveUndefined(const Undefined &other);
   void resolveCommon(const CommonSymbol &other);
   void resolveDefined(const Defined &other);
-  template <class LazyT> void resolveLazy(const LazyT &other);
+  void resolveLazy(const LazyObject &other);
   void resolveShared(const SharedSymbol &other);
 
   int compare(const Symbol *other) const;