进行IWYU分析包括标题,而不仅仅是主要程序

发布于 2025-02-08 10:38:23 字数 1109 浏览 1 评论 0原文

我有一个解决

cmake .. -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="iwyu"
make

问题的项目是,iwyu似乎只是在查看*。cpp要编译的文件,而不在>中包含的标题中。 CPP本身。 您将您传递给iwyu的哪个选项强制分析包含的标题。 当然,我不会对系统标头的报告(-isystem)不感兴趣,但是我对属于同一项目的标头感兴趣。

我尝试使用选项-Check_also =*。HPP,但我获得了消息错误:不支持的选项'-Check_also = HPP = HPP'

我正在使用的版本是:

iwyu- version包括基于ubuntu clang版本13.0.0.1-2ubuntu2

apt-get -get-version apt 2.4.7( AMD64)


我意识到我必须将-XIWYU放在任何选项上。 因此,我必须执行-XIWYU -CHECK_ALSO =*。HPP,但是现在我得到了此错误:

Error running 'iwyu': iwyu: /usr/lib/llvm-11/include/clang/AST/Decl.h:251: llvm::StringRef clang::NamedDecl::getName() const: Assertion `Name.isIdentifier() && "Name is not a simple identifier"' failed.

这使我认为这不支持模式,而是个人文件。

因此,看来通过CMAKE的使用对于这种情况并不是很有用,最好使用以下方式检查整个项目:

find ./include -name '*.hpp' -exec iwyu -Xiwyu --cxx17ns -Xiwyu --quoted_includes_first -std=c++17 {} \;

I have a project which I compile with

cmake .. -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="iwyu"
make

The problem is that iwyu seems to be only looking at the *.cpp files being compiled and not at headers included from the cpp itself.
What option you I pass to iwyu to force to analyze included headers.
Of course I wouldn't be interested in reports of system headers (-isystem) but I am interested in headers that belong to the same project.

I tried with the option --check_also=*.hpp but I get the message error: unsupported option '--check_also=hpp'.

The versions I am using are:

iwyu --version include-what-you-use 0.17 based on Ubuntu clang version 13.0.1-2ubuntu2

apt-get --version apt 2.4.7 (amd64)


I realized that I have to put -Xiwyu in front any option.
So, I have to do -Xiwyu --check_also=*.hpp but now I get this error:

Error running 'iwyu': iwyu: /usr/lib/llvm-11/include/clang/AST/Decl.h:251: llvm::StringRef clang::NamedDecl::getName() const: Assertion `Name.isIdentifier() && "Name is not a simple identifier"' failed.

which makes me think that this doesn't support patterns but individual files.

So, it seems that the use through cmake is not very useful for this case and it is better to check the whole project using:

find ./include -name '*.hpp' -exec iwyu -Xiwyu --cxx17ns -Xiwyu --quoted_includes_first -std=c++17 {} \;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文