mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 21:21:37 +00:00
- 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>
45 lines
1.8 KiB
C++
45 lines
1.8 KiB
C++
/********************************************************************************
|
|
* 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 */
|