[lld] [llvm] [mlir] [polly] [NFC] Add explicit #include llvm-config.h where its macros are used, last part. (PR #107615)

Daniil Fukalov via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 7 01:59:22 PDT 2024


dfukalov wrote:

> > Without these explicit includes, removing other headers, who implicitly include llvm-config.h, may have non-trivial side effects.
> 
> I'm not opposed to this change, but how does it differ from any other headers? I didn't quite get what would be special about llvm-config.h here?

This and some similar headers are actually generated by cmake "configuration" headers containing only defines are used in different places to switch some parts of sources depending on target, host, libraries used, etc. One of approaches to use such defines is '#ifdef'. In this case, if a config header was not actually included (explicit or implicit) the build will be successful, but can be incorrect. Moreover, tests can pass (that was observed in PR #104825).
 
> > For example, clangd may report even llvm-config.h as "no used" in case it defines a macro, that is explicitly used with #ifdef. It is actually amplified with different build configs which use different set of macros.
> 
> You start this sentence with "For example", but I can't follow how what you're describing relates to the first sentence?

`clangd` is usually used to report unused headers for a source file. But it can falsely report such config headers as unused (that I also got in PR #104825).

https://github.com/llvm/llvm-project/pull/107615


More information about the llvm-commits mailing list