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" 23 AST_MATCHER_P(CXXRecordDecl, matchesAnyName, ArrayRef<std::string>, Names) {
24 std::string QualifiedName = Node.getQualifiedNameAsString();
25 return llvm::any_of(Names,
26 [&](StringRef
Name) {
return QualifiedName ==
Name; });
29 void TemporaryObjectsCheck::registerMatchers(MatchFinder *Finder) {
32 cxxTemporaryObjectExpr(hasDeclaration(cxxConstructorDecl(hasParent(
33 cxxRecordDecl(matchesAnyName(Names))))))
39 cxxConstructExpr(hasParent(cxxFunctionalCastExpr()),
40 hasDeclaration(cxxConstructorDecl(
41 hasParent(cxxRecordDecl(matchesAnyName(Names))))))
46 void TemporaryObjectsCheck::check(
const MatchFinder::MatchResult &Result) {
47 if (
const auto *D = Result.Nodes.getNodeAs<CXXConstructExpr>(
"temps"))
48 diag(D->getLocation(),
49 "creating a temporary object of type %q0 is prohibited")
50 << D->getConstructor()->getParent();
std::string serializeStringList(ArrayRef< std::string > Strings)
Serialize a sequence of names that can be parsed by parseStringList.
AST_MATCHER_P(CXXRecordDecl, matchesAnyName, ArrayRef< std::string >, Names)
static constexpr llvm::StringLiteral Name
std::map< std::string, std::string > OptionMap
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//