[PATCH] D113676: WIP: [clang][lex] Fix search path usage remark with modules

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 12 08:15:19 PST 2021

jansvoboda11 added inline comments.

Comment at: clang/lib/Lex/HeaderSearch.cpp:94
+      // Module map parsing initiated by header search.
+      if (HS.CurrentSearchPathIdx != ~0U)
+        HS.ModuleToSearchDirIdx[M] = HS.CurrentSearchPathIdx;
ahoppen wrote:
> jansvoboda11 wrote:
> > ahoppen wrote:
> > > When would the `moduleMapModuleCreated` be called while `CurrentSearchPathIdx == ~0U`? Could this be an `assert` instead?
> > This happens whenever any of the `ModuleMap` member functions that create new `Module` instances are called outside of `HeaderSearch`.
> > 
> > The `MMCallback` callback is basically "global" (present for the whole lifetime of `ModuleMap`), so that we don't have to repeatedly register/deregister it in `HeaderSearch::lookupModule`.
> Is there any reasonable case where module maps would be created without `HeaderSearch` triggering the creation?
I think parsing of module maps (and therefore creation of contained modules) should be triggered through `HeaderSearch`.

However, there are also C++20 modules and explicit Clang modules that are not discovered by the header search mechanisms or modulemap parsing.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list