This is an archive of the discontinued LLVM Phabricator instance.

[flang][driver] Add actions that execute despite semantic errors
ClosedPublic

Authored by awarzynski on Oct 7 2021, 5:23 AM.

Details

Summary

This patch adds a new abstract class for frontend actions: PrescanAndSemaDebugAction. It's very similar to PrescanAndSemaAction, but in the presence of semantic errors it does not skip the corresponding ExecuteAction specialisation. Instead, it runs it as if there were no semantic errors. This class is for developer actions only (i.e. front-end driver options).

The new behaviour does not affect the return code from flang-new -fc1 when the input file is semantically incorrect. The return code is inferred from the number of driver diagnostics generated in CompilerInstance::ExecuteAction and this patch does not change that. More specifically, the semantic errors are still reported and hence the driver is able to correctly report that the compilation has failed (with a non-zero return code).

This new base class is meant for debug actions only and DebugDumpAllAction is updated to demonstrate the new behaviour. With this change, flang-new -fc1 -fdebug-dump-all dumps the parse tree and symbols for all input files, regardless of whether any semantic errors were found.

This patch addresses https://bugs.llvm.org/show_bug.cgi?id=52097.

Diff Detail

Event Timeline

awarzynski created this revision.Oct 7 2021, 5:23 AM
Herald added a project: Restricted Project. · View Herald Transcript
awarzynski requested review of this revision.Oct 7 2021, 5:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 7 2021, 5:23 AM
PeteSteinfeld accepted this revision.Oct 7 2021, 12:57 PM

LGTM

All looks good. Thanks for doing this!

This revision is now accepted and ready to land.Oct 7 2021, 12:57 PM
MatsPetersson added inline comments.
flang/lib/Frontend/FrontendActions.cpp
45

Probably should fix the & to && in this one too, following the suggestion from FIR-Dev.

awarzynski updated this revision to Diff 378141.Oct 8 2021, 2:38 AM

As per suggestion from @MatsPetersson, fixing the erroneous &.

Thanks Mats!

flang/lib/Frontend/FrontendActions.cpp
45
PeteSteinfeld added inline comments.Oct 8 2021, 6:22 AM
flang/lib/Frontend/FrontendActions.cpp
45

Note that this line of code is also modified by https://reviews.llvm.org/D111395. Should these patches be combined?

awarzynski added inline comments.Oct 8 2021, 7:12 AM
flang/lib/Frontend/FrontendActions.cpp
45

https://reviews.llvm.org/D111395 fixes a bug on L40, so it's a different line.

This patch creates PrescanAndSemaDebugAction. It will work correctly without modifying PrescanAndSemaAction. https://reviews.llvm.org/D111395 fixes the latter, but that does not affect the former.

As the two changes are unrelated, I think that it's worthwhile to keep them in separate commits. This way it will be easier to track down the rationale for the fix.