diff options
author | Daniel Jasper <djasper@google.com> | 2012-10-17 13:35:36 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2012-10-17 13:35:36 +0000 |
commit | 1802daf8539f3320c369e442d3c8471b10ffd3cb (patch) | |
tree | 08aa08b0dab4d90899166049321c9d66e0f05c89 | |
parent | 86ce8f5873e73fc1486d847cc7378dbb597436b2 (diff) |
Fix tests, which accidentally matched implicit code on specific
platforms to make buildbots happy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166100 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | unittests/ASTMatchers/ASTMatchersTest.cpp | 70 |
1 files changed, 44 insertions, 26 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index 3dc4e1defb..9676fde96b 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -2991,14 +2991,17 @@ TEST(TypeMatching, MatchesAutoTypes) { } TEST(TypeMatching, PointerTypes) { - EXPECT_TRUE(matchAndVerifyResultTrue( - "int* a;", - pointerTypeLoc(pointeeLoc(typeLoc().bind("loc"))), - new VerifyIdIsBoundTo<TypeLoc>("loc", 1))); - EXPECT_TRUE(matchAndVerifyResultTrue( - "int* a;", - pointerTypeLoc().bind("loc"), - new VerifyIdIsBoundTo<TypeLoc>("loc", 1))); + // FIXME: Reactive when these tests can be more specific (not matching + // implicit code on certain platforms), likely when we have hasDescendant for + // Types/TypeLocs. + //EXPECT_TRUE(matchAndVerifyResultTrue( + // "int* a;", + // pointerTypeLoc(pointeeLoc(typeLoc().bind("loc"))), + // new VerifyIdIsBoundTo<TypeLoc>("loc", 1))); + //EXPECT_TRUE(matchAndVerifyResultTrue( + // "int* a;", + // pointerTypeLoc().bind("loc"), + // new VerifyIdIsBoundTo<TypeLoc>("loc", 1))); EXPECT_TRUE(matches( "int** a;", pointerTypeLoc(pointeeLoc(loc(qualType()))))); @@ -3010,22 +3013,34 @@ TEST(TypeMatching, PointerTypes) { loc(qualType(isConstQualified(), pointerType())))); std::string Fragment = "struct A { int i; }; int A::* ptr = &A::i;"; - EXPECT_TRUE(notMatches(Fragment, blockPointerType())); - EXPECT_TRUE(matches(Fragment, memberPointerType())); - EXPECT_TRUE(notMatches(Fragment, pointerType())); - EXPECT_TRUE(notMatches(Fragment, referenceType())); - - Fragment = "int *I;"; - EXPECT_TRUE(notMatches(Fragment, blockPointerType())); - EXPECT_TRUE(notMatches(Fragment, memberPointerType())); - EXPECT_TRUE(matches(Fragment, pointerType())); - EXPECT_TRUE(notMatches(Fragment, referenceType())); - - Fragment = "int a; int &b = a;"; - EXPECT_TRUE(notMatches(Fragment, blockPointerType())); - EXPECT_TRUE(notMatches(Fragment, memberPointerType())); - EXPECT_TRUE(notMatches(Fragment, pointerType())); - EXPECT_TRUE(matches(Fragment, referenceType())); + EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"), + hasType(blockPointerType())))); + EXPECT_TRUE(matches(Fragment, varDecl(hasName("ptr"), + hasType(memberPointerType())))); + EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"), + hasType(pointerType())))); + EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"), + hasType(referenceType())))); + + Fragment = "int *ptr;"; + EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"), + hasType(blockPointerType())))); + EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"), + hasType(memberPointerType())))); + EXPECT_TRUE(matches(Fragment, varDecl(hasName("ptr"), + hasType(pointerType())))); + EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"), + hasType(referenceType())))); + + Fragment = "int a; int &ref = a;"; + EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ref"), + hasType(blockPointerType())))); + EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ref"), + hasType(memberPointerType())))); + EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ref"), + hasType(pointerType())))); + EXPECT_TRUE(matches(Fragment, varDecl(hasName("ref"), + hasType(referenceType())))); } TEST(TypeMatching, PointeeTypes) { @@ -3058,9 +3073,12 @@ TEST(TypeMatching, MatchesPointersToConstTypes) { } TEST(TypeMatching, MatchesTypedefTypes) { - EXPECT_TRUE(matches("typedef int X;", typedefType())); + EXPECT_TRUE(matches("typedef int X; X a;", varDecl(hasName("a"), + hasType(typedefType())))); - EXPECT_TRUE(matches("typedef int X;", typedefType(hasDecl(decl())))); + EXPECT_TRUE(matches("typedef int X; X a;", + varDecl(hasName("a"), + hasType(typedefType(hasDecl(decl())))))); } TEST(NNS, MatchesNestedNameSpecifiers) { |