AST_POLYMORPHIC_MATCHER_P(hasAnyArgument, AST_POLYMORPHIC_SUPPORTED_TYPES_2(
CallExpr, CXXConstructExpr),
internal::Matcher<Expr>, InnerMatcher) {
- for (unsigned I = 0; I < Node.getNumArgs(); ++I) {
+ for (const Expr *Arg : Node.arguments()) {
BoundNodesTreeBuilder Result(*Builder);
- if (InnerMatcher.matches(*Node.getArg(I)->IgnoreParenImpCasts(), Finder,
- &Result)) {
+ if (InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, &Result)) {
*Builder = std::move(Result);
return true;
}
const ast_type_traits::DynTypedNode &DynNode) {
if (Bindings.empty())
Bindings.push_back(BoundNodesMap());
- for (unsigned i = 0, e = Bindings.size(); i != e; ++i)
- Bindings[i].addNode(Id, DynNode);
+ for (BoundNodesMap &Binding : Bindings)
+ Binding.addNode(Id, DynNode);
}
/// \brief Adds a branch in the tree.
}
std::vector<DynTypedMatcher> DynMatchers;
- for (size_t i = 0, e = InnerMatchers.size(); i != e; ++i) {
- DynMatchers.push_back(*InnerMatchers[i]);
+ DynMatchers.reserve(InnerMatchers.size());
+ for (const auto *InnerMatcher : InnerMatchers) {
+ DynMatchers.push_back(*InnerMatcher);
}
// FIXME: Use DynTypedMatcher::constructVariadic() instead.
return BindableMatcher<T>(new VariadicOperatorMatcherInterface<T>(
void BoundNodesTreeBuilder::visitMatches(Visitor *ResultVisitor) {
if (Bindings.empty())
Bindings.push_back(BoundNodesMap());
- for (unsigned i = 0, e = Bindings.size(); i != e; ++i) {
- ResultVisitor->visitMatch(BoundNodes(Bindings[i]));
+ for (BoundNodesMap &Binding : Bindings) {
+ ResultVisitor->visitMatch(BoundNodes(Binding));
}
}
}
void BoundNodesTreeBuilder::addMatch(const BoundNodesTreeBuilder &Other) {
- for (unsigned i = 0, e = Other.Bindings.size(); i != e; ++i) {
- Bindings.push_back(Other.Bindings[i]);
- }
+ Bindings.append(Other.Bindings.begin(), Other.Bindings.end());
}
bool NotUnaryOperator(const ast_type_traits::DynTypedNode DynNode,
// allOf leads to one matcher for each alternative in the first
// matcher combined with each alternative in the second matcher.
// Thus, we can reuse the same Builder.
- for (size_t i = 0, e = InnerMatchers.size(); i != e; ++i) {
- if (!InnerMatchers[i].matches(DynNode, Finder, Builder))
+ for (const DynTypedMatcher &InnerMatcher : InnerMatchers) {
+ if (!InnerMatcher.matches(DynNode, Finder, Builder))
return false;
}
return true;
ArrayRef<DynTypedMatcher> InnerMatchers) {
BoundNodesTreeBuilder Result;
bool Matched = false;
- for (size_t i = 0, e = InnerMatchers.size(); i != e; ++i) {
+ for (const DynTypedMatcher &InnerMatcher : InnerMatchers) {
BoundNodesTreeBuilder BuilderInner(*Builder);
- if (InnerMatchers[i].matches(DynNode, Finder, &BuilderInner)) {
+ if (InnerMatcher.matches(DynNode, Finder, &BuilderInner)) {
Matched = true;
Result.addMatch(BuilderInner);
}
ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder,
ArrayRef<DynTypedMatcher> InnerMatchers) {
- for (size_t i = 0, e = InnerMatchers.size(); i != e; ++i) {
+ for (const DynTypedMatcher &InnerMatcher : InnerMatchers) {
BoundNodesTreeBuilder Result = *Builder;
- if (InnerMatchers[i].matches(DynNode, Finder, &Result)) {
+ if (InnerMatcher.matches(DynNode, Finder, &Result)) {
*Builder = std::move(Result);
return true;
}