[PATCH] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute
Arthur O'Dwyer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 24 09:54:51 PST 2020
Quuxplusone added a comment.
Probably irrelevant comment from the C++ world: If I needed this concept in C++, I'd probably piggyback on the existing semantic analysis of `std::move`: I'd design a `class OnceCallable` with an `operator() &&` that both called and nulled-out its object parameter, and then call it like `std::move(myCallback)()`. Then if I ever tried to call it a second time, the static analyzer would (hopefully) complain that I was accessing a moved-from `myCallback`. But you want this for existing APIs that take the built-in block type, so never mind. :)
Probably irrelevant scope creep: Is it worth trying to support the possibility that someone might want to pass both a `successHandler` and a `failureHandler`, with the invariant that we'd make //exactly one call to one of them// (but never call both)? Is that just not a thing that ever happens in NSWhatever?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92039/new/
https://reviews.llvm.org/D92039
More information about the cfe-commits
mailing list