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.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index 4fd037e..7af8c89 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -869,10 +869,9 @@ TEST(CommandLineTest, ResponseFiles) {
// Expand response files.
llvm::BumpPtrAllocator A;
- llvm::StringSaver Saver(A);
- ASSERT_TRUE(llvm::cl::ExpandResponseFiles(
- Saver, llvm::cl::TokenizeGNUCommandLine, Argv, false, true, false,
- /*CurrentDir=*/StringRef(TestRoot), FS));
+ llvm::cl::ExpansionContext ECtx(A, llvm::cl::TokenizeGNUCommandLine);
+ ECtx.setVFS(&FS).setCurrentDir(TestRoot).setRelativeNames(true);
+ ASSERT_TRUE(ECtx.expandResponseFiles(Argv));
EXPECT_THAT(Argv, testing::Pointwise(
StringEquality(),
{"test/test", "-flag_1", "-option_1", "-option_2",
@@ -927,15 +926,14 @@ TEST(CommandLineTest, RecursiveResponseFiles) {
SmallVector<const char *, 4> Argv = {"test/test", SelfFileRef.c_str(),
"-option_3"};
BumpPtrAllocator A;
- StringSaver Saver(A);
#ifdef _WIN32
cl::TokenizerCallback Tokenizer = cl::TokenizeWindowsCommandLine;
#else
cl::TokenizerCallback Tokenizer = cl::TokenizeGNUCommandLine;
#endif
- ASSERT_FALSE(
- cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, false,
- /*CurrentDir=*/llvm::StringRef(TestRoot), FS));
+ llvm::cl::ExpansionContext ECtx(A, Tokenizer);
+ ECtx.setVFS(&FS).setCurrentDir(TestRoot);
+ ASSERT_FALSE(ECtx.expandResponseFiles(Argv));
EXPECT_THAT(Argv,
testing::Pointwise(StringEquality(),
@@ -971,10 +969,9 @@ TEST(CommandLineTest, ResponseFilesAtArguments) {
Argv.push_back(ResponseFileRef.c_str());
BumpPtrAllocator A;
- StringSaver Saver(A);
- ASSERT_FALSE(cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv,
- false, false, false,
- /*CurrentDir=*/StringRef(TestRoot), FS));
+ llvm::cl::ExpansionContext ECtx(A, cl::TokenizeGNUCommandLine);
+ ECtx.setVFS(&FS).setCurrentDir(TestRoot);
+ ASSERT_FALSE(ECtx.expandResponseFiles(Argv));
// ASSERT instead of EXPECT to prevent potential out-of-bounds access.
ASSERT_EQ(Argv.size(), 1 + NON_RSP_AT_ARGS + 2);
@@ -1006,10 +1003,9 @@ TEST(CommandLineTest, ResponseFileRelativePath) {
SmallVector<const char *, 2> Argv = {"test/test", "@dir/outer.rsp"};
BumpPtrAllocator A;
- StringSaver Saver(A);
- ASSERT_TRUE(cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv,
- false, true, false,
- /*CurrentDir=*/StringRef(TestRoot), FS));
+ llvm::cl::ExpansionContext ECtx(A, cl::TokenizeGNUCommandLine);
+ ECtx.setVFS(&FS).setCurrentDir(TestRoot).setRelativeNames(true);
+ ASSERT_TRUE(ECtx.expandResponseFiles(Argv));
EXPECT_THAT(Argv,
testing::Pointwise(StringEquality(), {"test/test", "-flag"}));
}
@@ -1026,10 +1022,10 @@ TEST(CommandLineTest, ResponseFileEOLs) {
MemoryBuffer::getMemBuffer("-Xclang -Wno-whatever\n input.cpp"));
SmallVector<const char *, 2> Argv = {"clang", "@eols.rsp"};
BumpPtrAllocator A;
- StringSaver Saver(A);
- ASSERT_TRUE(cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine,
- Argv, true, true, false,
- /*CurrentDir=*/StringRef(TestRoot), FS));
+ llvm::cl::ExpansionContext ECtx(A, cl::TokenizeWindowsCommandLine);
+ ECtx.setVFS(&FS).setCurrentDir(TestRoot).setMarkEOLs(true).setRelativeNames(
+ true);
+ ASSERT_TRUE(ECtx.expandResponseFiles(Argv));
const char *Expected[] = {"clang", "-Xclang", "-Wno-whatever", nullptr,
"input.cpp"};
ASSERT_EQ(std::size(Expected), Argv.size());
@@ -1125,9 +1121,8 @@ TEST(CommandLineTest, ReadConfigFile) {
EXPECT_NE(CurrDir.str(), TestDir.path());
llvm::BumpPtrAllocator A;
- llvm::StringSaver Saver(A);
- bool Result = llvm::cl::readConfigFile(ConfigFile.path(), Saver, Argv,
- *llvm::vfs::getRealFileSystem());
+ llvm::cl::ExpansionContext ECtx(A, cl::tokenizeConfigFile);
+ bool Result = ECtx.readConfigFile(ConfigFile.path(), Argv);
EXPECT_TRUE(Result);
EXPECT_EQ(Argv.size(), 13U);