diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 35432fa98e5909..aa02821aa971ba 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2768,8 +2768,12 @@ llvm::DIModule *CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod, llvm::DIBuilder DIB(CGM.getModule()); SmallString<0> PCM; - if (!llvm::sys::path::is_absolute(Mod.getASTFile())) - PCM = Mod.getPath(); + if (!llvm::sys::path::is_absolute(Mod.getASTFile())) { + if (CGM.getHeaderSearchOpts().ModuleFileHomeIsCwd) + PCM = getCurrentDirname(); + else + PCM = Mod.getPath(); + } llvm::sys::path::append(PCM, Mod.getASTFile()); DIB.createCompileUnit( TheCU->getSourceLanguage(), diff --git a/clang/test/Modules/module-file-home-is-cwd.m b/clang/test/Modules/module-file-home-is-cwd.m index 4f79c5abd9ccdf..57f8856406484f 100644 --- a/clang/test/Modules/module-file-home-is-cwd.m +++ b/clang/test/Modules/module-file-home-is-cwd.m @@ -1,8 +1,22 @@ // RUN: cd %S -// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-file-home-is-cwd -fmodule-name=libA -emit-module Inputs/normal-module-map/module.map -o %t/mod.pcm +// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules \ +// RUN: -fmodule-file-home-is-cwd -fmodule-name=libA -emit-module \ +// 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 // 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 + +@import libA; + +// RUN: cd %t +// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -debug-info-kind=limited \ +// RUN: -debugger-tuning=lldb -dwarf-ext-refs -fmodule-file-home-is-cwd \ +// RUN: -fmodule-map-file=%S/Inputs/normal-module-map/module.map \ +// RUN: -fmodule-file=libA=mod.pcm -emit-llvm -o %t-mod.ll %s +// RUN: cat %t-mod.ll | FileCheck %s --check-prefix=SKELETON + +// SKELETON: !DICompileUnit(language: DW_LANG_ObjC, {{.*}}, splitDebugFilename: "mod.pcm"