[clang] [C++20][Modules] Improve namespace look-up performance for modules. (PR #171769)
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 7 04:58:30 PST 2026
alexfh wrote:
> > Repro:
> > ```c++
> > // RUN: rm -rf %t
> > // RUN: mkdir -p %t
> > // RUN: split-file %s %t
> > // RUN: cd %t
> > //
> >
> > // RUN: %clang_cc1 -fmodule-name=A -fno-cxx-modules -xc++ -emit-module \
> > // RUN: -fmodules A.cppmap -o A.pcm
> > // RUN: %clang_cc1 -fmodule-name=B -fno-cxx-modules -xc++ -emit-module \
> > // RUN: -fmodules -fmodule-file=A.pcm B.cppmap -o B.pcm
> > // RUN: %clang_cc1 -fmodule-name=C -fno-cxx-modules -xc++ -emit-module \
> > // RUN: -fmodules C.cppmap -o C.pcm
> > // RUN: %clang_cc1 -fmodule-name=D -fno-cxx-modules -xc++ -emit-module \
> > // RUN: -fmodules -fmodule-file=C.pcm D.cppmap -o D.pcm
> > // RUN: %clang_cc1 -fmodule-name=E -fno-cxx-modules -xc++ -emit-module \
> > // RUN: -fmodules -fmodule-file=B.pcm E.cppmap -o E.pcm
> > // RUN: %clang_cc1 -fmodule-name=F -fno-cxx-modules -xc++ -emit-module \
> > // RUN: -fmodules -fmodule-file=D.pcm F.cppmap -o F.pcm
> > // RUN: %clang_cc1 -fmodule-name=G -fno-cxx-modules -xc++ -emit-module \
> > // RUN: -fmodules -fmodule-file=E.pcm -fmodule-file=F.pcm G.cppmap -o G.pcm
> > // RUN: %clang_cc1 -fno-cxx-modules -fmodules -fmodule-file=G.pcm src.cpp \
> > // RUN: -o /dev/null
> >
> > //--- A.cppmap
> > module "A" { header "A.h" }
> >
> > //--- A.h
> > int x;
> >
> > //--- B.cppmap
> > module "B" {}
> >
> > //--- C.cppmap
> > module "C" { header "D.h" }
> >
> > //--- D.cppmap
> > module "D" {}
> >
> > //--- D.h
> > namespace xyz {}
> >
> > //--- E.cppmap
> > module "E" {}
> >
> > //--- F.cppmap
> > module "F" { header "F.h" }
> >
> > //--- F.h
> > namespace xyz { inline void func() {} }
> >
> > //--- G.cppmap
> > module "G" { header "G.h" }
> >
> > //--- G.h
> > #include "F.h"
> > namespace { void func2() { xyz::func(); } }
> >
> > //--- hdr.h
> > #include "F.h"
> > namespace xyz_ns = xyz;
> >
> > //--- src.cpp
> > #include "hdr.h"
> > ```
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Fails with this:
> > ```
> > In file included from src.cpp:1:
> > ./hdr.h:2:20: error: declaration of 'xyz' must be imported from module 'C' before it is required
> > 2 | namespace xyz_ns = xyz;
> > | ^
> > ```
>
> @mpark do I understand correctly that this hasn't been fixed yet? Should the commit be reverted until there's a fix available (also for the issue reported by @boomanaiden154, if it's a distinct problem)? There's already been a few commits on top of this one. Later commits in this area will add conflicts and make reverting this locally (what we've been doing for a couple of weeks now) more and more complex.
https://github.com/llvm/llvm-project/pull/171769
More information about the cfe-commits
mailing list