11 #include "../utils/OptionsUtils.h" 12 #include "clang/AST/ASTContext.h" 13 #include "clang/ASTMatchers/ASTMatchFinder.h" 14 #include "llvm/ADT/STLExtras.h" 15 #include "llvm/ADT/SmallVector.h" 24 AST_MATCHER_P(CXXRecordDecl, matchesAnyName, ArrayRef<std::string>, Names) {
25 std::string QualifiedName = Node.getQualifiedNameAsString();
26 return llvm::any_of(Names,
27 [&](StringRef
Name) {
return QualifiedName ==
Name; });
30 void TemporaryObjectsCheck::registerMatchers(MatchFinder *Finder) {
33 cxxTemporaryObjectExpr(hasDeclaration(cxxConstructorDecl(hasParent(
34 cxxRecordDecl(matchesAnyName(Names))))))
40 cxxConstructExpr(hasParent(cxxFunctionalCastExpr()),
41 hasDeclaration(cxxConstructorDecl(
42 hasParent(cxxRecordDecl(matchesAnyName(Names))))))
47 void TemporaryObjectsCheck::check(
const MatchFinder::MatchResult &
Result) {
48 if (
const auto *
D = Result.Nodes.getNodeAs<CXXConstructExpr>(
"temps"))
49 diag(
D->getLocation(),
50 "creating a temporary object of type %q0 is prohibited")
51 <<
D->getConstructor()->getParent();
std::string serializeStringList(ArrayRef< std::string > Strings)
Serialize a sequence of names that can be parsed by parseStringList.
static constexpr llvm::StringLiteral Name
std::map< std::string, std::string > OptionMap
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
AST_MATCHER_P(FunctionDecl, throws, internal::Matcher< Type >, InnerMatcher)