mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-19 00:14:20 +00:00
There is only one saver of strings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244854 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
27df06a970
commit
42fe3754c5
@ -33,7 +33,6 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class BumpPtrStringSaver;
|
||||
class StringSaver;
|
||||
|
||||
/// cl Namespace - This namespace contains all of the command line option
|
||||
|
@ -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
|
||||
|
@ -102,7 +102,7 @@ static Optional<std::string> findInputFile(StringRef File,
|
||||
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;
|
||||
|
||||
|
@ -799,7 +799,7 @@ void cl::ParseEnvironmentOptions(const char *progName, const char *envVar,
|
||||
// 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"
|
||||
@ -822,7 +822,7 @@ void CommandLineParser::ParseCommandLineOptions(int argc,
|
||||
// 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());
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
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';
|
||||
|
@ -155,7 +155,7 @@ void testCommandLineTokenizer(ParserFunction *parse, const char *Input,
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user