From: Richard Howell Date: Tue, 4 Apr 2023 19:35:45 +0000 (-0700) Subject: [clang] don't serialize MODULE_DIRECTORY with ModuleFileHomeIsCwd X-Git-Tag: upstream/17.0.6~12583 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8ee5029b225ba1ff415e0a0a6a68dc4e3efee4d1;p=platform%2Fupstream%2Fllvm.git [clang] don't serialize MODULE_DIRECTORY with ModuleFileHomeIsCwd Fix a bug in the MODULE_DIRECTORY serialization logic that would cause MODULE_DIRECTORY to be serialized when `-fmodule-file-home-is-cwd` is specified. This matches the original logic added in: https://github.com/apple/llvm-project/commit/f7b41371d9ede1aecf0930e5bd4a463519264633 Reviewed By: keith Differential Revision: https://reviews.llvm.org/D147561 --- diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 177a3c3..2453042 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 706b815..a3875d5 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;