forked from OSchip/llvm-project
[ASTMatchers] Allow forField to match indirect fields.
This is needed for PR32966. Reviewed by alexfh. llvm-svn: 309667
This commit is contained in:
parent
d56595184b
commit
31d08b6e51
|
@ -3237,7 +3237,7 @@ AST_MATCHER_P(CXXConstructorDecl, hasAnyConstructorInitializer,
|
|||
/// with forField matching foo_
|
||||
AST_MATCHER_P(CXXCtorInitializer, forField,
|
||||
internal::Matcher<FieldDecl>, InnerMatcher) {
|
||||
const FieldDecl *NodeAsDecl = Node.getMember();
|
||||
const FieldDecl *NodeAsDecl = Node.getAnyMember();
|
||||
return (NodeAsDecl != nullptr &&
|
||||
InnerMatcher.matches(*NodeAsDecl, Finder, Builder));
|
||||
}
|
||||
|
|
|
@ -785,14 +785,18 @@ TEST(HasAnyConstructorInitializer, ForField) {
|
|||
static const char Code[] =
|
||||
"class Baz { };"
|
||||
"class Foo {"
|
||||
" Foo() : foo_() { }"
|
||||
" Foo() : foo_(), bar_() { }"
|
||||
" Baz foo_;"
|
||||
" Baz bar_;"
|
||||
" struct {"
|
||||
" Baz bar_;"
|
||||
" };"
|
||||
"};";
|
||||
EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
|
||||
forField(hasType(recordDecl(hasName("Baz"))))))));
|
||||
EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
|
||||
forField(hasName("foo_"))))));
|
||||
EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
|
||||
forField(hasName("bar_"))))));
|
||||
EXPECT_TRUE(notMatches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
|
||||
forField(hasType(recordDecl(hasName("Bar"))))))));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue