summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LibDriver
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-06-13 12:49:52 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-06-13 12:49:52 +0000
commit454adf645480245725c74fdbe8840ceff039ef64 (patch)
tree0412a6ae637df95d5eb30d87e35bb26cd220069c /llvm/lib/LibDriver
parentd9ad0cbd70426f1b85d37d9059e66b2e5f1f0c8b (diff)
downloadbcm5719-llvm-454adf645480245725c74fdbe8840ceff039ef64.tar.gz
bcm5719-llvm-454adf645480245725c74fdbe8840ceff039ef64.zip
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
Diffstat (limited to 'llvm/lib/LibDriver')
-rw-r--r--llvm/lib/LibDriver/LibDriver.cpp25
1 files changed, 3 insertions, 22 deletions
diff --git a/llvm/lib/LibDriver/LibDriver.cpp b/llvm/lib/LibDriver/LibDriver.cpp
index d028e4bbca5..44929580f82 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<char *> Dups;
-
-public:
- ~StrDupSaver() override {
- for (std::vector<char *>::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<const char *, 20> NewArgv(Argv, Argv + Argc);
- StrDupSaver Saver;
+ BumpPtrAllocator Alloc;
+ BumpPtrStringSaver Saver(Alloc);
cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgv);
Argv = &NewArgv[0];
Argc = static_cast<int>(NewArgv.size());
OpenPOWER on IntegriCloud