[llvm] Move the preserve-{bc,ll}-uselistorder options out of individual tools, make them global defaults for AsmWriter and BitcodeWriter (PR #160079)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 9 01:01:04 PDT 2025


================
@@ -118,6 +118,11 @@ static cl::opt<bool>
 #endif
                                 cl::desc(""));
 
+static cl::opt<bool> PreserveBitcodeUseListOrder(
+    "preserve-bc-uselistorder",
+    cl::desc("Preserve use-list order when writing LLVM bitcode."),
+    cl::init(false), cl::Hidden);
----------------
nikic wrote:

There shouldn't be a need to use an actual `std::optional<bool>` with a custom parser. The standard pattern for this is something like `Opt.getNumOccurences() ? Opt : Default`.

We should probably add some kind of `get_or` helper to cl::opt, given how common this is...

(My std::optional suggestion for for making the function parameters optional, but your approach of making the option "optional" instead works as well.)

https://github.com/llvm/llvm-project/pull/160079


More information about the llvm-commits mailing list