Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 6654efac69c9d4cc90f2ff95d1751e837881f01ba7a9eb0c27884b72bfffda4e
Ticket: c7dc599e73a7094298594c4383ad3524f009e6f8
Add IWYU export pragma annotations for improved clangd and clang-tidy diagnostics
User & Date: hzeller on 2025-10-24 16:16:13
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-plain"
  4. comment changed to:
    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 */
     
     /*
      *----------------------------------------------------------------------------
    
  5. foundin changed to: "head"
  6. is_private changed to: "0"
  7. login: "hzeller"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "9bef9914fb30c8aedb6cfa0bafc4b43d058d4e85"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "hzeller"
  14. subsystem changed to: "None"
  15. title changed to:
    Add IWYU export pragma annotations for improved clangd and clang-tidy diagnostics
    
  16. type changed to: "Patch"