[clang] [clang][transformer] Allow usage of applyFirst with rewriteDescendants (PR #117658)

Yitzhak Mandelbaum via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 18 06:18:08 PST 2024


ymand wrote:

> > Can you expand on your concern about the clash?
> 
> The clash is happening in `NodesMap`. See,
> 
> 1. the matcher which is associated with `rewriteDescendants` gets "Tag0",
> 2. tags for matchers from `applyfirst` are shifted, they get "Tag1", ...
> 3. that is why `transformer::detail::findSelectedCase` selects incorrect `Tag` from `NodesMap` (this also leads to error "ID not bound", for expected bound ID from other matcher)
> 
> Have I made anything clearer? Do you want for me to update the description of the commit?

Thanks for the explanation (and for your patience). Yes, this would be good to specify in the description. That said, I'm still a little unclear:
1. Will any of the new tests trigger the bug?
2. Can you clarify where the matchers  associated with the nested rule will be shifted? As far as I can tell, the original match uses Tag0 but happens in a separate context (that is, MatchFinder) than the nested match so I don't see how they are interacting.

https://github.com/llvm/llvm-project/pull/117658


More information about the cfe-commits mailing list