summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers
diff options
context:
space:
mode:
authorAnton Bikineev <ant.bikineev@gmail.com>2019-07-25 14:48:55 +0000
committerAnton Bikineev <ant.bikineev@gmail.com>2019-07-25 14:48:55 +0000
commit0ef3f27458f5e24f77d5c1341d09999329b58c8f (patch)
treefd67a8a9b766b474aa8d4be287abfc2e8206e7da /clang/unittests/ASTMatchers
parent2488ae9df155cd66253512c42aba5daef1f076be (diff)
downloadbcm5719-llvm-0ef3f27458f5e24f77d5c1341d09999329b58c8f.tar.gz
bcm5719-llvm-0ef3f27458f5e24f77d5c1341d09999329b58c8f.zip
[clang] Fail for empty names in is*DerivedFrom matchers.
Differential Revision: https://reviews.llvm.org/D65279 llvm-svn: 367022
Diffstat (limited to 'clang/unittests/ASTMatchers')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 0fedb0c8d60..cb5cf9ebf52 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -566,6 +566,13 @@ TEST(DeclarationMatcher, ClassIsDerived) {
cxxRecordDecl(isDerivedFrom(namedDecl(hasName("X"))))));
}
+TEST(DeclarationMatcher, IsDerivedFromEmptyName) {
+ const char *const Code = "class X {}; class Y : public X {};";
+ EXPECT_TRUE(notMatches(Code, cxxRecordDecl(isDerivedFrom(""))));
+ EXPECT_TRUE(notMatches(Code, cxxRecordDecl(isDirectlyDerivedFrom(""))));
+ EXPECT_TRUE(notMatches(Code, cxxRecordDecl(isSameOrDerivedFrom(""))));
+}
+
TEST(DeclarationMatcher, IsLambda) {
const auto IsLambda = cxxMethodDecl(ofClass(cxxRecordDecl(isLambda())));
EXPECT_TRUE(matches("auto x = []{};", IsLambda));
OpenPOWER on IntegriCloud