[PATCH] D116902: [lld-macho] Change some global pointers to unique_ptr
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 9 15:07:46 PST 2022
MaskRay created this revision.
MaskRay added a reviewer: lld-macho.
Herald added a subscriber: pengfei.
Herald added a project: lld-macho.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Similar to D116143 <https://reviews.llvm.org/D116143>. My x86-64 `lld` is ~8KiB smaller.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D116902
Files:
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/Driver.h
lld/MachO/SymbolTable.cpp
lld/MachO/SymbolTable.h
Index: lld/MachO/SymbolTable.h
===================================================================
--- lld/MachO/SymbolTable.h
+++ lld/MachO/SymbolTable.h
@@ -70,7 +70,7 @@
void treatUndefinedSymbol(const Undefined &, StringRef source = "");
-extern SymbolTable *symtab;
+extern std::unique_ptr<SymbolTable> symtab;
} // namespace macho
} // namespace lld
Index: lld/MachO/SymbolTable.cpp
===================================================================
--- lld/MachO/SymbolTable.cpp
+++ lld/MachO/SymbolTable.cpp
@@ -319,4 +319,4 @@
}
}
-SymbolTable *macho::symtab;
+std::unique_ptr<SymbolTable> macho::symtab;
Index: lld/MachO/Driver.h
===================================================================
--- lld/MachO/Driver.h
+++ lld/MachO/Driver.h
@@ -115,7 +115,7 @@
std::set<std::string> notFounds;
};
-extern DependencyTracker *depTracker;
+extern std::unique_ptr<DependencyTracker> depTracker;
} // namespace macho
} // namespace lld
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -59,8 +59,8 @@
using namespace lld;
using namespace lld::macho;
-Configuration *macho::config;
-DependencyTracker *macho::depTracker;
+std::unique_ptr<Configuration> macho::config;
+std::unique_ptr<DependencyTracker> macho::depTracker;
static HeaderFileType getOutputType(const InputArgList &args) {
// TODO: -r, -dylinker, -preload...
@@ -1136,11 +1136,11 @@
return true;
}
- config = make<Configuration>();
- symtab = make<SymbolTable>();
+ config = std::make_unique<Configuration>();
+ symtab = std::make_unique<SymbolTable>();
target = createTargetInfo(args);
- depTracker =
- make<DependencyTracker>(args.getLastArgValue(OPT_dependency_info));
+ depTracker = std::make_unique<DependencyTracker>(
+ args.getLastArgValue(OPT_dependency_info));
if (errorCount())
return false;
Index: lld/MachO/Config.h
===================================================================
--- lld/MachO/Config.h
+++ lld/MachO/Config.h
@@ -207,7 +207,7 @@
No, // Never load the archive, regardless of other flags
};
-extern Configuration *config;
+extern std::unique_ptr<Configuration> config;
} // namespace macho
} // namespace lld
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116902.398463.patch
Type: text/x-patch
Size: 2300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220109/69033780/attachment.bin>
More information about the llvm-commits
mailing list