Skip to content

Commit 2ab447a

Browse files
authored
Fix dangling IPOAmendableCB function_ref. (#120698)
The `IPOAmendableCB`'s type is `llvm::function_ref`, it is error-prone to write code (e.g. https://github.com/llvm/llvm-project/blob/5656cbca52545e608f6fb8b7c9a778c7c9b4b468/llvm/lib/Transforms/IPO/OpenMPOpt.cpp#L5812) that assign a temporary lambda to an `IPOAmendableCB` object, which is a use-after-free issue. This patch changes the `IPOAmendableCB` to `std::function`, to avoid the dangling issue.
1 parent 29b5c18 commit 2ab447a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/include/llvm/Transforms/IPO/Attributor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ struct AttributorConfig {
14781478
/// The name of the pass running the attributor, used to emit remarks.
14791479
const char *PassName = nullptr;
14801480

1481-
using IPOAmendableCBTy = function_ref<bool(const Function &F)>;
1481+
using IPOAmendableCBTy = std::function<bool(const Function &F)>;
14821482
IPOAmendableCBTy IPOAmendableCB;
14831483
};
14841484

0 commit comments

Comments
 (0)