[PATCH] D45641: Rename sys::Process::GetArgumentVector -> sys::windows::GetCommandLineArguments

Stella Stamenova via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 16 13:09:04 PDT 2018


stella.stamenova added a comment.

In https://reviews.llvm.org/D45641#1068965, @zturner wrote:

> So I think one option here that maybe solves both problems at once is to create two functions in `sys::Process`.
>
> Then, call the first one from `InitLLVM::InitLLVM` constructor.  Have the second one **not** require the argument vector to be passed in, instead save it in a global in `sys::Process` or something.
>
> This way, anyone using `InitLLVM` (which should be everyone) has to do nothing, and all command line arguments are available from anywhere in the program, without needing to pass in the args from main.  This way it is not Windows specific, and provides value everywhere.


Do we frequently need to get the arguments outside of the main() function? If I recall correctly, most of the tools today have argument processing only in main(), so a function like `sys::Process::GetSavedCommandLineArguments` wouldn't provide value outside of main(). It's probably also likely that if there were globals in sys::Process for the arguments, people would try to use them directly (assuming they were accessible), rather than calling the function anyway.

@zturner, what scenario do you see where `sys::Process::GetSavedCommandLineArguments` would be used (other than in main() or `InitLLVM`)?


https://reviews.llvm.org/D45641





More information about the llvm-commits mailing list