clangd: "IWYU pragma: export" is not respected outside of the preamble region

I have some functionality outsourced into a .tpp file and included it into the .h file at the end of the file like:

[file.h]

// some template declarations

#include file.tpp // IWYU pragma: export

[file.tpp]

// respective implementations

if it put the comment to a unused header at the beginning of the file where all other headers are, the warning disappears like it should.

System information

Output of clangd --version:

Ubuntu clangd version 14.0.0-1ubuntu1.1 Features: linux+grpc Platform: x86_64-pc-linux-gnu

Editor/LSP plugin: VSCode Plugin

Operating system: Linux

About this issue

  • Original URL
  • State: open
  • Created 5 months ago
  • Comments: 18

Most upvoted comments

Based on playing around with it a bit, it seems that:

  • the extension of the included file (e.g. .tpp vs. .hpp or .h) is not relevant
  • whether the #include is located in the preamble region of the file (at the top) or later on (after the first non-preprocessor declaration) is relevant

I am going to revise the issue title accordingly.