[ASTMatchers] Avoid recursion in ancestor matching to save stack space.
authorSam McCall <sam.mccall@gmail.com>
Tue, 1 Sep 2020 18:22:59 +0000 (20:22 +0200)
committerSam McCall <sam.mccall@gmail.com>
Tue, 22 Sep 2020 17:43:41 +0000 (19:43 +0200)
commit625761825620f19a44c7a1482ce05d678a1b0deb
tree2e3fa3b8ad6a1e16ca5f0ba4005224f16ef0cdc5
parentc3c08bfdfd6244e0429753ee56df39c90187d772
[ASTMatchers] Avoid recursion in ancestor matching to save stack space.

A recent change increased the stack size of memoizedMatchesAncestorOfRecursively
leading to stack overflows on real code involving large fold expressions.
It's not totally unreasonable to choke on very deep ASTs, but as common
infrastructure it's be nice if ASTMatchFinder is more robust.
(It already uses data recursion for the regular "downward" traversal.)

Differential Revision: https://reviews.llvm.org/D86964
clang/lib/ASTMatchers/ASTMatchFinder.cpp