[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
Thu Nov 11 07:15:29 PST 2021

jansvoboda11 created this revision.
jansvoboda11 added a reviewer: ahoppen.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When looking for module, `HeaderSearch::lookupModule` iterates through search paths, parses modulemaps, eagerly creates `Module` instances and caches them in `ModuleMap`. When first called, it will correctly note usage of the search path that discovered the returned module. On subsequent calls, however, it can pull previously created `Module` from `ModuleMap` without noting the search path was used.

This patch fixes that. This requires `HeaderSearch` to be able to go from `Module` to the index of corresponding search path. This is achieved by adding a callback to the modulemap parser, intercepting creations of `Module` instances and pairing them with the current search path index.

The outlined solution doesn't handle all corner cases, though. It's possible for clients to use `HeaderSearch` to lookup module `B`, which could deserialize unrelated modulemap and create instance of module `A`. The client can then look up module `A` directly in `ModuleMap`, avoiding the logic in `HeaderSearch` that makes `-Rsearch-path-usage` work.

  rG LLVM Github Monorepo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113676.386508.patch
Type: text/x-patch
Size: 10624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211111/c16db090/attachment-0001.bin>

More information about the cfe-commits mailing list