From 454adf645480245725c74fdbe8840ceff039ef64 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sat, 13 Jun 2015 12:49:52 +0000 Subject: Bring in a BumpPtrStringSaver from lld and simplify the interface. StringSaver now always saves to a BumpPtrAllocator. The only reason for having the virtual saveImpl is so lld can have a thread safe version. The reason for the distinct BumpPtrStringSaver class is to avoid the virtual destructor. llvm-svn: 239669 --- llvm/lib/LibDriver/LibDriver.cpp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'llvm/lib/LibDriver/LibDriver.cpp') diff --git a/llvm/lib/LibDriver/LibDriver.cpp b/llvm/lib/LibDriver/LibDriver.cpp index d028e4b..4492958 100644 --- a/llvm/lib/LibDriver/LibDriver.cpp +++ b/llvm/lib/LibDriver/LibDriver.cpp @@ -19,6 +19,7 @@ #include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/StringSaver.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" @@ -67,30 +68,10 @@ static std::string getOutputPath(llvm::opt::InputArgList *Args) { llvm_unreachable("internal error"); } -namespace { -// FIXME: Should re-use StringSaver from lld. -class StrDupSaver : public cl::StringSaver { - std::vector Dups; - -public: - ~StrDupSaver() override { - for (std::vector::iterator I = Dups.begin(), E = Dups.end(); I != E; - ++I) { - char *Dup = *I; - free(Dup); - } - } - const char *SaveString(const char *Str) override { - char *Dup = strdup(Str); - Dups.push_back(Dup); - return Dup; - } -}; -} - int llvm::libDriverMain(int Argc, const char **Argv) { SmallVector NewArgv(Argv, Argv + Argc); - StrDupSaver Saver; + BumpPtrAllocator Alloc; + BumpPtrStringSaver Saver(Alloc); cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgv); Argv = &NewArgv[0]; Argc = static_cast(NewArgv.size()); -- cgit v1.1