diff options
author | Daniel Jasper <djasper@google.com> | 2012-09-18 13:36:17 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2012-09-18 13:36:17 +0000 |
commit | e6d2a96cc9689be584c3bfc09ac527a03a25b3bc (patch) | |
tree | b4e00814ffc0ee71671e172d1892ee61d4412ec3 /unittests/ASTMatchers/ASTMatchersTest.cpp | |
parent | ea104cd90ed2f468ccffe689750efaf4f8afa187 (diff) |
Add missing matcher for C-style cast expressions.
Patch by Gábor Horváth.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164123 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r-- | unittests/ASTMatchers/ASTMatchersTest.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index 348034f0ed..b8ffaa4300 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -2229,6 +2229,20 @@ TEST(StaticCast, DoesNotMatchOtherCasts) { staticCastExpr())); } +TEST(CStyleCast, MatchesSimpleCase) { + EXPECT_TRUE(matches("int i = (int) 2.2f;", cStyleCastExpr())); +} + +TEST(CStyleCast, DoesNotMatchOtherCasts) { + EXPECT_TRUE(notMatches("char* p = static_cast<char*>(0);" + "char q, *r = const_cast<char*>(&q);" + "void* s = reinterpret_cast<char*>(&s);" + "struct B { virtual ~B() {} }; struct D : B {};" + "B b;" + "D* t = dynamic_cast<D*>(&b);", + cStyleCastExpr())); +} + TEST(HasDestinationType, MatchesSimpleCase) { EXPECT_TRUE(matches("char* p = static_cast<char*>(0);", staticCastExpr(hasDestinationType( |