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

IWYU pragmas can be misleading in presence of forward declarations #62172

Open
kadircet opened this issue Apr 17, 2023 · 2 comments
Open

IWYU pragmas can be misleading in presence of forward declarations #62172

kadircet opened this issue Apr 17, 2023 · 2 comments

Comments

@kadircet
Copy link
Member

kadircet commented Apr 17, 2023

foo_priv.h:

// IWYU pragma: private, include "foo.h"
class Bar;
class Foo {};

foo.h:

#include "foo_priv.h"

bar_header.h:

class Bar {};

Despite of foo.h not owning Bar, we'll infer it as canonical header for Bar, because of the IWYU private pragma.

I guess we can adjust private pragma to only affect declarations with a definition.

The other alternative is changing the strength for canonical signal, but it might regress other cases.

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 17, 2023

@llvm/issue-subscribers-clang-include-cleaner

@kadircet
Copy link
Member Author

kadircet commented Sep 6, 2023

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

No branches or pull requests

3 participants