[PATCH] D134911: [clang][DebugInfo] Respect fmodule-file-home-is-cwd in skeleton CUs for clang modules

Alex Langford via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 29 14:49:50 PDT 2022


bulbazord created this revision.
bulbazord added reviewers: rmaz, aprantl.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When `-fmodule-file-home-is-cwd` and the path to the PCM is relative, we shouldn't assume that the path to the PCM is relative to the modulemap that produced it. To respect the option `-fmodule-file-home-is-cwd`, we should assume the path is relative to the current working directory.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134911

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/Modules/module-file-home-is-cwd.m


Index: clang/test/Modules/module-file-home-is-cwd.m
===================================================================
--- clang/test/Modules/module-file-home-is-cwd.m
+++ 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: <INPUT_FILE {{.*}}/> blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map'
 // CHECK: <INPUT_FILE {{.*}}/> blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h'
 // CHECK: <INPUT_FILE {{.*}}/> blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h'
 // CHECK-NOT: MODULE_DIRECTORY
+
+ at 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"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2768,8 +2768,12 @@
 
     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(),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134911.464044.patch
Type: text/x-patch
Size: 2233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220929/7583ed1d/attachment-0001.bin>


More information about the cfe-commits mailing list