进行IWYU分析包括标题,而不仅仅是主要程序
我有一个解决
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论