This is an archive of the discontinued LLVM Phabricator instance.

[clang][codegen] Don't assert on CurLinkModule for silenced diagnostic
Needs ReviewPublic

Authored by inglorion on Aug 20 2021, 4:44 PM.

Details

Reviewers
mantognini
xur
Summary

Fixes PR51564.

Under certain circumstances, it is possible to enter Clang's
BackendConsumer::DiagnosticHandlerImpl without CurLinkModule set.
For diagnostics of kind DK_Linker, this results in an assert.
However, these diagnostics are never actually surfaced, unless
they are errors. Crashing the compiler for diagnostics we don't
actually surface seems not worth it, so this change moves the
assert below the check so that it only triggers for diagnostics
we actually surface.

Diff Detail

Event Timeline

inglorion requested review of this revision.Aug 20 2021, 4:44 PM
inglorion created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2021, 4:44 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

There are some possible follow-ups here:

  1. Making sure CurLinkModule is set in all (or at least more) cases.
  2. Addressing the FIXME about warnings and notes.

I have some partial implementations of those ideas, but I figure we can take this change first while I figure out the other bits.

xur added a comment.Aug 20 2021, 6:19 PM

This looks fine to me. But I agree you that a more complete fix would be having CurLinkModule set for all callers.