feat(tidy): add fairmq-bugprone-run-loop-ignores-state

- Report endless loops (while (true), for (;;), ...) in an override of
  Device::Run() that do not call NewStatePending() or WaitFor(). Such a
  device does not stop when a state change is requested.
- Skip loops that call Send() or Receive(), which an interrupt stops,
  and loops with a break, return, throw or goto.

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 42952bfa42
commit 349573fb5f
6 changed files with 176 additions and 0 deletions

View File

@@ -14,6 +14,7 @@
#include <fairmq/tidy/PartsApiCheck.h>
#include <fairmq/tidy/ProgOptionsAccessorsCheck.h>
#include <fairmq/tidy/RunDeviceCheck.h>
#include <fairmq/tidy/RunLoopIgnoresStateCheck.h>
#include <fairmq/tidy/TransferCodeCheck.h>
#include <fairmq/tidy/UncheckedTransferResultCheck.h>
#include <fairmq/tidy/UseAfterSendCheck.h>
@@ -31,6 +32,7 @@ class Module : public clang::tidy::ClangTidyModule
void addCheckFactories(clang::tidy::ClangTidyCheckFactories& factories) override
{
factories.registerCheck<OnDataWithConditionalRunCheck>("fairmq-bugprone-ondata-with-conditionalrun");
factories.registerCheck<RunLoopIgnoresStateCheck>("fairmq-bugprone-run-loop-ignores-state");
factories.registerCheck<UncheckedTransferResultCheck>("fairmq-bugprone-unchecked-transfer-result");
factories.registerCheck<UseAfterSendCheck>("fairmq-bugprone-use-after-send");
factories.registerCheck<ChannelsAccessCheck>("fairmq-modernize-channels-access");