c++ - 是否可以编写新的 clang-tidy 现代化规则?

标签 c++ qt clang-tidy

特别是,我正在使用 Qt;我们的代码库仍然充斥着旧的 foreach 宏,比如 foreach (T foo, bar) { ... } 。我想将其转换为 for (T foo : bar) { ... }。有没有办法编写 clang-tidy 规则来执行此操作?

最佳答案

是的,这绝对有可能。 Clang-tidy 是开源的,因此您可以修改代码或编写自己的检查。

modernize-loop-convert check 做了一些与您的用例非常相似的事情,所以这可能是一个好的开始。 ( source )

Clang-tidy 甚至还有官方documentation on writing new checks .

关于c++ - 是否可以编写新的 clang-tidy 现代化规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58002117/

相关文章:

c++ - Jenkins 构建在 Windows 上因 GitLockFailedException 而失败

c++ - 重载 "operator++"返回非常量,并且 clang-tidy 提示

c++ - 带有标准输出重定向的 `boost::process` 在 Ubuntu 16 中随机失败

c++ - 关于列表项及其类设计的看法

c++ - GDB:我们如何从 std::tuple 中提取值

c++ - ifstream 没有匹配的初始化构造函数

qt - QWidget 报告错误的宽度值

c++ - QCompare 测试失败 : wrong number of arguments produced by the [] operator on an unorded_map

c - "Use of a signed integer operand with a binary bitwise operator"- 使用无符号短整型时