本地和 CI 中不同的 clang-tidy-17 行为

问题描述 投票:0回答:0

我在 Ubuntu jammy 本地和 GitHub Actions 中运行 clang-tidy。问题是我在这些环境中对以下代码有不同的行为,其中

MyType
是平凡可复制的:

void MyClass::setField(MyType value) {
  field_ = value;
}

在 GitHub Actions 中,我从 clang-tidy 得到以下错误:

error: parameter 'value' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param,-warnings-as-errors]

本地不会出现此错误,如果我应用建议的更改(通过添加

std::move
),我会收到以下错误:

error: std::move of the variable 'value' of the trivially-copyable type 'MyType' has no effect; remove std::move() [performance-move-const-arg,-warnings-as-errors]

我从

https://apt.llvm.org/jammy/
安装了 clang-tidy-17,执行
apt update
apt upgrade
等,并且在两种环境中
clang-tidy --version
打印
Ubuntu LLVM version 17.0.0 Optimized build
,所以它应该是相同版本的 clang-tidy-17。

我运行 clang-tidy 的命令是:

run-clang-tidy -p build -quiet <files to scan>
——它使用我在存储库中的
.clang-tidy
配置,所以 clang-tidy 应该接收相同的参数。

两个环境我使用的编译器都是GNU 11.3.0.

为什么会这样?对我来说,我在本地获得的行为似乎是正确的,我更愿意在 CI 中看到它。

c++ continuous-integration github-actions lint clang-tidy
© www.soinside.com 2019 - 2024. All rights reserved.