================
@@ -445,13 +424,30 @@ class CowCompilerInvocation : public
CompilerInvocationBase {
ssaf::SSAFOptions &getMutSSAFOpts();
/// @}
+ /// The result of mutable visitation.
+ struct VisitMutResult {
+ /// Whether to replace the given StringRef with the modified std::string &.
+ bool Replace = false;
+ /// Whether to short-circuit the visitation.
+ bool Terminate = false;
+ };
+
/// Visits paths stored in the invocation, allowing the callback to mutate
- /// them. To preserve the copy-on-write invariant for groups whose paths the
- /// caller might modify, this ensures unique ownership of every option group
- /// up front; if the callback only inspects (and does not mutate) the paths,
- /// the const \c visitPaths overload should be used instead to avoid those
- /// per-group copies.
- void visitMutPaths(llvm::function_ref<bool(std::string &)> Callback);
+ /// them via the out-param. This upholds the same copy-on-write semantics as
+ /// the mutable getters.
+ void visitMutPaths(
+ llvm::function_ref<VisitMutResult(StringRef, std::string &)> Cb);
----------------
jansvoboda11 wrote:
I considered this, but I didn't like that this prevents you from erasing a
path, which is IMO important in an API as general as this.
https://github.com/llvm/llvm-project/pull/205686
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits