[AMDGPU][AsmParser][NFC] Translate parsed MIMG instructions to MCInsts automatically.
[llvm-project.git] / clang-tools-extra / clang-tidy / cppcoreguidelines / AvoidReferenceCoroutineParametersCheck.cpp
blob17e09c208363465fd8f77abd4e4748a7dcb724a7
1 //===--- AvoidReferenceCoroutineParametersCheck.cpp - clang-tidy ----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "AvoidReferenceCoroutineParametersCheck.h"
10 #include "clang/AST/ASTContext.h"
11 #include "clang/ASTMatchers/ASTMatchFinder.h"
13 using namespace clang::ast_matchers;
15 namespace clang::tidy::cppcoreguidelines {
17 void AvoidReferenceCoroutineParametersCheck::registerMatchers(
18 MatchFinder *Finder) {
19 auto IsCoroMatcher =
20 hasDescendant(expr(anyOf(coyieldExpr(), coreturnStmt(), coawaitExpr())));
21 Finder->addMatcher(parmVarDecl(hasType(type(referenceType())),
22 hasAncestor(functionDecl(IsCoroMatcher)))
23 .bind("param"),
24 this);
27 void AvoidReferenceCoroutineParametersCheck::check(
28 const MatchFinder::MatchResult &Result) {
29 if (const auto *Param = Result.Nodes.getNodeAs<ParmVarDecl>("param")) {
30 diag(Param->getBeginLoc(), "coroutine parameters should not be references");
34 } // namespace clang::tidy::cppcoreguidelines