I am looking into various scenarios where UnresolvedLookupExpr
node occurs. I notice that the output of -ast-dump
and clang-query
don't match.
Here is an example code in c++/9/bits/range_access.h
.
template<typename _Container>
inline constexpr auto
cbegin(const _Container& __cont) noexcept(noexcept(std::begin(__cont)))
-> decltype(std::begin(__cont))
{ return std::begin(__cont); }
The output of -ast-dump
contains only one UnresolvedLookupExpr
node.
| |-FunctionTemplateDecl 0xf4c0d8 <line:114:3, line:118:34> line:116:5 cbegin
| | |-TemplateTypeParmDecl 0xf4bbe0 <line:114:12, col:21> col:21 referenced typename depth 0 index 0 _Container
| | `-FunctionDecl 0xf4c030 <line:115:5, line:118:34> line:116:5 constexpr cbegin 'auto (const _Container &) noexcept(noexcept(std::begin(__cont))) -> decltype(std::begin(__cont))' inline
| | |-ParmVarDecl 0xf4bcb0 <col:12, col:30> col:30 referenced __cont 'const _Container &'
| | `-CompoundStmt 0xf4c2c8 <line:118:5, col:34>
| | `-ReturnStmt 0xf4c2b8 <col:7, col:31>
| | `-CallExpr 0xf4c290 <col:14, col:31> '<dependent type>'
| | |-UnresolvedLookupExpr 0xf4c1e8 <col:14, col:19> '<overloaded function type>' lvalue (no ADL) = 'begin' 0xd8f4b0 0xf48bb8 0xf490f8 0xf4a130 0xf4aeb8 0xf4b308
| | `-DeclRefExpr 0xf4c270 <col:25> 'const _Container' lvalue ParmVar 0xf4bcb0 '__cont' 'const _Container &'
The output of clang-query shows three.
clang-query> m unresolvedLookupExpr(hasAnyDeclaration(functionTemplateDecl(hasName("begin"))))
Match #1:
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/range_access.h:117:19: note: "root" binds here
-> decltype(std::begin(__cont))
^~~~~~~~~~
Match #2:
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/range_access.h:116:56: note: "root" binds here
cbegin(const _Container& __cont) noexcept(noexcept(std::begin(__cont)))
^~~~~~~~~~
Match #3:
/usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/range_access.h:118:14: note: "root" binds here
{ return std::begin(__cont); }
^~~~~~~~~~
3 matches.
It looks like the code in noexcept()
and return type are not shown as AST in -ast-dump
output.
- Why is there such discrepancy?
- Given that
clang-query
shows more occurrences, I assume-ast-dump
doesn't show the full AST. Is there a way to easily get a more detailed AST?