summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
diff options
context:
space:
mode:
authorSamuel Benzaquen <sbenza@google.com>2013-08-29 15:39:26 +0000
committerSamuel Benzaquen <sbenza@google.com>2013-08-29 15:39:26 +0000
commit68cd396f828e385b69341f077a0a461e3caa6e12 (patch)
tree6b87ba1c2cfb1c5ce093090af36f3e2991e5637f /clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
parent24cca0805431f521edac7842efc05e4b1a06ee25 (diff)
downloadbcm5719-llvm-68cd396f828e385b69341f077a0a461e3caa6e12.tar.gz
bcm5719-llvm-68cd396f828e385b69341f077a0a461e3caa6e12.zip
Fix tests to be more specific.
The environments can inject some declaration in every translation unit, which can match very generic matchers, thus failing the tests. Summary: Fix tests to be more specific. The environments can inject some declaration in every translation unit, which can match very generic matchers, thus failing the tests. Reviewers: aaron.ballman CC: klimek, cfe-commits, revane Differential Revision: http://llvm-reviews.chandlerc.com/D1541 llvm-svn: 189587
Diffstat (limited to 'clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
index 874a4f35a0b..9a24c80cc7f 100644
--- a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -169,22 +169,16 @@ TEST_F(RegistryTest, PolymorphicMatchers) {
EXPECT_FALSE(matches("void f();", Func));
Matcher<Decl> Anything = constructMatcher("anything").getTypedMatcher<Decl>();
- Matcher<Decl> RecordDecl =
- constructMatcher("recordDecl", VariantMatcher::SingleMatcher(Anything))
- .getTypedMatcher<Decl>();
-
- EXPECT_TRUE(matches("int a;", Anything));
- EXPECT_TRUE(matches("class A {};", Anything));
- EXPECT_TRUE(matches("void f(){};", Anything));
- // FIXME: A couple of tests have been suppressed.
- // I know it'd be bad with _MSC_VER here, though.
-#if !defined(_MSC_VER)
- EXPECT_FALSE(matches("int a;", RecordDecl));
-#endif
- EXPECT_TRUE(matches("class A {};", RecordDecl));
-#if !defined(_MSC_VER)
- EXPECT_FALSE(matches("void f(){};", RecordDecl));
-#endif
+ Matcher<Decl> RecordDecl = constructMatcher(
+ "recordDecl", constructMatcher("hasName", std::string("Foo")),
+ VariantMatcher::SingleMatcher(Anything)).getTypedMatcher<Decl>();
+
+ EXPECT_TRUE(matches("int Foo;", Anything));
+ EXPECT_TRUE(matches("class Foo {};", Anything));
+ EXPECT_TRUE(matches("void Foo(){};", Anything));
+ EXPECT_FALSE(matches("int Foo;", RecordDecl));
+ EXPECT_TRUE(matches("class Foo {};", RecordDecl));
+ EXPECT_FALSE(matches("void Foo(){};", RecordDecl));
}
TEST_F(RegistryTest, TemplateArgument) {
@@ -263,7 +257,9 @@ TEST_F(RegistryTest, Adaptative) {
TEST_F(RegistryTest, VariadicOp) {
Matcher<Decl> D = constructMatcher(
- "anyOf", constructMatcher("recordDecl"),
+ "anyOf",
+ constructMatcher("recordDecl",
+ constructMatcher("hasName", std::string("Foo"))),
constructMatcher("namedDecl",
constructMatcher("hasName", std::string("foo"))))
.getTypedMatcher<Decl>();
OpenPOWER on IntegriCloud