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_
 | 
					/// with forField matching foo_
 | 
				
			||||||
AST_MATCHER_P(CXXCtorInitializer, forField,
 | 
					AST_MATCHER_P(CXXCtorInitializer, forField,
 | 
				
			||||||
              internal::Matcher<FieldDecl>, InnerMatcher) {
 | 
					              internal::Matcher<FieldDecl>, InnerMatcher) {
 | 
				
			||||||
  const FieldDecl *NodeAsDecl = Node.getMember();
 | 
					  const FieldDecl *NodeAsDecl = Node.getAnyMember();
 | 
				
			||||||
  return (NodeAsDecl != nullptr &&
 | 
					  return (NodeAsDecl != nullptr &&
 | 
				
			||||||
      InnerMatcher.matches(*NodeAsDecl, Finder, Builder));
 | 
					      InnerMatcher.matches(*NodeAsDecl, Finder, Builder));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -785,14 +785,18 @@ TEST(HasAnyConstructorInitializer, ForField) {
 | 
				
			||||||
  static const char Code[] =
 | 
					  static const char Code[] =
 | 
				
			||||||
    "class Baz { };"
 | 
					    "class Baz { };"
 | 
				
			||||||
      "class Foo {"
 | 
					      "class Foo {"
 | 
				
			||||||
      "  Foo() : foo_() { }"
 | 
					      "  Foo() : foo_(), bar_() { }"
 | 
				
			||||||
      "  Baz foo_;"
 | 
					      "  Baz foo_;"
 | 
				
			||||||
 | 
					      "  struct {"
 | 
				
			||||||
      "    Baz bar_;"
 | 
					      "    Baz bar_;"
 | 
				
			||||||
 | 
					      "  };"
 | 
				
			||||||
      "};";
 | 
					      "};";
 | 
				
			||||||
  EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
 | 
					  EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
 | 
				
			||||||
    forField(hasType(recordDecl(hasName("Baz"))))))));
 | 
					    forField(hasType(recordDecl(hasName("Baz"))))))));
 | 
				
			||||||
  EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
 | 
					  EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
 | 
				
			||||||
    forField(hasName("foo_"))))));
 | 
					    forField(hasName("foo_"))))));
 | 
				
			||||||
 | 
					  EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
 | 
				
			||||||
 | 
					    forField(hasName("bar_"))))));
 | 
				
			||||||
  EXPECT_TRUE(notMatches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
 | 
					  EXPECT_TRUE(notMatches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
 | 
				
			||||||
    forField(hasType(recordDecl(hasName("Bar"))))))));
 | 
					    forField(hasType(recordDecl(hasName("Bar"))))))));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue