ASTMatchers: Replace some copies of the bound nodes tree builder with moves.

But don't move if all we do is clearing the thing. The move method is too large
to be inlined and performs a ton of unnecessary checking when the RHS is empty.

No functionality change.

llvm-svn: 216723
This commit is contained in:
Benjamin Kramer 2014-08-29 11:22:47 +00:00
parent 90d6101410
commit d9c9162bb9
3 changed files with 8 additions and 8 deletions

View File

@ -2285,7 +2285,7 @@ AST_POLYMORPHIC_MATCHER_P(hasAnyArgument, AST_POLYMORPHIC_SUPPORTED_TYPES_2(
BoundNodesTreeBuilder Result(*Builder);
if (InnerMatcher.matches(*Node.getArg(I)->IgnoreParenImpCasts(), Finder,
&Result)) {
*Builder = Result;
*Builder = std::move(Result);
return true;
}
}
@ -3614,7 +3614,7 @@ AST_MATCHER_P(SwitchStmt, forEachSwitchCase, internal::Matcher<SwitchCase>,
Result.addMatch(CaseBuilder);
}
}
*Builder = Result;
*Builder = std::move(Result);
return Matched;
}
@ -3637,7 +3637,7 @@ AST_MATCHER_P(CXXConstructorDecl, forEachConstructorInitializer,
Result.addMatch(InitBuilder);
}
}
*Builder = Result;
*Builder = std::move(Result);
return Matched;
}

View File

@ -262,7 +262,7 @@ public:
// Delete all bindings when a matcher does not match.
// This prevents unexpected exposure of bound nodes in unmatches
// branches of the match tree.
*Builder = BoundNodesTreeBuilder();
Builder->removeBindings([](const BoundNodesMap &) { return true; });
return false;
}
@ -490,7 +490,7 @@ bool matchesFirstInRange(const MatcherT &Matcher, IteratorT Start,
for (IteratorT I = Start; I != End; ++I) {
BoundNodesTreeBuilder Result(*Builder);
if (Matcher.matches(*I, Finder, &Result)) {
*Builder = Result;
*Builder = std::move(Result);
return true;
}
}
@ -506,7 +506,7 @@ bool matchesFirstInPointerRange(const MatcherT &Matcher, IteratorT Start,
for (IteratorT I = Start; I != End; ++I) {
BoundNodesTreeBuilder Result(*Builder);
if (Matcher.matches(**I, Finder, &Result)) {
*Builder = Result;
*Builder = std::move(Result);
return true;
}
}

View File

@ -81,7 +81,7 @@ bool EachOfVariadicOperator(const ast_type_traits::DynTypedNode DynNode,
Result.addMatch(BuilderInner);
}
}
*Builder = Result;
*Builder = std::move(Result);
return Matched;
}
@ -92,7 +92,7 @@ bool AnyOfVariadicOperator(const ast_type_traits::DynTypedNode DynNode,
for (size_t i = 0, e = InnerMatchers.size(); i != e; ++i) {
BoundNodesTreeBuilder Result = *Builder;
if (InnerMatchers[i].matches(DynNode, Finder, &Result)) {
*Builder = Result;
*Builder = std::move(Result);
return true;
}
}