Page MenuHomePhabricator

[flang][driver] Refactor methods for parsing options (nfc)
ClosedPublic

Authored by awarzynski on Thu, Apr 15, 6:28 AM.

Details

Summary

This is just a small update that makes sure that errors arising from
parsing command-line options are captured more visibly. Also, all
parsing methods will now consistently return either a bool ("may fail")
or void ("never fails").

An instance of InputKind coming from -x is added to
FrontendOptions rather then being returned from ParseFrontendArgs.
It's currently not used, but we will require it shortly. In particular,
once code-generation is available we will use it to differentiate
between LLVM IR and Fortran input. FrontendOptions is a very suitable
place to keep it.

This changes don't affect the error reporting in the driver. In this
respect these are non-functional-changes. However, it will simplify
things in the forthcoming patches in which we may need a better error
tracking/recovery mechanism.

Diff Detail

Event Timeline

awarzynski requested review of this revision.Thu, Apr 15, 6:28 AM
awarzynski created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptThu, Apr 15, 6:28 AM
SouraVX accepted this revision.Tue, Apr 20, 3:45 AM

LG - Thanks! with one question inline :)

flang/include/flang/Frontend/FrontendOptions.h
225

Out of curiosity, what does clang does for this ?

clang -x c++ main.c

Is sharing possible ?

This revision is now accepted and ready to land.Tue, Apr 20, 3:45 AM
SouraVX added inline comments.Tue, Apr 20, 3:53 AM
flang/include/flang/Frontend/FrontendOptions.h
225

I meant what clangDriver does, for handling this ? Code sharing possible ?

Thank you for reviewing @SouraVX !

flang/include/flang/Frontend/FrontendOptions.h
225

I meant what clangDriver does, for handling this ? Code sharing possible ?

Not without some non-trivial refactor. This code is for the frontend driver. clangDriver is only used for the compiler driver. It's the same in Clang.

I agree that it would be nice to share some code from the frontend driver with Clang. And in theory it shouldn't be too difficult - one would simply create a few generic/abstract classes that Flang and Clang would specialise. But the devil is going to be in the details. Also, we need a volunteer first :)

This revision was landed with ongoing or failed builds.Tue, Apr 20, 7:01 AM
This revision was automatically updated to reflect the committed changes.