mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 21:21:37 +00:00
- Implement the checks as a clang-tidy module (object library fairmq-tidy-module) instead of a standalone LibTooling program. - Build fairmq-tidy from clangTidyMain plus the module. It gets all clang-tidy features: --fix, --export-fixes, .clang-tidy files, NOLINT, header filter, and the upstream checks on the same parse. - Without a --checks option, add fairmq-* to the configured checks. - Point the driver to the resource directory of the LLVM installation it was built with, so it finds the Clang builtin headers from any install location. The -I hint in fairmq_target_tidy() is no longer necessary. - Add the include directories of LLVM and Clang. The old target compiled only where they are in /usr/include. - Port fairmq-modernize-nonnamespaced-types. Match deprecated global aliases into fair::mq instead of the name prefix "FairMQ": this also finds e.g. InputMsgCallback and skips aliases that are not deprecated. Match only the TypedefTypeLoc, so each use is reported once. BREAKING CHANGE: fairmq-tidy takes the options of clang-tidy and reads .clang-tidy files. With no .clang-tidy file it now also runs the default clang-tidy checks (clang-diagnostic-*, clang-analyzer-*). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
2.2 KiB
C++
51 lines
2.2 KiB
C++
/********************************************************************************
|
|
* Copyright (C) 2021-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" *
|
|
********************************************************************************/
|
|
|
|
// fairmq-tidy is the upstream clang-tidy driver with the FairMQ module linked in.
|
|
// It accepts every clang-tidy option and runs the upstream checks and the
|
|
// fairmq-* checks on one parse of each file. Without a --checks option it adds
|
|
// the fairmq-* checks to the checks of the .clang-tidy configuration.
|
|
|
|
#include <clang-tidy/tool/ClangTidyMain.h>
|
|
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
extern volatile int FairMQTidyModuleAnchorSource;
|
|
[[maybe_unused]] static int const fairmqModuleAnchor = FairMQTidyModuleAnchorSource;
|
|
|
|
int main(int argc, char const** argv)
|
|
{
|
|
std::vector<char const*> args(argv, argv + argc);
|
|
bool userResourceDir = false;
|
|
bool userChecks = false;
|
|
for (std::string_view arg : args) {
|
|
if (arg == "--") {
|
|
break; // the compiler command line follows
|
|
}
|
|
if (arg.find("-resource-dir") != std::string_view::npos) {
|
|
userResourceDir = true;
|
|
}
|
|
if (arg.rfind("--checks", 0) == 0 || arg.rfind("-checks", 0) == 0) {
|
|
userChecks = true;
|
|
}
|
|
}
|
|
// The driver looks for its builtin headers (e.g. <stddef.h>) relative to
|
|
// the executable. fairmq-tidy is not installed next to clang, so point it
|
|
// to the resource directory of the LLVM installation it was built with.
|
|
if (argc > 0 && !userResourceDir) {
|
|
args.insert(args.begin() + 1, "--extra-arg-before=-resource-dir=" FAIRMQ_TIDY_CLANG_RESOURCE_DIR);
|
|
}
|
|
// --checks appends to the Checks of the configuration.
|
|
if (argc > 0 && !userChecks) {
|
|
args.insert(args.begin() + 1, "--checks=fairmq-*");
|
|
}
|
|
|
|
return clang::tidy::clangTidyMain(static_cast<int>(args.size()), args.data());
|
|
}
|