Skip to content

Commit 0d45e86

Browse files
authored
DependencyScan: change commandline processing style
We would previously unconditionally treat the command line as GNU style arguments. However, Windows uses a different command-line style, and this would incorrectly process the arguments, potentially corrupting paths which do not quote the path separator. Ideally, we would introduce a new api (`swiftscan_compiler_target_info_query_v3`?) that takes a quoting style (matching `--rsp-quoting`) which would allow us to support both quoting styles properly.
1 parent c8ef200 commit 0d45e86

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/DependencyScan/DependencyScanningTool.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ llvm::ErrorOr<swiftscan_string_ref_t> getTargetInfo(ArrayRef<const char *> Comma
4242
SmallVector<const char *, 4> Args;
4343
llvm::BumpPtrAllocator Alloc;
4444
llvm::StringSaver Saver(Alloc);
45-
llvm::cl::TokenizeGNUCommandLine(CommandString, Saver, Args);
45+
// Ensure that we use the Windows command line parsing on Windows as we need
46+
// to ensure that we properly handle paths.
47+
if (llvm::Triple(llvm::sys::getProcessTriple()).isOSwindows())
48+
llvm::cl::TokenizeWindowsCommandLine(CommandString, Saver, Args);
49+
else
50+
llvm::cl::TokenizeGNUCommandLine(CommandString, Saver, Args);
4651
SourceManager dummySM;
4752
DiagnosticEngine DE(dummySM);
4853
CompilerInvocation Invocation;

0 commit comments

Comments
 (0)