[PATCH] D87527: [ASTMatchers] Fix `hasBody` for the descendants of `FunctionDecl`
Balogh, Ádám via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 14 05:57:05 PDT 2020
baloghadamsoftware added a comment.
In D87527#2270939 <https://reviews.llvm.org/D87527#2270939>, @ymandel wrote:
> Can you expand on what is wrong currently for `FunctionDecl` descendants? Would the new test `FindsBodyOfFunctionChildren` fail with the current implementation?
Yes, exactly. They return 2 findings instead of 1 because the matcher matches both the forward declaration and the definition. The cause for this is that template specializations do not work for the descendants of the class for which is template specialized. Instead, the generic version is used. Thus for the children of `FunctionDecl` the original `GetBodyMatcher` is instantiated which does not check whether `doesThisDeclarationHaveABody()` but returns a body instead which may be bound to another declaration of the same function in the declaration chain. This is obviously wrong.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87527/new/
https://reviews.llvm.org/D87527
More information about the cfe-commits
mailing list