-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Add an llvm::cl::opt::operator=(T &&Val) #147502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… value, to avoid an unecessary copy for types with memory allocation (string, vector, etc)
|
@llvm/pr-subscribers-llvm-support Author: Tom Natan (tomnatan30) ChangesAdd 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). Full diff: https://github.com/llvm/llvm-project/pull/147502.diff 1 Files Affected:
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h
index 5489b3ff78f51..adaa75cc6c348 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -1496,6 +1496,12 @@ class opt
return this->getValue();
}
+ template <class T> DataType &operator=(T &&Val) {
+ this->getValue() = std::forward<T>(Val);
+ Callback(this->getValue());
+ return this->getValue();
+ }
+
template <class... Mods>
explicit opt(const Mods &... Ms)
: Option(llvm::cl::Optional, NotHidden), Parser(*this) {
|
jpienaar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me, thanks!
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/12744 Here is the relevant piece of the build log for the reference |
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).