[all-commits] [llvm/llvm-project] 69e036: [clang][Modules] Diagnosing Module Redefinition Ac...

Qiongsi Wu via All-commits all-commits at lists.llvm.org
Wed Apr 8 14:22:28 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 69e0367e8221b8002b5d438fb70ff3daf36257fc
      https://github.com/llvm/llvm-project/commit/69e0367e8221b8002b5d438fb70ff3daf36257fc
  Author: Qiongsi Wu <qiongsiwu at gmail.com>
  Date:   2026-04-08 (Wed, 08 Apr 2026)

  Changed paths:
    M clang/lib/Lex/ModuleMap.cpp
    M clang/lib/Tooling/DependencyScanningTool.cpp
    A clang/test/ClangScanDeps/modules-byname-dup-module-decl-diag.c
    A clang/test/ClangScanDeps/modules-mmap-redef.c
    A clang/test/Modules/implicit-module-redefinition-same-file.c
    A clang/test/Modules/implicit-module-redefinition.c

  Log Message:
  -----------
  [clang][Modules] Diagnosing Module Redefinition Across ModuleMaps (#190085)

This PR enhances the module redefinition diagnostic to cover a very
specific case.

1. A module, say `B`, is discovered first during header search. In other
words, it is declared in a modulemap that shows up first on the search
paths.
2. `B` is declared again in a different modulemap, which shows up in a
later search path, and the compiler discovers `B` again when it is
searching for a different named module.

See the two tests added for examples of this specific scenario. Under
such a scenario, the compiler now reports the module redefined error.

Note that we are not diagnosing duplicating module definitions globally,
because that requires looking through all search paths and loading all
module maps, which is too expensive.

Assisted-by: claude-opus-4.6



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