[clang] [clang] use absolute path for builtin headers during module compilation (PR #68023)

Richard Howell via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 6 09:52:33 PDT 2023


rmaz wrote:

I had a go at this approach this morning, it mostly works but fails for the case where we have a module with a textual header with the same name as a builtin header. When using relative paths for the builtin headers we now prefer the module's textual header instead of the builtin header. This fails the following test case:
https://github.com/llvm/llvm-project/blob/main/clang/test/Modules/cstd.m#L27-L29

I believe this is because:

- https://github.com/llvm/llvm-project/blob/main/clang/lib/Lex/PPDirectives.cpp#L984 during file lookup we always add the modules directory at the front of the search paths
- https://github.com/llvm/llvm-project/blob/main/clang/lib/Lex/HeaderSearch.cpp#L883 previously we would have hit this case for the builtin headers and directly included the file, but now we go through path lookup logic and instead pick up the location here from the module dir includers: https://github.com/llvm/llvm-project/blob/main/clang/lib/Lex/HeaderSearch.cpp#L932

What would you suggest as the best solution here? Do you think its reasonable to always add the builtin header directory to the front of the Includers ahead of the module build directory?


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


More information about the cfe-commits mailing list