mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Frontend] Nicer assert when -dump-parse foo.sil
Invoking the following command to `-dump-parse` a file containing SIL triggers an assertion from within the Swift compiler frontend: ``` swiftc -dump-parse foo.sil ``` The assertion is not coupled with a description of what went wrong. It turns out the frontend doesn't support `-dump-parse` for SIL files, although `swiftc -help` wouldn't inform users of that: ``` -dump-parse Parse input file(s) and dump AST(s) ``` As a result, a user may invoke `-dump-parse` on a SIL file and not know what went wrong. Add an assertion message to inform the user that only Swift code may be parsed. (`IFK_Swift_Library` here is for the case where `swiftc -parse-as-library -dump-parse foo.swift` is invoked.)
This commit is contained in:
@@ -531,7 +531,8 @@ void CompilerInstance::performParseOnly() {
|
||||
Module *MainModule = getMainModule();
|
||||
Context->LoadedModules[MainModule->getName()] = MainModule;
|
||||
|
||||
assert(Kind == InputFileKind::IFK_Swift || Kind == InputFileKind::IFK_Swift_Library);
|
||||
assert((Kind == InputFileKind::IFK_Swift || Kind == InputFileKind::IFK_Swift_Library) &&
|
||||
"only supports parsing a single .swift file");
|
||||
assert(BufferIDs.size() == 1 && "only supports parsing a single file");
|
||||
|
||||
if (Kind == InputFileKind::IFK_Swift)
|
||||
|
||||
Reference in New Issue
Block a user