[clang] [LifeitimeSafety] Support C Language in LifetimeSafety (PR #203270)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 11 07:26:27 PDT 2026
================
@@ -347,6 +353,12 @@ void FactsGenerator::VisitUnaryOperator(const UnaryOperator *UO) {
switch (UO->getOpcode()) {
case UO_AddrOf: {
const Expr *SubExpr = UO->getSubExpr();
+ // In C, function addresses do not need lifetime tracking. Also skip
----------------
Xazax-hun wrote:
There are two cases I can think of, you either take the address of a lambda, in that case you have the address of an object (wherever that lambda is stored, usually on the stack). That is not a function pointer. Or you could take the address of the `operator()(...)` of the lambda, but that is going to have static lifetime.
There is a 3rd case, lambdas can implicitly be converted to function pointers, but only if they do not capture anything. No `&` is involved there and the returned pointer should have static lifetime.
That being said if you have a code snippet in mind feel free to share it, just in case I am missing something.
https://github.com/llvm/llvm-project/pull/203270
More information about the cfe-commits
mailing list