Skip to content

Commit 9f79615

Browse files
authored
Add clang::lifetimebound annotation to llvm::function_ref (llvm#115019)
This helps catch dangling llvm::function_ref references, see llvm#114950, llvm#114949, llvm#114808, llvm#114789
1 parent 343a810 commit 9f79615

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/include/llvm/ADT/STLFunctionalExtras.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define LLVM_ADT_STLFUNCTIONALEXTRAS_H
1717

1818
#include "llvm/ADT/STLForwardCompat.h"
19+
#include "llvm/Support/Compiler.h"
1920

2021
#include <cstdint>
2122
#include <type_traits>
@@ -52,7 +53,7 @@ class function_ref<Ret(Params...)> {
5253

5354
template <typename Callable>
5455
function_ref(
55-
Callable &&callable,
56+
Callable &&callable LLVM_LIFETIME_BOUND,
5657
// This is not the copy-constructor.
5758
std::enable_if_t<!std::is_same<remove_cvref_t<Callable>,
5859
function_ref>::value> * = nullptr,

0 commit comments

Comments
 (0)