diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 177a3c3a34d73..245304254811a 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1288,11 +1288,11 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context, // 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() + if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd && + (!PP.getHeaderSearchInfo() .getHeaderSearchOpts() .ModuleMapFileHomeIsCwd || - PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd) || - WritingModule->Directory->getName() != StringRef(".")) { + WritingModule->Directory->getName() != StringRef("."))) { // Module directory. auto Abbrev = std::make_shared(); Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY)); diff --git a/clang/test/Modules/module-file-home-is-cwd.m b/clang/test/Modules/module-file-home-is-cwd.m index 706b815e6d0c2..a3875d578bb60 100644 --- a/clang/test/Modules/module-file-home-is-cwd.m +++ b/clang/test/Modules/module-file-home-is-cwd.m @@ -5,11 +5,12 @@ // RUN: -fmodules-embed-all-files %S/Inputs/normal-module-map/module.map \ // RUN: -o %t/mod.pcm // RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s +// RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s --check-prefix=INPUT -// CHECK: blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map' -// CHECK: blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h' -// CHECK: blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h' // CHECK-NOT: MODULE_DIRECTORY +// INPUT: blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map' +// INPUT: blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h' +// INPUT: blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h' @import libA;