aaron.ballman added a comment.

In D120952#3381224 <https://reviews.llvm.org/D120952#3381224>, 
@ajohnson-uoregon wrote:

> I still need to write tests but: I do have a use case for these over here: 
> https://github.com/ajohnson-uoregon/llvm-project/blob/feature-ajohnson/clang-tools-extra/clang-rewrite/ConstructMatchers.cpp#L472
>  
> tl;dr, we'd like to match the kernel launch arguments (i.e., the arguments to 
> `__cudaPushCallConfiguration()`) and these matchers made writing the code to 
> generate those AST matchers much easier.

Thanks for the example use case, that helps! Do you expect to need it in more 
than one project though? We support defining local AST matchers so people can 
do one-off matching, but we typically only add AST matchers for things that we 
expect to be generally useful (multiple projects would benefit from it). For 
example, this project adds a number of local matchers: 
https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp#L435

> Without at least the `hasKernelConfig()` matcher, it's actually currently 
> impossible to match the kernel launch args. (I wasn't able to find a way 
> after quite a while poking at the AST, at least.) As for the others, it's not 
> clear how to match the kernel launch args without exposing the fact that 
> there's a second CallExpr inside the CUDAKernelCallExpr to the user and 
> writing a pretty messy matcher, along the lines of 
> `cudaKernelCallExpr(hasKernelConfig(callExpr(hasArgument(0, expr()))))` for 
> the grid dim. `cudaKernelCallExpr(cudaGridDim())` is a lot cleaner and easier 
> to understand.

Yup, I think you need these kind of matchers for what you want to do. What I'm 
less certain of is whether others will need them (we don't have any 
CUDA-specific clang-tidy modules, I don't think any of the existing coding 
standards we support checks for have anything to say about CUDA, etc).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120952/new/

https://reviews.llvm.org/D120952

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to