diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:16:04 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:16:04 +0900 |
commit | 0aa930a41f2d1ebf1fa90ec42da8f96d15a4dcbb (patch) | |
tree | 6a77b463f700e090df586672c26b9fe765fd115b /clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp | |
parent | ec6892d1c979ce0b84c86918d5cdbb03037b409a (diff) | |
parent | 6d16b1c5c468a79ecf867293023c89ac518ecdda (diff) | |
download | llvm-users/chapuni/cov/single/nextcount-base.zip llvm-users/chapuni/cov/single/nextcount-base.tar.gz llvm-users/chapuni/cov/single/nextcount-base.tar.bz2 |
Merge branch 'users/chapuni/cov/single/pair' into users/chapuni/cov/single/nextcount-baseusers/chapuni/cov/single/nextcount-base
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp')
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp index 9bc287e..680e218 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -556,6 +556,21 @@ TEST_P(ASTMatchersTest, DeclRefExpr) { Reference)); } +TEST_P(ASTMatchersTest, DependentScopeDeclRefExpr) { + if (!GetParam().isCXX() || GetParam().hasDelayedTemplateParsing()) { + // FIXME: Fix this test to work with delayed template parsing. + return; + } + + EXPECT_TRUE(matches("template <class T> class X : T { void f() { T::v; } };", + dependentScopeDeclRefExpr())); + + EXPECT_TRUE( + matches("template <typename T> struct S { static T Foo; };" + "template <typename T> void declToImport() { (void)S<T>::Foo; }", + dependentScopeDeclRefExpr())); +} + TEST_P(ASTMatchersTest, CXXMemberCallExpr) { if (!GetParam().isCXX()) { return; @@ -629,10 +644,8 @@ TEST_P(ASTMatchersTest, MemberExpr_MatchesVariable) { EXPECT_TRUE(matches("template <class T>" "class X : T { void f() { this->T::v; } };", cxxDependentScopeMemberExpr())); - // FIXME: Add a matcher for DependentScopeDeclRefExpr. - EXPECT_TRUE( - notMatches("template <class T> class X : T { void f() { T::v; } };", - cxxDependentScopeMemberExpr())); + EXPECT_TRUE(matches("template <class T> class X : T { void f() { T::v; } };", + dependentScopeDeclRefExpr())); EXPECT_TRUE(matches("template <class T> void x() { T t; t.v; }", cxxDependentScopeMemberExpr())); } @@ -1899,6 +1912,35 @@ TEST_P(ASTMatchersTest, DeducedTemplateSpecializationType) { deducedTemplateSpecializationType())); } +TEST_P(ASTMatchersTest, DependentNameType) { + if (!GetParam().isCXX()) { + return; + } + + EXPECT_TRUE(matches( + R"( + template <typename T> struct declToImport { + typedef typename T::type dependent_name; + }; + )", + dependentNameType())); +} + +TEST_P(ASTMatchersTest, DependentTemplateSpecializationType) { + if (!GetParam().isCXX()) { + return; + } + + EXPECT_TRUE(matches( + R"( + template<typename T> struct A; + template<typename T> struct declToImport { + typename A<T>::template B<T> a; + }; + )", + dependentTemplateSpecializationType())); +} + TEST_P(ASTMatchersTest, RecordType) { EXPECT_TRUE(matches("struct S {}; struct S s;", recordType(hasDeclaration(recordDecl(hasName("S")))))); |