如何启用clang-tidy的“ modernize”检查? [英] How can I enable clang-tidy's "modernize" checks?

查看:197
本文介绍了如何启用clang-tidy的“ modernize”检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了 ClangOnWin ,我正尝试获取 clang -tidy 的现代化检查工作。不幸的是, clang-tidy 似乎并不了解它们: clang-tidy -list-checks foo.cpp-| grep modernize 不产生任何输出。

I just installed ClangOnWin,and I'm trying to get clang-tidy's "modernize" checks to work. Unfortunately, clang-tidy doesn't seem to know about them: clang-tidy -list-checks foo.cpp -- | grep modernize produces no output.

列出了 modernize检查此处,但是该页面似乎记录了Clang 3.8,而我安装的版本是3.7。但是,版本3.7是 LLVM下载页面中列出的最新版本。

The "modernize" checks are listed here, but that page seems to document Clang 3.8, and the version I have installed is 3.7. However, version 3.7 is the current one listed at the LLVM Download Page.

clang-tidy 知道各种安全检查,因此我认为我已正确安装了它。例如, clang-tidy -list-checks foo.cpp-| grep security 产生以下结果:

clang-tidy knows about a variety of security checks, so I think I have it installed correctly. For example, clang-tidy -list-checks foo.cpp -- | grep security yields this:

clang-analyzer-security.FloatLoopCounter
clang-analyzer-security.insecureAPI.UncheckedReturn
clang-analyzer-security.insecureAPI.getpw
clang-analyzer-security.insecureAPI.gets
clang-analyzer-security.insecureAPI.mkstemp
clang-analyzer-security.insecureAPI.mktemp
clang-analyzer-security.insecureAPI.rand
clang-analyzer-security.insecureAPI.strcpy
clang-analyzer-security.insecureAPI.vfork

我需要做一些特别的事情来启用诸如 modernize-use-override之类的检查吗 modernize-use-nullptr

Is there something special I need to do to enable checks such as modernize-use-override and modernize-use-nullptr?

推荐答案

现代化支票是在3.7之后添加的(从clang-modernize移植),但是尝试添加 -checks = * 以查看可用支票的整个列表。

The modernize checks were added after 3.7 (ported from clang-modernize), but try adding -checks="*" to see the whole list of available checks.

clang-tidy -list-checks -checks="*" foo.cpp --

这篇关于如何启用clang-tidy的“ modernize”检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆