From 9f796159f28775b3f93d77e173c1fd3413c2e60e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 7 Nov 2024 08:24:54 +0100 Subject: [PATCH] Add clang::lifetimebound annotation to llvm::function_ref (#115019) This helps catch dangling llvm::function_ref references, see #114950, #114949, #114808, #114789 --- llvm/include/llvm/ADT/STLFunctionalExtras.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/STLFunctionalExtras.h b/llvm/include/llvm/ADT/STLFunctionalExtras.h index 6f172504b3c167..3b9d40959d7142 100644 --- a/llvm/include/llvm/ADT/STLFunctionalExtras.h +++ b/llvm/include/llvm/ADT/STLFunctionalExtras.h @@ -16,6 +16,7 @@ #define LLVM_ADT_STLFUNCTIONALEXTRAS_H #include "llvm/ADT/STLForwardCompat.h" +#include "llvm/Support/Compiler.h" #include #include @@ -52,7 +53,7 @@ class function_ref { template function_ref( - Callable &&callable, + Callable &&callable LLVM_LIFETIME_BOUND, // This is not the copy-constructor. std::enable_if_t, function_ref>::value> * = nullptr,