[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
Mon Sep 9 03:42:34 PDT 2024


dfukalov wrote:

> The right fix for this IMO is to stop using ifdef and use if instead, with `-Wundef` (which is [already enabled in MLIR](https://github.com/llvm/llvm-project/blob/main/mlir/CMakeLists.txt#L74-L78) by the way, just for this reason!

I guess this is a good idea, to use `#if` with `-Wundef` instead of `#ifdef`, but there are huge number of places where `#ifdef` is already used for configuration purposes (including MLIR sources) and refactoring it is out of scope.

> I don't quite the explanation, or rather I still don't see the connection: how is this patch adding these headers will impact what clangd says? Seems like you're describing a bug in clang?

No. Just because `clangd` should check a particular compilation of each module, it uses a set of defines (the most convenient way I guess is to use `compile_commands.json`) and we have no guarantee we checked all of the combinations of configurations (including host, targets, libraries etc). The only way to be sure that all defines have appropriate definitions is to explicitly include corresponding configuration headers.



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


More information about the llvm-commits mailing list