[clang] [Clang][Modules] Ensure global diagnostic overrides are respected in system modules (PR #180684)

Takuto Ikuta via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 12 03:06:49 PST 2026


atetubou wrote:

 Thank you for the detailed reviews, Hans and Nico. You are both exactly right about the hermeticity concern.


  Addressing Hermeticity (Hans's concern):
  I have updated the patch to avoid breaking the diagnostic hermeticity established in e37391c. Instead of checking the SuppressSystemWarnings bit of the current DiagState, I introduced a new `ForceSystemWarnings` flag in DiagnosticsEngine that lives outside of the DiagState mechanism.


   * ForceSystemWarnings is global and non-hermetic: It is not saved to or restored from PCMs.
   * It is intended strictly for intentional, temporary overrides like the one in SemaAvailability.
   * Preserving Isolation: Command-line flags like -Wsystem-headers only modify the initial DiagState. When Clang enters code from a module, the module's own DiagState is restored, preserving its build-time configuration. Since -Wsystem-headers does not touch ForceSystemWarnings, it will not incorrectly resurface unrelated system warnings inside the module.


  ShowInSystemHeader & Expanded Testing (Nico's suggestion):
  I have expanded the test GH170429.cpp to include a case for -Wdelete-non-virtual-dtor (which has ShowInSystemHeader set) as suggested.


  The test now explicitly verifies three scenarios:
   1. Targeted fix: deprecated warnings from system modules are shown during user-triggered instantiation (via the RAII override).
   2. Consistency: Warnings with ShowInSystemHeader continue to be emitted as expected.
   3. Hermeticity Verification: Unrelated warnings suppressed during module build (e.g., -Wextra-semi) remain suppressed even when the user compiles with -Wsystem-headers, ensuring we don't undo the effect of e37391c.

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


More information about the cfe-commits mailing list