}
}
-static Optional<StringRef> findLibrary(StringRef name) {
+static Optional<std::string> findLibrary(StringRef name) {
if (config->searchDylibsFirst) {
- if (Optional<StringRef> path = findPathCombination(
+ if (Optional<std::string> path = findPathCombination(
"lib" + name, config->librarySearchPaths, {".tbd", ".dylib"}))
return path;
return findPathCombination("lib" + name, config->librarySearchPaths,
static void addLibrary(StringRef name, bool isNeeded, bool isWeak,
bool isReexport, bool isExplicit, bool forceLoad) {
- if (Optional<StringRef> path = findLibrary(name)) {
+ if (Optional<std::string> path = findLibrary(name)) {
if (auto *dylibFile = dyn_cast_or_null<DylibFile>(
addFile(*path, forceLoad, isExplicit))) {
if (isNeeded)
// Search for all possible combinations of `{root}/{name}.{extension}`.
// If \p extensions are not specified, then just search for `{root}/{name}`.
-llvm::Optional<llvm::StringRef>
+llvm::Optional<std::string>
findPathCombination(const llvm::Twine &name,
const std::vector<llvm::StringRef> &roots,
ArrayRef<llvm::StringRef> extensions = {""});
// If -syslibroot is specified, absolute paths to non-object files may be
// rerooted.
-llvm::StringRef rerootPath(llvm::StringRef path);
+std::string rerootPath(llvm::StringRef path);
llvm::Optional<InputFile *> loadArchiveMember(MemoryBufferRef, uint32_t modTime,
StringRef archiveName,
return newFile;
}
-Optional<StringRef>
+Optional<std::string>
macho::findPathCombination(const Twine &name,
const std::vector<StringRef> &roots,
ArrayRef<StringRef> extensions) {
bool exists = fs::exists(location);
searchedDylib(location, exists);
if (exists)
- return saver.save(location.str());
+ return location.str();
}
}
return {};
}
-StringRef macho::rerootPath(StringRef path) {
+std::string macho::rerootPath(StringRef path) {
if (!path::is_absolute(path, path::Style::posix) || path.endswith(".o"))
- return path;
+ return std::string(path);
- if (Optional<StringRef> rerootedPath =
+ if (Optional<std::string> rerootedPath =
findPathCombination(path, config->systemLibraryRoots))
return *rerootedPath;
- return path;
+ return std::string(path);
}
Optional<InputFile *> macho::loadArchiveMember(MemoryBufferRef mb,