10 #include "clang/AST/ASTContext.h" 11 #include "clang/ASTMatchers/ASTMatchFinder.h" 17 namespace performance {
19 void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {
22 if (!getLangOpts().CPlusPlus11)
26 cxxMethodDecl(anyOf(cxxConstructorDecl(), hasOverloadedOperatorName(
"=")),
27 unless(isImplicit()), unless(isDeleted()))
32 void NoexceptMoveConstructorCheck::check(
33 const MatchFinder::MatchResult &
Result) {
34 if (
const auto *Decl = Result.Nodes.getNodeAs<CXXMethodDecl>(
"decl")) {
35 StringRef MethodType =
"assignment operator";
36 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(Decl)) {
37 if (!Ctor->isMoveConstructor())
39 MethodType =
"constructor";
40 }
else if (!Decl->isMoveAssignmentOperator()) {
44 const auto *ProtoType = Decl->getType()->getAs<FunctionProtoType>();
46 if (isUnresolvedExceptionSpec(ProtoType->getExceptionSpecType()))
49 if (!isNoexceptExceptionSpec(ProtoType->getExceptionSpecType())) {
50 diag(Decl->getLocation(),
"move %0s should be marked noexcept")
58 if (ProtoType->canThrow() == CT_Can) {
59 Expr *E = ProtoType->getNoexceptExpr();
60 E = E->IgnoreImplicit();
61 if (!isa<CXXBoolLiteralExpr>(E)) {
63 "noexcept specifier on the move %0 evaluates to 'false'")
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result