10 #include "../utils/Matchers.h" 11 #include "../utils/OptionsUtils.h" 12 #include "clang/AST/ASTContext.h" 13 #include "clang/ASTMatchers/ASTMatchFinder.h" 19 namespace performance {
21 NoAutomaticMoveCheck::NoAutomaticMoveCheck(StringRef
Name,
32 const auto ConstLocalVariable =
33 varDecl(hasLocalStorage(), unless(hasType(lValueReferenceType())),
37 unless(hasDeclaration(namedDecl(
38 matchers::matchesAnyListedName(AllowedTypes)))))))
43 const auto LValueRefCtor = cxxConstructorDecl(
45 hasType(lValueReferenceType(pointee(type().bind(
"SrcT"))))),
46 ofClass(cxxRecordDecl(hasMethod(cxxConstructorDecl(
47 hasParameter(0, hasType(rValueReferenceType(
48 pointee(type(equalsBoundNode(
"SrcT")))))))))));
52 hasReturnValue(ignoringElidableConstructorCall(ignoringParenImpCasts(
53 cxxConstructExpr(hasDeclaration(LValueRefCtor),
54 hasArgument(0, ignoringParenImpCasts(declRefExpr(
55 to(ConstLocalVariable)))))
56 .bind(
"ctor_call"))))),
61 const auto *Var = Result.Nodes.getNodeAs<VarDecl>(
"vardecl");
62 const auto *CtorCall = Result.Nodes.getNodeAs<Expr>(
"ctor_call");
63 diag(CtorCall->getExprLoc(),
"constness of '%0' prevents automatic move")
std::string serializeStringList(ArrayRef< std::string > Strings)
Serialize a sequence of names that can be parsed by parseStringList.
Base class for all clang-tidy checks.
const LangOptions & getLangOpts() const
Returns the language options from the context.
std::vector< std::string > parseStringList(StringRef Option)
Parse a semicolon separated list of strings.
llvm::Optional< bool > isExpensiveToCopy(QualType Type, const ASTContext &Context)
Returns true if Type is expensive to copy.
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.
static constexpr llvm::StringLiteral Name
std::map< std::string, std::string > OptionMap
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.