From: David Blaikie Date: Mon, 18 Feb 2013 19:04:16 +0000 (+0000) Subject: Clean up last use of dyn_cast on TypeLoc in ASTMatchers X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5be093c0ef46c7749c942d0d9056af6dc3d591a4;p=clang Clean up last use of dyn_cast on TypeLoc in ASTMatchers git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175454 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/ASTMatchers/ASTMatchersMacros.h b/include/clang/ASTMatchers/ASTMatchersMacros.h index b2629c6627..f5ca26bca7 100644 --- a/include/clang/ASTMatchers/ASTMatchersMacros.h +++ b/include/clang/ASTMatchers/ASTMatchersMacros.h @@ -273,9 +273,9 @@ /// \brief Creates a variadic matcher for both a specific \c Type as well as /// the corresponding \c TypeLoc. #define AST_TYPE_MATCHER(NodeType, MatcherName) \ - const internal::VariadicDynCastAllOfMatcher MatcherName; \ - const internal::VariadicDynCastAllOfMatcher MatcherName##Loc + const internal::VariadicDynCastAllOfMatcher MatcherName +// FIXME: add a matcher for TypeLoc derived classes using its custom casting +// API (no longer dyn_cast) if/when we need such matching /// \brief AST_TYPE_TRAVERSE_MATCHER(MatcherName, FunctionName) defines /// the matcher \c MatcherName that can be used to traverse from one \c Type diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index 129f90f2dc..608e7479a6 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -673,7 +673,7 @@ TEST(HasDescendant, MatchesDescendantsOfTypes) { qualType(hasDescendant( pointerType(pointee(builtinType())))))); EXPECT_TRUE(matches("void f() { int*** i; }", - typeLoc(hasDescendant(builtinTypeLoc())))); + typeLoc(hasDescendant(loc(builtinType()))))); EXPECT_TRUE(matchAndVerifyResultTrue( "void f() { int*** i; }", @@ -3279,7 +3279,7 @@ TEST(TypeMatching, PointerTypes) { // new VerifyIdIsBoundTo("loc", 1))); EXPECT_TRUE(matches( "int** a;", - pointerTypeLoc(pointeeLoc(loc(qualType()))))); + loc(pointerType(pointee(qualType()))))); EXPECT_TRUE(matches( "int** a;", loc(pointerType(pointee(pointerType()))))); @@ -3324,7 +3324,7 @@ TEST(TypeMatching, PointeeTypes) { EXPECT_TRUE(matches("int *a;", pointerType(pointee(builtinType())))); EXPECT_TRUE(matches("int *a;", - pointerTypeLoc(pointeeLoc(loc(builtinType()))))); + loc(pointerType(pointee(builtinType()))))); EXPECT_TRUE(matches( "int const *A;", @@ -3338,10 +3338,10 @@ TEST(TypeMatching, MatchesPointersToConstTypes) { EXPECT_TRUE(matches("int b; int * const a = &b;", loc(pointerType()))); EXPECT_TRUE(matches("int b; int * const a = &b;", - pointerTypeLoc())); + loc(pointerType()))); EXPECT_TRUE(matches( "int b; const int * a = &b;", - pointerTypeLoc(pointeeLoc(builtinTypeLoc())))); + loc(pointerType(pointee(builtinType()))))); EXPECT_TRUE(matches( "int b; const int * a = &b;", pointerType(pointee(builtinType()))));