mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 21:53:12 +08:00
[modules] When writing a module file built with -fmodule-map-file-home-is-cwd,
via a module map found by -fmodule-map-file=, the home directory of the module is the current working directory, even if that's a different directory on reload. llvm-svn: 244988
This commit is contained in:
@@ -1185,17 +1185,26 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
|
||||
}
|
||||
|
||||
if (WritingModule && WritingModule->Directory) {
|
||||
// Module directory.
|
||||
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
|
||||
Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));
|
||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Directory
|
||||
unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
|
||||
RecordData Record;
|
||||
Record.push_back(MODULE_DIRECTORY);
|
||||
|
||||
SmallString<128> BaseDir(WritingModule->Directory->getName());
|
||||
cleanPathForOutput(Context.getSourceManager().getFileManager(), BaseDir);
|
||||
Stream.EmitRecordWithBlob(AbbrevCode, Record, BaseDir);
|
||||
|
||||
// If the home of the module is the current working directory, then we
|
||||
// want to pick up the cwd of the build process loading the module, not
|
||||
// our cwd, when we load this module.
|
||||
if (!PP.getHeaderSearchInfo()
|
||||
.getHeaderSearchOpts()
|
||||
.ModuleMapFileHomeIsCwd ||
|
||||
WritingModule->Directory->getName() != StringRef(".")) {
|
||||
// Module directory.
|
||||
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
|
||||
Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));
|
||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Directory
|
||||
unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
|
||||
|
||||
RecordData Record;
|
||||
Record.push_back(MODULE_DIRECTORY);
|
||||
Stream.EmitRecordWithBlob(AbbrevCode, Record, BaseDir);
|
||||
}
|
||||
|
||||
// Write out all other paths relative to the base directory if possible.
|
||||
BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
|
||||
|
||||
@@ -17,14 +17,22 @@
|
||||
// RUN: FileCheck --check-prefix=CHECK-BUILD %s < %t/build-cwd.d
|
||||
// RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-explicit-cwd.d
|
||||
// RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-implicit-cwd.d
|
||||
//
|
||||
// Check that the .d file is still correct after relocating the module.
|
||||
// RUN: mkdir %t/Inputs
|
||||
// RUN: cp %S/Inputs/relative-dep-gen-1.h %t/Inputs
|
||||
// RUN: cp %s %t
|
||||
// RUN: cd %t
|
||||
// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-file=%t/mod-cwd.pcm -dependency-file %t/use-explicit-no-map-cwd.d -MT use.o relative-dep-gen.cpp -fsyntax-only -fmodule-map-file-home-is-cwd
|
||||
// RUN: cat %t/use-explicit-no-map-cwd.d
|
||||
// RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-explicit-no-map-cwd.d
|
||||
|
||||
#include "Inputs/relative-dep-gen-1.h"
|
||||
|
||||
// CHECK-BUILD: mod.pcm:
|
||||
// CHECK-BUILD: Inputs/relative-dep-gen{{(-cwd)?}}.modulemap
|
||||
// CHECK-BUILD: Inputs/relative-dep-gen-1.h
|
||||
// CHECK-BUILD: Inputs/relative-dep-gen-2.h
|
||||
// CHECK-BUILD: {{[ \t]}}Inputs/relative-dep-gen{{(-cwd)?}}.modulemap
|
||||
// CHECK-BUILD: {{[ \t]}}Inputs/relative-dep-gen-1.h
|
||||
// CHECK-BUILD: {{[ \t]}}Inputs/relative-dep-gen-2.h
|
||||
// CHECK-USE: use.o:
|
||||
// CHECK-USE-DAG: Inputs/relative-dep-gen{{(-cwd)?}}.modulemap
|
||||
// CHECK-USE-DAG: relative-dep-gen.cpp
|
||||
// CHECK-USE-DAG: Inputs{{[/\\]}}relative-dep-gen-1.h
|
||||
// CHECK-USE-DAG: {{[ \t]}}relative-dep-gen.cpp
|
||||
// CHECK-USE-DAG: {{[ \t]}}Inputs{{[/\\]}}relative-dep-gen-1.h
|
||||
|
||||
Reference in New Issue
Block a user