-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Pass std::initializer_list by value to ArrayRef constructor. #113590
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
The std::initializer_list is a light-weight object, in general, it is passed by value. This would also avoid a false positive when adding the lifetimebound annotation. ``` ArrayRef<int> foo(std::initializer_list<int> list) { return ArrayRef<int>(list); } ```
@llvm/pr-subscribers-llvm-adt Author: Haojian Wu (hokein) ChangesThe std::initializer_list is a lightweight object, it is passed by value in general. This would also avoid a false positive when adding the lifetimebound annotation (#113547)
Full diff: https://github.com/llvm/llvm-project/pull/113590.diff 1 Files Affected:
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index d9897320ce091a..bf6b55923b84ba 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -113,7 +113,7 @@ namespace llvm {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winit-list-lifetime"
#endif
- constexpr /*implicit*/ ArrayRef(const std::initializer_list<T> &Vec)
+ constexpr /*implicit*/ ArrayRef(std::initializer_list<T> Vec)
: Data(Vec.begin() == Vec.end() ? (T *)nullptr : Vec.begin()),
Length(Vec.size()) {}
#if LLVM_GNUC_PREREQ(9, 0, 0)
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/7517 Here is the relevant piece of the build log for the reference
|
…3590) The std::initializer_list is a lightweight object, it is passed by value in general. This would also avoid a false positive when adding the lifetimebound annotation (llvm#113547) ``` ArrayRef<int> foo(std::initializer_list<int> list) { return ArrayRef<int>(list); } ```
The std::initializer_list is a lightweight object, it is passed by value in general.
This would also avoid a false positive when adding the lifetimebound annotation (#113547)