r256278 - [ASTMatchers] Add booleanType() matcher.
Samuel Benzaquen via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 22 13:10:34 PST 2015
On Tue, Dec 22, 2015 at 3:16 PM, Aaron Ballman <aaron at aaronballman.com>
wrote:
> On Tue, Dec 22, 2015 at 3:06 PM, Samuel Benzaquen via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
> > Author: sbenza
> > Date: Tue Dec 22 14:06:40 2015
> > New Revision: 256278
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=256278&view=rev
> > Log:
> > [ASTMatchers] Add booleanType() matcher.
> >
> > Modified:
> > cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> > cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> > cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> >
> > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=256278&r1=256277&r2=256278&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
> > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue Dec 22
> 14:06:40 2015
> > @@ -3762,6 +3762,18 @@ AST_MATCHER_FUNCTION_P_OVERLOAD(internal
> > new internal::TypeLocTypeMatcher(InnerMatcher));
> > }
> >
> > +/// \brief Matches type \c bool.
> > +///
> > +/// Given
> > +/// \code
> > +/// struct S { bool func(); };
> > +/// \endcode
> > +/// functionDecl(returns(boolType()))
>
> The comment does not match reality -- I think you meant booleanType()
> instead.
>
Sorry about that. Last minute typo.
Done at r256284.
>
> Also, this commit did not update the documentation; please run
> dump_ast_matchers.py as well.
>
Done. It also added another matcher that was missing.
>
> ~Aaron
>
> > +/// matches "bool func();"
> > +AST_MATCHER(Type, booleanType) {
> > + return Node.isBooleanType();
> > +}
> > +
> > /// \brief Matches type \c void.
> > ///
> > /// Given
> >
> > Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=256278&r1=256277&r2=256278&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
> > +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Tue Dec 22 14:06:40
> 2015
> > @@ -108,6 +108,7 @@ RegistryMaps::RegistryMaps() {
> > REGISTER_MATCHER(autoType);
> > REGISTER_MATCHER(binaryOperator);
> > REGISTER_MATCHER(blockPointerType);
> > + REGISTER_MATCHER(booleanType);
> > REGISTER_MATCHER(breakStmt);
> > REGISTER_MATCHER(builtinType);
> > REGISTER_MATCHER(callExpr);
> >
> > Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=256278&r1=256277&r2=256278&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
> > +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Tue Dec 22
> 14:06:40 2015
> > @@ -4146,6 +4146,13 @@ TEST(TypeMatching, MatchesTypes) {
> > EXPECT_TRUE(matches("struct S {};", qualType().bind("loc")));
> > }
> >
> > +TEST(TypeMatching, MatchesBool) {
> > + EXPECT_TRUE(matches("struct S { bool func(); };",
> > + cxxMethodDecl(returns(booleanType()))));
> > + EXPECT_TRUE(notMatches("struct S { void func(); };",
> > + cxxMethodDecl(returns(booleanType()))));
> > +}
> > +
> > TEST(TypeMatching, MatchesVoid) {
> > EXPECT_TRUE(matches("struct S { void func(); };",
> > cxxMethodDecl(returns(voidType()))));
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151222/09acc6c4/attachment-0001.html>
More information about the cfe-commits
mailing list