feat(tidy): add fairmq-bugprone-use-after-send

- Report uses of a MessagePtr after a Send() whose result is discarded.
  After the send the message is empty with zeromq, and still points to
  the sent buffer with shmem, so the same code acts differently per
  transport.
- Walk the CFG from the send with ExprSequence, like
  bugprone-use-after-move. A loop back to the send counts as a use.
- Assignment, reset(), Rebuild(), a new declaration in a loop and
  passing by non-const reference (e.g. to Receive()) give a new message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-11-09 23:14:01 +00:00
parent 3b3446bfcb
commit e9afe76155
6 changed files with 309 additions and 0 deletions

View File

@@ -14,6 +14,7 @@
#include <fairmq/tidy/ProgOptionsAccessorsCheck.h>
#include <fairmq/tidy/RunDeviceCheck.h>
#include <fairmq/tidy/UncheckedTransferResultCheck.h>
#include <fairmq/tidy/UseAfterSendCheck.h>
#include <clang-tidy/ClangTidyModule.h>
#include <clang-tidy/ClangTidyModuleRegistry.h>
@@ -28,6 +29,7 @@ class Module : public clang::tidy::ClangTidyModule
void addCheckFactories(clang::tidy::ClangTidyCheckFactories& factories) override
{
factories.registerCheck<UncheckedTransferResultCheck>("fairmq-bugprone-unchecked-transfer-result");
factories.registerCheck<UseAfterSendCheck>("fairmq-bugprone-use-after-send");
factories.registerCheck<ChannelsAccessCheck>("fairmq-modernize-channels-access");
factories.registerCheck<DeprecatedFunctionsCheck>("fairmq-modernize-deprecated-functions");
factories.registerCheck<DeprecatedHeadersCheck>("fairmq-modernize-deprecated-headers");