recordDecl() matching weirdness

For reference, please see:
<https://llvm.org/bugs/show_bug.cgi?id=26613&gt;
    recordDecl(unless(isDefinition())) is not the inverse of
    recordDecl(isDefinition())

<https://llvm.org/bugs/show_bug.cgi?id=26614&gt;
    recordDecl() matches same declaration twice

I'm working in trunk, but I checked against release_36 branch and saw
the same results.

Given this source:

1 class Foo;
2 class Foo;
3
4 class Bar {
5 };
6
7 class Bar;

Why does line 4 match recordDecl() twice?

If I try to filter declarations from definitions using
TagDecl::isThisDeclarationADefinition(), then one of the matches is
rejected, but the fact that it matches twice means that:

recordDecl(isDefinition()) matches line 4, but none of the others.
recordDecl(unless(isDefinition())) matches line 4 as well as the others.

What is going on here?

For reference, please see:
<https://llvm.org/bugs/show_bug.cgi?id=26613>
recordDecl(unless(isDefinition())) is not the inverse of
recordDecl(isDefinition())

<https://llvm.org/bugs/show_bug.cgi?id=26614>
recordDecl() matches same declaration twice

I’m working in trunk, but I checked against release_36 branch and saw
the same results.

Given this source:

1 class Foo;
2 class Foo;
3
4 class Bar {
5 };
6
7 class Bar;

Why does line 4 match recordDecl() twice?

That’s the injected class name. The injected class name is implicit, and is a declaration and not a definition. You’ll basically want to exclude matches on Bar::Bar