diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-06-13 12:49:52 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-06-13 12:49:52 +0000 |
commit | 454adf645480245725c74fdbe8840ceff039ef64 (patch) | |
tree | 0412a6ae637df95d5eb30d87e35bb26cd220069c /llvm/unittests/Support/CommandLineTest.cpp | |
parent | d9ad0cbd70426f1b85d37d9059e66b2e5f1f0c8b (diff) | |
download | bcm5719-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/unittests/Support/CommandLineTest.cpp')
-rw-r--r-- | llvm/unittests/Support/CommandLineTest.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp index 328c4b7fcf3..e0fbf5b09e5 100644 --- a/llvm/unittests/Support/CommandLineTest.cpp +++ b/llvm/unittests/Support/CommandLineTest.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Config/config.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/StringSaver.h" #include "gtest/gtest.h" #include <stdlib.h> #include <string> @@ -146,26 +147,20 @@ TEST(CommandLineTest, UseOptionCategory) { "Category."; } -class StrDupSaver : public cl::StringSaver { - const char *SaveString(const char *Str) override { - return strdup(Str); - } -}; - -typedef void ParserFunction(StringRef Source, llvm::cl::StringSaver &Saver, +typedef void ParserFunction(StringRef Source, StringSaver &Saver, SmallVectorImpl<const char *> &NewArgv, bool MarkEOLs); void testCommandLineTokenizer(ParserFunction *parse, const char *Input, const char *const Output[], size_t OutputSize) { SmallVector<const char *, 0> Actual; - StrDupSaver Saver; + BumpPtrAllocator A; + BumpPtrStringSaver Saver(A); parse(Input, Saver, Actual, /*MarkEOLs=*/false); EXPECT_EQ(OutputSize, Actual.size()); for (unsigned I = 0, E = Actual.size(); I != E; ++I) { if (I < OutputSize) EXPECT_STREQ(Output[I], Actual[I]); - free(const_cast<char *>(Actual[I])); } } |