From a67cf0001f5d24305f6c443da05266781c94de2e Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sat, 11 Feb 2017 05:25:21 +0000 Subject: [PATCH] Fix memory leak by using unique_ptr llvm-svn: 294823 --- clang-tools-extra/modularize/CoverageChecker.cpp | 10 +++++----- clang-tools-extra/modularize/CoverageChecker.h | 7 +++---- clang-tools-extra/modularize/ModularizeUtilities.cpp | 5 +++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/clang-tools-extra/modularize/CoverageChecker.cpp b/clang-tools-extra/modularize/CoverageChecker.cpp index 630ab55..510d062 100644 --- a/clang-tools-extra/modularize/CoverageChecker.cpp +++ b/clang-tools-extra/modularize/CoverageChecker.cpp @@ -150,12 +150,12 @@ CoverageChecker::CoverageChecker(StringRef ModuleMapPath, // Create instance of CoverageChecker, to simplify setting up // subordinate objects. -CoverageChecker *CoverageChecker::createCoverageChecker( - StringRef ModuleMapPath, std::vector &IncludePaths, - ArrayRef CommandLine, clang::ModuleMap *ModuleMap) { +std::unique_ptr CoverageChecker::createCoverageChecker( + StringRef ModuleMapPath, std::vector &IncludePaths, + ArrayRef CommandLine, clang::ModuleMap *ModuleMap) { - return new CoverageChecker(ModuleMapPath, IncludePaths, CommandLine, - ModuleMap); + return llvm::make_unique(ModuleMapPath, IncludePaths, + CommandLine, ModuleMap); } // Do checks. diff --git a/clang-tools-extra/modularize/CoverageChecker.h b/clang-tools-extra/modularize/CoverageChecker.h index a0e5f6f..f6c8367 100644 --- a/clang-tools-extra/modularize/CoverageChecker.h +++ b/clang-tools-extra/modularize/CoverageChecker.h @@ -91,10 +91,9 @@ public: /// \param CommandLine Compile command line arguments. /// \param ModuleMap The module map to check. /// \returns Initialized CoverageChecker object. - static CoverageChecker *createCoverageChecker( - llvm::StringRef ModuleMapPath, std::vector &IncludePaths, - llvm::ArrayRef CommandLine, - clang::ModuleMap *ModuleMap); + static std::unique_ptr createCoverageChecker( + llvm::StringRef ModuleMapPath, std::vector &IncludePaths, + llvm::ArrayRef CommandLine, clang::ModuleMap *ModuleMap); /// Do checks. /// Starting from the directory of the module.modulemap file, diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp index bb098da..874742d 100644 --- a/clang-tools-extra/modularize/ModularizeUtilities.cpp +++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp @@ -120,8 +120,9 @@ std::error_code ModularizeUtilities::doCoverageCheck( std::error_code EC; for (ModuleMapIndex = 0; ModuleMapIndex < ModuleMapCount; ++ModuleMapIndex) { std::unique_ptr &ModMap = ModuleMaps[ModuleMapIndex]; - CoverageChecker *Checker = CoverageChecker::createCoverageChecker( - InputFilePaths[ModuleMapIndex], IncludePaths, CommandLine, ModMap.get()); + auto Checker = CoverageChecker::createCoverageChecker( + InputFilePaths[ModuleMapIndex], IncludePaths, CommandLine, + ModMap.get()); std::error_code LocalEC = Checker->doChecks(); if (LocalEC.value() > 0) EC = LocalEC; -- 2.7.4