Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing headers when consumed by iwyu.sh #216

Closed
sthornington opened this issue Aug 31, 2024 · 5 comments
Closed

Missing headers when consumed by iwyu.sh #216

sthornington opened this issue Aug 31, 2024 · 5 comments

Comments

@sthornington
Copy link

Hi folks!

This is a vague issue to be sure, but has anyone had an issue with the compile_commands.json resulting from this rule causing iwyu.sh to fail to find issues in .hpp files?

I plan to dig into this more next week, but if anyone else is using the hedronvision rule as an input to iwyu.sh without any coverage gaps (or with) I'm curious to hear if there were any changes or flags you needed to specify.

Thanks!

@sthornington
Copy link
Author

I guess another minor related question - when hedron picks a cpp file to use as bait, when producing a rule for a header file, it does at least pick a cpp file which includes that header, right…?

@cpsauer
Copy link
Contributor

cpsauer commented Sep 1, 2024

Hey Simon! Great to meet you--and thanks for working with this tool

The command listed for the header is indeed one that's actually used to compile the header; that is, the cpp file includes that header (potentially transitively). If you want to see where this happens in the code, _get_headers in refresh.template.py is your man.

I haven't used iqyu.sh personally, unfortunately, so I don't have comparative advantage there (sorry!) but if it chokes on headers, I want to make sure you know about the header-search exclusion options, at least to track down the issue? They Ideally they'd be robust to this, though, since needing to enrich the compilation database with headers is a a broader thing than this tool.

Happy coding!
Chris

@sthornington
Copy link
Author

Hi yeah thanks, I'll look into it a bit more next week. I'm happy enough to have gotten it working wel for clangd with our bazel wrapper situation using the changes in my PR #215 -- getting iwyu.sh working is a secondary concern and just as likely to be a bug in that tool.

@sthornington
Copy link
Author

For anyone else that lands here, I fixed this issue by modifying our iwyu_tool.sh so that it passes -Xiwyu --check_also=... when building the Invocation. Specifically, I had to strip the <directory>/ from the <file> for all headers and pass that in. This causes iwyu to try to patch up that header, using the build command for the exemplar cpp file provided by the hedronvision compile_commands.json.

@sthornington
Copy link
Author

workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants