@@ -188,6 +188,7 @@ class CommandLineParser {
188
188
189
189
bool ParseCommandLineOptions (int argc, const char *const *argv,
190
190
StringRef Overview, raw_ostream *Errs = nullptr ,
191
+ vfs::FileSystem *VFS = nullptr ,
191
192
bool LongOptionsUseDoubleDash = false );
192
193
193
194
void forEachSubCommand (Option &Opt, function_ref<void (SubCommand &)> Action) {
@@ -1401,8 +1402,9 @@ bool cl::ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer,
1401
1402
return true ;
1402
1403
}
1403
1404
1404
- ExpansionContext::ExpansionContext (BumpPtrAllocator &A, TokenizerCallback T)
1405
- : Saver(A), Tokenizer(T), FS(vfs::getRealFileSystem().get()) {}
1405
+ ExpansionContext::ExpansionContext (BumpPtrAllocator &A, TokenizerCallback T,
1406
+ vfs::FileSystem *FS)
1407
+ : Saver(A), Tokenizer(T), FS(FS ? FS : vfs::getRealFileSystem().get()) {}
1406
1408
1407
1409
bool ExpansionContext::findConfigFile (StringRef FileName,
1408
1410
SmallVectorImpl<char > &FilePath) {
@@ -1461,7 +1463,7 @@ Error ExpansionContext::readConfigFile(StringRef CfgFile,
1461
1463
static void initCommonOptions ();
1462
1464
bool cl::ParseCommandLineOptions (int argc, const char *const *argv,
1463
1465
StringRef Overview, raw_ostream *Errs,
1464
- const char *EnvVar,
1466
+ vfs::FileSystem *VFS, const char *EnvVar,
1465
1467
bool LongOptionsUseDoubleDash) {
1466
1468
initCommonOptions ();
1467
1469
SmallVector<const char *, 20 > NewArgv;
@@ -1482,8 +1484,8 @@ bool cl::ParseCommandLineOptions(int argc, const char *const *argv,
1482
1484
int NewArgc = static_cast <int >(NewArgv.size ());
1483
1485
1484
1486
// Parse all options.
1485
- return GlobalParser->ParseCommandLineOptions (NewArgc, &NewArgv[ 0 ], Overview,
1486
- Errs, LongOptionsUseDoubleDash);
1487
+ return GlobalParser->ParseCommandLineOptions (
1488
+ NewArgc, &NewArgv[ 0 ], Overview, Errs, VFS , LongOptionsUseDoubleDash);
1487
1489
}
1488
1490
1489
1491
// / Reset all options at least once, so that we can parse different options.
@@ -1503,17 +1505,17 @@ void CommandLineParser::ResetAllOptionOccurrences() {
1503
1505
}
1504
1506
}
1505
1507
1506
- bool CommandLineParser::ParseCommandLineOptions (int argc,
1507
- const char *const *argv,
1508
- StringRef Overview,
1509
- raw_ostream *Errs,
1510
- bool LongOptionsUseDoubleDash) {
1508
+ bool CommandLineParser::ParseCommandLineOptions (
1509
+ int argc, const char *const *argv, StringRef Overview, raw_ostream *Errs,
1510
+ vfs::FileSystem *VFS, bool LongOptionsUseDoubleDash) {
1511
1511
assert (hasOptions () && " No options specified!" );
1512
1512
1513
1513
ProgramOverview = Overview;
1514
1514
bool IgnoreErrors = Errs;
1515
1515
if (!Errs)
1516
1516
Errs = &errs ();
1517
+ if (!VFS)
1518
+ VFS = vfs::getRealFileSystem ().get ();
1517
1519
bool ErrorParsing = false ;
1518
1520
1519
1521
// Expand response files.
@@ -1524,7 +1526,7 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
1524
1526
#else
1525
1527
auto Tokenize = cl::TokenizeGNUCommandLine;
1526
1528
#endif
1527
- ExpansionContext ECtx (A, Tokenize);
1529
+ ExpansionContext ECtx (A, Tokenize, VFS );
1528
1530
if (Error Err = ECtx.expandResponseFiles (newArgv)) {
1529
1531
*Errs << toString (std::move (Err)) << ' \n ' ;
1530
1532
return false ;
0 commit comments