Page MenuHomePhabricator

[clang][tooling] Create SourceManager for DiagnosticsEngine before command-line parsing

Authored by jansvoboda11 on Mar 26 2021, 5:38 AM.



In D84673, we started using DiagnosticsEngine during command-line parsing in more contexts.

When using ToolInvocation, a custom DiagnosticsConsumer can be specified and it might expect SourceManager to be present on the emitted diagnostics.

This patch ensures the SourceManager is set up in such scenarios.

Test authored by Jordan Rupprecht.

Diff Detail

Event Timeline

jansvoboda11 requested review of this revision.Mar 26 2021, 5:38 AM
jansvoboda11 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 26 2021, 5:38 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jansvoboda11 edited the summary of this revision. (Show Details)Mar 27 2021, 2:19 AM
rupprecht accepted this revision.Mar 29 2021, 12:20 PM

Thanks, the error message is much better now!

When applying this patch locally and also undoing the fix in our internal tool (i.e. change it to -ferror-limit=-1), the error I get is:

message: "invalid integral value \'-1\' in \'-ferror-limit -1\'"

which, you know, actually tells me what to fix instead of giving some weird internal assertion :)

This revision is now accepted and ready to land.Mar 29 2021, 12:20 PM
This revision was landed with ongoing or failed builds.Apr 6 2021, 1:40 AM
This revision was automatically updated to reflect the committed changes.