diff options
Diffstat (limited to 'lld/lib/Driver')
-rw-r--r-- | lld/lib/Driver/GnuLdDriver.cpp | 17 | ||||
-rw-r--r-- | lld/lib/Driver/WinLinkDriver.cpp | 17 |
2 files changed, 4 insertions, 30 deletions
diff --git a/lld/lib/Driver/GnuLdDriver.cpp b/lld/lib/Driver/GnuLdDriver.cpp index 0375ec8a665..935908b33ef 100644 --- a/lld/lib/Driver/GnuLdDriver.cpp +++ b/lld/lib/Driver/GnuLdDriver.cpp @@ -31,6 +31,7 @@ #include "llvm/Support/Path.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" +#include "llvm/Support/StringSaver.h" #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" #include <cstring> @@ -74,20 +75,6 @@ public: GnuLdOptTable() : OptTable(infoTable, llvm::array_lengthof(infoTable)){} }; -class DriverStringSaver : public llvm::cl::StringSaver { -public: - DriverStringSaver(BumpPtrAllocator &alloc) : _alloc(alloc) {} - - const char *SaveString(const char *s) override { - char *p = _alloc.Allocate<char>(strlen(s) + 1); - strcpy(p, s); - return p; - } - -private: - BumpPtrAllocator &_alloc; -}; - } // anonymous namespace // If a command line option starts with "@", the driver reads its suffix as a @@ -101,7 +88,7 @@ maybeExpandResponseFiles(int argc, const char **argv, BumpPtrAllocator &alloc) { SmallVector<const char *, 256> smallvec; for (int i = 0; i < argc; ++i) smallvec.push_back(argv[i]); - DriverStringSaver saver(alloc); + llvm::BumpPtrStringSaver saver(alloc); llvm::cl::ExpandResponseFiles(saver, llvm::cl::TokenizeGNUCommandLine, smallvec); // Pack the results to a C-array and return it. diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp index 7bc26bb24b0..80bd0b3d250 100644 --- a/lld/lib/Driver/WinLinkDriver.cpp +++ b/lld/lib/Driver/WinLinkDriver.cpp @@ -29,6 +29,7 @@ #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" #include "llvm/Support/Program.h" +#include "llvm/Support/StringSaver.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> #include <cctype> @@ -694,20 +695,6 @@ static void processLibEnv(PECOFFLinkingContext &ctx) { ctx.appendInputSearchPath(ctx.allocate(path)); } -namespace { -class DriverStringSaver : public llvm::cl::StringSaver { -public: - DriverStringSaver(PECOFFLinkingContext &ctx) : _ctx(ctx) {} - - const char *SaveString(const char *s) override { - return _ctx.allocate(StringRef(s)).data(); - } - -private: - PECOFFLinkingContext &_ctx; -}; -} - // Tokenize command line options in a given file and add them to result. static bool readResponseFile(StringRef path, PECOFFLinkingContext &ctx, std::vector<const char *> &result) { @@ -716,7 +703,7 @@ static bool readResponseFile(StringRef path, PECOFFLinkingContext &ctx, return false; StringRef contentsStr(reinterpret_cast<const char *>(contents.data()), contents.size()); - DriverStringSaver saver(ctx); + llvm::BumpPtrStringSaver saver(ctx.getAllocator()); SmallVector<const char *, 0> args; llvm::cl::TokenizeWindowsCommandLine(contentsStr, saver, args); for (const char *s : args) |