r271288 - [ASTMatchers] Breaking change of `has` matcher

Piotr Padlewski via cfe-commits cfe-commits at lists.llvm.org
Tue May 31 09:09:05 PDT 2016


Already commited. It should work right now.

2016-05-31 18:00 GMT+02:00 Rafael EspĂ­ndola <rafael.espindola at gmail.com>:

> I think is just the usual "llvm.org is crazy slow". I am trying to commit.
>
> Cheers,
> Rafael
>
>
> On 31 May 2016 at 08:54, Piotr Padlewski <piotr.padlewski at gmail.com>
> wrote:
> > dunno why but I can't fetch from upstream
> >
> > Can you push this change?
> >
> > ------------------------- include/clang/CMakeLists.txt
> > -------------------------
> > index 96905c9..feb81f0 100644
> > @@ -5,4 +5,3 @@ add_subdirectory(Parse)
> >  add_subdirectory(Sema)
> >  add_subdirectory(Serialization)
> >  add_subdirectory(StaticAnalyzer/Checkers)
> > -add_subdirectory(ASTMatchers)
> >
> > 2016-05-31 17:48 GMT+02:00 Piotr Padlewski <piotr.padlewski at gmail.com>:
> >>
> >> Yep, sending fix
> >>
> >> 2016-05-31 17:45 GMT+02:00 Rafael EspĂ­ndola <rafael.espindola at gmail.com
> >:
> >>>
> >>> This broke the build:
> >>>
> >>>
> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/36968/steps/cmake-configure/logs/stdio
> >>>
> >>> On 31 May 2016 at 08:25, Piotr Padlewski via cfe-commits
> >>> <cfe-commits at lists.llvm.org> wrote:
> >>> > Author: prazek
> >>> > Date: Tue May 31 10:25:05 2016
> >>> > New Revision: 271288
> >>> >
> >>> > URL: http://llvm.org/viewvc/llvm-project?rev=271288&view=rev
> >>> > Log:
> >>> > [ASTMatchers] Breaking change of `has` matcher
> >>> >
> >>> > has matcher can now match to implicit and paren casts
> >>> >
> >>> > http://reviews.llvm.org/D20801
> >>> >
> >>> > Modified:
> >>> >     cfe/trunk/docs/ReleaseNotes.rst
> >>> >     cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> >>> >     cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
> >>> >     cfe/trunk/include/clang/CMakeLists.txt
> >>> >     cfe/trunk/unittests/AST/ASTImporterTest.cpp
> >>> >     cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
> >>> >
> >>> > Modified: cfe/trunk/docs/ReleaseNotes.rst
> >>> > URL:
> >>> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=271288&r1=271287&r2=271288&view=diff
> >>> >
> >>> >
> ==============================================================================
> >>> > --- cfe/trunk/docs/ReleaseNotes.rst (original)
> >>> > +++ cfe/trunk/docs/ReleaseNotes.rst Tue May 31 10:25:05 2016
> >>> > @@ -185,11 +185,13 @@ this section should help get you past th
> >>> >  AST Matchers
> >>> >  ------------
> >>> >
> >>> > -- hasAnyArgument: Matcher no longer ignores parentheses and implicit
> >>> > casts on
> >>> > -  the argument before applying the inner matcher. The fix was done
> to
> >>> > allow for
> >>> > -  greater control by the user. In all existing checkers that use
> this
> >>> > matcher
> >>> > -  all instances of code ``hasAnyArgument(<inner matcher>)`` must be
> >>> > changed to
> >>> > -  ``hasAnyArgument(ignoringParenImpCasts(<inner matcher>))``.
> >>> > +- has and hasAnyArgument: Matchers no longer ignores parentheses and
> >>> > implicit
> >>> > +  casts on the argument before applying the inner matcher. The fix
> was
> >>> > done to
> >>> > +  allow for greater control by the user. In all existing checkers
> that
> >>> > use this
> >>> > +  matcher all instances of code ``hasAnyArgument(<inner matcher>)``
> or
> >>> > +  ``has(<inner matcher>)`` must be changed to
> >>> > +  ``hasAnyArgument(ignoringParenImpCasts(<inner matcher>))`` or
> >>> > +  ``has(ignoringParenImpCasts(<inner matcher>))``.
> >>> >
> >>> >  ...
> >>> >
> >>> >
> >>> > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> >>> > URL:
> >>> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=271288&r1=271287&r2=271288&view=diff
> >>> >
> >>> >
> ==============================================================================
> >>> > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
> >>> > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue May 31
> >>> > 10:25:05 2016
> >>> > @@ -2169,6 +2169,10 @@ AST_MATCHER_P(CXXRecordDecl, hasMethod,
> >>> >  /// ChildT must be an AST base type.
> >>> >  ///
> >>> >  /// Usable as: Any Matcher
> >>> > +/// Note that has is direct matcher, so it also matches things like
> >>> > implicit
> >>> > +/// casts and paren casts. If you are matching with expr then you
> >>> > should
> >>> > +/// probably consider using ignoringParenImpCasts like:
> >>> > +/// has(ignoringParenImpCasts(expr())).
> >>> >  const internal::ArgumentAdaptingMatcherFunc<internal::HasMatcher>
> >>> >  LLVM_ATTRIBUTE_UNUSED has = {};
> >>> >
> >>> >
> >>> > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
> >>> > URL:
> >>> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=271288&r1=271287&r2=271288&view=diff
> >>> >
> >>> >
> ==============================================================================
> >>> > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
> >>> > (original)
> >>> > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Tue May
> >>> > 31 10:25:05 2016
> >>> > @@ -1165,8 +1165,6 @@ public:
> >>> >  /// ChildT must be an AST base type.
> >>> >  template <typename T, typename ChildT>
> >>> >  class HasMatcher : public WrapperMatcherInterface<T> {
> >>> > -  static_assert(IsBaseType<ChildT>::value,
> >>> > -                "has only accepts base type matcher");
> >>> >
> >>> >  public:
> >>> >    explicit HasMatcher(const Matcher<ChildT> &ChildMatcher)
> >>> > @@ -1174,10 +1172,9 @@ public:
> >>> >
> >>> >    bool matches(const T &Node, ASTMatchFinder *Finder,
> >>> >                 BoundNodesTreeBuilder *Builder) const override {
> >>> > -    return Finder->matchesChildOf(
> >>> > -        Node, this->InnerMatcher, Builder,
> >>> > -        ASTMatchFinder::TK_IgnoreImplicitCastsAndParentheses,
> >>> > -        ASTMatchFinder::BK_First);
> >>> > +    return Finder->matchesChildOf(Node, this->InnerMatcher, Builder,
> >>> > +                                  ASTMatchFinder::TK_AsIs,
> >>> > +                                  ASTMatchFinder::BK_First);
> >>> >    }
> >>> >  };
> >>> >
> >>> >
> >>> > Modified: cfe/trunk/include/clang/CMakeLists.txt
> >>> > URL:
> >>> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CMakeLists.txt?rev=271288&r1=271287&r2=271288&view=diff
> >>> >
> >>> >
> ==============================================================================
> >>> > --- cfe/trunk/include/clang/CMakeLists.txt (original)
> >>> > +++ cfe/trunk/include/clang/CMakeLists.txt Tue May 31 10:25:05 2016
> >>> > @@ -5,3 +5,4 @@ add_subdirectory(Parse)
> >>> >  add_subdirectory(Sema)
> >>> >  add_subdirectory(Serialization)
> >>> >  add_subdirectory(StaticAnalyzer/Checkers)
> >>> > +add_subdirectory(ASTMatchers)
> >>> >
> >>> > Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
> >>> > URL:
> >>> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=271288&r1=271287&r2=271288&view=diff
> >>> >
> >>> >
> ==============================================================================
> >>> > --- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
> >>> > +++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Tue May 31 10:25:05
> >>> > 2016
> >>> > @@ -225,20 +225,14 @@ TEST(ImportExpr, ImportCXXThisExpr) {
> >>> >
> >>> >  TEST(ImportExpr, ImportAtomicExpr) {
> >>> >    MatchVerifier<Decl> Verifier;
> >>> > -  EXPECT_TRUE(
> >>> > -        testImport(
> >>> > -          "void declToImport() { int *ptr; __atomic_load_n(ptr, 1);
> >>> > }",
> >>> > -          Lang_CXX, "", Lang_CXX, Verifier,
> >>> > -          functionDecl(
> >>> > -            hasBody(
> >>> > -              compoundStmt(
> >>> > -                has(
> >>> > -                  atomicExpr(
> >>> > -                    has(declRefExpr(
> >>> > -                          hasDeclaration(varDecl(hasName("ptr"))),
> >>> > -                          hasType(asString("int *")))),
> >>> > -                    has(integerLiteral(equals(1),
> >>> > hasType(asString("int"))))
> >>> > -                    )))))));
> >>> > +  EXPECT_TRUE(testImport(
> >>> > +      "void declToImport() { int *ptr; __atomic_load_n(ptr, 1); }",
> >>> > Lang_CXX,
> >>> > +      "", Lang_CXX, Verifier,
> >>> > +      functionDecl(hasBody(compoundStmt(has(atomicExpr(
> >>> > +          has(ignoringParenImpCasts(
> >>> > +              declRefExpr(hasDeclaration(varDecl(hasName("ptr"))),
> >>> > +                          hasType(asString("int *"))))),
> >>> > +          has(integerLiteral(equals(1),
> >>> > hasType(asString("int")))))))))));
> >>> >  }
> >>> >
> >>> >  TEST(ImportExpr, ImportLabelDeclAndAddrLabelExpr) {
> >>> >
> >>> > Modified:
> cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
> >>> > URL:
> >>> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=271288&r1=271287&r2=271288&view=diff
> >>> >
> >>> >
> ==============================================================================
> >>> > --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
> >>> > (original)
> >>> > +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Tue
> >>> > May 31 10:25:05 2016
> >>> > @@ -122,8 +122,8 @@ TEST(Has, MatchesChildTypes) {
> >>> >
> >>> >  TEST(StatementMatcher, Has) {
> >>> >    StatementMatcher HasVariableI =
> >>> > -    expr(hasType(pointsTo(recordDecl(hasName("X")))),
> >>> > -         has(declRefExpr(to(varDecl(hasName("i"))))));
> >>> > +      expr(hasType(pointsTo(recordDecl(hasName("X")))),
> >>> > +
> >>> > has(ignoringParenImpCasts(declRefExpr(to(varDecl(hasName("i")))))));
> >>> >
> >>> >    EXPECT_TRUE(matches(
> >>> >      "class X; X *x(int); void c() { int i; x(i); }", HasVariableI));
> >>> >
> >>> >
> >>> > _______________________________________________
> >>> > 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/20160531/75209c34/attachment-0001.html>


More information about the cfe-commits mailing list