[clang][modules][pch] Allow loading PCH with different modules cache path
authorJan Svoboda <jan_svoboda@apple.com>
Mon, 14 Jun 2021 08:51:04 +0000 (10:51 +0200)
committerJan Svoboda <jan_svoboda@apple.com>
Mon, 14 Jun 2021 09:04:56 +0000 (11:04 +0200)
commit78668c822af9504f77a554f5924e1097365d9c33
tree058ab6805b146662da5c79d1e0430b9aa67b9d7d
parente63f27a3cf8129cb66b8350ad50bf19633554a6b
[clang][modules][pch] Allow loading PCH with different modules cache path

It's useful to be able to load explicitly-built PCH files into an implicit build (e.g. during dependency scanning). That's currently impossible, since the explicitly-built PCH has an empty modules cache path, while the current compilation has (and needs to have) a valid path, triggering an error in the `PCHValidator`.

This patch adds a preprocessor option and command-line flag that can be used to omit this check.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D103802
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/PreprocessorOptions.h
clang/lib/Serialization/ASTReader.cpp
clang/test/Modules/Inputs/pch-typedef.h [new file with mode: 0644]
clang/test/Modules/module-pch-different-cache-path.c [new file with mode: 0644]