[llvm] [openmp] Revert "[Offload][OpenMP] remove SourceInfo::removePath (#226283)" (PR #226557)

Jason Van Beusekom via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 11:10:21 PDT 2026


https://github.com/Jason-Van-Beusekom created https://github.com/llvm/llvm-project/pull/226557

This reverts commit 5b8e65685b4fe99191a217bfa0527c51cf36925c.

In https://github.com/llvm/llvm-project/pull/226283 I forgot to update info.c to account for the full file paths in its output, will update commit with fixed test and re open PR

>From ca9bf420290fc4fb5c06d7b155602557c8d421f4 Mon Sep 17 00:00:00 2001
From: Jason Van Beusekom <jason.van-beusekom at hpe.com>
Date: Fri, 25 Sep 2026 13:07:37 -0500
Subject: [PATCH] Revert "[Offload][OpenMP] remove SourceInfo::removePath
 (#226283)"

This reverts commit 5b8e65685b4fe99191a217bfa0527c51cf36925c.
---
 offload/include/Shared/SourceInfo.h | 16 ++++++++++++++--
 openmp/docs/ReleaseNotes.md         |  3 ---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/offload/include/Shared/SourceInfo.h b/offload/include/Shared/SourceInfo.h
index e8dfb46c973e0..63488ff0e8cac 100644
--- a/offload/include/Shared/SourceInfo.h
+++ b/offload/include/Shared/SourceInfo.h
@@ -16,6 +16,12 @@
 #include <cstdint>
 #include <string>
 
+#ifdef _WIN32
+constexpr bool OSWindows = true;
+#else
+constexpr bool OSWindows = false;
+#endif
+
 /// Type alias for source location information for variable mappings with
 /// data layout ";name;filename;row;col;;\0" from clang.
 using map_var_info_t = void *;
@@ -69,15 +75,21 @@ class SourceInfo {
     return SourceStr.substr(Begin + 1, End - Begin - 1);
   };
 
+  /// Get the filename from a full path.
+  std::string removePath(const std::string &Path) const {
+    std::size_t Pos = (OSWindows) ? Path.rfind('\\') : Path.rfind('/');
+    return Path.substr(Pos + 1);
+  };
+
 public:
   SourceInfo(const ident_t *Loc)
       : SourceStr(initStr(Loc)), Name(getSubstring(1)),
-        Filename(getSubstring(0)), Line(std::stoi(getSubstring(2))),
+        Filename(removePath(getSubstring(0))), Line(std::stoi(getSubstring(2))),
         Column(std::stoi(getSubstring(3))) {}
 
   SourceInfo(const map_var_info_t Name)
       : SourceStr(initStr(Name)), Name(getSubstring(0)),
-        Filename(getSubstring(1)), Line(std::stoi(getSubstring(2))),
+        Filename(removePath(getSubstring(1))), Line(std::stoi(getSubstring(2))),
         Column(std::stoi(getSubstring(3))) {}
 
   const char *getName() const { return Name.c_str(); }
diff --git a/openmp/docs/ReleaseNotes.md b/openmp/docs/ReleaseNotes.md
index ada8321ed256c..ba597999938ac 100644
--- a/openmp/docs/ReleaseNotes.md
+++ b/openmp/docs/ReleaseNotes.md
@@ -18,9 +18,6 @@ from the [LLVM releases web site](https://llvm.org/releases/).
 - Removed the standalone build mode. It is redundant with the runtimes default
   build.
 
-- `LIBOMPTARGET_INFO` and offloading error messages now report the full path to
-  the source file instead of only the base filename
-
 ### Device Runtime
 
 - Changed the OpenMP DeviceRTL to use 'generic' IR. The



More information about the llvm-commits mailing list