[lld] 65c9b84 - [Driver] Remove elf::script indirection. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri May 10 19:45:47 PDT 2024


Author: Fangrui Song
Date: 2024-05-10T19:45:42-07:00
New Revision: 65c9b8460b1aa309d012a5fe031524dbb813d64e

URL: https://github.com/llvm/llvm-project/commit/65c9b8460b1aa309d012a5fe031524dbb813d64e
DIFF: https://github.com/llvm/llvm-project/commit/65c9b8460b1aa309d012a5fe031524dbb813d64e.diff

LOG: [Driver] Remove elf::script indirection. NFC

There are 100+ references.
Use a wrapper similar to a623a4c8b4d5cc933ebc1856ce30aac935f62b18

Added: 
    

Modified: 
    lld/ELF/Driver.cpp
    lld/ELF/LinkerScript.cpp
    lld/ELF/LinkerScript.h

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index b29e1e1a67f13..dd33f4bd772f2 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -151,7 +151,7 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
                                  "--error-limit=0 to see all errors)";
 
   config = ConfigWrapper();
-  script = std::make_unique<LinkerScript>();
+  script = ScriptWrapper();
 
   symAux.emplace_back();
 

diff  --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index f9d8dcc4f71d9..c0a5014817b9c 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -44,7 +44,7 @@ using namespace llvm::support::endian;
 using namespace lld;
 using namespace lld::elf;
 
-std::unique_ptr<LinkerScript> elf::script;
+ScriptWrapper elf::script;
 
 static bool isSectionPrefix(StringRef prefix, StringRef name) {
   return name.consume_front(prefix) && (name.empty() || name[0] == '.');

diff  --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index fa7c6eb9c0d8f..b09cd12c46f99 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -402,7 +402,12 @@ class LinkerScript final {
   llvm::MapVector<StringRef, SmallVector<StringRef, 0>> provideMap;
 };
 
-LLVM_LIBRARY_VISIBILITY extern std::unique_ptr<LinkerScript> script;
+struct ScriptWrapper {
+  LinkerScript s;
+  LinkerScript *operator->() { return &s; }
+};
+
+LLVM_LIBRARY_VISIBILITY extern ScriptWrapper script;
 
 } // end namespace lld::elf
 


        


More information about the llvm-commits mailing list