diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-08-13 23:47:44 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-08-13 23:47:44 +0000 |
commit | f7b41371d9ede1aecf0930e5bd4a463519264633 (patch) | |
tree | ded8cb90f77507d5e88941ec46ff0b95c5161fb9 /clang/lib/Serialization/ASTWriter.cpp | |
parent | d7be603ab1a2fc9deac68328732355bb9d409bf9 (diff) | |
download | bcm5719-llvm-f7b41371d9ede1aecf0930e5bd4a463519264633.tar.gz bcm5719-llvm-f7b41371d9ede1aecf0930e5bd4a463519264633.zip |
[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
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 0a731f0d942..566c7d7c9f2 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -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()); |