how-to-use/clang-tidy.txt

124 lines
12 KiB
Plaintext
Raw Normal View History

2024-03-08 13:36:39 +08:00
readability-delete-null-pointer:建议使用 delete 而不是 delete[] 来释放空指针。
readability-deleted-default:提醒添加显式的 = default 或 = delete 来明确声明默认的或者删除的特殊成员函数。
readability-inconsistent-declaration-parameter-name:在不同的声明中参数名称不一致时给出警告。
readability-make-member-function-const:建议将不修改类成员的函数标记为 const。
readability-misleading-indentation:提示缩进可能会误导阅读代码的意图。
readability-non-const-parameter:建议将不修改参数值的函数参数声明为 const。
readability-redundant-control-flow:发现冗余的控制流结构,建议简化代码。
readability-redundant-declaration:警告多余的变量或函数声明。
readability-redundant-function-ptr-dereference:提示不必要的函数指针解引用。
readability-redundant-smartptr-get:发现多余的智能指针的 .get() 调用。
readability-redundant-string-cstr:发现多余的字符串转换为 C 风格字符串的操作。
readability-redundant-string-init:警告多余的字符串初始化。
readability-simplify-subscript-expr:建议简化数组下标表达式。
readability-static-accessed-through-instance:警告通过实例访问静态成员。
readability-static-definition-in-anonymous-namespace:在匿名命名空间中定义静态变量时给出警告。
readability-string-compare:建议使用字符串操作函数而不是直接使用运算符进行比较。
readability-uniqueptr-delete-release:建议使用 reset() 而不是 release() 来释放 std::unique_ptr。
readability-use-anyofallof:建议使用 C++17 的 std::any_of 或 std::all_of 算法。
performance-implicit-conversion-in-loop:警告循环中的隐式类型转换可能影响性能。
performance-inefficient-algorithm:提示可能存在效率低下的算法使用。
performance-inefficient-string-concatenation:发现效率低下的字符串拼接操作。
performance-inefficient-vector-operation:提示可能效率低下的向量操作。
performance-move-const-arg:建议在函数参数传递时使用 std::move 来移动 const 对象。
performance-move-constructor-init:提示在构造函数初始化列表中使用移动语义。
performance-no-automatic-move:建议禁止自动移动语义,需要显式使用 std::move。
performance-noexcept-move-constructor:建议将移动构造函数声明为 noexcept,以便优化。
performance-trivially-destructible:标识可以标记为 trivially destructible 的类型。
performance-type-promotion-in-math-fn:警告数学函数中可能的类型提升。
performance-unnecessary-copy-initialization:提示不必要的拷贝初始化操作。
performance-unnecessary-value-param:警告可能不必要的值传递参数。
portability-simd-intrinsics:识别可能与 SIMD 指令集相关的代码,这可能不具备跨平台移植性。
readability-avoid-const-params-in-decls:建议避免在函数声明中使用 const 参数。
readability-const-return-type:建议将返回类型声明为 const。
readability-container-size-empty:提示使用容器的 empty() 函数来检查容器是否为空,而不是使用 size()。
readability-convert-member-functions-to-static:建议将不修改对象状态的成员函数改为静态函数。
modernize-shrink-to-fit:建议使用 shrink_to_fit() 来减小容器的容量,以节省内存。
modernize-unary-static-assert:建议使用一元静态断言(static_assert)代替传统的 assert。
modernize-use-auto:推荐使用 auto 类型推断,以减少代码冗余和提高可读性。
modernize-use-bool-literals:建议使用布尔字面值 true 和 false 代替 0 和 1。
modernize-use-emplace:推荐使用容器的 emplace 函数代替 push_back 或 insert。
modernize-use-equals-default:建议使用 = default 来声明默认的特殊成员函数。
modernize-use-equals-delete:建议使用 = delete 明确删除特殊成员函数。
modernize-use-nodiscard:建议在可能的情况下使用 [[nodiscard]] 标记函数,以便提醒调用者检查返回值。
modernize-use-noexcept:建议使用 noexcept 来标记不会抛出异常的函数。
modernize-use-nullptr:建议使用 C++11 的 nullptr 关键字代替 NULL。
modernize-use-override:建议在派生类中使用 override 关键字来标记重写的函数。
modernize-use-transparent-functors:建议使用透明函数对象代替手动构造函数对象。
modernize-use-uncaught-exceptions:建议使用 std::uncaught_exceptions() 来替代 std::uncaught_exception()。
mpi-buffer-deref 和 mpi-type-mismatch:这两个参数是针对 MPI(Message Passing Interface)库的规则,用于检查缓冲区解引用和类型不匹配的问题。
openmp-use-default-none:建议在 OpenMP 指令中显式指定 default(none),以确保线程安全性。
performance-faster-string-find:优化字符串查找操作以提高性能。
performance-for-range-copy:优化循环中对于范围迭代器的复制操作。
misc-new-delete-overloads:建议同时重载 new 和 delete 运算符以实现自定义的内存分配和释放方式。
misc-no-recursion:提示避免递归调用,可能会导致栈溢出和性能问题。
misc-non-copyable-objects:建议标记不可复制的类为 delete,以防止意外的复制。
misc-throw-by-value-catch-by-reference:建议异常抛出时使用值,而捕获异常时使用引用,以避免异常对象切片问题。
misc-unconventional-assign-operator:识别并提醒使用了非传统的赋值操作符。
misc-uniqueptr-reset-release:建议使用 reset() 替代 release() 来释放 std::unique_ptr。
modernize-avoid-bind:建议使用 lambda 表达式代替 std::bind。
modernize-concat-nested-namespaces:提示合并嵌套的命名空间,以提高代码的可读性。
modernize-deprecated-headers 和 modernize-deprecated-ios-base-aliases:识别并提醒使用了已弃用的头文件和 I/O 流别名。
modernize-loop-convert:建议使用现代化的循环语法替代传统的循环语句。
modernize-make-shared 和 modernize-make-unique:建议使用 std::make_shared 和 std::make_unique 来创建智能指针。
modernize-pass-by-value:建议将按值传递的函数参数修改为按引用传递,以避免不必要的拷贝。
modernize-raw-string-literal:建议使用原始字符串字面量(raw string literals)来提高字符串的可读性。
modernize-redundant-void-arg:警告冗余的 void 参数。
modernize-replace-auto-ptr:建议将已弃用的 std::auto_ptr 替换为更安全的智能指针。
modernize-replace-disallow-copy-and-assign-macro:建议使用 delete 关键字禁用拷贝和赋值操作,而不是宏。
modernize-replace-random-shuffle:建议使用 std::shuffle 替代 std::random_shuffle。
modernize-return-braced-init-list:建议使用大括号初始化列表(braced-init-list)来返回对象,以提高代码的清晰度和一致性。
cert-dcl21-cpp:避免不正确的使用逗号运算符分隔的声明。
cert-dcl58-cpp:确保不同的成员变量使用不同的类型。
cert-err34-c:避免使用不存在的指针。
cert-err52-cpp:避免将一个标量赋值给一个不兼容的类型。
cert-err60-cpp:在空语句块中使用注释来提醒代码的维护者。
cert-flp30-c:避免使用函数指针执行非函数类型的对象。
cert-msc50-cpp 和 cert-msc51-cpp:关于 C++ 中对象的析构和构造的安全性准则。
cert-str34-c:避免在字符串拷贝函数中出现缓冲区溢出。
cppcoreguidelines-interfaces-global-init:警告全局初始化的接口。
cppcoreguidelines-narrowing-conversions:避免窄化转换。
cppcoreguidelines-pro-type-member-init:建议在构造函数中对所有成员变量进行初始化。
cppcoreguidelines-pro-type-static-cast-downcast:建议使用静态转换来进行向下转型。
cppcoreguidelines-slicing:提示有可能出现对象切割(slicing)的地方。
google-default-arguments 和 google-explicit-constructor:关于 Google C++ 编码规范中默认参数和显式构造函数的规则。
google-runtime-operator:Google C++ 编码规范中关于运算符的规则。
hicpp-exception-baseclass 和 hicpp-multiway-paths-covered:关于异常类基类和多路径覆盖的 HIC++ 规则。
misc-misplaced-const:警告误放的 const。
bugprone-sizeof-container 和 bugprone-sizeof-expression:在容器或表达式上使用 sizeof 可能导致 bug 的检测。
bugprone-spuriously-wake-up-functions:检测可能误唤醒线程的函数。
bugprone-string-constructor 和 bugprone-string-integer-assignment:检测字符串构造函数和整数赋值可能带来的潜在问题。
bugprone-string-literal-with-embedded-nul:发现在字符串字面值中嵌入空字符可能带来问题的情况。
bugprone-suspicious-enum-usage:检测可疑的枚举使用情况。
bugprone-suspicious-include:发现不合适的头文件引入。
bugprone-suspicious-memset-usage 和 bugprone-suspicious-memory-comparison:检测可能有问题的 memset 使用和内存比较。
bugprone-suspicious-missing-comma 和 bugprone-suspicious-semicolon:检测可能缺少逗号或分号的地方。
bugprone-suspicious-string-compare:发现可疑的字符串比较。
bugprone-suspicious-realloc-usage:检测可能不正确使用 realloc 的地方。
bugprone-swapped-arguments:检测参数错误排序的情况。
bugprone-terminating-continue 和 bugprone-throw-keyword-missing:检测不良的 continue 使用和可能缺少 throw 关键字的情况。
bugprone-too-small-loop-variable 和 bugprone-undefined-memory-manipulation:发现循环变量过小和潜在未定义的内存操作。
bugprone-undelegated-constructor:检测未委托的构造函数。
bugprone-unhandled-self-assignment:检测可能未处理的自赋值操作。
bugprone-unused-raii 和 bugprone-unused-return-value:发现未使用的 RAII 对象和返回值。
bugprone-use-after-move 和 bugprone-virtual-near-miss:检测移动后使用和潜在的虚函数近似错误。
bugprone-argument-comment:发现参数注释可能不正确的情况。
bugprone-assert-side-effect:检测断言中可能引起副作用的代码。
bugprone-bad-signal-to-kill-thread:发现线程杀死信号可能有问题的情况。
bugprone-branch-clone:发现可能会造成冗余分支的代码。
bugprone-copy-constructor-init:检测复制构造函数中可能的初始化错误。
bugprone-dangling-handle:发现悬空的句柄或引用。
bugprone-dynamic-static-initializers:检测可能会引发静态初始化问题的动态初始化。
bugprone-fold-init-type:发现在初始化中可能导致折叠类型的情况。
bugprone-forward-declaration-namespace:检测可能导致前置声明命名空间的情况。
bugprone-forwarding-reference-overload 和 bugprone-move-forwarding-reference:检测传递引用相关的错误。
bugprone-inaccurate-erase:发现可能不准确的 erase() 操作。
bugprone-incorrect-roundings 和 bugprone-integer-division:检测不正确的舍入和整数除法。
bugprone-lambda-function-name:警告 lambda 表达式中未命名的函数。
bugprone-macro-parentheses 和 bugprone-macro-repeated-side-effects:检测宏使用中可能存在的问题。
bugprone-misplaced-operator-in-strlen-in-alloc 和 bugprone-misplaced-pointer-arithmetic-in-alloc:检测在分配内存时可能存在的字符串长度或指针算术错误。
bugprone-misplaced-widening-cast:发现可能放置不当的宽化转换。
bugprone-multiple-statement-macro:发现多个语句的宏。
bugprone-no-escape 和 bugprone-not-null-terminated-result:检测逃逸问题和可能未以空字符结尾的结果。
bugprone-parent-virtual-call:发现可能会出现问题的父类虚函数调用。
bugprone-posix-return 和 bugprone-reserved-identifier:检测 POSIX 返回错误和保留标识符使用的问