[PATCH] Make the negative test more specific.
Samuel Benzaquen
sbenza at google.com
Fri Nov 22 15:04:39 PST 2013
Hi aaron.ballman,
Make the negative test more specific.
Otherwise it can accidentally match injected code.
http://llvm-reviews.chandlerc.com/D2257
Files:
unittests/ASTMatchers/Dynamic/RegistryTest.cpp
Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===================================================================
--- unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -296,16 +296,16 @@
EXPECT_TRUE(matches("class Bar{};", D));
EXPECT_FALSE(matches("class OtherBar{};", D));
- D = constructMatcher(
- "recordDecl",
+ D = recordDecl(
+ has(fieldDecl(hasName("Foo"))),
constructMatcher(
"unless",
constructMatcher("namedDecl",
- constructMatcher("hasName", std::string("Bar")))))
- .getTypedMatcher<Decl>();
+ constructMatcher("hasName", std::string("Bar"))))
+ .getTypedMatcher<Decl>());
- EXPECT_FALSE(matches("class Bar{};", D));
- EXPECT_TRUE(matches("class OtherBar{};", D));
+ EXPECT_FALSE(matches("class Bar{ int Foo; };", D));
+ EXPECT_TRUE(matches("class OtherBar{ int Foo; };", D));
}
TEST_F(RegistryTest, Errors) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2257.1.patch
Type: text/x-patch
Size: 1012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131122/39b48d7c/attachment.bin>
More information about the cfe-commits
mailing list