mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 21:21:37 +00:00
feat(tidy): add fairmq-bugprone-unchecked-transfer-result
- Report Receive() calls whose result is discarded. On a timeout, an error or an interrupt the message stays empty, and only the result tells. - Report Send() too with the option CheckSend: true. Off by default, because many devices ignore the result of Send() on purpose. - A cast to void discards the result on purpose and is not reported. - Add Transfer.h with matchers for Send() and Receive() of Device, Channel and Socket, and isDiscarded(), for this and later checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
44
fairmq/tidy/UncheckedTransferResultCheck.h
Normal file
44
fairmq/tidy/UncheckedTransferResultCheck.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2026 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
#ifndef FAIR_MQ_TIDY_UNCHECKEDTRANSFERRESULTCHECK_H
|
||||
#define FAIR_MQ_TIDY_UNCHECKEDTRANSFERRESULTCHECK_H
|
||||
|
||||
#include <clang-tidy/ClangTidyCheck.h>
|
||||
|
||||
namespace fair::mq::tidy {
|
||||
|
||||
/// Finds calls of `Receive()` whose result is discarded. On a timeout, an
|
||||
/// error or an interrupt (e.g. a state change request) the message stays
|
||||
/// empty, and only the result tells.
|
||||
///
|
||||
/// Option `CheckSend` (default `false`): also report `Send()`. Many devices
|
||||
/// ignore the result of `Send()` on purpose, so this is off by default.
|
||||
///
|
||||
/// Cast the call to `void` to discard the result on purpose.
|
||||
class UncheckedTransferResultCheck : public clang::tidy::ClangTidyCheck
|
||||
{
|
||||
public:
|
||||
UncheckedTransferResultCheck(llvm::StringRef name, clang::tidy::ClangTidyContext* context);
|
||||
|
||||
bool isLanguageVersionSupported(clang::LangOptions const& opts) const override
|
||||
{
|
||||
return opts.CPlusPlus17;
|
||||
}
|
||||
void storeOptions(clang::tidy::ClangTidyOptions::OptionMap& opts) override;
|
||||
void registerMatchers(clang::ast_matchers::MatchFinder* finder) override;
|
||||
void check(clang::ast_matchers::MatchFinder::MatchResult const& result) override;
|
||||
|
||||
private:
|
||||
bool const fCheckSend;
|
||||
};
|
||||
|
||||
} // namespace fair::mq::tidy
|
||||
|
||||
#endif /* FAIR_MQ_TIDY_UNCHECKEDTRANSFERRESULTCHECK_H */
|
||||
Reference in New Issue
Block a user