Merge remote-tracking branch 'origin/main' into rebranch

This commit is contained in:
swift-ci
2024-07-11 09:16:06 -07:00
6 changed files with 271 additions and 98 deletions

View File

@@ -590,56 +590,6 @@ static void bridgeDependencyIDs(const ArrayRef<ModuleDependencyID> dependencies,
}
}
static swiftscan_diagnostic_set_t *mapCollectedDiagnosticsForOutput(
const SourceManager &SM,
const DependencyScanDiagnosticCollector *diagnosticCollector) {
auto collectedDiagnostics = diagnosticCollector->getDiagnostics();
auto numDiagnostics = collectedDiagnostics.size();
swiftscan_diagnostic_set_t *diagnosticOutput = new swiftscan_diagnostic_set_t;
diagnosticOutput->count = numDiagnostics;
diagnosticOutput->diagnostics =
new swiftscan_diagnostic_info_t[numDiagnostics];
for (size_t i = 0; i < numDiagnostics; ++i) {
const auto &Diagnostic = collectedDiagnostics[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;
}
if (Diagnostic.ImportLocation.has_value()) {
auto importLocation = Diagnostic.ImportLocation.value();
swiftscan_source_location_s *sourceLoc = new swiftscan_source_location_s;
if (importLocation.bufferIdentifier.empty())
sourceLoc->buffer_identifier = swift::c_string_utils::create_null();
else
sourceLoc->buffer_identifier = swift::c_string_utils::create_clone(
importLocation.bufferIdentifier.c_str());
sourceLoc->line_number = importLocation.lineNumber;
sourceLoc->column_number = importLocation.columnNumber;
diagnosticInfo->source_location = sourceLoc;
} else {
diagnosticInfo->source_location = nullptr;
}
diagnosticOutput->diagnostics[i] = diagnosticInfo;
}
return diagnosticOutput;
}
static swiftscan_macro_dependency_set_t *createMacroDependencySet(
const std::map<std::string, MacroPluginDependency> &macroDeps) {
swiftscan_macro_dependency_set_t *set = new swiftscan_macro_dependency_set_t;
@@ -868,8 +818,7 @@ generateFullDependencyGraph(const CompilerInstance &instance,
result->dependencies = dependencySet;
result->diagnostics =
diagnosticCollector
? mapCollectedDiagnosticsForOutput(instance.getSourceMgr(),
diagnosticCollector)
? mapCollectedDiagnosticsForOutput(diagnosticCollector)
: nullptr;
return result;
}
@@ -1575,13 +1524,11 @@ swift::dependencies::performModulePrescan(CompilerInstance &instance,
importSet->imports = create_set(importIdentifiers);
importSet->diagnostics =
diagnosticCollector
? mapCollectedDiagnosticsForOutput(instance.getSourceMgr(),
diagnosticCollector)
? mapCollectedDiagnosticsForOutput(diagnosticCollector)
: nullptr;
importSet->diagnostics =
diagnosticCollector
? mapCollectedDiagnosticsForOutput(instance.getSourceMgr(),
diagnosticCollector)
? mapCollectedDiagnosticsForOutput(diagnosticCollector)
: nullptr;
return importSet;
}