[all-commits] [llvm/llvm-project] 40472e: [clang][modules] Serialize VFS overlay paths into ...

Jan Svoboda via All-commits all-commits at lists.llvm.org
Fri Dec 2 16:12:30 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 40472ef14cd3bbed665789825b47d055e0a83402
      https://github.com/llvm/llvm-project/commit/40472ef14cd3bbed665789825b47d055e0a83402
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2022-12-02 (Fri, 02 Dec 2022)

  Changed paths:
    M clang/include/clang/Frontend/CompilerInvocation.h
    M clang/include/clang/Serialization/ASTBitCodes.h
    M clang/include/clang/Serialization/ASTReader.h
    M clang/lib/Frontend/ASTUnit.cpp
    M clang/lib/Frontend/CompilerInvocation.cpp
    M clang/lib/Serialization/ASTReader.cpp
    M clang/lib/Serialization/ASTWriter.cpp

  Log Message:
  -----------
  [clang][modules] Serialize VFS overlay paths into PCMs

With implicitly built modules, the importing `CompilerInstance` assumes PCMs were built in a "compatible way" (i.e. with similarly set up instance). Either because their context hash matches, or because this instance has just built them.

There are some use-cases, however, where this assumption doesn't hold, libclang/c-index-test being one of them. There, the importing instance (or `ASTUnit`) is being set up while the PCM file is being deserialized. Until now, we've assumed the serialized paths to input files are the actual on-disk files, meaning the default physical VFS was always able to resolve them. This won't be the case after D135636. Therefore, this patch makes sure `ASTUnit` is initialized with the same VFS as the PCM it's deserializing - by storing paths to the VFS overlay files into the PCM itself.

For the VFS overlay files to be adopted at the very start of PCM deserialization, they are stored in a new section in the unhashed control block, together with header search paths and system header prefixes. The move to the unhashed control block should be safe: if two modules were built with different header search paths and they produced different results, the hashed part of the PCM file will reflect that.

Reviewed By: akyrtzi, benlangmuir

Differential Revision: https://reviews.llvm.org/D135634


  Commit: 7806a928688c12accdf47e7f8dc33d484c295858
      https://github.com/llvm/llvm-project/commit/7806a928688c12accdf47e7f8dc33d484c295858
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2022-12-02 (Fri, 02 Dec 2022)

  Changed paths:
    M clang/lib/Serialization/ASTWriter.cpp
    M clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
    A clang/test/ClangScanDeps/modules-file-name-as-requested.m

  Log Message:
  -----------
  [clang][modules][deps] Serialize inputs into PCMs using the "as requested" name

This patch changes the PCM serialization logic to refer to input files by their "requested" name. This fixes a bug where the dependency scanner reports the "final" file paths, which can result in failed explicit compiles due to the `module.modulemap` file not being surrounded by the expected framework directory structure.

Depends on D135634.

Reviewed By: benlangmuir, Bigcheese

Differential Revision: https://reviews.llvm.org/D135636


Compare: https://github.com/llvm/llvm-project/compare/5ea0ba2c13af...7806a928688c


More information about the All-commits mailing list