[cfe-dev] Possible ASTMatchers bug
Hartogs Siegfried via cfe-dev
cfe-dev at lists.llvm.org
Sun Jan 31 13:06:37 PST 2021
Hi!
On the following code
template<typename T>
class C{};
template<typename T>
C<T> c;
void func(){
c<float>;
}
with the matcher
varDecl(hasType(classTemplateSpecializationDecl()))
I get two matches which are exactly the same:
Match #1:
Binding for "root":
VarTemplateSpecializationDecl 0x7fe879820a28 <test:16:1, col:6> col:6 used c 'C<float>':'C<float>' callinit
|-TemplateArgument type 'float'
| `-BuiltinType 0x7fe87901ee00 'float'
`-CXXConstructExpr 0x7fe879852190 <col:6> 'C<float>':'C<float>' 'void () noexcept'
Match #2:
Binding for "root":
VarTemplateSpecializationDecl 0x7fe879820a28 <test:16:1, col:6> col:6 used c 'C<float>':'C<float>' callinit
|-TemplateArgument type 'float'
| `-BuiltinType 0x7fe87901ee00 'float'
`-CXXConstructExpr 0x7fe879852190 <col:6> 'C<float>':'C<float>' 'void () noexcept'
Is this a bug? I'd expect there to be only one match.
The goal is to find variables whose type refers to a class instantiation, is this a good approach?
Behavior occurs in clang-query and the C++ API on Apple, on both clang 11.0.0 and 10.0.1; didn't yet have the possibility to test 11.0.1.
Thanks & best,
Sigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210131/873030fa/attachment.html>
More information about the cfe-dev
mailing list