mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add error messages for Swift module map parser
Parser errors with large Swift module map files can be hard to diagnose. Refactor the parser to return an llvm::Error so clearer diagnostics can be passed to the user.
This commit is contained in:
@@ -1604,8 +1604,12 @@ static bool generateReproducer(CompilerInstance &Instance,
|
||||
}
|
||||
auto map = llvm::json::parse(mapProxy->getData());
|
||||
if (!map) {
|
||||
diags.diagnose(SourceLoc(), diag::explicit_swift_module_map_corrupted,
|
||||
mapOpts);
|
||||
llvm::handleAllErrors(
|
||||
map.takeError(), [&diags, &mapOpts](const llvm::json::ParseError &E) {
|
||||
diags.diagnose(SourceLoc(),
|
||||
diag::explicit_swift_module_map_corrupted, mapOpts,
|
||||
E.message());
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (auto array = map->getAsArray()) {
|
||||
|
||||
Reference in New Issue
Block a user