forked from OSchip/llvm-project
[clang] serialize SUBMODULE_TOPHEADER relative to BaseDirectory
This diff changes the serialization of the `SUBMODULE_TOPHEADER` entry in module files to be serialized relative to the module's `BaseDirectory`. This matches the behavior of the `SUBMODULE_HEADER` entry and will allow for the module to be relocatable across machines. The path is restored relative to the module's `BaseDirectory` on deserialization. Reviewed By: urnathan Differential Revision: https://reviews.llvm.org/D124938
This commit is contained in:
parent
646e502de0
commit
f11056943e
|
@ -5637,9 +5637,12 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
|
|||
// them here.
|
||||
break;
|
||||
|
||||
case SUBMODULE_TOPHEADER:
|
||||
CurrentModule->addTopHeaderFilename(Blob);
|
||||
case SUBMODULE_TOPHEADER: {
|
||||
std::string HeaderName(Blob);
|
||||
ResolveImportedPath(F, HeaderName);
|
||||
CurrentModule->addTopHeaderFilename(HeaderName);
|
||||
break;
|
||||
}
|
||||
|
||||
case SUBMODULE_UMBRELLA_DIR: {
|
||||
// See comments in SUBMODULE_UMBRELLA_HEADER
|
||||
|
|
|
@ -2857,8 +2857,11 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
|
|||
{
|
||||
auto TopHeaders = Mod->getTopHeaders(PP->getFileManager());
|
||||
RecordData::value_type Record[] = {SUBMODULE_TOPHEADER};
|
||||
for (auto *H : TopHeaders)
|
||||
Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, H->getName());
|
||||
for (auto *H : TopHeaders) {
|
||||
SmallString<128> HeaderName(H->getName());
|
||||
PreparePathForOutput(HeaderName);
|
||||
Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, HeaderName);
|
||||
}
|
||||
}
|
||||
|
||||
// Emit the imports.
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// RUN: cd %S
|
||||
// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x objective-c++ -fmodule-name=std -emit-module Inputs/submodules/module.map -o %t/mod.pcm
|
||||
// RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s
|
||||
|
||||
// CHECK: <SUBMODULE_HEADER abbrevid=6/> blob data = 'vector.h'
|
||||
// CHECK: <SUBMODULE_TOPHEADER abbrevid=7/> blob data = 'vector.h'
|
||||
// CHECK: <SUBMODULE_HEADER abbrevid=6/> blob data = 'type_traits.h'
|
||||
// CHECK: <SUBMODULE_TOPHEADER abbrevid=7/> blob data = 'type_traits.h'
|
||||
// CHECK: <SUBMODULE_HEADER abbrevid=6/> blob data = 'hash_map.h'
|
||||
// CHECK: <SUBMODULE_TOPHEADER abbrevid=7/> blob data = 'hash_map.h'
|
Loading…
Reference in New Issue