void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) {
  // Only register the matchers for C++11; the functionality currently does not
  // provide any benefit to other languages, despite being benign.
  if (getLangOpts().CPlusPlus11) {
    Finder->addMatcher(
      constructorDecl(unless(isImplicit()), allOf(
        isMoveConstructor(),
        hasAnyConstructorInitializer(
          ctorInitializer(withInitializer(constructExpr(hasDeclaration(
            constructorDecl(isCopyConstructor()).bind("ctor")
            )))).bind("init")
          )
        )), this);
  }
}
void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {
    Finder->addMatcher(
        methodDecl(anyOf(constructorDecl(), hasOverloadedOperatorName("=")),
                   unless(isImplicit()), unless(isDeleted()))
        .bind("decl"),
        this);
}
namespace EffectiveCPP {

    StatementMatcher ctorCallVtlMatcherEC = compoundStmt(
            hasParent(constructorDecl().bind("cDecl")),
            hasDescendant(callExpr(callee(methodDecl(isVirtual()))))
            );
    
    StatementMatcher dtorCallVtlMatcherEC = compoundStmt(
            hasParent(destructorDecl().bind("dDecl")),
            hasDescendant(callExpr(callee(methodDecl(isVirtual()))))
            );
}
Beispiel #4
0
TEST(FriendDecl, FriendConstructorDestructorRange) {
  const std::string Code = "struct B {\n"
                           "B();\n"
                           "~B();\n"
                           "};\n"
                           "struct A {\n"
                           "friend B::B(), B::~B();\n"
                           "};\n";
  RangeVerifier<FriendDecl> ConstructorVerifier;
  ConstructorVerifier.expectRange(6, 1, 6, 13);
  EXPECT_TRUE(ConstructorVerifier.match(
      Code, friendDecl(has(constructorDecl(ofClass(hasName("B")))))));
  RangeVerifier<FriendDecl> DestructorVerifier;
  DestructorVerifier.expectRange(6, 1, 6, 22);
  EXPECT_TRUE(DestructorVerifier.match(
      Code, friendDecl(has(destructorDecl(ofClass(hasName("B")))))));
}
Beispiel #5
0
TEST(FriendDecl, FriendConstructorDestructorLocation) {
  const std::string Code = "struct B {\n"
                           "B();\n"
                           "~B();\n"
                           "};\n"
                           "struct A {\n"
                           "friend B::B(), B::~B();\n"
                           "};\n";
  LocationVerifier<FriendDecl> ConstructorVerifier;
  ConstructorVerifier.expectLocation(6, 11);
  EXPECT_TRUE(ConstructorVerifier.match(
      Code, friendDecl(has(constructorDecl(ofClass(hasName("B")))))));
  LocationVerifier<FriendDecl> DestructorVerifier;
  DestructorVerifier.expectLocation(6, 19);
  EXPECT_TRUE(DestructorVerifier.match(
      Code, friendDecl(has(destructorDecl(ofClass(hasName("B")))))));
}