Re: r272386 - [ASTMatchers] New forEachOverriden matcher.

2016-06-10 Thread Chandler Carruth via cfe-commits
This has broken Windows build bots all day. Here are some recent examples:
http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/8506/steps/ninja%20check%201/logs/stdio
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/12981/steps/ninja%20check%201/logs/stdio

Please pay attention to the bots when you are committing changes. I've
reverted it in r272453.

On Fri, Jun 10, 2016 at 5:01 AM Clement Courbet via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: courbet
> Date: Fri Jun 10 06:54:43 2016
> New Revision: 272386
>
> URL: http://llvm.org/viewvc/llvm-project?rev=272386&view=rev
> Log:
> [ASTMatchers] New forEachOverriden matcher.
>
> Matches methods overridden by the given method.
>
> Modified:
> cfe/trunk/docs/LibASTMatchersReference.html
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/AST/DeclCXX.h
> cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
>
> Modified: cfe/trunk/docs/LibASTMatchersReference.html
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=272386&r1=272385&r2=272386&view=diff
>
> ==
> --- cfe/trunk/docs/LibASTMatchersReference.html (original)
> +++ cfe/trunk/docs/LibASTMatchersReference.html Fri Jun 10 06:54:43 2016
> @@ -3968,6 +3968,30 @@ matcher, or is a pointer to a type that
>  
>
>
> +MatcherCXXMethodDecl> class="name" onclick="toggle('forEachOverridden0')"> name="forEachOverridden0Anchor">forEachOverriddenMatcher< href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html";>CXXMethodDecl>
> InnerMatcher
> +Matches each
> method overriden by the given method. This matcher may
> +produce multiple matches.
> +
> +Given
> +  class A { virtual void f(); };
> +  class B : public A { void f(); };
> +  class C : public B { void f(); };
> +cxxMethodDecl(ofClass(hasName("C")),
> +  forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
> +  matches once, with "b" binding "A::f" and "d" binding "C::f" (Note
> +  that B::f is not overridden by C::f).
> +
> +The check can produce multiple matches in case of multiple inheritance,
> e.g.
> +  class A1 { virtual void f(); };
> +  class A2 { virtual void f(); };
> +  class C : public A1, public A2 { void f(); };
> +cxxMethodDecl(ofClass(hasName("C")),
> +  forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
> +  matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and
> +  once with "b" binding "A2::f" and "d" binding "C::f".
> +
> +
> +
>  MatcherCXXMethodDecl> class="name" onclick="toggle('ofClass0')"> name="ofClass0Anchor">ofClassMatcherCXXRecordDecl>
> InnerMatcher
>  Matches the class
> declaration that the given method declaration
>  belongs to.
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=272386&r1=272385&r2=272386&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Fri Jun 10 06:54:43 2016
> @@ -821,6 +821,9 @@ public:
>overridden_methods_end(const CXXMethodDecl *Method) const;
>
>unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
> +  typedef llvm::iterator_range
> +  overridden_method_range;
> +  overridden_method_range overridden_methods(const CXXMethodDecl *Method)
> const;
>
>/// \brief Note that the given C++ \p Method overrides the given \p
>/// Overridden method.
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=272386&r1=272385&r2=272386&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Jun 10 06:54:43 2016
> @@ -16,6 +16,7 @@
>  #ifndef LLVM_CLANG_AST_DECLCXX_H
>  #define LLVM_CLANG_AST_DECLCXX_H
>
> +#include "clang/AST/ASTContext.h"
>  #include "clang/AST/ASTUnresolvedSet.h"
>  #include "clang/AST/Attr.h"
>  #include "clang/AST/Decl.h"
> @@ -1828,6 +1829,8 @@ public:
>method_iterator begin_overridden_methods() const;
>method_iterator end_overridden_methods() const;
>unsigned size_overridden_methods() const;
> +  typedef ASTContext::overridden_method_range overridden_method_range;
> +  overridden_method_range overridden_methods() const;
>
>/// Returns the parent of this method declaration, which
>/// is the class in which 

r272386 - [ASTMatchers] New forEachOverriden matcher.

2016-06-10 Thread Clement Courbet via cfe-commits
Author: courbet
Date: Fri Jun 10 06:54:43 2016
New Revision: 272386

URL: http://llvm.org/viewvc/llvm-project?rev=272386&view=rev
Log:
[ASTMatchers] New forEachOverriden matcher.

Matches methods overridden by the given method.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=272386&r1=272385&r2=272386&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Fri Jun 10 06:54:43 2016
@@ -3968,6 +3968,30 @@ matcher, or is a pointer to a type that
 
 
 
+MatcherCXXMethodDecl>forEachOverriddenMatcherCXXMethodDecl>
 InnerMatcher
+Matches each 
method overriden by the given method. This matcher may
+produce multiple matches.
+
+Given
+  class A { virtual void f(); };
+  class B : public A { void f(); };
+  class C : public B { void f(); };
+cxxMethodDecl(ofClass(hasName("C")),
+  forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
+  matches once, with "b" binding "A::f" and "d" binding "C::f" (Note
+  that B::f is not overridden by C::f).
+
+The check can produce multiple matches in case of multiple inheritance, e.g.
+  class A1 { virtual void f(); };
+  class A2 { virtual void f(); };
+  class C : public A1, public A2 { void f(); };
+cxxMethodDecl(ofClass(hasName("C")),
+  forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
+  matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and
+  once with "b" binding "A2::f" and "d" binding "C::f".
+
+
+
 MatcherCXXMethodDecl>ofClassMatcherCXXRecordDecl>
 InnerMatcher
 Matches the class 
declaration that the given method declaration
 belongs to.

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=272386&r1=272385&r2=272386&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Fri Jun 10 06:54:43 2016
@@ -821,6 +821,9 @@ public:
   overridden_methods_end(const CXXMethodDecl *Method) const;
 
   unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
+  typedef llvm::iterator_range
+  overridden_method_range;
+  overridden_method_range overridden_methods(const CXXMethodDecl *Method) 
const;
 
   /// \brief Note that the given C++ \p Method overrides the given \p
   /// Overridden method.

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=272386&r1=272385&r2=272386&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Jun 10 06:54:43 2016
@@ -16,6 +16,7 @@
 #ifndef LLVM_CLANG_AST_DECLCXX_H
 #define LLVM_CLANG_AST_DECLCXX_H
 
+#include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTUnresolvedSet.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
@@ -1828,6 +1829,8 @@ public:
   method_iterator begin_overridden_methods() const;
   method_iterator end_overridden_methods() const;
   unsigned size_overridden_methods() const;
+  typedef ASTContext::overridden_method_range overridden_method_range;
+  overridden_method_range overridden_methods() const;
 
   /// Returns the parent of this method declaration, which
   /// is the class in which this method is defined.

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=272386&r1=272385&r2=272386&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Fri Jun 10 06:54:43 2016
@@ -3770,6 +3770,47 @@ AST_MATCHER_P(CXXMethodDecl, ofClass,
   InnerMatcher.matches(*Parent, Finder, Builder));
 }
 
+/// \brief Matches each method overriden by the given method. This matcher may
+/// produce multiple matches.
+///
+/// Given
+/// \code
+///   class A { virtual void f(); };
+///   class B : public A { void f(); };
+///   class C : public B { void f(); };
+///