[all-commits] [llvm/llvm-project] d60902: [clang][modules] Allow module maps with textual he...

Jan Svoboda via All-commits all-commits at lists.llvm.org
Wed Apr 24 09:06:18 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d609029d6c9aae84b52238f39c35200316bdbb93
      https://github.com/llvm/llvm-project/commit/d609029d6c9aae84b52238f39c35200316bdbb93
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2024-04-24 (Wed, 24 Apr 2024)

  Changed paths:
    M clang/include/clang/Lex/HeaderSearch.h
    M clang/lib/Lex/HeaderSearch.cpp
    M clang/lib/Serialization/ASTWriter.cpp
    A clang/test/Modules/prune-non-affecting-module-map-files-textual.c

  Log Message:
  -----------
  [clang][modules] Allow module maps with textual headers to be non-affecting (#89441)

When writing out a PCM, we skip serializing headers' `HeaderFileInfo`
struct whenever this condition evaluates to `true`:

```c++
!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader)
```

However, when Clang parses a module map file, each textual header gets a
`HFI` with `isModuleHeader=false`, `isTextualModuleHeader=true` and
`isCompilingModuleHeader=false`. This means the condition evaluates to
`false` even if the header was never included and the module map did not
affect the compilation. Each PCM file that happened to parse such module
map then contains a copy of the `HeaderFileInfo` struct for all textual
headers, and considers the containing module map affecting.

This patch makes it so that we skip headers that have not been included,
essentially removing the virality of textual headers when it comes to
PCM serialization.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list