r220560 - ASTMatchers: Peel off a layer of indirection from true matcher. NFC.
Benjamin Kramer
benny.kra at googlemail.com
Fri Oct 24 06:29:21 PDT 2014
Author: d0k
Date: Fri Oct 24 08:29:21 2014
New Revision: 220560
URL: http://llvm.org/viewvc/llvm-project?rev=220560&view=rev
Log:
ASTMatchers: Peel off a layer of indirection from true matcher. NFC.
Modified:
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
Modified: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp?rev=220560&r1=220559&r2=220560&view=diff
==============================================================================
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp Fri Oct 24 08:29:21 2014
@@ -71,17 +71,15 @@ class IdDynMatcher : public DynMatcherIn
/// 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::constru
DynTypedMatcher DynTypedMatcher::trueMatcher(
ast_type_traits::ASTNodeKind NodeKind) {
- return DynTypedMatcher(NodeKind, NodeKind, TrueMatcherInstance->Instance);
+ return DynTypedMatcher(NodeKind, NodeKind, &*TrueMatcherInstance);
}
DynTypedMatcher DynTypedMatcher::dynCastTo(
More information about the cfe-commits
mailing list