[lld] [lld] check cache in loadDylib before real_path (PR #143595)

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 12 01:39:02 PDT 2025


================
@@ -225,21 +225,44 @@ std::optional<StringRef> macho::resolveDylibPath(StringRef dylibPath) {
 // especially if it's a commonly re-exported core library.
 static DenseMap<CachedHashStringRef, DylibFile *> loadedDylibs;
 
+static StringRef realPathIfDifferent(StringRef path) {
+  SmallString<128> realPathBuf;
+  std::error_code err = fs::real_path(path, realPathBuf);
+  if (err)
----------------
zmodem wrote:

You could fold the call into the if, and since you're only using `err` to check its truthiness, you don't need to declare it:

```
if (fs::real_path(path, realPathBuf))
  return StringRef();
```

https://github.com/llvm/llvm-project/pull/143595


More information about the llvm-commits mailing list