mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 05:25:47 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239669 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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]));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user