[llvm-bugs] [Bug 27788] New: DeclRefExprs in lambda captures are not matched by ASTMatchers
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue May 17 08:24:15 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27788
Bug ID: 27788
Summary: DeclRefExprs in lambda captures are not matched by
ASTMatchers
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: libclang
Assignee: unassignedclangbugs at nondot.org
Reporter: flx at google.com
CC: klimek at google.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
Sample code:
```c++
void foo(int i) {
[i](){}();
}
````
clang_query$ match declRefExpr(to(varDecl(hasName("i"))))
returns 0 matches.
The generated AST contains a DeclRefExpr to the parameter "i":
`-FunctionDecl 0x7f4243f37980 </tmp/test.cc:1:1, line:3:1> line:1:6 foo 'void
(int)'
|-ParmVarDecl 0x7f4243f378c0 <col:10, col:14> col:14 used i 'int'
`-CompoundStmt 0x7f4243f38000 <col:17, line:3:1>
`-CXXOperatorCallExpr 0x7f4243f37f80 <line:2:3, col:11> 'void'
|-ImplicitCastExpr 0x7f4243f37f68 <col:10, col:11> 'void (*)(void) const'
<FunctionToPointerDecay>
| `-DeclRefExpr 0x7f4243f37f18 <col:10, col:11> 'void (void) const'
lvalue CXXMethod 0x7f4243f37bf0 'operator()' 'void (void) const'
`-ImplicitCastExpr 0x7f4243f37fe8 <col:3, col:9> 'const class (lambda at
/tmp/test.cc:2:3)' <NoOp>
`-LambdaExpr 0x7f4243f37d90 <col:3, col:9> 'class (lambda at
/tmp/test.cc:2:3)'
|-CXXRecordDecl 0x7f4243f37ac0 <col:3> col:3 implicit class
definition
| |-FieldDecl 0x7f4243f37cb8 <col:4> col:4 implicit 'int'
| |-CXXMethodDecl 0x7f4243f37bf0 <col:7, col:9> col:3 used operator()
'void (void) const' inline
| | `-CompoundStmt 0x7f4243f37d00 <col:8, col:9>
| `-CXXDestructorDecl 0x7f4243f37df8 <col:3> col:3 implicit
referenced ~ 'void (void)' inline noexcept-unevaluated 0x7f4243f37df8
|-ImplicitCastExpr 0x7f4243f37d78 <col:4> 'int' <LValueToRValue>
| `-DeclRefExpr 0x7f4243f37d50 <col:4> 'int' lvalue ParmVar
0x7f4243f378c0 'i' 'int'
`-CompoundStmt 0x7f4243f37d00 <col:8, col:9>
Should the DeclRefExpr above be matched or do lambda captures need to be
treated specially?
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160517/56fd8052/attachment-0001.html>
More information about the llvm-bugs
mailing list