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()))))
            );
}
Exemplo n.º 2
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")))))));
}
Exemplo n.º 3
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")))))));
}