namespace llvm {
-class BumpPtrStringSaver;
class StringSaver;
/// cl Namespace - This namespace contains all of the command line option
/// \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
int llvm::libDriverMain(llvm::ArrayRef<const char*> ArgsArr) {
SmallVector<const char *, 20> NewArgs(ArgsArr.begin(), ArgsArr.end());
BumpPtrAllocator Alloc;
- BumpPtrStringSaver Saver(Alloc);
+ StringSaver Saver(Alloc);
cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgs);
ArgsArr = NewArgs;
// telling us.
SmallVector<const char *, 20> 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"
// Expand response files.
SmallVector<const char *, 20> newArgv(argv, argv + argc);
BumpPtrAllocator A;
- BumpPtrStringSaver Saver(A);
+ StringSaver Saver(A);
ExpandResponseFiles(Saver, TokenizeGNUCommandLine, newArgv);
argv = &newArgv[0];
argc = static_cast<int>(newArgv.size());
using namespace llvm;
-const char *StringSaver::saveImpl(StringRef S) {
+const char *StringSaver::save(StringRef S) {
char *P = Alloc.Allocate<char>(S.size() + 1);
memcpy(P, S.data(), S.size());
P[S.size()] = '\0';
const char *const Output[], size_t OutputSize) {
SmallVector<const char *, 0> 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) {