summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-09-27 11:24:26 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-09-27 11:25:11 (GMT)
commit068effa4d8ad2813499a6e79b056d79a2120e1ad (patch)
tree008fcbf88c2f6813542e83fb37a95e45c807b2d4
parentbb371753cb1d35c68060298ae5be6697144c9403 (diff)
parentf0489856e30b1b5236d1897071ea38dfde438fc7 (diff)
downloadCMake-068effa4d8ad2813499a6e79b056d79a2120e1ad.zip
CMake-068effa4d8ad2813499a6e79b056d79a2120e1ad.tar.gz
CMake-068effa4d8ad2813499a6e79b056d79a2120e1ad.tar.bz2
Merge topic 'auto_ptr'
f0489856 Retire std::auto_ptr and its macro CM_AUTO_PTR Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Pavel Solodovnikov <hellyeahdominate@gmail.com> Merge-request: !1300
-rw-r--r--.clang-tidy1
-rw-r--r--Help/dev/source.rst6
-rw-r--r--Source/CMakeLists.txt1
-rw-r--r--Source/CPack/cmCPackGenerator.cxx50
-rw-r--r--Source/CPack/cpack.cxx52
-rw-r--r--Source/CTest/cmCTestLaunch.cxx8
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx10
-rw-r--r--Source/CTest/cmCTestUpdateHandler.cxx19
-rw-r--r--Source/cmCTest.cxx15
-rw-r--r--Source/cmCryptoHash.cxx27
-rw-r--r--Source/cmCryptoHash.h5
-rw-r--r--Source/cmCustomCommandGenerator.cxx7
-rw-r--r--Source/cmELF.cxx13
-rw-r--r--Source/cmExportBuildAndroidMKGenerator.cxx4
-rw-r--r--Source/cmExportFileGenerator.cxx15
-rw-r--r--Source/cmExportLibraryDependenciesCommand.cxx14
-rw-r--r--Source/cmExportTryCompileFileGenerator.cxx4
-rw-r--r--Source/cmFileCommand.cxx23
-rw-r--r--Source/cmFindPackageCommand.cxx37
-rw-r--r--Source/cmForEachCommand.cxx9
-rw-r--r--Source/cmGeneratorExpression.cxx8
-rw-r--r--Source/cmGeneratorExpression.h7
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx14
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.h12
-rw-r--r--Source/cmGeneratorExpressionNode.cxx4
-rw-r--r--Source/cmGeneratorTarget.cxx47
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx2
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx11
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx10
-rw-r--r--Source/cmGraphVizWriter.cxx14
-rw-r--r--Source/cmIfCommand.cxx6
-rw-r--r--Source/cmInstallDirectoryGenerator.cxx5
-rw-r--r--Source/cmInstallFilesGenerator.cxx5
-rw-r--r--Source/cmInstalledFile.h4
-rw-r--r--Source/cmLocalNinjaGenerator.cxx4
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx8
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx4
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx4
-rw-r--r--Source/cmLocalVisualStudioGenerator.h8
-rw-r--r--Source/cmMakefile.cxx21
-rw-r--r--Source/cmMakefile.h13
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx12
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx14
-rw-r--r--Source/cmMakefileTargetGenerator.cxx8
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx10
-rw-r--r--Source/cmNinjaTargetGenerator.cxx8
-rw-r--r--Source/cmStringCommand.cxx6
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx50
-rw-r--r--Source/cmWhileCommand.cxx6
-rw-r--r--Source/cm_auto_ptr.hxx220
-rw-r--r--Source/cmake.cxx47
-rw-r--r--Source/cmcmd.cxx6
-rw-r--r--Utilities/IWYU/mapping.imp6
54 files changed, 353 insertions, 573 deletions
diff --git a/.clang-tidy b/.clang-tidy
index e8d39ce..a6e2597 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -10,7 +10,6 @@ modernize-*,\
-modernize-deprecated-headers,\
-modernize-pass-by-value,\
-modernize-raw-string-literal,\
--modernize-replace-auto-ptr,\
-modernize-use-auto,\
-modernize-use-default-member-init,\
-modernize-use-emplace,\
diff --git a/Help/dev/source.rst b/Help/dev/source.rst
index b40a884..96fc4a7 100644
--- a/Help/dev/source.rst
+++ b/Help/dev/source.rst
@@ -26,11 +26,9 @@ C++ Subset Permitted
CMake requires compiling as C++11 or above. However, in order to support
building on older toolchains some constructs need to be handled with care:
-* Do not use ``CM_AUTO_PTR`` or ``std::auto_ptr``.
+* Do not use ``std::auto_ptr``.
- The ``std::auto_ptr`` template is deprecated in C++11. The ``CM_AUTO_PTR``
- macro remains leftover from C++98 support until its uses can be ported to
- ``std::unique_ptr``. Do not add new uses of the macro.
+ The ``std::auto_ptr`` template is deprecated in C++11. Use ``std::unique_ptr``.
* Use ``CM_EQ_DELETE;`` instead of ``= delete;``.
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 9cd7b84..fdc6476 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -587,7 +587,6 @@ set(SRCS
cmWriteFileCommand.cxx
cmWriteFileCommand.h
- cm_auto_ptr.hxx
cm_get_date.h
cm_get_date.c
cm_utf8.h
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index f56b5fa..ecb5adb 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -6,6 +6,7 @@
#include "cmsys/Glob.hxx"
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
+#include <memory> // IWYU pragma: keep
#include <utility>
#include "cmCPackComponentGroup.h"
@@ -17,7 +18,6 @@
#include "cmStateSnapshot.h"
#include "cmWorkingDirectory.h"
#include "cmXMLSafe.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
#if defined(__HAIKU__)
@@ -156,7 +156,7 @@ int cmCPackGenerator::PrepareNames()
}
const char* algoSignature = this->GetOption("CPACK_PACKAGE_CHECKSUM");
if (algoSignature) {
- if (cmCryptoHash::New(algoSignature).get() == nullptr) {
+ if (!cmCryptoHash::New(algoSignature)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot recognize algorithm: "
<< algoSignature << std::endl);
return 0;
@@ -610,8 +610,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
cm.AddCMakePaths();
cm.SetProgressCallback(cmCPackGeneratorProgress, this);
cmGlobalGenerator gg(&cm);
- CM_AUTO_PTR<cmMakefile> mf(
- new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+ cmMakefile mf(&gg, cm.GetCurrentSnapshot());
if (!installSubDirectory.empty() && installSubDirectory != "/" &&
installSubDirectory != ".") {
tempInstallDirectory += installSubDirectory;
@@ -657,11 +656,11 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
if (this->GetOption("CPACK_INSTALL_PREFIX")) {
dir += this->GetOption("CPACK_INSTALL_PREFIX");
}
- mf->AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str());
+ mf.AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str());
cmCPackLogger(
cmCPackLog::LOG_DEBUG,
- "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf->AddDefinition)"
+ "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf.AddDefinition)"
<< std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'"
@@ -698,8 +697,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
return 0;
}
} else {
- mf->AddDefinition("CMAKE_INSTALL_PREFIX",
- tempInstallDirectory.c_str());
+ mf.AddDefinition("CMAKE_INSTALL_PREFIX",
+ tempInstallDirectory.c_str());
if (!cmsys::SystemTools::MakeDirectory(
tempInstallDirectory.c_str())) {
@@ -710,7 +709,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
}
cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Using non-DESTDIR install... (mf->AddDefinition)"
+ "- Using non-DESTDIR install... (mf.AddDefinition)"
<< std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Setting CMAKE_INSTALL_PREFIX to '"
@@ -718,19 +717,19 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
}
if (!buildConfig.empty()) {
- mf->AddDefinition("BUILD_TYPE", buildConfig.c_str());
+ mf.AddDefinition("BUILD_TYPE", buildConfig.c_str());
}
std::string installComponentLowerCase =
cmSystemTools::LowerCase(installComponent);
if (installComponentLowerCase != "all") {
- mf->AddDefinition("CMAKE_INSTALL_COMPONENT",
- installComponent.c_str());
+ mf.AddDefinition("CMAKE_INSTALL_COMPONENT",
+ installComponent.c_str());
}
// strip on TRUE, ON, 1, one or several file names, but not on
// FALSE, OFF, 0 and an empty string
if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES"))) {
- mf->AddDefinition("CMAKE_INSTALL_DO_STRIP", "1");
+ mf.AddDefinition("CMAKE_INSTALL_DO_STRIP", "1");
}
// Remember the list of files before installation
// of the current component (if we are in component install)
@@ -750,7 +749,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
// If CPack was asked to warn on ABSOLUTE INSTALL DESTINATION
// then forward request to cmake_install.cmake script
if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")) {
- mf->AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
+ mf.AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
}
// If current CPack generator does support
// ABSOLUTE INSTALL DESTINATION or CPack has been asked for
@@ -758,18 +757,17 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
// as soon as it occurs (before installing file)
if (!SupportsAbsoluteDestination() ||
this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) {
- mf->AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION",
- "1");
+ mf.AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
}
// do installation
- int res = mf->ReadListFile(installFile.c_str());
+ int res = mf.ReadListFile(installFile.c_str());
// forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES
// to CPack (may be used by generators like CPack RPM or DEB)
// in order to transparently handle ABSOLUTE PATH
- if (mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) {
- mf->AddDefinition(
+ if (mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) {
+ mf.AddDefinition(
"CPACK_ABSOLUTE_DESTINATION_FILES",
- mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"));
+ mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"));
}
// Now rebuild the list of files after installation
@@ -803,12 +801,12 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
}
}
- if (nullptr != mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
+ if (nullptr != mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
if (!absoluteDestFiles.empty()) {
absoluteDestFiles += ";";
}
absoluteDestFiles +=
- mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
+ mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Got some ABSOLUTE DESTINATION FILES: "
<< absoluteDestFiles << std::endl);
@@ -822,13 +820,13 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
this->GetOption(absoluteDestFileComponent);
absoluteDestFilesListComponent += ";";
absoluteDestFilesListComponent +=
- mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
+ mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
this->SetOption(absoluteDestFileComponent,
absoluteDestFilesListComponent.c_str());
} else {
this->SetOption(
absoluteDestFileComponent,
- mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
+ mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
}
}
}
@@ -964,7 +962,7 @@ int cmCPackGenerator::DoPackage()
/* Prepare checksum algorithm*/
const char* algo = this->GetOption("CPACK_PACKAGE_CHECKSUM");
- CM_AUTO_PTR<cmCryptoHash> crypto = cmCryptoHash::New(algo ? algo : "");
+ std::unique_ptr<cmCryptoHash> crypto = cmCryptoHash::New(algo ? algo : "");
/*
* Copy the generated packages to final destination
@@ -997,7 +995,7 @@ int cmCPackGenerator::DoPackage()
<< packageFileName << " generated." << std::endl);
/* Generate checksum file */
- if (crypto.get() != nullptr) {
+ if (crypto) {
std::string hashFile(this->GetOption("CPACK_OUTPUT_FILE_PREFIX"));
hashFile += "/" + filename;
hashFile += "." + cmSystemTools::LowerCase(algo);
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index cc51c60..f2c54fc 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -5,6 +5,7 @@
#include "cmsys/Encoding.hxx"
#include <iostream>
#include <map>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stddef.h>
#include <string>
@@ -24,7 +25,6 @@
#include "cmMakefile.h"
#include "cmStateSnapshot.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
static const char* cmDocumentationName[][2] = {
@@ -192,8 +192,7 @@ int main(int argc, char const* const* argv)
cminst.SetHomeOutputDirectory("");
cminst.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator cmgg(&cminst);
- CM_AUTO_PTR<cmMakefile> globalMF(
- new cmMakefile(&cmgg, cminst.GetCurrentSnapshot()));
+ cmMakefile globalMF(&cmgg, cminst.GetCurrentSnapshot());
#if defined(__CYGWIN__)
globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
#endif
@@ -225,16 +224,16 @@ int main(int argc, char const* const* argv)
// find out which system cpack is running on, so it can setup the search
// paths, so FIND_XXX() commands can be used in scripts
std::string systemFile =
- globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
- if (!globalMF->ReadListFile(systemFile.c_str())) {
+ globalMF.GetModulesFile("CMakeDetermineSystem.cmake");
+ if (!globalMF.ReadListFile(systemFile.c_str())) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error reading CMakeDetermineSystem.cmake" << std::endl);
return 1;
}
systemFile =
- globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
- if (!globalMF->ReadListFile(systemFile.c_str())) {
+ globalMF.GetModulesFile("CMakeSystemSpecificInformation.cmake");
+ if (!globalMF.ReadListFile(systemFile.c_str())) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error reading CMakeSystemSpecificInformation.cmake"
<< std::endl);
@@ -242,7 +241,7 @@ int main(int argc, char const* const* argv)
}
if (!cpackBuildConfig.empty()) {
- globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
+ globalMF.AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
}
if (cmSystemTools::FileExists(cpackConfigFile.c_str())) {
@@ -250,7 +249,7 @@ int main(int argc, char const* const* argv)
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Read CPack configuration file: " << cpackConfigFile
<< std::endl);
- if (!globalMF->ReadListFile(cpackConfigFile.c_str())) {
+ if (!globalMF.ReadListFile(cpackConfigFile.c_str())) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Problem reading CPack config file: \""
<< cpackConfigFile << "\"" << std::endl);
@@ -264,45 +263,44 @@ int main(int argc, char const* const* argv)
}
if (!generator.empty()) {
- globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str());
+ globalMF.AddDefinition("CPACK_GENERATOR", generator.c_str());
}
if (!cpackProjectName.empty()) {
- globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
+ globalMF.AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
}
if (!cpackProjectVersion.empty()) {
- globalMF->AddDefinition("CPACK_PACKAGE_VERSION",
- cpackProjectVersion.c_str());
+ globalMF.AddDefinition("CPACK_PACKAGE_VERSION",
+ cpackProjectVersion.c_str());
}
if (!cpackProjectVendor.empty()) {
- globalMF->AddDefinition("CPACK_PACKAGE_VENDOR",
- cpackProjectVendor.c_str());
+ globalMF.AddDefinition("CPACK_PACKAGE_VENDOR",
+ cpackProjectVendor.c_str());
}
// if this is not empty it has been set on the command line
// go for it. Command line override values set in config file.
if (!cpackProjectDirectory.empty()) {
- globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
- cpackProjectDirectory.c_str());
+ globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY",
+ cpackProjectDirectory.c_str());
}
// The value has not been set on the command line
else {
// get a default value (current working directory)
cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory();
// use default value iff no value has been provided by the config file
- if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY")) {
- globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
- cpackProjectDirectory.c_str());
+ if (!globalMF.IsSet("CPACK_PACKAGE_DIRECTORY")) {
+ globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY",
+ cpackProjectDirectory.c_str());
}
}
for (auto const& cd : definitions.Map) {
- globalMF->AddDefinition(cd.first, cd.second.c_str());
+ globalMF.AddDefinition(cd.first, cd.second.c_str());
}
- const char* cpackModulesPath =
- globalMF->GetDefinition("CPACK_MODULE_PATH");
+ const char* cpackModulesPath = globalMF.GetDefinition("CPACK_MODULE_PATH");
if (cpackModulesPath) {
- globalMF->AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
+ globalMF.AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
}
- const char* genList = globalMF->GetDefinition("CPACK_GENERATOR");
+ const char* genList = globalMF.GetDefinition("CPACK_GENERATOR");
if (!genList) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified"
<< std::endl);
@@ -310,8 +308,8 @@ int main(int argc, char const* const* argv)
std::vector<std::string> generatorsVector;
cmSystemTools::ExpandListArgument(genList, generatorsVector);
for (std::string const& gen : generatorsVector) {
- cmMakefile::ScopePushPop raii(globalMF.get());
- cmMakefile* mf = globalMF.get();
+ cmMakefile::ScopePushPop raii(&globalMF);
+ cmMakefile* mf = &globalMF;
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Specified generator: " << gen << std::endl);
if (parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME")) {
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index 453ae99..a1249f5 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -6,6 +6,7 @@
#include "cmsys/Process.h"
#include "cmsys/RegularExpression.hxx"
#include <iostream>
+#include <memory> // IWYU pragma: keep
#include <stdlib.h>
#include <string.h>
@@ -17,7 +18,6 @@
#include "cmStateSnapshot.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
#ifdef _WIN32
@@ -626,12 +626,12 @@ void cmCTestLaunch::LoadConfig()
cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm);
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+ cmMakefile mf(&gg, cm.GetCurrentSnapshot());
std::string fname = this->LogDir;
fname += "CTestLaunchConfig.cmake";
if (cmSystemTools::FileExists(fname.c_str()) &&
- mf->ReadListFile(fname.c_str())) {
- this->SourceDir = mf->GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
+ mf.ReadListFile(fname.c_str())) {
+ this->SourceDir = mf.GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
cmSystemTools::ConvertToUnixSlashes(this->SourceDir);
}
}
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 5896014..c7ed927 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -8,6 +8,7 @@
#include <functional>
#include <iomanip>
#include <iterator>
+#include <memory> // IWYU pragma: keep
#include <set>
#include <sstream>
#include <stdio.h>
@@ -28,7 +29,6 @@
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
#include "cmXMLWriter.h"
-#include "cm_auto_ptr.hxx"
#include "cm_utf8.h"
#include "cmake.h"
#include "cmsys/FStream.hxx"
@@ -1636,9 +1636,9 @@ void cmCTestTestHandler::GetListOfTests()
cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm);
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
- mf->AddDefinition("CTEST_CONFIGURATION_TYPE",
- this->CTest->GetConfigType().c_str());
+ cmMakefile mf(&gg, cm.GetCurrentSnapshot());
+ mf.AddDefinition("CTEST_CONFIGURATION_TYPE",
+ this->CTest->GetConfigType().c_str());
// Add handler for ADD_TEST
cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand;
@@ -1678,7 +1678,7 @@ void cmCTestTestHandler::GetListOfTests()
return;
}
- if (!mf->ReadListFile(testFilename)) {
+ if (!mf.ReadListFile(testFilename)) {
return;
}
if (cmSystemTools::GetErrorOccuredFlag()) {
diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx
index 7173439..786ed5e 100644
--- a/Source/CTest/cmCTestUpdateHandler.cxx
+++ b/Source/CTest/cmCTestUpdateHandler.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestUpdateHandler.h"
+#include "cmAlgorithms.h"
#include "cmCLocaleEnvironmentScope.h"
#include "cmCTest.h"
#include "cmCTestBZR.h"
@@ -16,7 +17,7 @@
#include "cmVersion.h"
#include "cmXMLWriter.h"
-#include "cm_auto_ptr.hxx"
+#include <memory> // IWYU pragma: keep
#include <sstream>
static const char* cmCTestUpdateHandlerUpdateStrings[] = {
@@ -134,28 +135,28 @@ int cmCTestUpdateHandler::ProcessHandler()
, this->Quiet);
// Create an object to interact with the VCS tool.
- CM_AUTO_PTR<cmCTestVC> vc;
+ std::unique_ptr<cmCTestVC> vc;
switch (this->UpdateType) {
case e_CVS:
- vc.reset(new cmCTestCVS(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestCVS>(this->CTest, ofs);
break;
case e_SVN:
- vc.reset(new cmCTestSVN(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestSVN>(this->CTest, ofs);
break;
case e_BZR:
- vc.reset(new cmCTestBZR(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestBZR>(this->CTest, ofs);
break;
case e_GIT:
- vc.reset(new cmCTestGIT(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestGIT>(this->CTest, ofs);
break;
case e_HG:
- vc.reset(new cmCTestHG(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestHG>(this->CTest, ofs);
break;
case e_P4:
- vc.reset(new cmCTestP4(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestP4>(this->CTest, ofs);
break;
default:
- vc.reset(new cmCTestVC(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestVC>(this->CTest, ofs);
break;
}
vc->SetCommandLineTool(this->UpdateCommand);
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index ba50986..e248219 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -15,6 +15,7 @@
#include <ctype.h>
#include <iostream>
#include <map>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
@@ -50,7 +51,6 @@
#include "cmVersion.h"
#include "cmVersionConfig.h"
#include "cmXMLWriter.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
#if defined(__BEOS__) || defined(__HAIKU__)
@@ -421,9 +421,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm);
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
- if (!this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(),
- mf.get())) {
+ cmMakefile mf(&gg, cm.GetCurrentSnapshot());
+ if (!this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), &mf)) {
cmCTestOptionalLog(
this, DEBUG, "Cannot find custom configuration file tree" << std::endl,
quiet);
@@ -1123,9 +1122,9 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
*log << "* Run internal CTest" << std::endl;
}
- CM_AUTO_PTR<cmSystemTools::SaveRestoreEnvironment> saveEnv;
+ std::unique_ptr<cmSystemTools::SaveRestoreEnvironment> saveEnv;
if (modifyEnv) {
- saveEnv.reset(new cmSystemTools::SaveRestoreEnvironment);
+ saveEnv = cm::make_unique<cmSystemTools::SaveRestoreEnvironment>();
cmSystemTools::AppendEnv(*environment);
}
@@ -1150,9 +1149,9 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
output->clear();
}
- CM_AUTO_PTR<cmSystemTools::SaveRestoreEnvironment> saveEnv;
+ std::unique_ptr<cmSystemTools::SaveRestoreEnvironment> saveEnv;
if (modifyEnv) {
- saveEnv.reset(new cmSystemTools::SaveRestoreEnvironment);
+ saveEnv = cm::make_unique<cmSystemTools::SaveRestoreEnvironment>();
cmSystemTools::AppendEnv(*environment);
}
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx
index 965f55b..d914eb1 100644
--- a/Source/cmCryptoHash.cxx
+++ b/Source/cmCryptoHash.cxx
@@ -2,11 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCryptoHash.h"
+#include "cmAlgorithms.h"
#include "cm_kwiml.h"
#include "cm_rhash.h"
#include "cmsys/FStream.hxx"
#include <string.h>
+#include <memory> // IWYU pragma: keep
+
static unsigned int const cmCryptoHashAlgoToId[] = {
/* clang-format needs this comment to break after the opening brace */
RHASH_MD5, //
@@ -43,39 +46,39 @@ cmCryptoHash::~cmCryptoHash()
rhash_free(this->CTX);
}
-CM_AUTO_PTR<cmCryptoHash> cmCryptoHash::New(const char* algo)
+std::unique_ptr<cmCryptoHash> cmCryptoHash::New(const char* algo)
{
if (strcmp(algo, "MD5") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoMD5));
+ return cm::make_unique<cmCryptoHash>(AlgoMD5);
}
if (strcmp(algo, "SHA1") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA1));
+ return cm::make_unique<cmCryptoHash>(AlgoSHA1);
}
if (strcmp(algo, "SHA224") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA224));
+ return cm::make_unique<cmCryptoHash>(AlgoSHA224);
}
if (strcmp(algo, "SHA256") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA256));
+ return cm::make_unique<cmCryptoHash>(AlgoSHA256);
}
if (strcmp(algo, "SHA384") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA384));
+ return cm::make_unique<cmCryptoHash>(AlgoSHA384);
}
if (strcmp(algo, "SHA512") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA512));
+ return cm::make_unique<cmCryptoHash>(AlgoSHA512);
}
if (strcmp(algo, "SHA3_224") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_224));
+ return cm::make_unique<cmCryptoHash>(AlgoSHA3_224);
}
if (strcmp(algo, "SHA3_256") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_256));
+ return cm::make_unique<cmCryptoHash>(AlgoSHA3_256);
}
if (strcmp(algo, "SHA3_384") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_384));
+ return cm::make_unique<cmCryptoHash>(AlgoSHA3_384);
}
if (strcmp(algo, "SHA3_512") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_512));
+ return cm::make_unique<cmCryptoHash>(AlgoSHA3_512);
}
- return CM_AUTO_PTR<cmCryptoHash>(nullptr);
+ return std::unique_ptr<cmCryptoHash>(nullptr);
}
bool cmCryptoHash::IntFromHexDigit(char input, char& output)
diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h
index 9c13968..1f2a1b5 100644
--- a/Source/cmCryptoHash.h
+++ b/Source/cmCryptoHash.h
@@ -5,12 +5,11 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <memory> // IWYU pragma: keep
#include <stddef.h>
#include <string>
#include <vector>
-#include "cm_auto_ptr.hxx"
-
/**
* @brief Abstract base class for cryptographic hash generators
*/
@@ -42,7 +41,7 @@ public:
/// SHA3_224, SHA3_256, SHA3_384, SHA3_512
/// @return A valid auto pointer if algo is supported or
/// an invalid/NULL pointer otherwise
- static CM_AUTO_PTR<cmCryptoHash> New(const char* algo);
+ static std::unique_ptr<cmCryptoHash> New(const char* algo);
/// @brief Converts a hex character to its binary value (4 bits)
/// @arg input Hex character [0-9a-fA-F].
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index ff62a60..3d816d5 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -11,8 +11,8 @@
#include "cmOutputConverter.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
+#include <memory> // IWYU pragma: keep
#include <stddef.h>
cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
@@ -29,7 +29,8 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
for (cmCustomCommandLine const& cmdline : cmdlines) {
cmCustomCommandLine argv;
for (std::string const& clarg : cmdline) {
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(clarg);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
+ this->GE->Parse(clarg);
std::string parsed_arg = cge->Evaluate(this->LG, this->Config);
if (this->CC.GetCommandExpandLists()) {
std::vector<std::string> ExpandedArg;
@@ -44,7 +45,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
std::vector<std::string> depends = this->CC.GetDepends();
for (std::string const& d : depends) {
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(d);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = this->GE->Parse(d);
std::vector<std::string> result;
cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config),
result);
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index 2d6d8f9..76374b2 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -2,10 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmELF.h"
-#include "cm_auto_ptr.hxx"
#include "cm_kwiml.h"
#include "cmsys/FStream.hxx"
#include <map>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stddef.h>
#include <utility>
@@ -108,7 +108,7 @@ public:
};
// Construct and take ownership of the file stream object.
- cmELFInternal(cmELF* external, CM_AUTO_PTR<cmsys::ifstream>& fin,
+ cmELFInternal(cmELF* external, std::unique_ptr<cmsys::ifstream>& fin,
ByteOrderType order)
: External(external)
, Stream(*fin.release())
@@ -231,7 +231,7 @@ public:
typedef typename Types::tagtype tagtype;
// Construct with a stream and byte swap indicator.
- cmELFInternalImpl(cmELF* external, CM_AUTO_PTR<cmsys::ifstream>& fin,
+ cmELFInternalImpl(cmELF* external, std::unique_ptr<cmsys::ifstream>& fin,
ByteOrderType order);
// Return the number of sections as specified by the ELF header.
@@ -424,9 +424,8 @@ private:
};
template <class Types>
-cmELFInternalImpl<Types>::cmELFInternalImpl(cmELF* external,
- CM_AUTO_PTR<cmsys::ifstream>& fin,
- ByteOrderType order)
+cmELFInternalImpl<Types>::cmELFInternalImpl(
+ cmELF* external, std::unique_ptr<cmsys::ifstream>& fin, ByteOrderType order)
: cmELFInternal(external, fin, order)
{
// Read the main header.
@@ -682,7 +681,7 @@ cmELF::cmELF(const char* fname)
: Internal(nullptr)
{
// Try to open the file.
- CM_AUTO_PTR<cmsys::ifstream> fin(new cmsys::ifstream(fname));
+ std::unique_ptr<cmsys::ifstream> fin(new cmsys::ifstream(fname));
// Quit now if the file could not be opened.
if (!fin.get() || !*fin) {
diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx
index b5b7214..5e2cd53 100644
--- a/Source/cmExportBuildAndroidMKGenerator.cxx
+++ b/Source/cmExportBuildAndroidMKGenerator.cxx
@@ -3,6 +3,7 @@
#include "cmExportBuildAndroidMKGenerator.h"
#include <algorithm>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <utility>
@@ -15,7 +16,6 @@
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
cmExportBuildAndroidMKGenerator::cmExportBuildAndroidMKGenerator()
@@ -126,7 +126,7 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
// evaluate any generator expressions with the current
// build type of the makefile
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(lib);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(lib);
std::string evaluated =
cge->Evaluate(target->GetLocalGenerator(), config);
bool relpath = false;
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index e729632..7f0cb97 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -17,9 +17,9 @@
#include "cmTargetExport.h"
#include "cmake.h"
-#include "cm_auto_ptr.hxx"
#include "cmsys/FStream.hxx"
#include <assert.h>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <string.h>
#include <utility>
@@ -65,18 +65,17 @@ const char* cmExportFileGenerator::GetMainExportFileName() const
bool cmExportFileGenerator::GenerateImportFile()
{
// Open the output file to generate it.
- CM_AUTO_PTR<cmsys::ofstream> foutPtr;
+ std::unique_ptr<cmsys::ofstream> foutPtr;
if (this->AppendMode) {
// Open for append.
- CM_AUTO_PTR<cmsys::ofstream> ap(
- new cmsys::ofstream(this->MainImportFile.c_str(), std::ios::app));
- foutPtr = ap;
+ foutPtr = cm::make_unique<cmsys::ofstream>(this->MainImportFile.c_str(),
+ std::ios::app);
} else {
// Generate atomically and with copy-if-different.
- CM_AUTO_PTR<cmGeneratedFileStream> ap(
+ std::unique_ptr<cmGeneratedFileStream> ap(
new cmGeneratedFileStream(this->MainImportFile.c_str(), true));
ap->SetCopyIfDifferent(true);
- foutPtr = ap;
+ foutPtr = std::move(ap);
}
if (!foutPtr.get() || !*foutPtr) {
std::string se = cmSystemTools::GetLastSystemError();
@@ -372,7 +371,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
std::string dirs = cmGeneratorExpression::Preprocess(
tei->InterfaceIncludeDirectories, preprocessRule, true);
this->ReplaceInstallPrefix(dirs);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
std::string exportDirs =
cge->Evaluate(target->GetLocalGenerator(), "", false, target);
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx
index cf12d33..50f8cb0 100644
--- a/Source/cmExportLibraryDependenciesCommand.cxx
+++ b/Source/cmExportLibraryDependenciesCommand.cxx
@@ -4,8 +4,10 @@
#include "cmsys/FStream.hxx"
#include <map>
+#include <memory> // IWYU pragma: keep
#include <utility>
+#include "cmAlgorithms.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
@@ -13,7 +15,6 @@
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetLinkLibraryType.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
class cmExecutionStatus;
@@ -47,16 +48,15 @@ void cmExportLibraryDependenciesCommand::FinalPass()
void cmExportLibraryDependenciesCommand::ConstFinalPass() const
{
// Use copy-if-different if not appending.
- CM_AUTO_PTR<cmsys::ofstream> foutPtr;
+ std::unique_ptr<cmsys::ofstream> foutPtr;
if (this->Append) {
- CM_AUTO_PTR<cmsys::ofstream> ap(
- new cmsys::ofstream(this->Filename.c_str(), std::ios::app));
- foutPtr = ap;
+ foutPtr =
+ cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), std::ios::app);
} else {
- CM_AUTO_PTR<cmGeneratedFileStream> ap(
+ std::unique_ptr<cmGeneratedFileStream> ap(
new cmGeneratedFileStream(this->Filename.c_str(), true));
ap->SetCopyIfDifferent(true);
- foutPtr = ap;
+ foutPtr = std::move(ap);
}
std::ostream& fout = *foutPtr;
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index 3e3fea1..1fb9cf8 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -11,9 +11,9 @@
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cm_auto_ptr.hxx"
#include <map>
+#include <memory> // IWYU pragma: keep
#include <utility>
cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator(
@@ -65,7 +65,7 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
cmGeneratorExpressionDAGChecker dagChecker(tgt->GetName(), propName, nullptr,
nullptr);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
cmTarget dummyHead("try_compile_dummy_exe", cmStateEnums::EXECUTABLE,
cmTarget::VisibilityNormal, tgt->Target->GetMakefile());
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 98c5733..f06ef43 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -10,6 +10,7 @@
#include "cmsys/String.hxx"
#include <algorithm>
#include <assert.h>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
@@ -30,7 +31,6 @@
#include "cmPolicies.h"
#include "cmSystemTools.h"
#include "cmTimestamp.h"
-#include "cm_auto_ptr.hxx"
#include "cm_sys_stat.h"
#include "cmake.h"
@@ -368,8 +368,8 @@ bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
return false;
}
- CM_AUTO_PTR<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
- if (hash.get()) {
+ std::unique_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
+ if (hash) {
std::string out = hash->HashFile(args[1]);
if (!out.empty()) {
this->Makefile->AddDefinition(args[2], out.c_str());
@@ -2629,7 +2629,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
const char* cainfo = this->Makefile->GetDefinition("CMAKE_TLS_CAINFO");
std::string expectedHash;
std::string hashMatchMSG;
- CM_AUTO_PTR<cmCryptoHash> hash;
+ std::unique_ptr<cmCryptoHash> hash;
bool showProgress = false;
std::string userpwd;
@@ -2688,8 +2688,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
this->SetError("DOWNLOAD missing sum value for EXPECTED_MD5.");
return false;
}
- hash =
- CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(cmCryptoHash::AlgoMD5));
+ hash = cm::make_unique<cmCryptoHash>(cmCryptoHash::AlgoMD5);
hashMatchMSG = "MD5 sum";
expectedHash = cmSystemTools::LowerCase(*i);
} else if (*i == "SHOW_PROGRESS") {
@@ -2710,7 +2709,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
}
std::string algo = i->substr(0, pos);
expectedHash = cmSystemTools::LowerCase(i->substr(pos + 1));
- hash = CM_AUTO_PTR<cmCryptoHash>(cmCryptoHash::New(algo.c_str()));
+ hash = std::unique_ptr<cmCryptoHash>(cmCryptoHash::New(algo.c_str()));
if (!hash.get()) {
std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: ";
err += algo;
@@ -2906,7 +2905,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// Verify MD5 sum if requested:
//
- if (hash.get()) {
+ if (hash) {
std::string actualHash = hash->HashFile(file);
if (actualHash.empty()) {
this->SetError("DOWNLOAD cannot compute hash on downloaded file");
@@ -3195,15 +3194,15 @@ void cmFileCommand::AddEvaluationFile(const std::string& inputName,
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression outputGe(lfbt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> outputCge =
+ std::unique_ptr<cmCompiledGeneratorExpression> outputCge =
outputGe.Parse(outputExpr);
cmGeneratorExpression conditionGe(lfbt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> conditionCge =
+ std::unique_ptr<cmCompiledGeneratorExpression> conditionCge =
conditionGe.Parse(condition);
- this->Makefile->AddEvaluationFile(inputName, outputCge, conditionCge,
- inputIsContent);
+ this->Makefile->AddEvaluationFile(inputName, std::move(outputCge),
+ std::move(conditionCge), inputIsContent);
}
bool cmFileCommand::HandleGenerateCommand(std::vector<std::string> const& args)
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index cd55e89..5a72655 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -13,6 +13,7 @@
#include <deque>
#include <functional>
#include <iterator>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdio.h>
#include <string.h>
@@ -24,7 +25,6 @@
#include "cmState.h"
#include "cmStateTypes.h"
#include "cmVersion.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
#if defined(__HAIKU__)
@@ -1611,10 +1611,10 @@ protected:
private:
bool Search(cmFileList&);
virtual bool Search(std::string const& parent, cmFileList&) = 0;
- virtual CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const = 0;
+ virtual std::unique_ptr<cmFileListGeneratorBase> Clone() const = 0;
friend class cmFileList;
cmFileListGeneratorBase* SetNext(cmFileListGeneratorBase const& next);
- CM_AUTO_PTR<cmFileListGeneratorBase> Next;
+ std::unique_ptr<cmFileListGeneratorBase> Next;
};
class cmFileList
@@ -1638,7 +1638,7 @@ public:
}
bool Search()
{
- if (this->First.get()) {
+ if (this->First) {
return this->First->Search(*this);
}
return false;
@@ -1647,7 +1647,7 @@ public:
private:
virtual bool Visit(std::string const& fullPath) = 0;
friend class cmFileListGeneratorBase;
- CM_AUTO_PTR<cmFileListGeneratorBase> First;
+ std::unique_ptr<cmFileListGeneratorBase> First;
cmFileListGeneratorBase* Last;
};
@@ -1688,7 +1688,7 @@ cmFileListGeneratorBase* cmFileListGeneratorBase::SetNext(
bool cmFileListGeneratorBase::Consider(std::string const& fullPath,
cmFileList& listing)
{
- if (this->Next.get()) {
+ if (this->Next) {
return this->Next->Search(fullPath + "/", listing);
}
return listing.Visit(fullPath + "/");
@@ -1715,9 +1715,9 @@ private:
std::string fullPath = parent + this->String;
return this->Consider(fullPath, lister);
}
- CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const override
+ std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{
- CM_AUTO_PTR<cmFileListGeneratorBase> g(
+ std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorFixed(*this));
return g;
}
@@ -1748,9 +1748,9 @@ private:
}
return false;
}
- CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const override
+ std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{
- CM_AUTO_PTR<cmFileListGeneratorBase> g(
+ std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorEnumerate(*this));
return g;
}
@@ -1820,9 +1820,9 @@ private:
}
return false;
}
- CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const override
+ std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{
- CM_AUTO_PTR<cmFileListGeneratorBase> g(
+ std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorProject(*this));
return g;
}
@@ -1874,9 +1874,9 @@ private:
}
return false;
}
- CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const override
+ std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{
- CM_AUTO_PTR<cmFileListGeneratorBase> g(
+ std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorMacProject(*this));
return g;
}
@@ -1918,9 +1918,9 @@ private:
}
return false;
}
- CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const override
+ std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{
- CM_AUTO_PTR<cmFileListGeneratorBase> g(
+ std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorCaseInsensitive(*this));
return g;
}
@@ -1963,10 +1963,9 @@ private:
}
return false;
}
- CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const override
+ std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{
- CM_AUTO_PTR<cmFileListGeneratorBase> g(new cmFileListGeneratorGlob(*this));
- return g;
+ return cm::make_unique<cmFileListGeneratorGlob>(*this);
}
};
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 37387b0..542a860 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmForEachCommand.h"
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
@@ -9,7 +10,6 @@
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf)
@@ -35,7 +35,8 @@ bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// if this is the endofreach for this statement
if (!this->Depth) {
// Remove the function blocker for this scope or bail.
- CM_AUTO_PTR<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff));
+ std::unique_ptr<cmFunctionBlocker> fb(
+ mf.RemoveFunctionBlocker(this, lff));
if (!fb.get()) {
return false;
}
@@ -181,7 +182,7 @@ bool cmForEachCommand::InitialPass(std::vector<std::string> const& args,
bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
{
- CM_AUTO_PTR<cmForEachFunctionBlocker> f(
+ std::unique_ptr<cmForEachFunctionBlocker> f(
new cmForEachFunctionBlocker(this->Makefile));
f->Args.push_back(args[0]);
@@ -213,7 +214,7 @@ bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
}
}
- this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr
+ this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass unique_ptr
return true;
}
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index d4b501f..86991c1 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -3,6 +3,7 @@
#include "cmGeneratorExpression.h"
#include "cmsys/RegularExpression.hxx"
+#include <memory> // IWYU pragma: keep
#include <utility>
#include "assert.h"
@@ -12,7 +13,6 @@
#include "cmGeneratorExpressionLexer.h"
#include "cmGeneratorExpressionParser.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
cmGeneratorExpression::cmGeneratorExpression(
const cmListFileBacktrace& backtrace)
@@ -20,14 +20,14 @@ cmGeneratorExpression::cmGeneratorExpression(
{
}
-CM_AUTO_PTR<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
+std::unique_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
std::string const& input)
{
- return CM_AUTO_PTR<cmCompiledGeneratorExpression>(
+ return std::unique_ptr<cmCompiledGeneratorExpression>(
new cmCompiledGeneratorExpression(this->Backtrace, input));
}
-CM_AUTO_PTR<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
+std::unique_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
const char* input)
{
return this->Parse(std::string(input ? input : ""));
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index d22a191..cface0d 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -7,8 +7,8 @@
#include "cmListFileCache.h"
-#include "cm_auto_ptr.hxx"
#include <map>
+#include <memory> // IWYU pragma: keep
#include <set>
#include <string>
#include <vector>
@@ -39,8 +39,9 @@ public:
cmListFileBacktrace const& backtrace = cmListFileBacktrace());
~cmGeneratorExpression();
- CM_AUTO_PTR<cmCompiledGeneratorExpression> Parse(std::string const& input);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> Parse(const char* input);
+ std::unique_ptr<cmCompiledGeneratorExpression> Parse(
+ std::string const& input);
+ std::unique_ptr<cmCompiledGeneratorExpression> Parse(const char* input);
enum PreprocessContext
{
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index ace9609..87b6b34 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -3,6 +3,7 @@
#include "cmGeneratorExpressionEvaluationFile.h"
#include "cmsys/FStream.hxx"
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <utility>
@@ -13,17 +14,16 @@
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile(
const std::string& input,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> outputFileExpr,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent,
- cmPolicies::PolicyStatus policyStatusCMP0070)
+ std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr,
+ std::unique_ptr<cmCompiledGeneratorExpression> condition,
+ bool inputIsContent, cmPolicies::PolicyStatus policyStatusCMP0070)
: Input(input)
- , OutputFileExpr(outputFileExpr)
- , Condition(condition)
+ , OutputFileExpr(std::move(outputFileExpr))
+ , Condition(std::move(condition))
, InputIsContent(inputIsContent)
, PolicyStatusCMP0070(policyStatusCMP0070)
{
@@ -144,7 +144,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
cmListFileBacktrace lfbt = this->OutputFileExpr->GetBacktrace();
cmGeneratorExpression contentGE(lfbt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> inputExpression =
+ std::unique_ptr<cmCompiledGeneratorExpression> inputExpression =
contentGE.Parse(inputContent);
std::map<std::string, std::string> outputFiles;
diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h
index ecf919d..2a79069 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.h
+++ b/Source/cmGeneratorExpressionEvaluationFile.h
@@ -6,12 +6,12 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
+#include <memory> // IWYU pragma: keep
#include <string>
#include <vector>
#include "cmGeneratorExpression.h"
#include "cmPolicies.h"
-#include "cm_auto_ptr.hxx"
#include "cm_sys_stat.h"
class cmLocalGenerator;
@@ -21,9 +21,9 @@ class cmGeneratorExpressionEvaluationFile
public:
cmGeneratorExpressionEvaluationFile(
const std::string& input,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> outputFileExpr,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent,
- cmPolicies::PolicyStatus policyStatusCMP0070);
+ std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr,
+ std::unique_ptr<cmCompiledGeneratorExpression> condition,
+ bool inputIsContent, cmPolicies::PolicyStatus policyStatusCMP0070);
void Generate(cmLocalGenerator* lg);
@@ -47,8 +47,8 @@ private:
private:
const std::string Input;
- const CM_AUTO_PTR<cmCompiledGeneratorExpression> OutputFileExpr;
- const CM_AUTO_PTR<cmCompiledGeneratorExpression> Condition;
+ const std::unique_ptr<cmCompiledGeneratorExpression> OutputFileExpr;
+ const std::unique_ptr<cmCompiledGeneratorExpression> Condition;
std::vector<std::string> Files;
const bool InputIsContent;
cmPolicies::PolicyStatus PolicyStatusCMP0070;
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 8f32410..fea20ba 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -17,7 +17,6 @@
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
#include "cmsys/RegularExpression.hxx"
@@ -26,6 +25,7 @@
#include <assert.h>
#include <errno.h>
#include <map>
+#include <memory> // IWYU pragma: keep
#include <set>
#include <sstream>
#include <stdlib.h>
@@ -39,7 +39,7 @@ std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
cmGeneratorExpressionDAGChecker* dagChecker)
{
cmGeneratorExpression ge(context->Backtrace);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem);
std::string result =
cge->Evaluate(lg, context->Config, context->Quiet, headTarget,
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 28b43e7..ea41204e 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -7,6 +7,7 @@
#include <assert.h>
#include <errno.h>
#include <iterator>
+#include <memory> // IWYU pragma: keep
#include <queue>
#include <sstream>
#include <stdio.h>
@@ -32,7 +33,6 @@
#include "cmTarget.h"
#include "cmTargetLinkLibraryType.h"
#include "cmTargetPropertyComputer.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
class cmMessenger;
@@ -64,13 +64,13 @@ class cmGeneratorTarget::TargetPropertyEntry
static cmLinkImplItem NoLinkImplItem;
public:
- TargetPropertyEntry(CM_AUTO_PTR<cmCompiledGeneratorExpression> cge,
+ TargetPropertyEntry(std::unique_ptr<cmCompiledGeneratorExpression> cge,
cmLinkImplItem const& item = NoLinkImplItem)
- : ge(cge)
+ : ge(std::move(cge))
, LinkImplItem(item)
{
}
- const CM_AUTO_PTR<cmCompiledGeneratorExpression> ge;
+ const std::unique_ptr<cmCompiledGeneratorExpression> ge;
cmLinkImplItem const& LinkImplItem;
};
cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem;
@@ -84,9 +84,10 @@ void CreatePropertyGeneratorExpressions(
for (std::vector<std::string>::const_iterator it = entries.begin();
it != entries.end(); ++it, ++btIt) {
cmGeneratorExpression ge(*btIt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*it);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*it);
cge->SetEvaluateForBuildsystem(evaluateForBuildsystem);
- items.push_back(new cmGeneratorTarget::TargetPropertyEntry(cge));
+ items.push_back(
+ new cmGeneratorTarget::TargetPropertyEntry(std::move(cge)));
}
}
@@ -309,7 +310,7 @@ std::string cmGeneratorTarget::GetOutputName(
// Now evaluate genex and update the previously-prepared map entry.
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(outName);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(outName);
i->second = cge->Evaluate(this->LocalGenerator, config);
} else if (i->second.empty()) {
// An empty map entry indicates we have been called recursively
@@ -333,9 +334,9 @@ void cmGeneratorTarget::AddSourceCommon(const std::string& src)
{
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(src);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src);
cge->SetEvaluateForBuildsystem(true);
- this->SourceEntries.push_back(new TargetPropertyEntry(cge));
+ this->SourceEntries.push_back(new TargetPropertyEntry(std::move(cge)));
this->ClearSourcesCache();
}
@@ -359,13 +360,14 @@ void cmGeneratorTarget::AddIncludeDirectory(const std::string& src,
this->Target->InsertInclude(src, this->Makefile->GetBacktrace(), before);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(src);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src);
cge->SetEvaluateForBuildsystem(true);
// Insert before begin/end
std::vector<TargetPropertyEntry*>::iterator pos = before
? this->IncludeDirectoriesEntries.begin()
: this->IncludeDirectoriesEntries.end();
- this->IncludeDirectoriesEntries.insert(pos, new TargetPropertyEntry(cge));
+ this->IncludeDirectoriesEntries.insert(
+ pos, new TargetPropertyEntry(std::move(cge)));
}
std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends(
@@ -795,10 +797,10 @@ static void AddInterfaceEntries(
if (lib.Target) {
std::string genex = "$<TARGET_PROPERTY:" + lib + "," + prop + ">";
cmGeneratorExpression ge(lib.Backtrace);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
cge->SetEvaluateForBuildsystem(true);
entries.push_back(
- new cmGeneratorTarget::TargetPropertyEntry(cge, lib));
+ new cmGeneratorTarget::TargetPropertyEntry(std::move(cge), lib));
}
}
}
@@ -2285,7 +2287,7 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
// Check for target references in generator expressions.
for (std::string const& cl : cCmdLine) {
- const CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cl);
+ const std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cl);
cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "", true);
std::set<cmGeneratorTarget*> geTargets = cge->GetTargets();
targets.insert(geTargets.begin(), geTargets.end());
@@ -2570,10 +2572,10 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
libDir = frameworkCheck.match(1);
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(libDir.c_str());
linkInterfaceIncludeDirectoriesEntries.push_back(
- new cmGeneratorTarget::TargetPropertyEntry(cge));
+ new cmGeneratorTarget::TargetPropertyEntry(std::move(cge)));
}
}
@@ -2781,10 +2783,10 @@ void cmGeneratorTarget::GetCompileDefinitions(
}
case cmPolicies::OLD: {
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(configProp);
linkInterfaceCompileDefinitionsEntries.push_back(
- new cmGeneratorTarget::TargetPropertyEntry(cge));
+ new cmGeneratorTarget::TargetPropertyEntry(std::move(cge)));
} break;
case cmPolicies::NEW:
case cmPolicies::REQUIRED_ALWAYS:
@@ -4214,7 +4216,7 @@ void cmGeneratorTarget::ExpandLinkItems(
dagChecker.SetTransitivePropertiesOnly();
}
std::vector<std::string> libs;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
cmSystemTools::ExpandListArgument(cge->Evaluate(this->LocalGenerator, config,
false, headTarget, this,
&dagChecker),
@@ -4484,7 +4486,8 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
if (const char* config_outdir = this->GetProperty(configProp)) {
// Use the user-specified per-configuration output directory.
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(config_outdir);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(config_outdir);
out = cge->Evaluate(this->LocalGenerator, config);
// Skip per-configuration subdirectory.
@@ -4492,7 +4495,7 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
} else if (const char* outdir = this->GetProperty(propertyName)) {
// Use the user-specified output directory.
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(outdir);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(outdir);
out = cge->Evaluate(this->LocalGenerator, config);
// Skip per-configuration subdirectory if the value contained a
@@ -5222,7 +5225,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
cmGeneratorExpressionDAGChecker dagChecker(
this->GetName(), "LINK_LIBRARIES", nullptr, nullptr);
cmGeneratorExpression ge(*btIt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> const cge = ge.Parse(*le);
+ std::unique_ptr<cmCompiledGeneratorExpression> const cge = ge.Parse(*le);
std::string const evaluated =
cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker);
cmSystemTools::ExpandListArgument(evaluated, llibs);
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 4f799ba..a31e415 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -363,7 +363,7 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries(
this->GeneratorTarget->GetCreateRuleVariable(language, config);
bool useWatcomQuote =
this->Makefile->IsOn(createRule + "_USE_WATCOM_QUOTE");
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->GetGlobalGenerator()->CreateLinkLineComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 3e9e995..d5531cb 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -10,6 +10,7 @@
#include <ctype.h>
#include <functional>
#include <iterator>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdio.h>
@@ -32,7 +33,6 @@
#include "cmTarget.h"
#include "cmTargetDepend.h"
#include "cmVersion.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
class cmLinkLineComputer;
@@ -1692,9 +1692,10 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
snapshot.GetDirectory().SetCurrentBinary(dir_cur_bld);
snapshot.GetDirectory().SetRelativePathTopSource(dir_top_src.c_str());
snapshot.GetDirectory().SetRelativePathTopBinary(dir_top_bld.c_str());
- CM_AUTO_PTR<cmMakefile> mfd(new cmMakefile(this, snapshot));
- CM_AUTO_PTR<cmLocalNinjaGenerator> lgd(static_cast<cmLocalNinjaGenerator*>(
- this->CreateLocalGenerator(mfd.get())));
+ auto mfd = cm::make_unique<cmMakefile>(this, snapshot);
+ std::unique_ptr<cmLocalNinjaGenerator> lgd(
+ static_cast<cmLocalNinjaGenerator*>(
+ this->CreateLocalGenerator(mfd.get())));
this->Makefiles.push_back(mfd.release());
this->LocalGenerators.push_back(lgd.release());
}
@@ -1869,7 +1870,7 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
cmake cm(cmake::RoleInternal);
cm.SetHomeDirectory(dir_top_src);
cm.SetHomeOutputDirectory(dir_top_bld);
- CM_AUTO_PTR<cmGlobalNinjaGenerator> ggd(
+ std::unique_ptr<cmGlobalNinjaGenerator> ggd(
static_cast<cmGlobalNinjaGenerator*>(cm.CreateGlobalGenerator("Ninja")));
if (!ggd.get() ||
!ggd->WriteDyndepFile(dir_top_src, dir_top_bld, dir_cur_src, dir_cur_bld,
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 8c1111e..a14b5f7 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -708,7 +708,7 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
const char* propertyValue =
target->Target->GetMakefile()->GetDefinition(propertyName);
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(propertyValue);
if (cmSystemTools::IsOn(
cge->Evaluate(target->GetLocalGenerator(), *i))) {
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 2a05d4e..9375f60 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -5,10 +5,12 @@
#include "cmsys/RegularExpression.hxx"
#include <assert.h>
#include <iomanip>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdio.h>
#include <string.h>
+#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
#include "cmCustomCommandGenerator.h"
#include "cmDocumentationEntry.h"
@@ -29,7 +31,6 @@
#include "cmXCode21Object.h"
#include "cmXCodeObject.h"
#include "cmXCodeScheme.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
struct cmLinkImplementation;
@@ -197,8 +198,8 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(
return nullptr;
}
- CM_AUTO_PTR<cmGlobalXCodeGenerator> gg(
- new cmGlobalXCodeGenerator(cm, version_string, version_number));
+ auto gg = cm::make_unique<cmGlobalXCodeGenerator>(cm, version_string,
+ version_number);
return gg.release();
#else
std::cerr << "CMake should be built with cmake to use Xcode, "
@@ -669,7 +670,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
if (const char* cflags = sf->GetProperty("COMPILE_FLAGS")) {
cmGeneratorExpression ge;
std::string configName = "NO-PER-CONFIG-SUPPORT-IN-XCODE";
- CM_AUTO_PTR<cmCompiledGeneratorExpression> compiledExpr = ge.Parse(cflags);
+ std::unique_ptr<cmCompiledGeneratorExpression> compiledExpr =
+ ge.Parse(cflags);
const char* processed = compiledExpr->Evaluate(lg, configName);
if (compiledExpr->GetHadContextSensitiveCondition()) {
std::ostringstream e;
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index ca87cbf..dd2993d 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -4,6 +4,7 @@
#include <cstddef>
#include <iostream>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <utility>
@@ -15,7 +16,6 @@
#include "cmStateSnapshot.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
namespace {
@@ -147,8 +147,8 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator ggi(&cm);
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&ggi, cm.GetCurrentSnapshot()));
- CM_AUTO_PTR<cmLocalGenerator> lg(ggi.CreateLocalGenerator(mf.get()));
+ cmMakefile mf(&ggi, cm.GetCurrentSnapshot());
+ std::unique_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator(&mf));
const char* inFileName = settingsFileName;
@@ -159,7 +159,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
}
}
- if (!mf->ReadListFile(inFileName)) {
+ if (!mf.ReadListFile(inFileName)) {
cmSystemTools::Error("Problem opening GraphViz options file: ",
inFileName);
return;
@@ -169,7 +169,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
#define __set_if_set(var, cmakeDefinition) \
{ \
- const char* value = mf->GetDefinition(cmakeDefinition); \
+ const char* value = mf.GetDefinition(cmakeDefinition); \
if (value) { \
(var) = value; \
} \
@@ -182,9 +182,9 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
#define __set_bool_if_set(var, cmakeDefinition) \
{ \
- const char* value = mf->GetDefinition(cmakeDefinition); \
+ const char* value = mf.GetDefinition(cmakeDefinition); \
if (value) { \
- (var) = mf->IsOn(cmakeDefinition); \
+ (var) = mf.IsOn(cmakeDefinition); \
} \
}
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 1a01854..4926f22 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -8,9 +8,10 @@
#include "cmMakefile.h"
#include "cmOutputConverter.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
+#include <memory> // IWYU pragma: keep
+
static std::string cmIfCommandError(
std::vector<cmExpandedCommandArgument> const& args)
{
@@ -36,7 +37,8 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// if this is the endif for this if statement, then start executing
if (!this->ScopeDepth) {
// Remove the function blocker for this scope or bail.
- CM_AUTO_PTR<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff));
+ std::unique_ptr<cmFunctionBlocker> fb(
+ mf.RemoveFunctionBlocker(this, lff));
if (!fb.get()) {
return false;
}
diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx
index 49e57b1..e4209bd 100644
--- a/Source/cmInstallDirectoryGenerator.cxx
+++ b/Source/cmInstallDirectoryGenerator.cxx
@@ -7,7 +7,8 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
+
+#include <memory> // IWYU pragma: keep
cmInstallDirectoryGenerator::cmInstallDirectoryGenerator(
std::vector<std::string> const& dirs, const char* dest,
@@ -63,7 +64,7 @@ void cmInstallDirectoryGenerator::GenerateScriptForConfig(
std::vector<std::string> dirs;
cmGeneratorExpression ge;
for (std::string const& d : this->Directories) {
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(d);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(d);
cmSystemTools::ExpandListArgument(
cge->Evaluate(this->LocalGenerator, config), dirs);
}
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index 0e79563..68e3f86 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -5,7 +5,8 @@
#include "cmGeneratorExpression.h"
#include "cmInstallType.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
+
+#include <memory> // IWYU pragma: keep
class cmLocalGenerator;
@@ -82,7 +83,7 @@ void cmInstallFilesGenerator::GenerateScriptForConfig(
std::vector<std::string> files;
cmGeneratorExpression ge;
for (std::string const& f : this->Files) {
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(f);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(f);
cmSystemTools::ExpandListArgument(
cge->Evaluate(this->LocalGenerator, config), files);
}
diff --git a/Source/cmInstalledFile.h b/Source/cmInstalledFile.h
index fbf754f..47a4959 100644
--- a/Source/cmInstalledFile.h
+++ b/Source/cmInstalledFile.h
@@ -6,9 +6,9 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmGeneratorExpression.h"
-#include "cm_auto_ptr.hxx"
#include <map>
+#include <memory> // IWYU pragma: keep
#include <string>
#include <vector>
@@ -22,7 +22,7 @@ class cmMakefile;
class cmInstalledFile
{
public:
- typedef CM_AUTO_PTR<cmCompiledGeneratorExpression>
+ typedef std::unique_ptr<cmCompiledGeneratorExpression>
CompiledGeneratorExpressionPtrType;
typedef std::vector<cmCompiledGeneratorExpression*> ExpressionVectorType;
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 73f5a16..477ce51 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -5,6 +5,7 @@
#include <algorithm>
#include <assert.h>
#include <iterator>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdio.h>
#include <utility>
@@ -22,7 +23,6 @@
#include "cmState.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
@@ -505,7 +505,7 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
std::string launcher = property_value;
launcher += " ";
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->CreateRulePlaceholderExpander());
rulePlaceholderExpander->ExpandRuleVariables(this, launcher, vars);
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 50ed0ed..e26182a 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -5,6 +5,7 @@
#include "cmsys/FStream.hxx"
#include "cmsys/Terminal.h"
#include <algorithm>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdio.h>
#include <utility>
@@ -28,7 +29,6 @@
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
// Include dependency scanners for supported languages. Only the
@@ -121,9 +121,9 @@ void cmLocalUnixMakefileGenerator3::Generate()
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- CM_AUTO_PTR<cmMakefileTargetGenerator> tg(
+ std::unique_ptr<cmMakefileTargetGenerator> tg(
cmMakefileTargetGenerator::New(target));
- if (tg.get()) {
+ if (tg) {
tg->WriteRuleFiles();
gg->RecordTargetProgress(tg.get());
}
@@ -930,7 +930,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
*content << dir;
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->CreateRulePlaceholderExpander());
// Add each command line to the set of commands.
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index afd71c8..8027191 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1453,7 +1453,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
}
if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) {
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
fc.CompileFlags = cge->Evaluate(lg, *i);
needfc = true;
}
@@ -1849,7 +1849,7 @@ void cmLocalVisualStudio7Generator::OutputTargetRules(
if (!addedPrelink) {
event.Write(target->GetPreLinkCommands());
}
- CM_AUTO_PTR<cmCustomCommand> pcc(
+ std::unique_ptr<cmCustomCommand> pcc(
this->MaybeCreateImplibDir(target, configName, this->FortranProject));
if (pcc.get()) {
event.Write(*pcc);
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 718c8cd..bbb91e0 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -78,12 +78,12 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
}
}
-CM_AUTO_PTR<cmCustomCommand>
+std::unique_ptr<cmCustomCommand>
cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
const std::string& config,
bool isFortran)
{
- CM_AUTO_PTR<cmCustomCommand> pcc;
+ std::unique_ptr<cmCustomCommand> pcc;
// If an executable exports symbols then VS wants to create an
// import library but forgets to create the output directory.
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index c47db4f..cba24fe 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -6,12 +6,11 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
-#include <memory>
+#include <memory> // IWYU pragma: keep
#include <string>
#include "cmGlobalVisualStudioGenerator.h"
#include "cmLocalGenerator.h"
-#include "cm_auto_ptr.hxx"
class cmCustomCommand;
class cmCustomCommandGenerator;
@@ -56,9 +55,8 @@ protected:
virtual bool CustomCommandUseLocal() const { return false; }
/** Construct a custom command to make exe import lib dir. */
- CM_AUTO_PTR<cmCustomCommand> MaybeCreateImplibDir(cmGeneratorTarget* target,
- const std::string& config,
- bool isFortran);
+ std::unique_ptr<cmCustomCommand> MaybeCreateImplibDir(
+ cmGeneratorTarget* target, const std::string& config, bool isFortran);
};
#endif
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index e51cfcc..32181cf 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -7,6 +7,7 @@
#include <algorithm>
#include <assert.h>
#include <ctype.h>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdlib.h>
#include <string.h>
@@ -37,7 +38,6 @@
#include "cmTestGenerator.h" // IWYU pragma: keep
#include "cmVersion.h"
#include "cmWorkingDirectory.h"
-#include "cm_auto_ptr.hxx"
#include "cm_sys_stat.h"
#include "cmake.h"
@@ -264,7 +264,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
// Lookup the command prototype.
if (cmCommand* proto = this->GetState()->GetCommand(name)) {
// Clone the prototype.
- CM_AUTO_PTR<cmCommand> pcmd(proto->Clone());
+ std::unique_ptr<cmCommand> pcmd(proto->Clone());
pcmd->SetMakefile(this);
// Decide whether to invoke the command.
@@ -584,11 +584,12 @@ void cmMakefile::EnforceDirectoryLevelRules() const
void cmMakefile::AddEvaluationFile(
const std::string& inputFile,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> outputName,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent)
+ std::unique_ptr<cmCompiledGeneratorExpression> outputName,
+ std::unique_ptr<cmCompiledGeneratorExpression> condition,
+ bool inputIsContent)
{
this->EvaluationFiles.push_back(new cmGeneratorExpressionEvaluationFile(
- inputFile, outputName, condition, inputIsContent,
+ inputFile, std::move(outputName), std::move(condition), inputIsContent,
this->GetPolicyStatus(cmPolicies::CMP0070)));
}
@@ -2874,7 +2875,7 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
FunctionBlockersType::size_type barrier =
this->FunctionBlockerBarriers.back();
while (this->FunctionBlockers.size() > barrier) {
- CM_AUTO_PTR<cmFunctionBlocker> fb(this->FunctionBlockers.back());
+ std::unique_ptr<cmFunctionBlocker> fb(this->FunctionBlockers.back());
this->FunctionBlockers.pop_back();
if (reportError) {
// Report the context in which the unclosed block was opened.
@@ -3009,7 +3010,7 @@ void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb)
this->FunctionBlockers.push_back(fb);
}
-CM_AUTO_PTR<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker(
+std::unique_ptr<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker(
cmFunctionBlocker* fb, const cmListFileFunction& lff)
{
// Find the function blocker stack barrier for the current scope.
@@ -3042,11 +3043,11 @@ CM_AUTO_PTR<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker(
}
cmFunctionBlocker* b = *pos;
this->FunctionBlockers.erase(pos);
- return CM_AUTO_PTR<cmFunctionBlocker>(b);
+ return std::unique_ptr<cmFunctionBlocker>(b);
}
}
- return CM_AUTO_PTR<cmFunctionBlocker>();
+ return std::unique_ptr<cmFunctionBlocker>();
}
const char* cmMakefile::GetHomeDirectory() const
@@ -3703,7 +3704,7 @@ cmTarget* cmMakefile::AddImportedTarget(const std::string& name,
bool global)
{
// Create the target.
- CM_AUTO_PTR<cmTarget> target(
+ std::unique_ptr<cmTarget> target(
new cmTarget(name, type, global ? cmTarget::VisibilityImportedGlobally
: cmTarget::VisibilityImported,
this));
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 272522c..0273f5b 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -8,6 +8,7 @@
#include "cmsys/RegularExpression.hxx"
#include <deque>
#include <map>
+#include <memory> // IWYU pragma: keep
#include <set>
#include <stack>
#include <stddef.h>
@@ -22,7 +23,6 @@
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
#include "cmTarget.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -92,7 +92,7 @@ public:
* Remove the function blocker whose scope ends with the given command.
* This returns ownership of the function blocker object.
*/
- CM_AUTO_PTR<cmFunctionBlocker> RemoveFunctionBlocker(
+ std::unique_ptr<cmFunctionBlocker> RemoveFunctionBlocker(
cmFunctionBlocker* fb, const cmListFileFunction& lff);
/**
@@ -781,10 +781,11 @@ public:
void EnforceDirectoryLevelRules() const;
- void AddEvaluationFile(const std::string& inputFile,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> outputName,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> condition,
- bool inputIsContent);
+ void AddEvaluationFile(
+ const std::string& inputFile,
+ std::unique_ptr<cmCompiledGeneratorExpression> outputName,
+ std::unique_ptr<cmCompiledGeneratorExpression> condition,
+ bool inputIsContent);
std::vector<cmGeneratorExpressionEvaluationFile*> GetEvaluationFiles() const;
std::vector<cmExportBuildFileGenerator*> GetExportBuildFileGenerators()
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index ebc8e30..801f72a 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -3,6 +3,7 @@
#include "cmMakefileExecutableTargetGenerator.h"
#include <algorithm>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <string>
#include <vector>
@@ -23,7 +24,6 @@
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator(
@@ -193,7 +193,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
// Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
new cmLinkLineDeviceComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -251,7 +251,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
launcher += " ";
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander());
// Expand placeholders in the commands.
@@ -448,7 +448,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
linkFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
{
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -538,7 +538,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -632,7 +632,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
launcher += " ";
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander());
// Expand placeholders in the commands.
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 68d73d4..80c62d1 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -3,6 +3,7 @@
#include "cmMakefileLibraryTargetGenerator.h"
#include <algorithm>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <vector>
@@ -22,7 +23,6 @@
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator(
@@ -199,7 +199,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
this->LocalGenerator->AddConfigVariableFlags(
extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -248,7 +248,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
this->LocalGenerator->AddConfigVariableFlags(
extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName);
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -348,7 +348,7 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
std::string linkLibs;
if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) {
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
new cmLinkLineDeviceComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -410,7 +410,7 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
launcher += " ";
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander());
// Construct the main link rule and expand placeholders.
@@ -754,7 +754,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
std::string linkLibs;
if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) {
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -873,7 +873,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
launcher += " ";
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander());
// Construct the main link rule and expand placeholders.
rulePlaceholderExpander->SetTargetImpLib(targetOutPathImport);
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index d0aad30..7db010c 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileTargetGenerator.h"
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdio.h>
#include <utility>
@@ -27,7 +28,6 @@
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target)
@@ -134,7 +134,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
if (const char* additional_clean_files =
this->Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) {
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(additional_clean_files);
cmSystemTools::ExpandListArgument(
@@ -434,7 +434,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
// Add flags from source file properties.
if (const char* cflags = source.GetProperty("COMPILE_FLAGS")) {
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
const char* evaluatedFlags = cge->Evaluate(this->LocalGenerator, config,
false, this->GeneratorTarget);
this->LocalGenerator->AppendFlags(flags, evaluatedFlags);
@@ -570,7 +570,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
bool const lang_has_assembly = lang_has_preprocessor;
bool const lang_can_export_cmds = lang_has_preprocessor;
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander());
// Construct the compile rules.
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index e0844e8..e0cc35a 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -6,6 +6,7 @@
#include <assert.h>
#include <iterator>
#include <map>
+#include <memory> // IWYU pragma: keep
#include <set>
#include <sstream>
@@ -29,7 +30,6 @@
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
class cmCustomCommand;
@@ -241,7 +241,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile)
launcher += " ";
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander());
// Rule for linking library/executable.
@@ -365,7 +365,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
launcher += " ";
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander());
// Rule for linking library/executable.
@@ -636,7 +636,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
vars["TARGET_FILE"] =
localGen.ConvertToOutputFormat(targetOutputReal, cmOutputConverter::SHELL);
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
new cmNinjaLinkLineDeviceComputer(
this->GetLocalGenerator(),
this->GetLocalGenerator()->GetStateSnapshot().GetDirectory(),
@@ -839,7 +839,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
vars["TARGET_FILE"] =
localGen.ConvertToOutputFormat(targetOutputReal, cmOutputConverter::SHELL);
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->GetGlobalGenerator()->CreateLinkLineComputer(
this->GetLocalGenerator(),
this->GetLocalGenerator()->GetStateSnapshot().GetDirectory()));
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 5fb4097..5805259 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -8,6 +8,7 @@
#include <assert.h>
#include <iterator>
#include <map>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <string.h>
@@ -29,7 +30,6 @@
#include "cmState.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
@@ -138,7 +138,7 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(
if (const char* cflags = source->GetProperty("COMPILE_FLAGS")) {
std::string config = this->LocalGenerator->GetConfigName();
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
const char* evaluatedFlags = cge->Evaluate(this->LocalGenerator, config,
false, this->GeneratorTarget);
this->LocalGenerator->AppendFlags(flags, evaluatedFlags);
@@ -463,7 +463,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
vars.Flags = flags.c_str();
vars.DependencyFile = depfile.c_str();
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander());
std::string const tdi = this->GetLocalGenerator()->ConvertToOutputFormat(
@@ -1077,7 +1077,7 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander());
for (std::string& i : compileCmds) {
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 3b6a7ee..55af078 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -4,6 +4,7 @@
#include "cmsys/RegularExpression.hxx"
#include <ctype.h>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
@@ -15,7 +16,6 @@
#include "cmSystemTools.h"
#include "cmTimestamp.h"
#include "cmUuid.h"
-#include "cm_auto_ptr.hxx"
class cmExecutionStatus;
@@ -108,8 +108,8 @@ bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args)
return false;
}
- CM_AUTO_PTR<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
- if (hash.get()) {
+ std::unique_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
+ if (hash) {
std::string out = hash->HashString(args[2]);
this->Makefile->AddDefinition(args[1], out.c_str());
return true;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 8dce028..e163783 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -15,7 +15,7 @@
#include "cmVisualStudioGeneratorOptions.h"
#include "windows.h"
-#include "cm_auto_ptr.hxx"
+#include <memory> // IWYU pragma: keep
static std::string cmVS10EscapeXML(std::string arg)
{
@@ -1722,7 +1722,8 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
if (!deployContent.empty()) {
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(deployContent);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(deployContent);
// Deployment location cannot be set on a configuration basis
if (!deployLocation.empty()) {
this->WriteString("<Link>", 3);
@@ -2089,7 +2090,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
}
if (configDependentFlags) {
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(flags);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(flags);
std::string evaluatedFlags =
cge->Evaluate(this->LocalGenerator, *config);
clOptions.Parse(evaluatedFlags.c_str());
@@ -2297,16 +2298,16 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions;
+ std::unique_ptr<Options> pOptions;
switch (this->ProjectType) {
case vcxproj:
- pOptions = CM_AUTO_PTR<Options>(new Options(
- this->LocalGenerator, Options::Compiler, gg->GetClFlagTable()));
+ pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::Compiler, gg->GetClFlagTable());
break;
case csproj:
- pOptions = CM_AUTO_PTR<Options>(new Options(this->LocalGenerator,
- Options::CSharpCompiler,
- gg->GetCSharpFlagTable()));
+ pOptions =
+ cm::make_unique<Options>(this->LocalGenerator, Options::CSharpCompiler,
+ gg->GetCSharpFlagTable());
break;
}
Options& clOptions = *pOptions;
@@ -2520,8 +2521,8 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
{
cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::ResourceCompiler, gg->GetRcFlagTable()));
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::ResourceCompiler, gg->GetRcFlagTable());
Options& rcOptions = *pOptions;
std::string CONFIG = cmSystemTools::UpperCase(configName);
@@ -2581,8 +2582,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
{
cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable()));
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable());
Options& cudaOptions = *pOptions;
// Get compile flags for CUDA in this directory.
@@ -2689,8 +2690,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions(
{
cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable()));
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable());
Options& cudaLinkOptions = *pOptions;
// Determine if we need to do a device link
@@ -2760,8 +2761,8 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions(
{
cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::MasmCompiler, gg->GetMasmFlagTable()));
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::MasmCompiler, gg->GetMasmFlagTable());
Options& masmOptions = *pOptions;
std::string CONFIG = cmSystemTools::UpperCase(configName);
@@ -2818,8 +2819,8 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions(
{
cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::NasmCompiler, gg->GetNasmFlagTable()));
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::NasmCompiler, gg->GetNasmFlagTable());
Options& nasmOptions = *pOptions;
std::string CONFIG = cmSystemTools::UpperCase(configName);
@@ -2980,7 +2981,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
if (const char* nativeLibDirectoriesExpression =
this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DIRECTORIES")) {
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(nativeLibDirectoriesExpression);
std::string nativeLibDirs =
cge->Evaluate(this->LocalGenerator, configName);
@@ -2993,7 +2994,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
this->GeneratorTarget->GetProperty(
"ANDROID_NATIVE_LIB_DEPENDENCIES")) {
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(nativeLibDependenciesExpression);
std::string nativeLibDeps =
cge->Evaluate(this->LocalGenerator, configName);
@@ -3012,7 +3013,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
if (const char* jarDirectoriesExpression =
this->GeneratorTarget->GetProperty("ANDROID_JAR_DIRECTORIES")) {
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(jarDirectoriesExpression);
std::string jarDirectories =
cge->Evaluate(this->LocalGenerator, configName);
@@ -3074,8 +3075,9 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
{
cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::Linker, gg->GetLinkFlagTable(), 0, this));
+ auto pOptions =
+ cm::make_unique<Options>(this->LocalGenerator, Options::Linker,
+ gg->GetLinkFlagTable(), nullptr, this);
Options& linkOptions = *pOptions;
cmGeneratorTarget::LinkClosure const* linkClosure =
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index 172ac62..a080034 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -7,9 +7,10 @@
#include "cmExpandedCommandArgument.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
+#include <memory> // IWYU pragma: keep
+
cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf)
: Makefile(mf)
, Depth(0)
@@ -34,7 +35,8 @@ bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// if this is the endwhile for this while loop then execute
if (!this->Depth) {
// Remove the function blocker for this scope or bail.
- CM_AUTO_PTR<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff));
+ std::unique_ptr<cmFunctionBlocker> fb(
+ mf.RemoveFunctionBlocker(this, lff));
if (!fb.get()) {
return false;
}
diff --git a/Source/cm_auto_ptr.hxx b/Source/cm_auto_ptr.hxx
deleted file mode 100644
index 1ac9220..0000000
--- a/Source/cm_auto_ptr.hxx
+++ /dev/null
@@ -1,220 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef CM_AUTO_PTR_HXX
-#define CM_AUTO_PTR_HXX
-
-#include "cmConfigure.h"
-
-#ifdef CMake_HAVE_CXX_AUTO_PTR
-
-#include <memory>
-#define CM_AUTO_PTR std::auto_ptr
-
-#else
-
-#define CM_AUTO_PTR cm::auto_ptr
-
-// The HP compiler cannot handle the conversions necessary to use
-// auto_ptr_ref to pass an auto_ptr returned from one function
-// directly to another function as in use_auto_ptr(get_auto_ptr()).
-// We instead use const_cast to achieve the syntax on those platforms.
-// We do not use const_cast on other platforms to maintain the C++
-// standard design and guarantee that if an auto_ptr is bound
-// to a reference-to-const then ownership will be maintained.
-#if defined(__HP_aCC)
-#define cm_AUTO_PTR_REF 0
-#define cm_AUTO_PTR_CONST const
-#define cm_AUTO_PTR_CAST(a) cast(a)
-#else
-#define cm_AUTO_PTR_REF 1
-#define cm_AUTO_PTR_CONST
-#define cm_AUTO_PTR_CAST(a) a
-#endif
-
-// In C++11, clang will warn about using dynamic exception specifications
-// as they are deprecated. But as this class is trying to faithfully
-// mimic std::auto_ptr, we want to keep the 'throw()' decorations below.
-// So we suppress the warning.
-#if defined(__clang__) && defined(__has_warning)
-#if __has_warning("-Wdeprecated")
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated"
-#endif
-#endif
-
-namespace cm {
-
-template <class X>
-class auto_ptr;
-
-#if cm_AUTO_PTR_REF
-namespace detail {
-// The auto_ptr_ref template is supposed to be a private member of
-// auto_ptr but Borland 5.8 cannot handle it. Instead put it in
-// a private namespace.
-template <class Y>
-struct auto_ptr_ref
-{
- Y* p_;
-
- // The extra constructor argument prevents implicit conversion to
- // auto_ptr_ref from auto_ptr through the constructor. Normally
- // this should be done with the explicit keyword but Borland 5.x
- // generates code in the conversion operator to call itself
- // infinately.
- auto_ptr_ref(Y* p, int)
- : p_(p)
- {
- }
-};
-}
-#endif
-
-/** C++98 Standard Section 20.4.5 - Template class auto_ptr. */
-template <class X>
-class auto_ptr
-{
-#if !cm_AUTO_PTR_REF
- template <typename Y>
- static inline auto_ptr<Y>& cast(auto_ptr<Y> const& a)
- {
- return const_cast<auto_ptr<Y>&>(a);
- }
-#endif
-
- /** The pointer to the object held. */
- X* x_;
-
-public:
- /** The type of object held by the auto_ptr. */
- typedef X element_type;
-
- /** Construct from an auto_ptr holding a compatible object. This
- transfers ownership to the newly constructed auto_ptr. */
- template <class Y>
- auto_ptr(auto_ptr<Y> cm_AUTO_PTR_CONST& a) throw()
- : x_(cm_AUTO_PTR_CAST(a).release())
- {
- }
-
- /** Assign from an auto_ptr holding a compatible object. This
- transfers ownership to the left-hand-side of the assignment. */
- template <class Y>
- auto_ptr& operator=(auto_ptr<Y> cm_AUTO_PTR_CONST& a) throw() // NOLINT
- {
- this->reset(cm_AUTO_PTR_CAST(a).release());
- return *this; // NOLINT
- }
-
- /**
- * Explicitly construct from a raw pointer. This is typically
- * called with the result of operator new. For example:
- *
- * auto_ptr<X> ptr(new X());
- */
- explicit auto_ptr(X* p = nullptr) throw()
- : x_(p)
- {
- }
-
- /** Construct from another auto_ptr holding an object of the same
- type. This transfers ownership to the newly constructed
- auto_ptr. */
- auto_ptr(auto_ptr cm_AUTO_PTR_CONST& a) throw()
- : x_(cm_AUTO_PTR_CAST(a).release())
- {
- }
-
- /** Assign from another auto_ptr holding an object of the same type.
- This transfers ownership to the newly constructed auto_ptr. */
- auto_ptr& operator=(auto_ptr cm_AUTO_PTR_CONST& a) throw() // NOLINT
- {
- this->reset(cm_AUTO_PTR_CAST(a).release());
- return *this; // NOLINT
- }
-
- /** Destruct and delete the object held. */
- ~auto_ptr() throw()
- {
- // Assume object destructor is nothrow.
- delete this->x_;
- }
-
- /** Dereference and return a reference to the object held. */
- X& operator*() const throw() { return *this->x_; }
-
- /** Return a pointer to the object held. */
- X* operator->() const throw() { return this->x_; }
-
- /** Return a pointer to the object held. */
- X* get() const throw() { return this->x_; }
-
- /** Return a pointer to the object held and reset to hold no object.
- This transfers ownership to the caller. */
- X* release() throw()
- {
- X* x = this->x_;
- this->x_ = nullptr;
- return x;
- }
-
- /** Assume ownership of the given object. The object previously
- held is deleted. */
- void reset(X* p = 0) throw()
- {
- if (this->x_ != p) {
- // Assume object destructor is nothrow.
- delete this->x_;
- this->x_ = p;
- }
- }
-
- /** Convert to an auto_ptr holding an object of a compatible type.
- This transfers ownership to the returned auto_ptr. */
- template <class Y>
- operator auto_ptr<Y>() throw()
- {
- return auto_ptr<Y>(this->release());
- }
-
-#if cm_AUTO_PTR_REF
- /** Construct from an auto_ptr_ref. This is used when the
- constructor argument is a call to a function returning an
- auto_ptr. */
- auto_ptr(detail::auto_ptr_ref<X> r) throw()
- : x_(r.p_)
- {
- }
-
- /** Assign from an auto_ptr_ref. This is used when a function
- returning an auto_ptr is passed on the right-hand-side of an
- assignment. */
- auto_ptr& operator=(detail::auto_ptr_ref<X> r) throw()
- {
- this->reset(r.p_);
- return *this; // NOLINT
- }
-
- /** Convert to an auto_ptr_ref. This is used when a function
- returning an auto_ptr is the argument to the constructor of
- another auto_ptr. */
- template <class Y>
- operator detail::auto_ptr_ref<Y>() throw()
- {
- return detail::auto_ptr_ref<Y>(this->release(), 1);
- }
-#endif
-};
-
-} // namespace cm
-
-// Undo warning suppression.
-#if defined(__clang__) && defined(__has_warning)
-#if __has_warning("-Wdeprecated")
-#pragma clang diagnostic pop
-#endif
-#endif
-
-#endif
-
-#endif
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index e61acb1..61595d5 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -24,7 +24,6 @@
#include "cmUtils.hxx"
#include "cmVersionConfig.h"
#include "cmWorkingDirectory.h"
-#include "cm_auto_ptr.hxx"
#include "cm_sys_stat.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -111,6 +110,7 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
#include <iostream>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
@@ -482,15 +482,15 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
snapshot.GetDirectory().SetCurrentSource(
cmSystemTools::GetCurrentWorkingDirectory());
snapshot.SetDefaultDefinitions();
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(gg, snapshot));
+ cmMakefile mf(gg, snapshot);
if (this->GetWorkingMode() != NORMAL_MODE) {
std::string file(cmSystemTools::CollapseFullPath(path));
cmSystemTools::ConvertToUnixSlashes(file);
- mf->SetScriptModeFile(file.c_str());
+ mf.SetScriptModeFile(file.c_str());
- mf->SetArgcArgv(args);
+ mf.SetArgcArgv(args);
}
- if (!mf->ReadListFile(path)) {
+ if (!mf.ReadListFile(path)) {
cmSystemTools::Error("Error processing file: ", path);
}
this->SetHomeDirectory(homeDir);
@@ -1874,8 +1874,8 @@ int cmake::CheckBuildSystem()
cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm);
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
- if (!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) ||
+ cmMakefile mf(&gg, cm.GetCurrentSnapshot());
+ if (!mf.ReadListFile(this->CheckBuildSystemArgument.c_str()) ||
cmSystemTools::GetErrorOccuredFlag()) {
if (verbose) {
std::ostringstream msg;
@@ -1889,25 +1889,25 @@ int cmake::CheckBuildSystem()
if (this->ClearBuildSystem) {
// Get the generator used for this build system.
- const char* genName = mf->GetDefinition("CMAKE_DEPENDS_GENERATOR");
+ const char* genName = mf.GetDefinition("CMAKE_DEPENDS_GENERATOR");
if (!genName || genName[0] == '\0') {
genName = "Unix Makefiles";
}
// Create the generator and use it to clear the dependencies.
- CM_AUTO_PTR<cmGlobalGenerator> ggd(this->CreateGlobalGenerator(genName));
- if (ggd.get()) {
+ std::unique_ptr<cmGlobalGenerator> ggd(
+ this->CreateGlobalGenerator(genName));
+ if (ggd) {
cm.GetCurrentSnapshot().SetDefaultDefinitions();
- CM_AUTO_PTR<cmMakefile> mfd(
- new cmMakefile(ggd.get(), cm.GetCurrentSnapshot()));
- CM_AUTO_PTR<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(mfd.get()));
- lgd->ClearDependencies(mfd.get(), verbose);
+ cmMakefile mfd(ggd.get(), cm.GetCurrentSnapshot());
+ std::unique_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(&mfd));
+ lgd->ClearDependencies(&mfd, verbose);
}
}
// If any byproduct of makefile generation is missing we must re-run.
std::vector<std::string> products;
- if (const char* productStr = mf->GetDefinition("CMAKE_MAKEFILE_PRODUCTS")) {
+ if (const char* productStr = mf.GetDefinition("CMAKE_MAKEFILE_PRODUCTS")) {
cmSystemTools::ExpandListArgument(productStr, products);
}
for (std::string const& p : products) {
@@ -1925,8 +1925,8 @@ int cmake::CheckBuildSystem()
// Get the set of dependencies and outputs.
std::vector<std::string> depends;
std::vector<std::string> outputs;
- const char* dependsStr = mf->GetDefinition("CMAKE_MAKEFILE_DEPENDS");
- const char* outputsStr = mf->GetDefinition("CMAKE_MAKEFILE_OUTPUTS");
+ const char* dependsStr = mf.GetDefinition("CMAKE_MAKEFILE_DEPENDS");
+ const char* outputsStr = mf.GetDefinition("CMAKE_MAKEFILE_OUTPUTS");
if (dependsStr && outputsStr) {
cmSystemTools::ExpandListArgument(dependsStr, depends);
cmSystemTools::ExpandListArgument(outputsStr, outputs);
@@ -2039,19 +2039,18 @@ void cmake::MarkCliAsUsed(const std::string& variable)
void cmake::GenerateGraphViz(const char* fileName) const
{
#ifdef CMAKE_BUILD_WITH_CMAKE
- CM_AUTO_PTR<cmGraphVizWriter> gvWriter(
- new cmGraphVizWriter(this->GetGlobalGenerator()->GetLocalGenerators()));
+ cmGraphVizWriter gvWriter(this->GetGlobalGenerator()->GetLocalGenerators());
std::string settingsFile = this->GetHomeOutputDirectory();
settingsFile += "/CMakeGraphVizOptions.cmake";
std::string fallbackSettingsFile = this->GetHomeDirectory();
fallbackSettingsFile += "/CMakeGraphVizOptions.cmake";
- gvWriter->ReadSettings(settingsFile.c_str(), fallbackSettingsFile.c_str());
+ gvWriter.ReadSettings(settingsFile.c_str(), fallbackSettingsFile.c_str());
- gvWriter->WritePerTargetFiles(fileName);
- gvWriter->WriteTargetDependersFiles(fileName);
- gvWriter->WriteGlobalFile(fileName);
+ gvWriter.WritePerTargetFiles(fileName);
+ gvWriter.WriteTargetDependersFiles(fileName);
+ gvWriter.WriteGlobalFile(fileName);
#endif
}
@@ -2357,7 +2356,7 @@ int cmake::Build(const std::string& dir, const std::string& target,
std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n";
return 1;
}
- CM_AUTO_PTR<cmGlobalGenerator> gen(
+ std::unique_ptr<cmGlobalGenerator> gen(
this->CreateGlobalGenerator(cachedGenerator));
if (!gen.get()) {
std::cerr << "Error: could create CMAKE_GENERATOR \"" << cachedGenerator
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 62a0094..5a9e321 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -12,7 +12,6 @@
#include "cmSystemTools.h"
#include "cmUtils.hxx"
#include "cmVersion.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -37,6 +36,7 @@
#include <functional>
#include <iostream>
#include <map>
+#include <memory> // IWYU pragma: keep
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
@@ -928,8 +928,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
cmStateSnapshot snapshot = cm.GetCurrentSnapshot();
snapshot.GetDirectory().SetCurrentBinary(startOutDir);
snapshot.GetDirectory().SetCurrentSource(startDir);
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(ggd, snapshot));
- CM_AUTO_PTR<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(mf.get()));
+ cmMakefile mf(ggd, snapshot);
+ std::unique_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(&mf));
// Actually scan dependencies.
return lgd->UpdateDependencies(depInfo.c_str(), verbose, color) ? 0
diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp
index 349945a..3240edf 100644
--- a/Utilities/IWYU/mapping.imp
+++ b/Utilities/IWYU/mapping.imp
@@ -49,12 +49,6 @@
#{ symbol: [ "std::pair", private, "<map>", public ] },
#{ symbol: [ "std::pair", private, "<set>", public ] },
- # IWYU wrongly suggests to include "cm_auto_ptr.hxx" in some places. This
- # might be a misinterpretation of a template specialization in <utility>.
- # As a workaround, map the symbol auto_ptr to "cmConfigure.h".
- # This will still correctly require "cm_auto_ptr.hxx" for CM_AUTO_PTR.
- { symbol: [ "cm::auto_ptr", private, "\"cmConfigure.h\"", public ] },
-
# __decay_and_strip is used internally in the C++11 standard library.
# IWYU does not classify it as internal and suggests to add <type_traits>.
# To ignore it, we simply map it to a file that is included anyway.