@@ -70,16 +70,6 @@ ParseIncompleteOSSA("parse-incomplete-ossa",
7070// ===----------------------------------------------------------------------===//
7171
7272SILParserState::~SILParserState () {
73- if (!ForwardRefFns.empty ()) {
74- for (auto Entry : ForwardRefFns) {
75- if (Entry.second .Loc .isValid ()) {
76- M.getASTContext ().Diags .diagnose (Entry.second .Loc ,
77- diag::sil_use_of_undefined_value,
78- Entry.first .str ());
79- }
80- }
81- }
82-
8373 // Turn any debug-info-only function declarations into zombies.
8474 markZombies ();
8575}
@@ -93,6 +83,21 @@ void SILParserState::markZombies() {
9383 }
9484}
9585
86+ bool SILParserState::diagnoseUndefinedValues (DiagnosticEngine &diags) {
87+ bool hasError = false ;
88+ if (!ForwardRefFns.empty ()) {
89+ for (auto Entry : ForwardRefFns) {
90+ if (Entry.second .Loc .isValid ()) {
91+ diags.diagnose (Entry.second .Loc ,
92+ diag::sil_use_of_undefined_value,
93+ Entry.first .str ());
94+ hasError = true ;
95+ }
96+ }
97+ }
98+ return hasError;
99+ }
100+
96101std::unique_ptr<SILModule>
97102ParseSILModuleRequest::evaluate (Evaluator &evaluator,
98103 ASTLoweringDescriptor desc) const {
@@ -111,6 +116,10 @@ ParseSILModuleRequest::evaluate(Evaluator &evaluator,
111116 }
112117
113118 auto hadError = parser.parseTopLevelSIL ();
119+
120+ if (parserState.diagnoseUndefinedValues (parser.Diags ))
121+ hadError = true ;
122+
114123 if (hadError) {
115124 // The rest of the SIL pipeline expects well-formed SIL, so if we encounter
116125 // a parsing error, just return an empty SIL module.
0 commit comments