[PATCH] D140793: [clang-tidy] Implement CppCoreGuideline CP.53

Chris Cotter via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 30 19:03:57 PST 2022


ccotter added a comment.

Passing and accessing a reference is safe if the access is done before any suspend point (taking into account whether the initial coroutine suspend actually suspends or not). Although CP.53 recommends warning on any reference parameter regardless of whether the code only accesses the reference before any suspend points, I did implement (not in this changeset - in a separate branch) a version of this check that uses the CFG to determine whether reference parameters are never accessed after a suspend point. If there's interest, I could reimplement this check with this (perhaps as a tool option). That said, I do agree with CP.53 that relying on such access being safe is brittle e.g. if the code is refactored in the future to rearrange suspend points, so I went with this approach for the review.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140793/new/

https://reviews.llvm.org/D140793



More information about the cfe-commits mailing list