This is an archive of the discontinued LLVM Phabricator instance.

[flang][driver] Add support for the "-init-only" option
ClosedPublic

Authored by stuartellis on May 20 2021, 8:38 AM.

Details

Summary

Adding the -init-only option and corresponding frontend action to
generate a diagnostic.

-init-only vs -test-io:
-init-only ignores the input (it never calls the prescanner)
-test-io is similar to -init-only, but does read and print the input
without calling the prescanner.

This patch also adds a Driver test to check this action.

Diff Detail

Unit TestsFailed

Event Timeline

stuartellis created this revision.May 20 2021, 8:38 AM
stuartellis requested review of this revision.May 20 2021, 8:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 20 2021, 8:38 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
SouraVX added a project: Restricted Project.May 25 2021, 9:43 PM

LGTM. I'll let someone else take a look too.

AMDChirag accepted this revision.Jun 1 2021, 5:16 AM
This revision is now accepted and ready to land.Jun 1 2021, 5:16 AM

Hi @stuartellis ,

Thank you for preparing this! This looks good to me, but I would appreciate a comment somewhere (e.g. in the commit message) comparing -init-only and -test-io. Essentially, both options are for testing purposes only. IMHO, we should only require one of them (I would be in favor of -init-only), but it's a bit tricky with input files being managed by the prescanner rather than the driver. So for the time being I would keep both, but just make it clear that:

  • -init-only ignores the input (because it never calls the prescanner)
  • -test-io is similar to -init-only, but does read and print the input without calling the prescanner.

Please let me know if any of this is unclear!

clang/include/clang/Driver/Options.td
5692

[nit] Remove empty line

flang/include/flang/Frontend/FrontendOptions.h
77

[Nit] Whenever possible, we've been adopting names from Clang (hopefully, this way it will be easier for developers to switch between the drivers). So, in this case, it would be InitOnly rather than InitializationOnly: https://github.com/llvm/llvm-project/blob/main/clang/lib/Frontend/CompilerInvocation.cpp#L2385.

flang/test/Driver/init-only.f90
2

Missing ! REQUIRES: new-flang-driver.

Address review comments
Renaming InitializationOnly to InitOnly
Add missing line in init-only.f90
Updating commit message with init-only/test-io comparison

stuartellis edited the summary of this revision. (Show Details)Jun 2 2021, 9:44 AM
stuartellis marked 3 inline comments as done.
awarzynski accepted this revision.Jun 3 2021, 2:48 AM
This revision was landed with ongoing or failed builds.Jun 7 2021, 7:40 AM
This revision was automatically updated to reflect the committed changes.