Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ WARNING(warning_inferred_simulator_target,none,
ERROR(error_argument_not_allowed_with, none,
"argument '%0' is not allowed with '%1'", (StringRef, StringRef))

ERROR(error_not_a_swift_file, none,
"not a swift file: '%0'", (StringRef))

WARNING(warning_argument_not_supported_with_optimization, none,
"argument '%0' is not supported with optimization", (StringRef))

Expand Down
24 changes: 12 additions & 12 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1270,19 +1270,19 @@ static bool performCompile(CompilerInstance &Instance,
return true;
}

assert([&]() -> bool {
if (FrontendOptions::shouldActionOnlyParse(Action)) {
// Parsing gets triggered lazily, but let's make sure we have the right
// input kind.
return llvm::all_of(
opts.InputsAndOutputs.getAllInputs(), [](const InputFile &IF) {
const auto kind = IF.getType();
return kind == file_types::TY_Swift ||
kind == file_types::TY_SwiftModuleInterfaceFile;
});
if (FrontendOptions::shouldActionOnlyParse(Action)) {
// Parsing gets triggered lazily, but let's make sure we have the right
// input kind.
for (const InputFile &IF : opts.InputsAndOutputs.getAllInputs()) {
const auto kind = IF.getType();
if (kind != file_types::TY_Swift &&
kind != file_types::TY_SwiftModuleInterfaceFile) {
Instance.getDiags().diagnose(SourceLoc(), diag::error_not_a_swift_file,
IF.getFileName());
return true;
}
}
return true;
}() && "Only supports parsing .swift files");
}

bool hadError = performAction(Instance, ReturnValue, observer);

Expand Down