Skip to content

Commit e1b3ad8

Browse files
committed
[Dependency Scanning] Reset LLVM option occurences for each libSwiftScan query
We must reset option occurences on each individual query because when an instance of the scanning tool is re-used in different contexts/different scans, we will be creating multiple compilation instances and re-parsing various (potentially-repeating) arguments. Resolves rdar://75247030
1 parent 4e0c6f9 commit e1b3ad8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/DependencyScan/DependencyScanningTool.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ DependencyScanningTool::initCompilerInstanceForScan(
101101
SmallString<128> WorkingDirectory;
102102
llvm::sys::fs::current_path(WorkingDirectory);
103103

104+
// We must reset option occurences because we are handling an unrelated
105+
// command-line to those possibly parsed parsed before using the same tool.
106+
// We must do so because LLVM options parsing is done using a managed
107+
// static `GlobalParser`.
108+
llvm::cl::ResetAllOptionOccurrences();
109+
104110
// Parse arguments.
105111
std::string CommandString;
106112
for (const auto *c : Command) {

0 commit comments

Comments
 (0)