Skip to content

Commit 1d18253

Browse files
committed
CLI Argument parsing: Move stdlib include guarantee to the Arguments constructor
Review: conceptually, where does this reponsibility belong? I.e., the responsibility to ensure that the standard library is always the first include path. [notest]
1 parent 4c645ff commit 1d18253

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/include/parse_arguments.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,22 @@ class Arguments {
7777
bool f_exit_early = false; // Exit early if the request is just -h/--help or -v/--version
7878

7979
public:
80+
constexpr Arguments() {
81+
// Ensure that the standard library directory is the very first include path
82+
//
83+
// TODO(@rail5): This does not seem like the proper place to make this guarantee.
84+
// In what sense is "ensuring the standard library is in the include paths" the
85+
// responsibility of the CLI argument parser?
86+
// Review the design of how include paths are managed and consider whether this
87+
// guarantee should be made elsewhere.
88+
m_include_paths->emplace_back("/usr/lib/bpp/stdlib3/");
89+
}
90+
~Arguments() = default;
91+
Arguments(const Arguments&) = delete;
92+
Arguments& operator=(const Arguments&) = delete;
93+
Arguments(Arguments&&) = default;
94+
Arguments& operator=(Arguments&&) = default;
95+
8096
/**
8197
* @brief Sets the program arguments to be passed to the compiled program
8298
*
@@ -248,8 +264,6 @@ class Arguments {
248264
inline Arguments parse_arguments(int argc, char* argv[]) {
249265
Arguments args;
250266

251-
args.add_include_path("/usr/lib/bpp/stdlib/");
252-
253267
// Will throw if invalid arguments are provided
254268
auto [compiler_arguments, program_arguments]
255269
= OptionParser.parse_until<XGetOpt::StopCondition::AfterFirstNonOptionArgument>(argc, argv);

0 commit comments

Comments
 (0)