diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h index 379d06a65741..467dc128aea7 100644 --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -33,7 +33,6 @@ namespace llvm { -class BumpPtrStringSaver; class StringSaver; /// cl Namespace - This namespace contains all of the command line option diff --git a/llvm/include/llvm/Support/StringSaver.h b/llvm/include/llvm/Support/StringSaver.h index f3853ee91570..38fb7bb38339 100644 --- a/llvm/include/llvm/Support/StringSaver.h +++ b/llvm/include/llvm/Support/StringSaver.h @@ -18,25 +18,15 @@ namespace llvm { /// \brief Saves strings in the inheritor's stable storage and returns a stable /// raw character pointer. -class StringSaver { -protected: - ~StringSaver() {} - virtual const char *saveImpl(StringRef S); +class StringSaver final { + BumpPtrAllocator &Alloc; public: StringSaver(BumpPtrAllocator &Alloc) : Alloc(Alloc) {} const char *save(const char *S) { return save(StringRef(S)); } - const char *save(StringRef S) { return saveImpl(S); } + const char *save(StringRef S); const char *save(const Twine &S) { return save(StringRef(S.str())); } const char *save(std::string &S) { return save(StringRef(S)); } - -private: - BumpPtrAllocator &Alloc; -}; - -class BumpPtrStringSaver final : public StringSaver { -public: - BumpPtrStringSaver(BumpPtrAllocator &Alloc) : StringSaver(Alloc) {} }; } #endif diff --git a/llvm/lib/LibDriver/LibDriver.cpp b/llvm/lib/LibDriver/LibDriver.cpp index ff9c31cd9758..cc5c543888c3 100644 --- a/llvm/lib/LibDriver/LibDriver.cpp +++ b/llvm/lib/LibDriver/LibDriver.cpp @@ -102,7 +102,7 @@ static Optional findInputFile(StringRef File, int llvm::libDriverMain(llvm::ArrayRef ArgsArr) { SmallVector NewArgs(ArgsArr.begin(), ArgsArr.end()); BumpPtrAllocator Alloc; - BumpPtrStringSaver Saver(Alloc); + StringSaver Saver(Alloc); cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgs); ArgsArr = NewArgs; diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 17fba95ebb2b..11162ce0ec47 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -799,7 +799,7 @@ void cl::ParseEnvironmentOptions(const char *progName, const char *envVar, // telling us. SmallVector newArgv; BumpPtrAllocator A; - BumpPtrStringSaver Saver(A); + StringSaver Saver(A); newArgv.push_back(Saver.save(progName)); // Parse the value of the environment variable into a "command line" @@ -822,7 +822,7 @@ void CommandLineParser::ParseCommandLineOptions(int argc, // Expand response files. SmallVector newArgv(argv, argv + argc); BumpPtrAllocator A; - BumpPtrStringSaver Saver(A); + StringSaver Saver(A); ExpandResponseFiles(Saver, TokenizeGNUCommandLine, newArgv); argv = &newArgv[0]; argc = static_cast(newArgv.size()); diff --git a/llvm/lib/Support/StringSaver.cpp b/llvm/lib/Support/StringSaver.cpp index d6b84e53dccd..bbc1fd276266 100644 --- a/llvm/lib/Support/StringSaver.cpp +++ b/llvm/lib/Support/StringSaver.cpp @@ -11,7 +11,7 @@ using namespace llvm; -const char *StringSaver::saveImpl(StringRef S) { +const char *StringSaver::save(StringRef S) { char *P = Alloc.Allocate(S.size() + 1); memcpy(P, S.data(), S.size()); P[S.size()] = '\0'; diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp index e0fbf5b09e57..2ae30c21ec4e 100644 --- a/llvm/unittests/Support/CommandLineTest.cpp +++ b/llvm/unittests/Support/CommandLineTest.cpp @@ -155,7 +155,7 @@ void testCommandLineTokenizer(ParserFunction *parse, const char *Input, const char *const Output[], size_t OutputSize) { SmallVector Actual; BumpPtrAllocator A; - BumpPtrStringSaver Saver(A); + StringSaver Saver(A); parse(Input, Saver, Actual, /*MarkEOLs=*/false); EXPECT_EQ(OutputSize, Actual.size()); for (unsigned I = 0, E = Actual.size(); I != E; ++I) {