[all-commits] [llvm/llvm-project] b8bda9: [clang][analyzer] Correctly handle lambda-converte...

flovent via All-commits all-commits at lists.llvm.org
Wed Jun 25 07:15:23 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b8bda9d446e756f1ec722a06d604a654b472e581
      https://github.com/llvm/llvm-project/commit/b8bda9d446e756f1ec722a06d604a654b472e581
  Author: flovent <flbven at protonmail.com>
  Date:   2025-06-25 (Wed, 25 Jun 2025)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
    M clang/lib/StaticAnalyzer/Core/CallEvent.cpp
    A clang/test/Analysis/lambda-convert-to-func-ptr.cpp

  Log Message:
  -----------
  [clang][analyzer] Correctly handle lambda-converted function pointers (#144906)

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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list