[clang-tools-extra] [clang-tidy] Improve `bugprone-exception-escape`'s handling of lambdas (PR #160592)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 24 13:09:21 PDT 2025


vbvictor wrote:

Also, could you share how we traversed before the fix and now? (If you debugged it)
Given the AST for `[] { throw 0; };` (stipped useless part):
```
    `-LambdaExpr <line:2:5, col:19> '(lambda at line:2:5)'
      |-CXXRecordDecl <col:5> col:5 implicit class definition
      | |-CXXMethodDecl <col:6, col:19> col:5 constexpr operator() 'auto () const -> void' inline
      | | |-CompoundStmt <col:8, col:19>
      | | | `-CXXThrowExpr <col:10, col:16> 'void'
      | | |   `-IntegerLiteral <col:16> 'int' 0
      | | `-InferredNoReturnAttr Implicit
      | |-CXXConversionDecl <col:5, col:19> col:5 implicit constexpr operator void (*)() 'auto (*() const noexcept)() -> void' inline
      | |-CXXMethodDecl <col:5, col:19> col:5 implicit __invoke 'auto () -> void' static inline
      | `-CXXDestructorDecl <col:5> col:5 implicit referenced ~(lambda at line:2:5) 'void () noexcept' inline default trivial
      `-CompoundStmt <col:8, col:19>
        `-CXXThrowExpr <col:10, col:16> 'void'
          `-IntegerLiteral <col:16> 'int' 0
```
I thought we needed some modelling for calling the lambda in order to properly handle `[] {}` but in your PR it's different.
Honestly from brief look I don't understand how this fix the problem

https://github.com/llvm/llvm-project/pull/160592


More information about the cfe-commits mailing list