mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Dependency Scanning][libSwiftScan] Deprecate scanner-global diagnostic collection
All clients are expected to have switched to the per-scan-query diagnostics using 'swiftscan_dependency_graph_get_diagnostics'
This commit is contained in:
@@ -85,11 +85,6 @@ public:
|
||||
llvm::ErrorOr<swiftscan_import_set_t>
|
||||
getImports(ArrayRef<const char *> Command, StringRef WorkingDirectory);
|
||||
|
||||
/// Query diagnostics consumed so far.
|
||||
std::vector<DependencyScanDiagnosticCollector::ScannerDiagnosticInfo> getDiagnostics();
|
||||
/// Discared the collection of diagnostics encountered so far.
|
||||
void resetDiagnostics();
|
||||
|
||||
/// Using the specified invocation command, instantiate a CompilerInstance
|
||||
/// that will be used for this scan.
|
||||
llvm::ErrorOr<ScanQueryInstance>
|
||||
@@ -104,9 +99,6 @@ private:
|
||||
|
||||
/// Shared state mutual-exclusivity lock
|
||||
llvm::sys::SmartMutex<true> DependencyScanningToolStateLock;
|
||||
|
||||
/// A shared consumer that accumulates encountered diagnostics.
|
||||
DependencyScanDiagnosticCollector CDC;
|
||||
llvm::BumpPtrAllocator Alloc;
|
||||
llvm::StringSaver Saver;
|
||||
};
|
||||
|
||||
@@ -259,7 +259,7 @@ static swiftscan_import_set_t generateHollowDiagnosticOutputImportSet(
|
||||
|
||||
DependencyScanningTool::DependencyScanningTool()
|
||||
: ScanningService(std::make_unique<SwiftDependencyScanningService>()),
|
||||
CDC(), Alloc(), Saver(Alloc) {}
|
||||
Alloc(), Saver(Alloc) {}
|
||||
|
||||
llvm::ErrorOr<swiftscan_dependency_graph_t>
|
||||
DependencyScanningTool::getDependencies(
|
||||
@@ -326,18 +326,6 @@ DependencyScanningTool::getImports(ArrayRef<const char *> Command,
|
||||
return std::move(*DependenciesOrErr);
|
||||
}
|
||||
|
||||
std::vector<
|
||||
DependencyScanDiagnosticCollector::ScannerDiagnosticInfo>
|
||||
DependencyScanningTool::getDiagnostics() {
|
||||
llvm::sys::SmartScopedLock<true> Lock(DependencyScanningToolStateLock);
|
||||
return CDC.Diagnostics;
|
||||
}
|
||||
|
||||
void DependencyScanningTool::resetDiagnostics() {
|
||||
llvm::sys::SmartScopedLock<true> Lock(DependencyScanningToolStateLock);
|
||||
CDC.reset();
|
||||
}
|
||||
|
||||
llvm::ErrorOr<ScanQueryInstance>
|
||||
DependencyScanningTool::initCompilerInstanceForScan(
|
||||
ArrayRef<const char *> CommandArgs,
|
||||
@@ -353,10 +341,6 @@ DependencyScanningTool::initCompilerInstanceForScan(
|
||||
|
||||
// State unique to an individual scan
|
||||
auto Instance = std::make_unique<CompilerInstance>();
|
||||
|
||||
// FIXME: The shared CDC must be deprecated once all clients have switched
|
||||
// to using per-scan diagnostic output embedded in the `swiftscan_dependency_graph_s`
|
||||
Instance->addDiagnosticConsumer(&CDC);
|
||||
Instance->addDiagnosticConsumer(scannerDiagnosticsCollector.get());
|
||||
|
||||
// Basic error checking on the arguments
|
||||
|
||||
@@ -589,45 +589,15 @@ swiftscan_compiler_supported_features_query() {
|
||||
//=== Scanner Diagnostics -------------------------------------------------===//
|
||||
swiftscan_diagnostic_set_t*
|
||||
swiftscan_scanner_diagnostics_query(swiftscan_scanner_t scanner) {
|
||||
DependencyScanningTool *ScanningTool = unwrap(scanner);
|
||||
auto Diagnostics = ScanningTool->getDiagnostics();
|
||||
auto NumDiagnostics = Diagnostics.size();
|
||||
|
||||
swiftscan_diagnostic_set_t *Result = new swiftscan_diagnostic_set_t;
|
||||
Result->count = NumDiagnostics;
|
||||
Result->diagnostics = new swiftscan_diagnostic_info_t[NumDiagnostics];
|
||||
|
||||
for (size_t i = 0; i < NumDiagnostics; ++i) {
|
||||
const auto &Diagnostic = Diagnostics[i];
|
||||
swiftscan_diagnostic_info_s *DiagnosticInfo = new swiftscan_diagnostic_info_s;
|
||||
DiagnosticInfo->message = swift::c_string_utils::create_clone(Diagnostic.Message.c_str());
|
||||
switch (Diagnostic.Severity) {
|
||||
case llvm::SourceMgr::DK_Error:
|
||||
DiagnosticInfo->severity = SWIFTSCAN_DIAGNOSTIC_SEVERITY_ERROR;
|
||||
break;
|
||||
case llvm::SourceMgr::DK_Warning:
|
||||
DiagnosticInfo->severity = SWIFTSCAN_DIAGNOSTIC_SEVERITY_WARNING;
|
||||
break;
|
||||
case llvm::SourceMgr::DK_Note:
|
||||
DiagnosticInfo->severity = SWIFTSCAN_DIAGNOSTIC_SEVERITY_NOTE;
|
||||
break;
|
||||
case llvm::SourceMgr::DK_Remark:
|
||||
DiagnosticInfo->severity = SWIFTSCAN_DIAGNOSTIC_SEVERITY_REMARK;
|
||||
break;
|
||||
}
|
||||
// swiftscan_scanner_diagnostics_query is deprecated,
|
||||
// so it does not support source locations.
|
||||
DiagnosticInfo->source_location = nullptr;
|
||||
Result->diagnostics[i] = DiagnosticInfo;
|
||||
}
|
||||
|
||||
return Result;
|
||||
// This method is deprecated
|
||||
swiftscan_diagnostic_set_t *set = new swiftscan_diagnostic_set_t;
|
||||
set->count = 0;
|
||||
return set;
|
||||
}
|
||||
|
||||
void
|
||||
swiftscan_scanner_diagnostics_reset(swiftscan_scanner_t scanner) {
|
||||
DependencyScanningTool *ScanningTool = unwrap(scanner);
|
||||
ScanningTool->resetDiagnostics();
|
||||
// This method is deprecated
|
||||
}
|
||||
|
||||
swiftscan_string_ref_t
|
||||
|
||||
Reference in New Issue
Block a user