Commit d9b2c7da authored by Marc Chevrier's avatar Marc Chevrier

Introduce memory management helper: cm_memory.hxx

parent 81389a5e
......@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackExternalGenerator.h"
#include "cmAlgorithms.h"
#include "cmCPackComponentGroup.h"
#include "cmCPackLog.h"
#include "cmMakefile.h"
......@@ -17,6 +16,8 @@
#include <utility>
#include <vector>
#include "cm_memory.hxx"
int cmCPackExternalGenerator::InitializeInternal()
{
this->SetOption("CPACK_EXTERNAL_KNOWN_VERSIONS", "1.0");
......
......@@ -11,7 +11,6 @@
#include "cmsys/RegularExpression.hxx"
#include <chrono>
#include <cmAlgorithms.h>
#include <cstdint>
#include <cstring>
#include <iomanip>
......@@ -20,6 +19,8 @@
#include <stdio.h>
#include <utility>
#include "cm_memory.hxx"
cmCTestRunTest::cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler)
: MultiTestHandler(multiHandler)
{
......
......@@ -2,7 +2,6 @@
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"
......@@ -18,9 +17,10 @@
#include "cmXMLWriter.h"
#include <chrono>
#include <memory>
#include <sstream>
#include "cm_memory.hxx"
static const char* cmCTestUpdateHandlerUpdateStrings[] = {
"Unknown", "CVS", "SVN", "BZR", "GIT", "HG", "P4"
};
......
......@@ -11,7 +11,6 @@
#include <algorithm>
#include <functional>
#include <iterator>
#include <memory>
#include <sstream>
#include <string.h>
#include <string>
......@@ -340,20 +339,6 @@ inline void cmStripSuffixIfExists(std::string& str, const std::string& suffix)
namespace cm {
#if defined(CMake_HAVE_CXX_MAKE_UNIQUE)
using std::make_unique;
#else
template <typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
#endif
#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
using std::size;
......
......@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmBinUtilsLinuxELFLinker.h"
#include "cmAlgorithms.h"
#include "cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.h"
#include "cmLDConfigLDConfigTool.h"
#include "cmMakefile.h"
......@@ -12,9 +12,10 @@
#include <cmsys/RegularExpression.hxx>
#include <memory>
#include <sstream>
#include "cm_memory.hxx"
static std::string ReplaceOrigin(const std::string& rpath,
const std::string& origin)
{
......
......@@ -12,6 +12,8 @@
#include <string>
#include <vector>
#include "cm_memory.hxx"
cmBinUtilsMacOSMachOLinker::cmBinUtilsMacOSMachOLinker(
cmRuntimeDependencyArchive* archive)
: cmBinUtilsLinker(archive)
......
......@@ -2,16 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmBinUtilsWindowsPELinker.h"
#include "cmAlgorithms.h"
#include "cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.h"
#include "cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h"
#include "cmRuntimeDependencyArchive.h"
#include "cmSystemTools.h"
#include <memory>
#include <sstream>
#include <vector>
#include "cm_memory.hxx"
#ifdef _WIN32
# include <windows.h>
#endif
......
......@@ -15,7 +15,6 @@
#include <ctype.h>
#include <iostream>
#include <map>
#include <memory>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
......@@ -30,6 +29,8 @@
# include <unistd.h> // IWYU pragma: keep
#endif
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmCTestBuildAndTestHandler.h"
#include "cmCTestBuildHandler.h"
......
......@@ -23,6 +23,8 @@
#include <string.h>
#include <utility>
#include "cm_memory.hxx"
/*
This file computes an ordered list of link items to use when linking a
......
......@@ -2,13 +2,13 @@
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>
#include "cm_memory.hxx"
static unsigned int const cmCryptoHashAlgoToId[] = {
/* clang-format needs this comment to break after the opening brace */
......
......@@ -20,11 +20,12 @@
#include "cmsys/FStream.hxx"
#include <assert.h>
#include <memory>
#include <sstream>
#include <string.h>
#include <utility>
#include "cm_memory.hxx"
static std::string cmExportFileGeneratorEscape(std::string const& str)
{
// Escape a property value for writing into a .cmake file.
......
......@@ -4,10 +4,10 @@
#include "cmsys/FStream.hxx"
#include <map>
#include <memory>
#include <utility>
#include "cmAlgorithms.h"
#include "cm_memory.hxx"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
......
......@@ -13,7 +13,6 @@
#include <cmath>
#include <ctype.h>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <stdio.h>
......@@ -21,6 +20,8 @@
#include <utility>
#include <vector>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmArgumentParser.h"
#include "cmCryptoHash.h"
......
......@@ -2,11 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileTimes.h"
#include "cmAlgorithms.h"
#include "cm_sys_stat.h"
#include <utility>
#include "cm_memory.hxx"
#if defined(_WIN32)
# include "cmSystemTools.h"
# include <windows.h>
......
......@@ -13,12 +13,13 @@
#include <deque>
#include <functional>
#include <iterator>
#include <memory>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <utility>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
......
......@@ -2,12 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmForEachCommand.h"
#include <memory>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include "cmAlgorithms.h"
#include "cm_memory.hxx"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
......
......@@ -9,10 +9,11 @@
#include <algorithm>
#include <ctype.h>
#include <iterator>
#include <memory>
#include <sstream>
#include <stdio.h>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmDocumentationEntry.h"
#include "cmFortranParser.h"
......
......@@ -4,10 +4,11 @@
#include <algorithm>
#include <functional>
#include <memory>
#include <sstream>
#include <utility>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratedFileStream.h"
......
......@@ -5,11 +5,12 @@
#include "cmsys/RegularExpression.hxx"
#include <assert.h>
#include <iomanip>
#include <memory>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
#include "cmCustomCommand.h"
......
......@@ -7,7 +7,6 @@
#include <assert.h>
#include <functional>
#include <iterator>
#include <memory>
#include <set>
#include <sstream>
#include <stdexcept>
......@@ -16,6 +15,8 @@
#include <utility>
#include <vector>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmGeneratorExpression.h"
#include "cmMakefile.h"
......
......@@ -5,11 +5,12 @@
#include "cmsys/FStream.hxx"
#include "cmsys/Terminal.h"
#include <algorithm>
#include <memory>
#include <sstream>
#include <stdio.h>
#include <utility>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmCustomCommand.h" // IWYU pragma: keep
#include "cmCustomCommandGenerator.h"
......
......@@ -4,10 +4,13 @@
#include "cmAlgorithms.h"
#include "cmsys/FStream.hxx"
#include <cstddef>
#include <string>
#include <vector>
#include "cm_memory.hxx"
// Include the Mach-O format information system header.
#include <mach-o/fat.h>
#include <mach-o/loader.h>
......
......@@ -2,13 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileExecutableTargetGenerator.h"
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
......
......@@ -2,13 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileLibraryTargetGenerator.h"
#include <memory>
#include <set>
#include <sstream>
#include <stddef.h>
#include <utility>
#include <vector>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
......
......@@ -2,13 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileUtilityTargetGenerator.h"
#include <memory>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
#include "cmAlgorithms.h"
#include "cm_memory.hxx"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalUnixMakefileGenerator3.h"
......
......@@ -6,11 +6,12 @@
#include <assert.h>
#include <iterator>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <utility>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmCustomCommand.h" // IWYU pragma: keep
#include "cmCustomCommandGenerator.h"
......
......@@ -8,10 +8,11 @@
#include <assert.h>
#include <iterator>
#include <map>
#include <memory>
#include <ostream>
#include <utility>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
#include "cmCustomCommandGenerator.h"
......
......@@ -4,7 +4,6 @@
#include "cmQtAutoGen.h"
#include "cmQtAutoGenInitializer.h"
#include "cmAlgorithms.h"
#include "cmCustomCommandLines.h"
#include "cmDuration.h"
#include "cmGeneratorTarget.h"
......@@ -17,9 +16,10 @@
#include "cmSystemTools.h"
#include "cmTarget.h"
#include <memory>
#include <utility>
#include "cm_memory.hxx"
cmQtAutoGenGlobalInitializer::Keywords::Keywords()
: AUTOMOC("AUTOMOC")
, AUTOUIC("AUTOUIC")
......
......@@ -38,6 +38,8 @@
#include <utility>
#include <vector>
#include "cm_memory.hxx"
static std::size_t GetParallelCPUCount()
{
static std::size_t count = 0;
......
......@@ -5,7 +5,8 @@
#include "cmsys/FStream.hxx"
#include "cmAlgorithms.h"
#include "cm_memory.hxx"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmState.h"
......@@ -14,8 +15,6 @@
#include "cmSystemTools.h"
#include "cmake.h"
#include <memory>
cmQtAutoGenerator::Logger::Logger()
{
// Initialize logger
......
......@@ -5,11 +5,12 @@
#include <algorithm>
#include <array>
#include <list>
#include <memory>
#include <set>
#include <sstream>
#include <utility>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmCryptoHash.h"
#include "cmGeneratedFileStream.h"
......
......@@ -3,7 +3,6 @@
#include "cmRuntimeDependencyArchive.h"
#include "cmAlgorithms.h"
#include "cmBinUtilsLinuxELFLinker.h"
#include "cmBinUtilsMacOSMachOLinker.h"
#include "cmBinUtilsWindowsPELinker.h"
......@@ -27,6 +26,8 @@
#include <utility>
#include <vector>
#include "cm_memory.hxx"
#if defined(_WIN32)
static void AddVisualStudioPath(std::vector<std::string>& paths,
const std::string& prefix,
......
......@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmServer.h"
#include "cmAlgorithms.h"
#include "cmConnection.h"
#include "cmFileMonitor.h"
#include "cmJsonObjectDictionary.h"
......@@ -18,10 +17,11 @@
#include <cassert>
#include <cstdint>
#include <iostream>
#include <memory>
#include <mutex>
#include <utility>
#include "cm_memory.hxx"
void on_signal(uv_signal_t* signal, int signum)
{
auto conn = static_cast<cmServerBase*>(signal->data);
......
......@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmServerProtocol.h"
#include "cmAlgorithms.h"
#include "cmExternalMakefileProjectGenerator.h"
#include "cmFileMonitor.h"
#include "cmGlobalGenerator.h"
......@@ -19,11 +18,12 @@
#include <algorithm>
#include <cassert>
#include <functional>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "cm_memory.hxx"
// Get rid of some windows macros:
#undef max
......
......@@ -8,6 +8,8 @@
#include <string.h>
#include <utility>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmCacheManager.h"
#include "cmCommand.h"
......
......@@ -12,6 +12,8 @@
#include <string.h>
#include <unordered_set>
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmCustomCommand.h"
#include "cmGeneratorExpression.h"
......
......@@ -11,9 +11,10 @@
#include <assert.h>
#include <iterator>
#include <memory>
#include <utility>
#include "cm_memory.hxx"
struct cmUVProcessChain::InternalData
{
struct BasicStreamData
......
......@@ -19,9 +19,10 @@
#include "windows.h"
#include <iterator>
#include <memory>
#include <set>
#include "cm_memory.hxx"
static void ConvertToWindowsSlash(std::string& s);
static std::string cmVS10EscapeXML(std::string arg)
......
......@@ -16,6 +16,8 @@
#include <stddef.h>
#include <thread>
#include "cm_memory.hxx"
/**
* @brief libuv pipe buffer class
*/
......
......@@ -5,14 +5,13 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmAlgorithms.h" // IWYU pragma: keep
#include <memory>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
#include "cm_memory.hxx"
// -- Types
class cmWorkerPoolInternal;
......
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cm_memory_hxx
#define cm_memory_hxx
#include "cmConfigure.h" // IWYU pragma: keep
#include <memory> // IWYU pragma: export
#if !defined(CMake_HAVE_CXX_MAKE_UNIQUE)
# include <utility>
#endif
namespace cm {
#if defined(CMake_HAVE_CXX_MAKE_UNIQUE)
using std::make_unique;
#else
template <typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
#endif
} // namespace cm
#endif
......@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmake.h"
#include "cm_memory.hxx"
#include "cmAlgorithms.h"
#include "cmCommands.h"
#include "cmDocumentation.h"
......@@ -104,7 +106,6 @@
#include <cstring>
#include <initializer_list>
#include <iostream>
#include <memory>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
......
#include "cmUVProcessChain.h"
#include "cmAlgorithms.h"
#include "cmGetPipes.h"
#include "cmUVHandlePtr.h"
#include "cmUVStreambuf.h"
......@@ -17,6 +16,8 @@
#include <csignal>
#include "cm_memory.hxx"
struct ExpectedStatus
{
bool Finished;
......
......@@ -51,7 +51,9 @@
{ symbol: [ "std::allocator_traits<std::allocator<cmOrderDirectories::ConflictList> >::value_type", private, "<vector>", public ] },
{ symbol: [ "std::allocator_traits<std::allocator<cmStateSnapshot> >::value_type", private, "<vector>", public ] },
{ symbol: [ "std::allocator_traits<std::allocator<std::basic_string<char> > >::value_type", private, "<vector>", public ] },
{ symbol: [ "std::allocator_traits<std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::value_type", private, "<vector>", public ] },
{ symbol: [ "std::allocator_traits<std::allocator<std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > > > >::value_type", private, "<vector>", public ] },
{ symbol: [ "std::allocator_traits<std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >::value_type", private, "<vector>", public ] },
{ symbol: [ "std::allocator_traits<std::allocator<uv_stdio_container_s> >::value_type", private, "<vector>", public ] },
# TODO: enable this block and remove some <utility> includes?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment