aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Program.cpp
diff options
context:
space:
mode:
authorYevgeny Rouban <yrouban@azul.com>2022-03-11 14:21:45 +0700
committerYevgeny Rouban <yrouban@azul.com>2022-03-11 14:24:25 +0700
commitc5f34d169244db3f321d75d036902751ec03fe42 (patch)
treea6d277501d0ae12f3e75e36206ce8f5512536d82 /llvm/lib/Support/Program.cpp
parentf2ac513812e197758e29354c190004eb7bc2f8b6 (diff)
downloadllvm-c5f34d169244db3f321d75d036902751ec03fe42.zip
llvm-c5f34d169244db3f321d75d036902751ec03fe42.tar.gz
llvm-c5f34d169244db3f321d75d036902751ec03fe42.tar.bz2
[CommandLine] Keep option default value unset if no cl::init() is used
Current declaration of cl::opt is incoherent between class and non-class specializations of the opt_storage template. There is an inconsistency in the initialization of the Default field: for inClass instances the default constructor is used - it sets the Optional Default field to None; though for non-inClass instances the Default field is set to the type's default value. For non-inClass instances it is impossible to know if the option is defined with cl::init() initializer or not: cl::opt<int> i1("option-i1"); cl::opt<int> i2("option-i2", cl::init(0)); cl::opt<std::string> s1("option-s1"); cl::opt<std::string> s2("option-s2", cl::init("")); assert(s1.Default.hasValue() != s2.Default.hasValue()); // Ok assert(i1.Default.hasValue() != i2.Default.hasValue()); // Fails This patch changes constructor of the non-class specializations to keep the Default field unset (that is None) rather than initialize it with DataType(). Reviewed By: lattner Differential Revision: https://reviews.llvm.org/D114645
Diffstat (limited to 'llvm/lib/Support/Program.cpp')
0 files changed, 0 insertions, 0 deletions