Fix memory leak by using unique_ptr

llvm-svn: 294823
This commit is contained in:
David Blaikie
2017-02-11 05:25:21 +00:00
parent fa3175f2f6
commit a67cf0001f
3 changed files with 11 additions and 11 deletions

View File

@@ -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<std::string> &IncludePaths,
ArrayRef<std::string> CommandLine, clang::ModuleMap *ModuleMap) {
std::unique_ptr<CoverageChecker> CoverageChecker::createCoverageChecker(
StringRef ModuleMapPath, std::vector<std::string> &IncludePaths,
ArrayRef<std::string> CommandLine, clang::ModuleMap *ModuleMap) {
return new CoverageChecker(ModuleMapPath, IncludePaths, CommandLine,
ModuleMap);
return llvm::make_unique<CoverageChecker>(ModuleMapPath, IncludePaths,
CommandLine, ModuleMap);
}
// Do checks.

View File

@@ -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<std::string> &IncludePaths,
llvm::ArrayRef<std::string> CommandLine,
clang::ModuleMap *ModuleMap);
static std::unique_ptr<CoverageChecker> createCoverageChecker(
llvm::StringRef ModuleMapPath, std::vector<std::string> &IncludePaths,
llvm::ArrayRef<std::string> CommandLine, clang::ModuleMap *ModuleMap);
/// Do checks.
/// Starting from the directory of the module.modulemap file,

View File

@@ -120,8 +120,9 @@ std::error_code ModularizeUtilities::doCoverageCheck(
std::error_code EC;
for (ModuleMapIndex = 0; ModuleMapIndex < ModuleMapCount; ++ModuleMapIndex) {
std::unique_ptr<clang::ModuleMap> &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;