[llvm] 9f79615 - Add clang::lifetimebound annotation to llvm::function_ref (#115019)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 6 23:24:58 PST 2024
Author: Haojian Wu
Date: 2024-11-07T08:24:54+01:00
New Revision: 9f796159f28775b3f93d77e173c1fd3413c2e60e
URL: https://github.com/llvm/llvm-project/commit/9f796159f28775b3f93d77e173c1fd3413c2e60e
DIFF: https://github.com/llvm/llvm-project/commit/9f796159f28775b3f93d77e173c1fd3413c2e60e.diff
LOG: Add clang::lifetimebound annotation to llvm::function_ref (#115019)
This helps catch dangling llvm::function_ref references, see #114950,
#114949, #114808, #114789
Added:
Modified:
llvm/include/llvm/ADT/STLFunctionalExtras.h
Removed:
################################################################################
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 <cstdint>
#include <type_traits>
@@ -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,
More information about the llvm-commits
mailing list