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

[clangd] Add an option to disable special handling of standard library headers in include-cleaner #122612

Open
philnik777 opened this issue Jan 11, 2025 · 7 comments
Labels
clang-include-cleaner clangd enhancement Improving things as opposed to bug fixing, e.g. new or missing feature

Comments

@philnik777
Copy link
Contributor

While there are good reasons for adding some special magic for standard libraries, this really gets in the way when actually working on a standard library. For example, the include cleaner is completely broken, since it's always mapping public symbols to the public headers, even though library-internal headers should actually be used. It would be awesome if there was a flag for clangd to disable such special magic, allowing it to be used when working on a standard library without patching your own version together.

@philnik777 philnik777 added clangd enhancement Improving things as opposed to bug fixing, e.g. new or missing feature labels Jan 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 11, 2025

@llvm/issue-subscribers-clangd

Author: Nikolas Klauser (philnik777)

While there are good reasons for adding some special magic for standard libraries, this really gets in the way when actually working on a standard library. For example, the include cleaner is completely broken, since it's always mapping public symbols to the public headers, even though library-internal headers should actually be used. It would be awesome if there was a flag for clangd to disable such special magic, allowing it to be used when working on a standard library without patching your own version together.

@HighCommander4
Copy link
Collaborator

Are there other examples of special handling besides include-cleaner that you've come across?

@philnik777
Copy link
Contributor Author

I'm pretty sure I've run into other stuff, but I can't remember right now. Could just be me misremembering as well. The two other things I've patched in are adding custom clang-tidy checks (which is really not standard-library specific) and the include inserter to always use angle brackets, but I can't remember why I did that.

@HighCommander4 HighCommander4 changed the title [clangd] Add an option to disable special handling of stanadard library code [clangd] Add an option to disable special handling of standard library headers in include-cleaner Jan 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 11, 2025

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

Author: Nikolas Klauser (philnik777)

While there are good reasons for adding some special magic for standard libraries, this really gets in the way when actually working on a standard library. For example, the include cleaner is completely broken, since it's always mapping public symbols to the public headers, even though library-internal headers should actually be used. It would be awesome if there was a flag for clangd to disable such special magic, allowing it to be used when working on a standard library without patching your own version together.

@HighCommander4
Copy link
Collaborator

Ok; I've tweaked the issue title to make it specific to include-cleaner for now. (Note that include-cleaner is a top-level "extra tool" living at clang-tools-extra/include-cleaner, so that may impact how such an option needs to be implemented.)

If you find other cases of special handling, we can track those in other issues.

@philnik777
Copy link
Contributor Author

I mostly wanted to express that I don't think there should be an option per site, but a single flag to say "I don't want special handling" regardless where it is. Maybe I should have made that more clear. I don't really see a use-case to be more fine-grained other than people doing more weird stuff with their standard libraries.

@HighCommander4
Copy link
Collaborator

Understood.

I'm going to keep the issue title as is to keep the issue focused. ("Audit all codepaths used by clangd that might treat system headers differently" is a larger and fuzzier task that's not likely to be done all at once.)

I'm fine though with keeping the name of such an option general (i.e. not specific to include-cleaner), with a view to possibly having the option affect other features as well in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-include-cleaner clangd enhancement Improving things as opposed to bug fixing, e.g. new or missing feature
Projects
None yet
Development

No branches or pull requests

3 participants