Skip to content

Commit 6c8c836

Browse files
authored
Add an llvm::cl::opt::operator=(T &&Val) (#147502)
Add an llvm::cl::opt::operator= that takes an rvalue reference of value, to avoid an unecessary copy for types with memory allocation (string, vector, etc).
1 parent 0f391d6 commit 6c8c836

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/include/llvm/Support/CommandLine.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,12 @@ class opt
14961496
return this->getValue();
14971497
}
14981498

1499+
template <class T> DataType &operator=(T &&Val) {
1500+
this->getValue() = std::forward<T>(Val);
1501+
Callback(this->getValue());
1502+
return this->getValue();
1503+
}
1504+
14991505
template <class... Mods>
15001506
explicit opt(const Mods &... Ms)
15011507
: Option(llvm::cl::Optional, NotHidden), Parser(*this) {

0 commit comments

Comments
 (0)