Skip to content

LambdaExpr matchers needs link to cxxMethodDecl() or functionDecl() #37329

Open
@llvmbot

Description

@llvmbot
Bugzilla Link 37981
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @JonasToth,@steveire

Extended Description

Looking through the matcher reference here

http://clang.llvm.org/docs/LibASTMatchersReference.html

I see two matchers for lambdaExpr, one that is "lambdaExpr" itself, and one to see if a cxxRecordDecl is a lambda (isLambda()). What I really need is a way to get a handle to the cxxMethodDecl() underlying the lambda, in a plugin this happens with getCallOperator ( https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html#a77f0b434b245a0a099a6317de2a7244e ). getLambdaClass() equivalents would be nice as well, perhaps called hasCallOperator and hasClass for matcher names.

This is really breaking a process we have for identifying bugs in our codes, a fix would be greatly appreciated.

In terms of test codes

int main(){
={};
}

Is enough to show that you can't get the cxxMethodDecl from the lambdaExpr

match lambdaExpr(hasDescendant(cxxMethodDecl()))
match lambdaExpr(hasDescendant(cxxRecordDecl()))

Even though (with output "dump" on)

match(lambdaExpr()) returns

LambdaExpr 0x2aaaad49c900 </g/g0/dzpolia/lammps/src/KOKKOS/npair_kokkos.cpp:119:29, col:40> 'class (lambda at /g/g0/dzpolia/lammps/src/KOKKOS/npair_kokkos.cpp:119:29)'
|-CXXRecordDecl 0x2aaaad49c6f0 col:29 col:29 implicit class definition
| |-CXXMethodDecl 0x2aaaad49c830 col:40 col:29 used operator() 'void (int) const' inline
......

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions