[PATCH] D100934: [clang][modules] Build inferred modules

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 21 01:14:03 PDT 2021


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

This patch enabled explicitly building inferred modules.

Effectively a cherry-pick of https://github.com/apple/llvm-project/pull/699 authored by @Bigcheese with libclang changes omitted and adapted to use the new full canonical command-line `clang-scan-deps` produces since D100534 <https://reviews.llvm.org/D100534>.

Contains the following changes:

1. [Clang][ScanDeps] Ignore __inferred_module.map dependency.
  - This shows up with inferred modules, but it doesn't exist on disk, so don't report it as a dependency.

2. [Clang] Fix the header paths in `clang::Module` for inferred modules.
  - The `UmbrellaAsWritten` and `NameAsWritten` fields in `clang::Module` are a lie for framework modules. For those they actually are the path to the header or umbrella relative to the `clang::Module::Directory`.
  - The exception to this case is for inferred modules. Here it actually is the name as written, because we print out the module and read it back in when implicitly building modules. This causes a problem when explicitly building an inferred module, as we skip the printing out step.
  - In order to fix this issue this patch adds a new field for the path we want to use in `getInputBufferForModule`. It also makes `NameAsWritten` actually be the name written in the module map file (or that would be, in the case of an inferred module).

3. [Clang] Allow explicitly building an inferred module.
  - Building the actual module still fails, but make sure it fails for the right reason.

4. [Clang][ScanDeps] Use the module map a module was inferred from for inferred modules.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100934

Files:
  clang/include/clang/Basic/Module.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Basic/Module.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h
  clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Headers/Inferred.h
  clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Headers/System.h
  clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Modules/module.modulemap
  clang/test/ClangScanDeps/Inputs/frameworks/module.modulemap
  clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json
  clang/test/ClangScanDeps/module-deps-to-rsp.py
  clang/test/ClangScanDeps/modules-full.cpp
  clang/test/ClangScanDeps/modules-inferred-explicit-build.m
  clang/test/ClangScanDeps/modules-inferred.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100934.339134.patch
Type: text/x-patch
Size: 23358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210421/015ef213/attachment-0001.bin>


More information about the cfe-commits mailing list