-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[Clang][ASTMatcher] Add dependentNameType Matcher
#121263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7711,6 +7711,16 @@ AST_MATCHER_P(DecayedType, hasDecayedType, internal::Matcher<QualType>, | |
| return InnerType.matches(Node.getDecayedType(), Finder, Builder); | ||
| } | ||
|
|
||
| /// Matches dependent name type | ||
|
||
| /// | ||
| /// Example matches T::type | ||
| /// \code | ||
| /// template <typename T> struct declToImport { | ||
| /// typedef typename T::type dependent_name; | ||
| /// }; | ||
| /// \endcode | ||
| extern const AstTypeMatcher<DependentNameType> dependentNameType; | ||
|
|
||
| /// Matches declarations whose declaration context, interpreted as a | ||
| /// Decl, matches \c InnerMatcher. | ||
| /// | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -218,6 +218,7 @@ RegistryMaps::RegistryMaps() { | |
| REGISTER_MATCHER(cxxTryStmt); | ||
| REGISTER_MATCHER(cxxUnresolvedConstructExpr); | ||
| REGISTER_MATCHER(decayedType); | ||
| REGISTER_MATCHER(dependentNameType); | ||
|
||
| REGISTER_MATCHER(decl); | ||
| REGISTER_MATCHER(decompositionDecl); | ||
| REGISTER_MATCHER(declCountIs); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1912,6 +1912,21 @@ TEST_P(ASTMatchersTest, DeducedTemplateSpecializationType) { | |
| deducedTemplateSpecializationType())); | ||
| } | ||
|
|
||
| TEST_P(ASTMatchersTest, DependentNameType) { | ||
| if (!GetParam().isCXX()) { | ||
| // FIXME: Add a test for `dependentNameType()` that does not depend on C++. | ||
|
||
| return; | ||
| } | ||
|
|
||
| EXPECT_TRUE(matches( | ||
| R"( | ||
| template <typename T> struct declToImport { | ||
| typedef typename T::type dependent_name; | ||
| }; | ||
| )", | ||
| dependentNameType())); | ||
| } | ||
|
|
||
| TEST_P(ASTMatchersTest, RecordType) { | ||
| EXPECT_TRUE(matches("struct S {}; struct S s;", | ||
| recordType(hasDeclaration(recordDecl(hasName("S")))))); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first column here should be
Matcher<Type>, notMatcher<Stmt>There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Done