[ASTMatcher] Correct memoization bug ignoring direction (descendants or ancestors)
authorLoïc Joly <loic.joly@sonarsource.com>
Mon, 22 Jun 2020 10:41:39 +0000 (12:41 +0200)
committerSam McCall <sam.mccall@gmail.com>
Mon, 22 Jun 2020 10:56:29 +0000 (12:56 +0200)
commitcba56e026c7beb91a2716276151c5b4360032834
tree02799411e4631c991087805832e6c963c555e601
parenteae0d2e9b276019713c796c435506ceb183329da
[ASTMatcher] Correct memoization bug ignoring direction (descendants or ancestors)

Summary:
In ASTMatcher, when we have `has(...)` and `hasParent(...)` called with the same internal matcher on the same node, the memoization process will mix-up the two calls because the direction of the traversal is not part of the memoization key.

This patch adds this information.

Reviewers: klimek

Reviewed By: klimek

Subscribers: Godin, njames93, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80025
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp