[Dependency Scanning] Always use a locking diagnostic consumer

Since we enabled parallel dependency scanning by-default, each individual scan needs a diagnostic consumer that is safe to use across many threads. Deprecate the 'Locking' sub-class, making its behavior the default in the base class.
This commit is contained in:
Artem Chikin
2025-05-02 15:25:07 -07:00
parent bb581a885b
commit f830a207b2
2 changed files with 6 additions and 21 deletions

View File

@@ -74,6 +74,8 @@ void DependencyScanDiagnosticCollector::handleDiagnostic(SourceManager &SM,
void DependencyScanDiagnosticCollector::addDiagnostic(
SourceManager &SM, const DiagnosticInfo &Info) {
llvm::sys::SmartScopedLock<true> Lock(ScanningDiagnosticConsumerStateLock);
// Determine what kind of diagnostic we're emitting.
llvm::SourceMgr::DiagKind SMKind;
switch (Info.Kind) {
@@ -129,12 +131,6 @@ void DependencyScanDiagnosticCollector::addDiagnostic(
}
}
void LockingDependencyScanDiagnosticCollector::addDiagnostic(
SourceManager &SM, const DiagnosticInfo &Info) {
llvm::sys::SmartScopedLock<true> Lock(ScanningDiagnosticConsumerStateLock);
DependencyScanDiagnosticCollector::addDiagnostic(SM, Info);
}
swiftscan_diagnostic_set_t *mapCollectedDiagnosticsForOutput(
const DependencyScanDiagnosticCollector *diagnosticCollector) {
auto collectedDiagnostics = diagnosticCollector->getDiagnostics();
@@ -272,7 +268,8 @@ DependencyScanningTool::getDependencies(
StringRef WorkingDirectory) {
// There may be errors as early as in instance initialization, so we must ensure
// we can catch those.
auto ScanDiagnosticConsumer = std::make_shared<DependencyScanDiagnosticCollector>();
auto ScanDiagnosticConsumer =
std::make_shared<DependencyScanDiagnosticCollector>();
// The primary instance used to scan the query Swift source-code
auto QueryContextOrErr = initCompilerInstanceForScan(Command,