diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -6422,6 +6422,14 @@ +
Matches the kernel launch config (in <<<>>>) on CUDA kernel calls. + +Example: cudaKernelCallExpr(hasKernelConfig()) will match <<<i,j>>> in + kernel<<<i,j>>>(); +
Matches if the type location of a node matches the inner matcher. diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -7826,6 +7826,20 @@ extern const internal::VariadicDynCastAllOfMatchercudaKernelCallExpr; +/// Matches the kernel launch config (in <<<>>>) on CUDA kernel calls. +/// +/// Example: cudaKernelCallExpr(hasKernelConfig()) will match <<>> in +/// \code +/// kernel<<>>(); +/// \endcode +AST_MATCHER_P(CUDAKernelCallExpr, hasKernelConfig, internal::Matcher , + InnerMatcher) { + if (const CallExpr *Config = Node.getConfig()) { + return InnerMatcher.matches(*Config, Finder, Builder); + } + return false; +} + /// Matches expressions that resolve to a null pointer constant, such as /// GNU's __null, C++11's nullptr, or C's NULL macro. /// diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp --- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -320,6 +320,7 @@ REGISTER_MATCHER(hasInit); REGISTER_MATCHER(hasInitializer); REGISTER_MATCHER(hasInitStatement); + REGISTER_MATCHER(hasKernelConfig); REGISTER_MATCHER(hasKeywordSelector); REGISTER_MATCHER(hasLHS); REGISTER_MATCHER(hasLocalQualifiers);