================
@@ -0,0 +1,66 @@
+//===-- RealpathPrefixes.cpp 
----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/RealpathPrefixes.h"
+
+#include "lldb/Target/Statistics.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/FileSpecList.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+
+using namespace lldb_private;
+
+RealpathPrefixes::RealpathPrefixes(const FileSpecList &file_spec_list)
+    : m_fs(llvm::vfs::getRealFileSystem()), m_target(nullptr) {
+  m_prefixes.reserve(file_spec_list.GetSize());
+  for (const FileSpec &file_spec : file_spec_list) {
+    m_prefixes.emplace_back(file_spec.GetPath());
+  }
+}
+
+void RealpathPrefixes::SetFileSystem(
+    llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs) {
+  m_fs = fs;
+}
+
+std::optional<FileSpec>
+RealpathPrefixes::ResolveSymlinks(const FileSpec &file_spec) const {
+  if (m_prefixes.empty())
+    return std::nullopt;
+
+  auto is_prefix = [](llvm::StringRef a, llvm::StringRef b,
+                      bool case_sensitive) -> bool {
+    return case_sensitive ? a.consume_front(b) : 
a.consume_front_insensitive(b);
----------------
jimingham wrote:

I can't remember offhand what the source path mapping does - that's the most 
obvious analog.  If that does substitution into partial names when adjusting 
paths, it seems reasonable this do so as well.  But if it doesn't, then this 
probably shouldn't either.

https://github.com/llvm/llvm-project/pull/102223
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to