diff options
author | Manuel Klimek <klimek@google.com> | 2014-05-27 12:31:10 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2014-05-27 12:31:10 +0000 |
commit | a2c2a4faa0ff98e2e6aad76a643933d50e77ebe9 (patch) | |
tree | 775a13200778f1db44f11e92065c3bd9b558edff /clang/unittests/ASTMatchers/ASTMatchersTest.cpp | |
parent | 1bed9afd30cbd4074d95aff686c952eae08ce4d3 (diff) | |
download | bcm5719-llvm-a2c2a4faa0ff98e2e6aad76a643933d50e77ebe9.tar.gz bcm5719-llvm-a2c2a4faa0ff98e2e6aad76a643933d50e77ebe9.zip |
Make equalsNode work with pointers to subtypes.
llvm-svn: 209652
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index 9d9b2a15b79..691719c04e4 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -4158,24 +4158,32 @@ public: } bool verify(const BoundNodes &Nodes, ASTContext &Context, const Stmt *Node) { + // Use the original typed pointer to verify we can pass pointers to subtypes + // to equalsNode. + const T *TypedNode = cast<T>(Node); return selectFirst<const T>( - "", match(stmt(hasParent(stmt(has(stmt(equalsNode(Node)))).bind(""))), - *Node, Context)) != NULL; + "", match(stmt(hasParent( + stmt(has(stmt(equalsNode(TypedNode)))).bind(""))), + *Node, Context)) != NULL; } bool verify(const BoundNodes &Nodes, ASTContext &Context, const Decl *Node) { + // Use the original typed pointer to verify we can pass pointers to subtypes + // to equalsNode. + const T *TypedNode = cast<T>(Node); return selectFirst<const T>( - "", match(decl(hasParent(decl(has(decl(equalsNode(Node)))).bind(""))), - *Node, Context)) != NULL; + "", match(decl(hasParent( + decl(has(decl(equalsNode(TypedNode)))).bind(""))), + *Node, Context)) != NULL; } }; TEST(IsEqualTo, MatchesNodesByIdentity) { EXPECT_TRUE(matchAndVerifyResultTrue( "class X { class Y {}; };", recordDecl(hasName("::X::Y")).bind(""), - new VerifyAncestorHasChildIsEqual<Decl>())); - EXPECT_TRUE( - matchAndVerifyResultTrue("void f() { if(true) {} }", ifStmt().bind(""), - new VerifyAncestorHasChildIsEqual<Stmt>())); + new VerifyAncestorHasChildIsEqual<CXXRecordDecl>())); + EXPECT_TRUE(matchAndVerifyResultTrue( + "void f() { if (true) if(true) {} }", ifStmt().bind(""), + new VerifyAncestorHasChildIsEqual<IfStmt>())); } class VerifyStartOfTranslationUnit : public MatchFinder::MatchCallback { |