[PATCH] D111543: [clang][modules] Stop creating `IdentifierInfo` for names of explicit modules

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 11 06:29:58 PDT 2021


jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, rsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When using explicit Clang modules, some declarations might unexpectedly become invisible.

This was noticed in the following scenario:

- module named `Interface` contains an ObjC interface declaration of the same name, and its PCM is passed to Clang via the `-fmodule-file=<path>` argument,
- another module referring to `Interface` within an attribute (`objc_bridge`) is passed to Clang (also via the `-fmodule-file=<path>` argument),
- the Clang invocation then can't find the `Interface` interface declaration.

This seems to be caused by the mechanism that loads PCM files passed via `-fmodule-file=<path>` which creates an `IdentifierInfo` for the module name. I'm not sure why exactly that trips up name resolution, but using `StringRef` for the module name resolves the error. Creating an `IdentifierInfo` with some prefix (e.g. `CI.getPreprocessor().getIdentifierInfo("LoadModuleCacheKey_" + ModuleName)`) also resolves the issue.

Note that the `-fmodule-file=<name>=<path>` form of the argument doesn't suffer from this issue, since it doesn't create `IdentifierInfo` for the module name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111543

Files:
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/test/Modules/Inputs/interface-visibility-2/Interface.h
  clang/test/Modules/Inputs/interface-visibility-2/InterfaceBridge.h
  clang/test/Modules/Inputs/interface-visibility-2/module.modulemap
  clang/test/Modules/interface-visibility-2.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111543.378646.patch
Type: text/x-patch
Size: 6389 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211011/66154891/attachment.bin>


More information about the cfe-commits mailing list