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

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 24 03:34:45 PDT 2024


================
@@ -2057,9 +2065,12 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
     // it as a header file (in which case HFI will be null) or if it hasn't
     // changed since it was loaded. Also skip it if it's for a modular header
     // from a different module; in that case, we rely on the module(s)
-    // containing the header to provide this information.
+    // containing the header to provide this information. Also skip it if it's
+    // for any header not from this module that has not been included; in that
+    // case, we don't need the information at all.
     const HeaderFileInfo *HFI = HS.getExistingLocalFileInfo(*File);
-    if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
+    if (!HFI || (!HFI->isCompilingModuleHeader &&
----------------
sam-mccall wrote:

nit: this seems hard to follow, consider splitting up as:

```
if (!HFI)
  continue; // we're not relying on this file at all
if (HFI->isModuleHeader && !HFI->isCompilingModuleHeader)
  continue; // will import HFI from its module
if (!HFI->isCompilingModuleHeader && !PP->alreadyIncluded(*File))
  continue; // unused header needs no description
```

and possibly pulling out as `static shouldDescribeHeader(HFI)` or so?

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


More information about the cfe-commits mailing list