ParentMap: add support for BlockExpr

We wanted to write the following check in clang-tidy: find all alloca calls inside a loop, but not those captured by a block.

Finding all alloca calls inside a loop is very easy with the matcher, but to exclude those in a block, we wanted to walk the AST from the alloca call to the loop in the checker.

One way to achieve that was to patch ParentMap, because it didn't go inside blocks. See the attached patch.

Is that approach correct or does anyone have a better suggestion ?

Cheers,
Xavier

0001-ParentMap-add-support-for-BlockExpr.patch (943 Bytes)

An alternative without patching clang is to check whether the matched statement has a parent. If not, it is probably in a block. This supposes ParentMap will never be patched to support BlockExpr.