This is an archive of the discontinued LLVM Phabricator instance.

[flang] COMMAND_ARGUMENT_COUNT runtime implementation
ClosedPublic

Authored by rovka on Sep 1 2021, 1:24 AM.

Details

Summary

Grab whatever ProgramStart has stored in
executionEnvironment.argc and subtract 1 (based on the
assumption that ProgramStart is called with a C-style argc
that counts the command name as an argument).

Spoiler alert: The tests will evolve into fixtures when we
implement GET_COMMAND_ARGUMENT etc.

Diff Detail

Event Timeline

rovka created this revision.Sep 1 2021, 1:24 AM
rovka requested review of this revision.Sep 1 2021, 1:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2021, 1:24 AM
klausler added inline comments.Sep 1 2021, 8:58 AM
flang/runtime/command.cpp
1

I don't think that you need the "*- C++ *" stuff in *.cpp files, just in headers (*.h).

14

Braced initialization, please; it's often safer.

rovka updated this revision to Diff 370180.Sep 2 2021, 1:02 AM
rovka added inline comments.Sep 2 2021, 1:09 AM
flang/runtime/command.cpp
1

Right, copy-paste artifact :) It seems we have it in 23 out of 45 .cpp files in the runtime, I'll remove it from all of them.

14

Sorry, muscle memory... /hides under a rock.

klausler accepted this revision.Sep 2 2021, 9:11 AM
This revision is now accepted and ready to land.Sep 2 2021, 9:11 AM
This revision was automatically updated to reflect the committed changes.

@rovka will you be implementing iargc which is mostly the same? What about get_command_argument, get_arg etc?
https://gcc.gnu.org/onlinedocs/gcc-4.2.4/gfortran/IARGC.html
https://gcc.gnu.org/onlinedocs/gfortran/GETARG.html