<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - DeclRefExprs in lambda captures are not matched by ASTMatchers"
href="https://llvm.org/bugs/show_bug.cgi?id=27788">27788</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>DeclRefExprs in lambda captures are not matched by ASTMatchers
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>libclang
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>flx@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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?</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>