@@ -188,6 +188,7 @@ class CommandLineParser {
188188
189189 bool ParseCommandLineOptions (int argc, const char *const *argv,
190190 StringRef Overview, raw_ostream *Errs = nullptr ,
191+ vfs::FileSystem *VFS = nullptr ,
191192 bool LongOptionsUseDoubleDash = false );
192193
193194 void forEachSubCommand (Option &Opt, function_ref<void (SubCommand &)> Action) {
@@ -1401,8 +1402,9 @@ bool cl::ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer,
14011402 return true ;
14021403}
14031404
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()) {}
14061408
14071409bool ExpansionContext::findConfigFile (StringRef FileName,
14081410 SmallVectorImpl<char > &FilePath) {
@@ -1461,7 +1463,7 @@ Error ExpansionContext::readConfigFile(StringRef CfgFile,
14611463static void initCommonOptions ();
14621464bool cl::ParseCommandLineOptions (int argc, const char *const *argv,
14631465 StringRef Overview, raw_ostream *Errs,
1464- const char *EnvVar,
1466+ vfs::FileSystem *VFS, const char *EnvVar,
14651467 bool LongOptionsUseDoubleDash) {
14661468 initCommonOptions ();
14671469 SmallVector<const char *, 20 > NewArgv;
@@ -1482,8 +1484,8 @@ bool cl::ParseCommandLineOptions(int argc, const char *const *argv,
14821484 int NewArgc = static_cast <int >(NewArgv.size ());
14831485
14841486 // 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);
14871489}
14881490
14891491// / Reset all options at least once, so that we can parse different options.
@@ -1503,17 +1505,17 @@ void CommandLineParser::ResetAllOptionOccurrences() {
15031505 }
15041506}
15051507
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) {
15111511 assert (hasOptions () && " No options specified!" );
15121512
15131513 ProgramOverview = Overview;
15141514 bool IgnoreErrors = Errs;
15151515 if (!Errs)
15161516 Errs = &errs ();
1517+ if (!VFS)
1518+ VFS = vfs::getRealFileSystem ().get ();
15171519 bool ErrorParsing = false ;
15181520
15191521 // Expand response files.
@@ -1524,7 +1526,7 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
15241526#else
15251527 auto Tokenize = cl::TokenizeGNUCommandLine;
15261528#endif
1527- ExpansionContext ECtx (A, Tokenize);
1529+ ExpansionContext ECtx (A, Tokenize, VFS );
15281530 if (Error Err = ECtx.expandResponseFiles (newArgv)) {
15291531 *Errs << toString (std::move (Err)) << ' \n ' ;
15301532 return false ;
0 commit comments