summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-08-13 23:47:44 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-08-13 23:47:44 +0000
commitf7b41371d9ede1aecf0930e5bd4a463519264633 (patch)
treeded8cb90f77507d5e88941ec46ff0b95c5161fb9 /clang/lib/Serialization/ASTWriter.cpp
parentd7be603ab1a2fc9deac68328732355bb9d409bf9 (diff)
downloadbcm5719-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.cpp27
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());
OpenPOWER on IntegriCloud