Skip to content

Commit 100582e

Browse files
authored
Pass std::initializer_list by value to ArrayRef constructor. (#113590)
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) ``` ArrayRef<int> foo(std::initializer_list<int> list) { return ArrayRef<int>(list); } ```
1 parent e2e7d56 commit 100582e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/include/llvm/ADT/ArrayRef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace llvm {
113113
#pragma GCC diagnostic push
114114
#pragma GCC diagnostic ignored "-Winit-list-lifetime"
115115
#endif
116-
constexpr /*implicit*/ ArrayRef(const std::initializer_list<T> &Vec)
116+
constexpr /*implicit*/ ArrayRef(std::initializer_list<T> Vec)
117117
: Data(Vec.begin() == Vec.end() ? (T *)nullptr : Vec.begin()),
118118
Length(Vec.size()) {}
119119
#if LLVM_GNUC_PREREQ(9, 0, 0)

0 commit comments

Comments
 (0)