10#include "../utils/OptionsUtils.h"
11#include "clang/AST/ASTContext.h"
12#include "clang/ASTMatchers/ASTMatchFinder.h"
13#include "llvm/ADT/STLExtras.h"
14#include "llvm/ADT/SmallVector.h"
21AST_MATCHER_P(CXXRecordDecl, matchesAnyName, ArrayRef<StringRef>, Names) {
22 std::string QualifiedName =
Node.getQualifiedNameAsString();
23 return llvm::is_contained(Names, QualifiedName);
29 cxxTemporaryObjectExpr(hasDeclaration(cxxConstructorDecl(hasParent(
30 cxxRecordDecl(matchesAnyName(Names))))))
37 cxxConstructExpr(hasParent(cxxFunctionalCastExpr()),
38 hasDeclaration(cxxConstructorDecl(hasParent(
39 cxxRecordDecl(matchesAnyName(Names))))))
45 if (
const auto *D = Result.Nodes.getNodeAs<CXXConstructExpr>(
"temps"))
46 diag(D->getLocation(),
47 "creating a temporary object of type %q0 is prohibited")
48 << D->getConstructor()->getParent();
::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.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
std::string serializeStringList(ArrayRef< StringRef > Strings)
Serialize a sequence of names that can be parsed by parseStringList.
AST_MATCHER_P(CXXRecordDecl, matchesAnyName, ArrayRef< StringRef >, Names)
llvm::StringMap< ClangTidyValue > OptionMap