Rules for overriding what "this" refers to in the AST (e.g., if under an InitListExpr)?

Hi,

While looking into [clang][dataflow] Crashes in getChild with incorrect "base" StorageLocation after #127338 · Issue #128068 · llvm/llvm-project · GitHub we were wondering if someone more familiar with the AST could help clarify the semantics / determining what “this” could refer to when InitListExpr or similar constructs are involved.

Is it something like “if a CXXThisExpr is contained in an CXXDefaultInitExpr in an InitListExpr (or CXXParenListInitExpr) it refers to the result object of that InitListExpr (and not the this pointer of the enclosing CXXMethodDecl)”? Are there other cases to consider?

Thank you!
Jan

I once had the same question and came up with a similar answer: [clang][bytecode] Add InitLinkScope for temporary variables by tbaederr · Pull Request #106552 · llvm/llvm-project · GitHub