================
@@ -1976,24 +1975,20 @@ void
CFGBuilder::addAutomaticObjHandling(LocalScope::const_iterator B,
for (auto [E, B] : Pairwise) {
if (!B.inSameLocalScope(E))
addScopeExitHandling(B, E, S);
- addAutomaticObjDestruction(B, E, S);
+ addAutomaticObjDestruction(llvm::iterator_range(B, E), S);
}
}
/// Add CFG elements corresponding to call destructor and end of lifetime
/// of all automatic variables with trivial and non-trivial destructors in
/// range [B, E). This includes AutomaticObjectDtor and LifetimeEnds elements.
-void CFGBuilder::addAutomaticObjDestruction(LocalScope::const_iterator B,
- LocalScope::const_iterator E,
+void
CFGBuilder::addAutomaticObjDestruction(llvm::iterator_range<LocalScope::const_iterator>
R,
Stmt *S) {
if (!BuildOpts.AddImplicitDtors && !BuildOpts.AddLifetime)
return;
- if (B == E)
- return;
-
SmallVector<VarDecl *, 10> LocalVarDecls;
- for (VarDecl *VD : llvm::make_range(B, E))
+ for (VarDecl *VD : R)
LocalVarDecls.push_back(VD);
----------------
steakhal wrote:
The better question, why do we need at all this `LocalVarDecls` variable?
We just take a copy here, but depending on the iterator category, we might be
able to reverse iterate anyway.
I suspect they come from some array, so random access should be feasible.
If this needs a larger refactoring then we could do that in a followup.
https://github.com/llvm/llvm-project/pull/243630
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits