@@ -76,22 +76,22 @@ static std::unique_ptr<DependencyIssueItem> createDiagnosticMessage( // NOLINT(m
7676}
7777
7878static void printDependencyError ( // NOLINT(misc-no-recursion)
79- std::unique_ptr< DependencyIssueItem> const & item,
80- std::ostream& stream,
81- size_t depth = 0
79+ DependencyIssueItem const & item,
80+ std::ostream& stream,
81+ size_t depth = 0
8282) {
8383 std::string indent (depth * 3 + 3 , ' ' );
84- if (item-> mContainsError ) {
85- stream << indent << fmt::format (" module: {}" , pl::utils::u8str2str (item-> mPath .u8string ())) << std::endl;
86- if (!item-> mMissingModule .empty ()) {
84+ if (item. mContainsError ) {
85+ stream << indent << fmt::format (" module: {}" , pl::utils::u8str2str (item. mPath .u8string ())) << std::endl;
86+ if (!item. mMissingModule .empty ()) {
8787 stream << indent << " missing module:" << std::endl;
88- for (const auto & missingModule : item-> mMissingModule ) {
88+ for (const auto & missingModule : item. mMissingModule ) {
8989 stream << indent << " |- " << missingModule << std::endl;
9090 }
9191 }
92- if (!item-> mMissingProcedure .empty ()) {
92+ if (!item. mMissingProcedure .empty ()) {
9393 stream << indent << " missing procedure:" << std::endl;
94- for (const auto & [module , missingProcedure] : item-> mMissingProcedure ) {
94+ for (const auto & [module , missingProcedure] : item. mMissingProcedure ) {
9595 stream << indent << " |- " << module << std::endl;
9696 for (const auto & procedure : missingProcedure) {
9797 stream << indent << " |---- " << procedure << std::endl;
@@ -101,24 +101,30 @@ static void printDependencyError( // NOLINT(misc-no-recursion)
101101 }
102102 }
103103 }
104- if (!item-> mDependencies .empty ()) {
105- for (const auto & [module , subItem] : item-> mDependencies ) {
106- printDependencyError (subItem, stream, depth + 1 );
104+ if (!item. mDependencies .empty ()) {
105+ for (const auto & [module , subItem] : item. mDependencies ) {
106+ printDependencyError (* subItem, stream, depth + 1 );
107107 }
108108 }
109109 }
110110}
111111
112- std::unique_ptr<DependencyIssueItem> pl::dependency_walker::pl_diagnostic_dependency (fs::path const & path) {
112+ static void deleteDependencyIssueItem (DependencyIssueItem* item) { delete item; }
113+
114+ std::unique_ptr<DependencyIssueItem, void (*)(DependencyIssueItem*)>
115+ pl::dependency_walker::pl_diagnostic_dependency (fs::path const & path) {
113116 auto libSearcher = LibrarySearcher::getInstance ();
114117 auto systemRoot = pl::utils::getSystemRoot ().u8string ();
115118 auto provider = std::make_unique<PortableExecutableProvider>(libSearcher, systemRoot, path);
116- return createDiagnosticMessage (path, std::move (provider), libSearcher, systemRoot);
119+ return {
120+ createDiagnosticMessage (path, std::move (provider), libSearcher, systemRoot).release (),
121+ deleteDependencyIssueItem
122+ };
117123}
118124
119125std::string pl::dependency_walker::pl_diagnostic_dependency_string (fs::path const & path) {
120126 auto result = pl_diagnostic_dependency (path);
121127 std::stringstream stream;
122- printDependencyError (result, stream);
128+ printDependencyError (* result, stream);
123129 return stream.str ();
124130}
0 commit comments