ricejasonf wrote:

@erichkeane, thanks for the approval. Does that mean I should stop making 
changes to this PR? I was messing with a more rangey interface for 
`flat_bindings`, but for some reason the `llvm::concat` range was referring to 
uninitialized memory when used as a temporary in a for loop (which even 
pre-C++23 I could not see why this was the case). I am not asking anyone to 
debug this, but I just wanted to know if this was the kind of "iterator" thing 
that you were requesting.
```cpp
  // Provide a flattened range to visit each binding.
  auto flat_bindings() const {
    llvm::ArrayRef<BindingDecl *> Bindings = bindings();
    llvm::ArrayRef<Expr *> PackExprs;
    // Split the bindings into subranges split by the pack.
    auto S1 = Bindings.take_until([](BindingDecl* BD) {
      return BD->isParameterPack();
    });  

    Bindings = Bindings.drop_front(S1.size());
    if (!Bindings.empty()) {
      PackExprs = Bindings.front()->getBindingPackExprs();
      Bindings = Bindings.drop_front();
    }    

    auto S2 = llvm::map_range(PackExprs, [](Expr* E) { 
      auto *DRE = cast<DeclRefExpr>(E);
      return cast<BindingDecl>(DRE->getDecl());
    });  

    return llvm::concat<BindingDecl *>(S1, S2, Bindings);
  }
```

I appreciate the people who have reviewed this PR as it did come with some of 
its own legacy and cruft.

Let me know if you want me to address any of the remaining concerns or not.

https://github.com/llvm/llvm-project/pull/121417
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to