@@ -254,7 +254,23 @@ DependencyScanningTool::initCompilerInstanceForScan(
254
254
// We must do so because LLVM options parsing is done using a managed
255
255
// static `GlobalParser`.
256
256
llvm::cl::ResetAllOptionOccurrences ();
257
- if (Invocation.parseArgs (CommandArgs, Instance->getDiags (),
257
+ // Parse/tokenize arguments.
258
+ std::string CommandString;
259
+ for (const auto *c : CommandArgs) {
260
+ CommandString.append (c);
261
+ CommandString.append (" " );
262
+ }
263
+ SmallVector<const char *, 4 > Args;
264
+ llvm::BumpPtrAllocator Alloc;
265
+ llvm::StringSaver Saver (Alloc);
266
+ // Ensure that we use the Windows command line parsing on Windows as we need
267
+ // to ensure that we properly handle paths.
268
+ if (llvm::Triple (llvm::sys::getProcessTriple ()).isOSWindows ())
269
+ llvm::cl::TokenizeWindowsCommandLine (CommandString, Saver, Args);
270
+ else
271
+ llvm::cl::TokenizeGNUCommandLine (CommandString, Saver, Args);
272
+
273
+ if (Invocation.parseArgs (Args, Instance->getDiags (),
258
274
nullptr , WorkingDirectory, " /tmp/foo" )) {
259
275
return std::make_error_code (std::errc::invalid_argument);
260
276
}
0 commit comments