[PATCH] D114645: [CommandLine] Keep option default value unset if no cl::init() is used

Don Hinton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 7 20:16:41 PST 2021


hintonda added inline comments.


================
Comment at: llvm/include/llvm/Support/CommandLine.h:1409
   // type.
-  opt_storage() : Value(DataType()), Default(DataType()) {}
+  opt_storage() : Value(DataType()), Default() {}
 
----------------
yrouban wrote:
> do you want me to add a comment?
>   // Do not initialize Default. Keep it None.
> 
This [[ https://github.com/llvm/llvm-project/commit/fcb37243f9906b1f2ea4c1aeff0a3438288df41f | change ]] was explicitly made in 2013, so we need to be careful not to break anything that depends on it.


================
Comment at: llvm/unittests/Support/CommandLineTest.cpp:1793
+  StackOption<bool> OptA("a", cl::desc("option a"), cl::init(false));
+  StackOption<bool> OptB(cl::init(false),
       "b", cl::desc("option b -- This option turns on option a"),
----------------
Are these additional `cl::init` calls needed? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114645/new/

https://reviews.llvm.org/D114645



More information about the llvm-commits mailing list