<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><blockquote type="cite"><div>On Aug 4, 2014, at 5:26 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 4, 2014 at 3:03 PM, Ben Langmuir <span dir="ltr"><<a href="mailto:blangmuir@apple.com" target="_blank">blangmuir@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Richard,<br>
<br>
We have several lazy builtin Decls (for ObjC decls, va_list, etc.) that might get filled in when we desugar a type for the ODR diagnostics, and these may deserialize more content from a module when they lookup an IdentifierInfo, leading to trying to emit a diagnostic while a diagnostic is already in flight.</blockquote>
<div><br></div><div>Hmm, thinking more about the specific problem here, I wonder if even the approaches we've discussed so far are not enough. In particular, suppose we hit this diagnostic:</div><div><br></div><div>Diag(...) << D->somethingThatTriggersDeserialization()</div>
<div><br></div><div>In this case, we'll again assert when deserialization issues a diagnostic with another diagnostic in flight. Some quick grepping was unable to find such a case, but I feel uneasy about this possibility; this seems like a time bomb. Maybe ASTReader should buffer all of its diagnostics, and emit them at some known-safe point in time, such as end of TU. What do you think?</div>
</div></div></div>
</div></blockquote></div><br><div>It looks like a lot of ASTReader is sort of doing that already by using the 1-item buffer from Diags.setDelayedDiagnostic() and just discarding any diagnostics after the first one. The “safe point” in this case is immediately when there is no in-flight diag, or whenever the in-flight diagnostic is emitted if there is. This is probably better than waiting until the end of the TU, as it maintains the order of the diagnostics. Right now this single delayed diagnostic is limited to <= 2 arguments, which must be StringRefs, but this could always be extended...</div><div><br></div><div>That being said, I don’t know that we necessarily *want* non-fatal errors to be emitted if they are encountered while a diagnostic is in flight. I think I’d need to see a specific example before I could say. Maybe as a first pass, we can make all ASTReader diagnostics that can occur during deserialization not emit at all when Diags.isDiagnosticInFlight() == true?</div><div><br></div><div>Ben</div></body></html>