Code completion: make sure to always emit a diagnostic so that ASTContext is

marked as erroneous

This is important so that other parts of the compiler (e.g., AST verifier) are
less strict about AST invariants.

Alternatively, we could make sure to emit a diagnostic in the parser when we
consume the code completion token, but chasing every place where we do it now
(and remembering to do this in future) does not scale well.

Fixes the crash in rdar://problem/16100914


Swift SVN r14865
This commit is contained in:
Dmitri Hrybenko
2014-03-10 10:37:52 +00:00
parent 91bed93ca5
commit ef78e2811a
2 changed files with 10 additions and 0 deletions

View File

@@ -285,6 +285,14 @@ void CompilerInstance::performParse() {
performNameBinding(*NextInput);
}
if (Invocation.isCodeCompletion()) {
// When we are doing code completion, make sure to emit at least one
// diagnostic, so that ASTContext is marked as erroneous. In this case
// various parts of the compiler (for example, AST verifier) have less
// strict assumptions about the AST.
Diagnostics.diagnose(SourceLoc(), diag::error_doing_code_completion);
}
if (hadLoadError)
return;