Skip to content

Commit

Permalink
Add clang::lifetimebound annotation to llvm::function_ref (llvm#115019)
Browse files Browse the repository at this point in the history
This helps catch dangling llvm::function_ref references, see llvm#114950,
llvm#114949, llvm#114808, llvm#114789
  • Loading branch information
hokein authored Nov 7, 2024
1 parent 343a810 commit 9f79615
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llvm/include/llvm/ADT/STLFunctionalExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define LLVM_ADT_STLFUNCTIONALEXTRAS_H

#include "llvm/ADT/STLForwardCompat.h"
#include "llvm/Support/Compiler.h"

#include <cstdint>
#include <type_traits>
Expand Down Expand Up @@ -52,7 +53,7 @@ class function_ref<Ret(Params...)> {

template <typename Callable>
function_ref(
Callable &&callable,
Callable &&callable LLVM_LIFETIME_BOUND,
// This is not the copy-constructor.
std::enable_if_t<!std::is_same<remove_cvref_t<Callable>,
function_ref>::value> * = nullptr,
Expand Down

0 comments on commit 9f79615

Please sign in to comment.