[PATCH] Remove instantiations of OwningPtr<T> and IntrusiveRefCntPtr<T> for every AST node type.
Samuel Benzaquen
sbenza at google.com
Fri Aug 30 11:50:25 PDT 2013
Hi klimek,
Remove instantiations of OwningPtr<T> and IntrusiveRefCntPtr<T> for every AST node type.
Removing those saves us another ~10% in the number of symbols in Registry.cpp.o
http://llvm-reviews.chandlerc.com/D1564
Files:
include/clang/ASTMatchers/ASTMatchersInternal.h
include/clang/ASTMatchers/Dynamic/VariantValue.h
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===================================================================
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -245,27 +245,29 @@
public:
/// \brief Takes ownership of the provided implementation pointer.
explicit Matcher(MatcherInterface<T> *Implementation)
- : Implementation(Implementation) {}
+ : Implementation(Implementation), RefCount(Implementation) {}
/// \brief Implicitly converts \c Other to a Matcher<T>.
///
/// Requires \c T to be derived from \c From.
template <typename From>
Matcher(const Matcher<From> &Other,
- typename llvm::enable_if_c<
- llvm::is_base_of<From, T>::value &&
- !llvm::is_same<From, T>::value >::type* = 0)
- : Implementation(new ImplicitCastMatcher<From>(Other)) {}
+ typename llvm::enable_if_c<llvm::is_base_of<From, T>::value &&
+ !llvm::is_same<From, T>::value>::type * =
+ 0)
+ : Implementation(new ImplicitCastMatcher<From>(Other)),
+ RefCount(Implementation) {}
/// \brief Implicitly converts \c Matcher<Type> to \c Matcher<QualType>.
///
/// The resulting matcher is not strict, i.e. ignores qualifiers.
template <typename TypeT>
Matcher(const Matcher<TypeT> &Other,
- typename llvm::enable_if_c<
- llvm::is_same<T, QualType>::value &&
- llvm::is_same<TypeT, Type>::value >::type* = 0)
- : Implementation(new TypeToQualType<TypeT>(Other)) {}
+ typename llvm::enable_if_c<llvm::is_same<
+ T, QualType>::value &&llvm::is_same<TypeT, Type>::value>::type * =
+ 0)
+ : Implementation(new TypeToQualType<TypeT>(Other)),
+ RefCount(Implementation) {}
/// \brief Returns \c true if the passed DynTypedMatcher can be converted
/// to a \c Matcher<T>.
@@ -305,7 +307,7 @@
uint64_t getID() const {
/// FIXME: Document the requirements this imposes on matcher
/// implementations (no new() implementation_ during a Matches()).
- return reinterpret_cast<uint64_t>(Implementation.getPtr());
+ return reinterpret_cast<uint64_t>(Implementation);
}
/// \brief Returns the type this matcher works on.
@@ -384,7 +386,8 @@
const OwningPtr<DynTypedMatcher> Inner;
};
- IntrusiveRefCntPtr< MatcherInterface<T> > Implementation;
+ MatcherInterface<T> *Implementation;
+ IntrusiveRefCntPtr<RefCountedBaseVPTR> RefCount;
}; // class Matcher
/// \brief A convenient helper for creating a Matcher<T> without specifying
Index: include/clang/ASTMatchers/Dynamic/VariantValue.h
===================================================================
--- include/clang/ASTMatchers/Dynamic/VariantValue.h
+++ include/clang/ASTMatchers/Dynamic/VariantValue.h
@@ -145,12 +145,16 @@
public:
typedef ast_matchers::internal::Matcher<T> MatcherT;
+ TypedMatcherOps() : Out() {}
+ ~TypedMatcherOps() { delete Out; }
+
virtual bool canConstructFrom(const DynTypedMatcher &Matcher) const {
return MatcherT::canConstructFrom(Matcher);
}
virtual void constructFrom(const DynTypedMatcher& Matcher) {
- Out.reset(new MatcherT(MatcherT::constructFrom(Matcher)));
+ delete Out;
+ Out = new MatcherT(MatcherT::constructFrom(Matcher));
}
virtual void constructVariadicOperator(
@@ -169,19 +173,20 @@
InnerArgs[i] = new MatcherT(InnerMatchers[i].getTypedMatcher<T>());
}
if (!HasError) {
- Out.reset(new MatcherT(
+ delete Out;
+ Out = new MatcherT(
new ast_matchers::internal::VariadicOperatorMatcherInterface<T>(
- Func, ArrayRef<const MatcherT *>(InnerArgs, NumArgs))));
+ Func, ArrayRef<const MatcherT *>(InnerArgs, NumArgs)));
}
std::for_each(InnerArgs, InnerArgs + NumArgs, llvm::deleter<MatcherT>);
delete[] InnerArgs;
}
- bool hasMatcher() const { return Out.get() != NULL; }
+ bool hasMatcher() const { return Out != NULL; }
const MatcherT &matcher() const { return *Out; }
private:
- OwningPtr<MatcherT> Out;
+ MatcherT* Out;
};
IntrusiveRefCntPtr<const Payload> Value;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1564.1.patch
Type: text/x-patch
Size: 4297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130830/a433b98a/attachment.bin>
More information about the cfe-commits
mailing list