10#include "../utils/Matchers.h"
11#include "../utils/OptionsUtils.h"
12#include "clang/AST/ASTContext.h"
13#include "clang/ASTMatchers/ASTMatchFinder.h"
29 utils::options::parseStringList(Options.get(
"AllowedTypes",
""))) {}
32 const auto NonNrvoConstLocalVariable =
33 varDecl(hasLocalStorage(), unless(hasType(lValueReferenceType())),
34 unless(isNRVOVariable()),
37 hasCanonicalType(matchers::isExpensiveToCopy()),
38 unless(hasDeclaration(namedDecl(
44 const auto LValueRefCtor = cxxConstructorDecl(
46 hasType(lValueReferenceType(pointee(type().bind(
"SrcT"))))),
47 ofClass(cxxRecordDecl(hasMethod(cxxConstructorDecl(
48 hasParameter(0, hasType(rValueReferenceType(
49 pointee(type(equalsBoundNode(
"SrcT")))))))))));
53 const auto ConstRefRefCtor = cxxConstructorDecl(
56 hasType(rValueReferenceType(pointee(isConstQualified())))));
61 returnStmt(hasReturnValue(
62 ignoringElidableConstructorCall(ignoringParenImpCasts(
64 hasDeclaration(anyOf(LValueRefCtor, ConstRefRefCtor)),
65 hasArgument(0, ignoringParenImpCasts(declRefExpr(
66 to(NonNrvoConstLocalVariable)))))
67 .bind(
"ctor_call")))))),
72 const auto *Var = Result.Nodes.getNodeAs<VarDecl>(
"vardecl");
73 const auto *CtorCall = Result.Nodes.getNodeAs<Expr>(
"ctor_call");
74 diag(CtorCall->getExprLoc(),
"constness of '%0' prevents automatic move")
llvm::SmallString< 256U > Name
::clang::DynTypedNode Node
void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, StringRef Value) const
Stores an option with the check-local name LocalName with string value Value to Options.
Base class for all clang-tidy checks.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
AST_MATCHER(Decl, declHasNoReturnAttr)
matches a Decl if it has a "no return" attribute of any kind
inline ::clang::ast_matchers::internal::Matcher< NamedDecl > matchesAnyListedName(llvm::ArrayRef< StringRef > NameList)
std::string serializeStringList(ArrayRef< StringRef > Strings)
Serialize a sequence of names that can be parsed by parseStringList.
llvm::StringMap< ClangTidyValue > OptionMap