[clang-tools-extra] [llvm] [LLVM][Support] Move default values out of the storage (PR #184581)
Yevgeny Rouban via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 21:05:20 PST 2026
================
@@ -1512,7 +1492,25 @@ class opt
opt &operator=(const opt &) = delete;
// setInitialValue - Used by the cl::init modifier...
- void setInitialValue(const DataType &V) { this->setValue(V, true); }
+ void setInitialValue(const DataType &V) {
+ this->setValue(V);
+ Default = V;
+ }
+
+ bool setLocation(Option &O, DataType &L) {
+ // Only external storage options can have their location set. For these we
+ // also need to set the default value.
+ if constexpr (ExternalStorage) {
+ if (opt_storage<DataType, ExternalStorage,
+ std::is_class_v<DataType>>::setLocation(O, L))
+ return true;
+ Default = L;
+ return false;
+ }
----------------
yrouban wrote:
I would re-phrase:
```
if constexpr (ExternalStorage)
if (!opt_storage<DataType, ExternalStorage,
std::is_class_v<DataType>>::setLocation(O, L)) {
Default = L;
return false;
}
```
https://github.com/llvm/llvm-project/pull/184581
More information about the llvm-commits
mailing list