| Ticket UUID: | c7dc599e73a7094298594c4383ad3524f009e6f8 | ||
| Title: | Add IWYU export pragma annotations for improved clangd and clang-tidy diagnostics | ||
| Type: | Patch | Created on: | 2025-10-24 16:16:13 |
| Submitter: | hzeller | Assigned to: | jan.nijtmans |
| Subsystem: | None | Severity: | Minor |
| Priority: | 5 Medium | Last modified: | 2025-10-28 10:50:02 |
| Status: | Closed | Closed by: | jan.nijtmans |
| Resolution: | Fixed | Closed on: | 2025-10-28 10:50:02 |
| Version: | head | ||
| Description: | ||||
Someone including the toplevel "tcl.h" header might get misc-include-cleaner warnings from the clangd language server and clang-tidy in their projects for some symbols that are only provided by the "tclDecls.h" or "tclPlatDecls.h" headers as they are not _directly_ included. The annotation with IWYU pragmas fixes that and tells the tools that it should consider that these includes indeed should be considered as exporting the symbols and thus as if they directly provided the symbol Documentation clangd and clang-tidy https://clang.llvm.org/extra/clang-tidy/checks/misc/include-cleaner.html points to https://clangd.llvm.org/design/include-cleaner#iwyu-pragmas This has been first implemented and docuemnted in the include-what-you-use project https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md#iwyu-pragma-begin_exportsend_exports === 8< === Patch ==== --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2343,7 +2343,7 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv); * table. */ -#include "tclDecls.h" +#include "tclDecls.h" /* IWYU pragma: export */ /* * Include platform specific public function declarations that are accessible @@ -2356,7 +2356,7 @@ EXTERN const char *TclZipfs_AppHook(int *argc, char ***argv); # define TCLAPI MODULE_SCOPE #endif -#include "tclPlatDecls.h" +#include "tclPlatDecls.h" /* IWYU pragma: export */ /* *---------------------------------------------------------------------------- | ||||
| User Comments: | ||||
jan.nijtmans added on 2025-10-28 10:50:02:
Added now for all *Decls.h inclusions. Also done for itcl and tdbc. | ||||
