[ASTMatchers] Add forCallable(), a generalization of forFunction().
authorArtem Dergachev <artem.dergachev@gmail.com>
Wed, 12 May 2021 03:22:58 +0000 (20:22 -0700)
committerArtem Dergachev <artem.dergachev@gmail.com>
Thu, 13 May 2021 18:25:00 +0000 (11:25 -0700)
commit6a079dfdc992706408f2bde84c48bf76e52c4311
treea8e089c68297b3ce829a8098bfcd1dab9888abb7
parentdd98ea528c0c23f5fee6d3dbafc261b81cca9f0d
[ASTMatchers] Add forCallable(), a generalization of forFunction().

The new matcher additionally covers blocks and Objective-C methods.

This matcher actually makes sure that the statement truly belongs
to that declaration's body. forFunction() incorrectly reported that
a statement in a nested block belonged to the surrounding function.

forFunction() is now deprecated due to the above footgun, in favor of
forCallable(functionDecl()) when only functions need to be considered.

Differential Revision: https://reviews.llvm.org/D102213
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp