aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/CommandLineTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index ffabaca..e4a1b67 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -146,19 +146,26 @@ TEST(CommandLineTest, UseOptionCategory) {
"Category.";
}
-typedef void ParserFunction(StringRef Source, StringSaver &Saver,
+class StrDupSaver : public cl::StringSaver {
+ const char *SaveString(const char *Str) override {
+ return strdup(Str);
+ }
+};
+
+typedef void ParserFunction(StringRef Source, llvm::cl::StringSaver &Saver,
SmallVectorImpl<const char *> &NewArgv);
void testCommandLineTokenizer(ParserFunction *parse, const char *Input,
const char *const Output[], size_t OutputSize) {
SmallVector<const char *, 0> Actual;
- StringSaver Saver;
+ StrDupSaver Saver;
parse(Input, Saver, Actual);
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]));
}
}