[all-commits] [llvm/llvm-project] 668d09: [clang][Modules] Fixing unexpected warnings trigge...

Qiongsi Wu via All-commits all-commits at lists.llvm.org
Wed Mar 4 08:27:12 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 668d09b2846d9794b35daa2744bf6d4c66c5ec42
      https://github.com/llvm/llvm-project/commit/668d09b2846d9794b35daa2744bf6d4c66c5ec42
  Author: Qiongsi Wu <qiongsiwu at gmail.com>
  Date:   2026-03-04 (Wed, 04 Mar 2026)

  Changed paths:
    M clang/lib/Frontend/CompilerInstance.cpp
    A clang/test/Modules/Inputs/pch-config-macros/include/Mod1.h
    A clang/test/Modules/Inputs/pch-config-macros/include/module.modulemap
    A clang/test/Modules/pch-config-macros.c

  Log Message:
  -----------
  [clang][Modules] Fixing unexpected warnings triggered by a PCH and a module with config macros  (#177078)

When a PCH is compiled with macro definitions on the command line, such
as `-DCONFIG1`, an unexpected warning can occur if the macro definitions
happen to belong to an imported module's config macros. The warning may
look like the following:
```
definition of configuration macro 'CONFIG1' has no effect on the import of 'Mod1'; pass '-DCONFIG1=...' on the command line to configure the module
```
while `-DCONFIG1` is clearly on the command line when `clang` compiles
the source that uses the PCH and the module.

The reason this can happen is a combination of two things:
1. The logic that checks for config macros is not aware of any command
line macros passed through the PCH

([here](https://github.com/llvm/llvm-project/blob/7976ac990000a58a7474269a3ca95e16aed8c35b/clang/lib/Frontend/CompilerInstance.cpp#L1562)).
2. `clang` _replaces_ the predefined macros on the command line with the
predefined macros from the PCH, which does not include any builtins
([here](https://github.com/llvm/llvm-project/blob/7976ac990000a58a7474269a3ca95e16aed8c35b/clang/lib/Frontend/CompilerInstance.cpp#L679)).

This PR teaches the preprocessor to recognize the command line macro
definitions passed transitively through the PCH, so that the error check
does not miss these definitions by mistake. The config macro itself
works fine, and it is only the error check that needs fixing.

rdar://95261458



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