]> granicus.if.org Git - clang/commitdiff
ASTMatchers: Peel off a layer of indirection from true matcher. NFC.
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 24 Oct 2014 13:29:21 +0000 (13:29 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 24 Oct 2014 13:29:21 +0000 (13:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220560 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ASTMatchers/ASTMatchersInternal.cpp

index c0052bd8977cb7be994887d75114ac576b9fda1d..06ec76753bdf2a9e81a4e0ec20aa88d0006c6a14 100644 (file)
@@ -71,17 +71,15 @@ class IdDynMatcher : public DynMatcherInterface {
 /// We only ever need one instance of this matcher, so we create a global one
 /// and reuse it to reduce the overhead of the matcher and increase the chance
 /// of cache hits.
-struct TrueMatcherImpl {
-  TrueMatcherImpl() : Instance(new Impl) {}
-  const IntrusiveRefCntPtr<DynMatcherInterface> Instance;
-
-  class Impl : public DynMatcherInterface {
-   public:
-    bool dynMatches(const ast_type_traits::DynTypedNode &, ASTMatchFinder *,
-                    BoundNodesTreeBuilder *) const override {
-      return true;
-    }
-  };
+class TrueMatcherImpl : public DynMatcherInterface {
+public:
+  TrueMatcherImpl() {
+    Retain(); // Reference count will never become zero.
+  }
+  bool dynMatches(const ast_type_traits::DynTypedNode &, ASTMatchFinder *,
+                  BoundNodesTreeBuilder *) const override {
+    return true;
+  }
 };
 static llvm::ManagedStatic<TrueMatcherImpl> TrueMatcherInstance;
 
@@ -107,7 +105,7 @@ DynTypedMatcher DynTypedMatcher::constructVariadic(
 
 DynTypedMatcher DynTypedMatcher::trueMatcher(
     ast_type_traits::ASTNodeKind NodeKind) {
-  return DynTypedMatcher(NodeKind, NodeKind, TrueMatcherInstance->Instance);
+  return DynTypedMatcher(NodeKind, NodeKind, &*TrueMatcherInstance);
 }
 
 DynTypedMatcher DynTypedMatcher::dynCastTo(