summaryrefslogtreecommitdiff
path: root/clang/test/Analysis/lambda-convert-to-func-ptr.cpp
AgeCommit message (Collapse)Author
2025-06-25[clang][analyzer] Correctly handle lambda-converted function pointers (#144906)flovent
For lambdas that are converted to C function pointers, ``` int (*ret_zero)() = []() { return 0; }; ``` clang will generate conversion method like: ``` CXXConversionDecl implicit used constexpr operator int (*)() 'int (*() const noexcept)()' inline -CompoundStmt -ReturnStmt -ImplicitCastExpr 'int (*)()' <FunctionToPointerDecay> -DeclRefExpr 'int ()' lvalue CXXMethod 0x5ddb6fe35b18 '__invoke' 'int ()' -CXXMethodDecl implicit used __invoke 'int ()' static inline -CompoundStmt (empty) ``` Based on comment in Sema, `__invoke`'s function body is left empty because it's will be filled in CodeGen, so in AST analysis phase we should get lambda's `operator()` directly instead of calling `__invoke` itself.