I have two static libs that use LLVM command line to parse arguments:
// lib1
void main(int argc, const char **argv) {
cl::opt<bool>LibOption1( ... ) // arg1
cl::ParseCommandLineOptions(argc, argv, "lib1\n");
}
.
// lib2
void main(int argc, const char **argv) {
// need to reset arguments list here ..
cl::opt<bool>LibOption2( ... ) // arg2
cl::ParseCommandLineOptions(argc, argv, "lib2\n"); // crash here!
}
The app is linked against two this libs and they parse arguments just fine if having only 1 lib in the app and crash while parsing arguments if having both libs in the app.
It seems that in lines with // arg
argument is added in some global static list (?) of arguments and this makes them have mixed arguments list and affect to each other.
Is there any opportunity to reset that global list before declaring arguments?
PS. I've found that static arguments list in CommandLine.cpp
:
/// RegisteredOptionList - This is the list of the command line options that
/// have statically constructed themselves.
static Option *RegisteredOptionList = 0;