diff --git a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp index b5574ea41e332..7a8cad56f6f79 100644 --- a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp +++ b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp @@ -358,17 +358,19 @@ static void stubifyDirectory(const StringRef InputPath, Context &Ctx) { SmallString NormalizedPath(Path); replace_extension(NormalizedPath, ""); + auto [It, Inserted] = Dylibs.try_emplace(NormalizedPath.str()); + if ((IF->getFileType() == FileType::MachO_DynamicLibrary) || (IF->getFileType() == FileType::MachO_DynamicLibrary_Stub)) { OriginalNames[NormalizedPath.c_str()] = IF->getPath(); // Don't add this MachO dynamic library because we already have a // text-based stub recorded for this path. - if (Dylibs.count(NormalizedPath.c_str())) + if (!Inserted) continue; } - Dylibs[NormalizedPath.c_str()] = std::move(IF); + It->second = std::move(IF); } for (auto &Lib : Dylibs) {