From 6f4582200097763bba9ba29a517ffe3a296f7bec Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Tue, 17 Jul 2018 13:27:44 -0700 Subject: [PATCH] clang-tidy: modernize make-unique/shared Change-Id: I913646526c767a409b74854c3a8efce5806a2a97 --- src/.clang-tidy | 9 +++++++++ src/gromacs/CMakeLists.txt | 1 + src/gromacs/analysisdata/datastorage.cpp | 3 ++- src/gromacs/awh/bias.cpp | 9 +++++---- src/gromacs/commandline/cmdlinehelpmodule.cpp | 21 +++++++++------------ src/gromacs/commandline/cmdlineinit.cpp | 5 +++-- src/gromacs/commandline/shellcompletions.cpp | 5 +++-- src/gromacs/essentialdynamics/edsam.cpp | 3 ++- src/gromacs/fileio/checkpoint.cpp | 14 ++++++++------ src/gromacs/gmxana/gmx_awh.cpp | 10 +++++----- src/gromacs/mdlib/forcerec.cpp | 2 +- src/gromacs/mdlib/mdebin_bar.cpp | 3 ++- src/gromacs/mdrun/md.cpp | 4 ++-- src/gromacs/mdrun/runner.cpp | 5 +++-- src/gromacs/mdrunutility/mdmodules.cpp | 5 +++-- src/gromacs/onlinehelp/helpwritercontext.cpp | 5 +++-- src/gromacs/options/options.cpp | 5 +++-- src/gromacs/selection/parsetree.cpp | 9 +++++---- src/gromacs/selection/selectioncollection.cpp | 7 ++++--- src/gromacs/swap/swapcoords.cpp | 3 ++- src/gromacs/utility/keyvaluetreetransform.cpp | 3 ++- 21 files changed, 77 insertions(+), 54 deletions(-) create mode 100644 src/.clang-tidy diff --git a/src/.clang-tidy b/src/.clang-tidy new file mode 100644 index 0000000000..f70b77d1e3 --- /dev/null +++ b/src/.clang-tidy @@ -0,0 +1,9 @@ +CheckOptions: + - key: modernize-make-unique.MakeSmartPtrFunction + value: gmx::compat::make_unique + - key: modernize-make-unique.MakeSmartPtrFunctionHeader + value: gromacs/compat/make_unique.h + - key: modernize-make-unique.IncludeStyle + value: google + - key: modernize-make-shared.IncludeStyle + value: google diff --git a/src/gromacs/CMakeLists.txt b/src/gromacs/CMakeLists.txt index beeddfeaa0..ec2876c840 100644 --- a/src/gromacs/CMakeLists.txt +++ b/src/gromacs/CMakeLists.txt @@ -345,6 +345,7 @@ if (GMX_CLANG_TIDY) "-readability-inconsistent-declaration-parameter-name" "-readability-implicit-bool-conversion" #TODO: Remove gmx_bool "modernize-use-nullptr" "modernize-use-emplace" + "modernize-make-unique" "modernize-make-shared" ) string(REPLACE ";" "," CLANG_TIDY_CHECKS "${CLANG_TIDY_CHECKS}") set_target_properties(libgromacs PROPERTIES CXX_CLANG_TIDY diff --git a/src/gromacs/analysisdata/datastorage.cpp b/src/gromacs/analysisdata/datastorage.cpp index d70f095258..164f9b877d 100644 --- a/src/gromacs/analysisdata/datastorage.cpp +++ b/src/gromacs/analysisdata/datastorage.cpp @@ -53,6 +53,7 @@ #include "gromacs/analysisdata/dataframe.h" #include "gromacs/analysisdata/datamodulemanager.h" #include "gromacs/analysisdata/paralleloptions.h" +#include "gromacs/compat/make_unique.h" #include "gromacs/utility/exceptions.h" #include "gromacs/utility/gmxassert.h" @@ -450,7 +451,7 @@ AnalysisDataStorageImpl::extendBuffer(size_t newSize) frames_.reserve(newSize); while (frames_.size() < newSize) { - frames_.push_back(FramePointer(new AnalysisDataStorageFrameData(this, nextIndex_))); + frames_.push_back(compat::make_unique(this, nextIndex_)); ++nextIndex_; } // The unused frame should not be included in the count. diff --git a/src/gromacs/awh/bias.cpp b/src/gromacs/awh/bias.cpp index 4310aef885..14f4bc770c 100644 --- a/src/gromacs/awh/bias.cpp +++ b/src/gromacs/awh/bias.cpp @@ -55,6 +55,7 @@ #include +#include "gromacs/compat/make_unique.h" #include "gromacs/fileio/gmxfio.h" #include "gromacs/gmxlib/network.h" #include "gromacs/math/utilities.h" @@ -349,11 +350,11 @@ Bias::Bias(int biasIndexInCollection, double blockLength = 0; /* Construct the force correlation object. */ forceCorrelationGrid_ = - gmx::compat::make_unique(state_.points().size(), ndim(), - blockLength, CorrelationGrid::BlockLengthMeasure::Time, - awhParams.nstSampleCoord*mdTimeStep); + compat::make_unique(state_.points().size(), ndim(), + blockLength, CorrelationGrid::BlockLengthMeasure::Time, + awhParams.nstSampleCoord*mdTimeStep); - writer_ = std::unique_ptr(new BiasWriter(*this)); + writer_ = compat::make_unique(*this); } } diff --git a/src/gromacs/commandline/cmdlinehelpmodule.cpp b/src/gromacs/commandline/cmdlinehelpmodule.cpp index dba1408a96..cf006c3908 100644 --- a/src/gromacs/commandline/cmdlinehelpmodule.cpp +++ b/src/gromacs/commandline/cmdlinehelpmodule.cpp @@ -50,6 +50,7 @@ #include "gromacs/commandline/cmdlinehelpcontext.h" #include "gromacs/commandline/cmdlinehelpwriter.h" #include "gromacs/commandline/cmdlineparser.h" +#include "gromacs/compat/make_unique.h" #include "gromacs/onlinehelp/helpformat.h" #include "gromacs/onlinehelp/helpmanager.h" #include "gromacs/onlinehelp/helptopic.h" @@ -567,15 +568,13 @@ HelpExportReStructuredText::HelpExportReStructuredText( void HelpExportReStructuredText::startModuleExport() { - indexFile_.reset( - new TextWriter( - outputRedirector_->openTextOutputFile("fragments/byname.rst"))); + indexFile_ = compat::make_unique( + outputRedirector_->openTextOutputFile("fragments/byname.rst")); indexFile_->writeLine(formatString("* :doc:`%s ` - %s", binaryName_.c_str(), binaryName_.c_str(), RootHelpText::title)); - manPagesFile_.reset( - new TextWriter( - outputRedirector_->openTextOutputFile("conf-man.py"))); + manPagesFile_ = compat::make_unique( + outputRedirector_->openTextOutputFile("conf-man.py")); manPagesFile_->writeLine("man_pages = ["); } @@ -636,12 +635,10 @@ void HelpExportReStructuredText::finishModuleExport() void HelpExportReStructuredText::startModuleGroupExport() { - indexFile_.reset( - new TextWriter( - outputRedirector_->openTextOutputFile("fragments/bytopic.rst"))); - manPagesFile_.reset( - new TextWriter( - outputRedirector_->openTextOutputFile("fragments/bytopic-man.rst"))); + indexFile_ = compat::make_unique( + outputRedirector_->openTextOutputFile("fragments/bytopic.rst")); + manPagesFile_ = compat::make_unique( + outputRedirector_->openTextOutputFile("fragments/bytopic-man.rst")); } void HelpExportReStructuredText::exportModuleGroup( diff --git a/src/gromacs/commandline/cmdlineinit.cpp b/src/gromacs/commandline/cmdlineinit.cpp index 0420c4cb47..a9561e08c2 100644 --- a/src/gromacs/commandline/cmdlineinit.cpp +++ b/src/gromacs/commandline/cmdlineinit.cpp @@ -51,6 +51,7 @@ #include "gromacs/commandline/cmdlinemodulemanager.h" #include "gromacs/commandline/cmdlineoptionsmodule.h" #include "gromacs/commandline/cmdlineprogramcontext.h" +#include "gromacs/compat/make_unique.h" #include "gromacs/utility/basenetwork.h" #include "gromacs/utility/datafilefinder.h" #include "gromacs/utility/exceptions.h" @@ -125,9 +126,9 @@ CommandLineProgramContext &initForCommandLine(int *argc, char ***argv) broadcastArguments(argc, argv); try { - g_commandLineContext.reset(new CommandLineProgramContext(*argc, *argv)); + g_commandLineContext = compat::make_unique(*argc, *argv); setProgramContext(g_commandLineContext.get()); - g_libFileFinder.reset(new DataFileFinder()); + g_libFileFinder = compat::make_unique(); g_libFileFinder->setSearchPathFromEnv("GMXLIB"); setLibraryFileFinder(g_libFileFinder.get()); } diff --git a/src/gromacs/commandline/shellcompletions.cpp b/src/gromacs/commandline/shellcompletions.cpp index 7a8e23da57..9ecb1a930c 100644 --- a/src/gromacs/commandline/shellcompletions.cpp +++ b/src/gromacs/commandline/shellcompletions.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -53,6 +53,7 @@ #include "gromacs/commandline/cmdlinehelpcontext.h" #include "gromacs/commandline/pargs.h" +#include "gromacs/compat/make_unique.h" #include "gromacs/fileio/filetypes.h" #include "gromacs/options/basicoptions.h" #include "gromacs/options/filenameoption.h" @@ -221,7 +222,7 @@ TextWriter &ShellCompletionWriter::outputWriter() void ShellCompletionWriter::startCompletions() { - impl_->file_.reset(new TextWriter(impl_->binaryName_ + "-completion.bash")); + impl_->file_ = compat::make_unique(impl_->binaryName_ + "-completion.bash"); } void ShellCompletionWriter::writeModuleCompletions( diff --git a/src/gromacs/essentialdynamics/edsam.cpp b/src/gromacs/essentialdynamics/edsam.cpp index 41febe0a6d..1549b0fdbf 100644 --- a/src/gromacs/essentialdynamics/edsam.cpp +++ b/src/gromacs/essentialdynamics/edsam.cpp @@ -45,6 +45,7 @@ #include #include "gromacs/commandline/filenm.h" +#include "gromacs/compat/make_unique.h" #include "gromacs/domdec/domdec_struct.h" #include "gromacs/fileio/gmxfio.h" #include "gromacs/fileio/xvgr.h" @@ -1128,7 +1129,7 @@ static gmx_edsam_t ed_open( // If we start from a checkpoint file, we already have an edsamHistory struct if (oh->edsamHistory == nullptr) { - oh->edsamHistory = std::unique_ptr(new edsamhistory_t {}); + oh->edsamHistory = gmx::compat::make_unique(edsamhistory_t {}); } edsamhistory_t *EDstate = oh->edsamHistory.get(); diff --git a/src/gromacs/fileio/checkpoint.cpp b/src/gromacs/fileio/checkpoint.cpp index 8cb2c57891..23181f40b5 100644 --- a/src/gromacs/fileio/checkpoint.cpp +++ b/src/gromacs/fileio/checkpoint.cpp @@ -52,8 +52,10 @@ #endif #include +#include #include "buildinfo.h" +#include "gromacs/compat/make_unique.h" #include "gromacs/fileio/filetypes.h" #include "gromacs/fileio/gmxfio.h" #include "gromacs/fileio/gmxfio-xdr.h" @@ -1367,7 +1369,7 @@ static int do_cpt_enerhist(XDR *xd, gmx_bool bRead, { if (deltaH == nullptr) { - enerhist->deltaHForeignLambdas.reset(new delta_h_history_t); + enerhist->deltaHForeignLambdas = gmx::compat::make_unique(); deltaH = enerhist->deltaHForeignLambdas.get(); } deltaH->dh.resize(numDeltaH); @@ -1646,7 +1648,7 @@ static int do_cpt_awh(XDR *xd, gmx_bool bRead, { GMX_RELEASE_ASSERT(bRead, "do_cpt_awh should not be called for writing without an AwhHistory"); - awhHistoryLocal = std::shared_ptr(new gmx::AwhHistory()); + awhHistoryLocal = std::make_shared(); awhHistory = awhHistoryLocal.get(); } @@ -2268,7 +2270,7 @@ static void read_checkpoint(const char *fn, FILE **pfplog, if (headerContents->flags_enh && observablesHistory->energyHistory == nullptr) { - observablesHistory->energyHistory = std::unique_ptr(new energyhistory_t {}); + observablesHistory->energyHistory = gmx::compat::make_unique(); } ret = do_cpt_enerhist(gmx_fio_getxdr(fp), TRUE, headerContents->flags_enh, observablesHistory->energyHistory.get(), nullptr); @@ -2290,7 +2292,7 @@ static void read_checkpoint(const char *fn, FILE **pfplog, if (headerContents->nED > 0 && observablesHistory->edsamHistory == nullptr) { - observablesHistory->edsamHistory = std::unique_ptr(new edsamhistory_t {}); + observablesHistory->edsamHistory = gmx::compat::make_unique(edsamhistory_t {}); } ret = do_cpt_EDstate(gmx_fio_getxdr(fp), TRUE, headerContents->nED, observablesHistory->edsamHistory.get(), nullptr); if (ret) @@ -2300,7 +2302,7 @@ static void read_checkpoint(const char *fn, FILE **pfplog, if (headerContents->flags_awhh != 0 && state->awhHistory == nullptr) { - state->awhHistory = std::shared_ptr(new gmx::AwhHistory()); + state->awhHistory = std::make_shared(); } ret = do_cpt_awh(gmx_fio_getxdr(fp), TRUE, headerContents->flags_awhh, state->awhHistory.get(), nullptr); @@ -2311,7 +2313,7 @@ static void read_checkpoint(const char *fn, FILE **pfplog, if (headerContents->eSwapCoords != eswapNO && observablesHistory->swapHistory == nullptr) { - observablesHistory->swapHistory = std::unique_ptr(new swaphistory_t {}); + observablesHistory->swapHistory = gmx::compat::make_unique(swaphistory_t {}); } ret = do_cpt_swapstate(gmx_fio_getxdr(fp), TRUE, headerContents->eSwapCoords, observablesHistory->swapHistory.get(), nullptr); if (ret) diff --git a/src/gromacs/gmxana/gmx_awh.cpp b/src/gromacs/gmxana/gmx_awh.cpp index f04f00b36e..9b0f14d397 100644 --- a/src/gromacs/gmxana/gmx_awh.cpp +++ b/src/gromacs/gmxana/gmx_awh.cpp @@ -641,11 +641,11 @@ int gmx_awh(int argc, char *argv[]) AwhGraphSelection awhGraphSelection = (moreGraphs ? AwhGraphSelection::All : AwhGraphSelection::Pmf); EnergyUnit energyUnit = (kTUnit ? EnergyUnit::KT : EnergyUnit::KJPerMol); awhReader = - std::unique_ptr(new AwhReader(ir.awhParams, - nfile, fnm, - awhGraphSelection, - energyUnit, BOLTZ*ir.opts.ref_t[0], - block)); + gmx::compat::make_unique(ir.awhParams, + nfile, fnm, + awhGraphSelection, + energyUnit, BOLTZ*ir.opts.ref_t[0], + block); } awhReader->processAwhFrame(*block, frame->t, oenv); diff --git a/src/gromacs/mdlib/forcerec.cpp b/src/gromacs/mdlib/forcerec.cpp index b7bcdb28d0..329a73feb4 100644 --- a/src/gromacs/mdlib/forcerec.cpp +++ b/src/gromacs/mdlib/forcerec.cpp @@ -2187,7 +2187,7 @@ static void init_nb_verlet(const gmx::MDLogger &mdlog, } } - nbv->listParams = std::unique_ptr(new NbnxnListParameters(ir->rlist)); + nbv->listParams = gmx::compat::make_unique(ir->rlist); setupDynamicPairlistPruning(mdlog, ir, mtop, box, nbv->grp[0].kernel_type, fr->ic, nbv->listParams.get()); diff --git a/src/gromacs/mdlib/mdebin_bar.cpp b/src/gromacs/mdlib/mdebin_bar.cpp index c1c359ac54..58d77cbc52 100644 --- a/src/gromacs/mdlib/mdebin_bar.cpp +++ b/src/gromacs/mdlib/mdebin_bar.cpp @@ -44,6 +44,7 @@ #include #include +#include "gromacs/compat/make_unique.h" #include "gromacs/fileio/enxio.h" #include "gromacs/mdlib/mdebin.h" #include "gromacs/mdtypes/energyhistory.h" @@ -716,7 +717,7 @@ void mde_delta_h_coll_update_energyhistory(const t_mde_delta_h_coll *dhc, { if (enerhist->deltaHForeignLambdas == nullptr) { - enerhist->deltaHForeignLambdas.reset(new delta_h_history_t); + enerhist->deltaHForeignLambdas = gmx::compat::make_unique(); enerhist->deltaHForeignLambdas->dh.resize(dhc->ndh); } diff --git a/src/gromacs/mdrun/md.cpp b/src/gromacs/mdrun/md.cpp index 1b0f144e66..e7040165f0 100644 --- a/src/gromacs/mdrun/md.cpp +++ b/src/gromacs/mdrun/md.cpp @@ -462,7 +462,7 @@ void gmx::Integrator::do_md() { top = dd_init_local_top(top_global); - stateInstance = gmx::compat::make_unique(); + stateInstance = compat::make_unique(); state = stateInstance.get(); dd_init_local_state(cr->dd, state_global, state); @@ -529,7 +529,7 @@ void gmx::Integrator::do_md() } if (observablesHistory->energyHistory == nullptr) { - observablesHistory->energyHistory = std::unique_ptr(new energyhistory_t {}); + observablesHistory->energyHistory = compat::make_unique(); } /* Set the initial energy history in state by updating once */ update_energyhistory(observablesHistory->energyHistory.get(), mdebin); diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index 672a93368c..4c7a2dead4 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -55,6 +55,7 @@ #include #include "gromacs/commandline/filenm.h" +#include "gromacs/compat/make_unique.h" #include "gromacs/domdec/domdec.h" #include "gromacs/domdec/domdec_struct.h" #include "gromacs/domdec/localatomsetmanager.h" @@ -505,7 +506,7 @@ int Mdrunner::mdrunner() if (SIMMASTER(cr)) { /* Only the master rank has the global state */ - globalState = std::unique_ptr(new t_state); + globalState = compat::make_unique(); /* Read (nearly) all data required for the simulation */ read_tpx_state(ftp2fn(efTPR, nfile, fnm), inputrec, globalState.get(), &mtop); @@ -663,7 +664,7 @@ int Mdrunner::mdrunner() { if (!MASTER(cr)) { - globalState = std::unique_ptr(new t_state); + globalState = compat::make_unique(); } broadcastStateWithoutDynamics(cr, globalState.get()); } diff --git a/src/gromacs/mdrunutility/mdmodules.cpp b/src/gromacs/mdrunutility/mdmodules.cpp index 2ee50c8928..62de105da3 100644 --- a/src/gromacs/mdrunutility/mdmodules.cpp +++ b/src/gromacs/mdrunutility/mdmodules.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2016,2017, by the GROMACS development team, led by + * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -39,6 +39,7 @@ #include #include "gromacs/applied-forces/electricfield.h" +#include "gromacs/compat/make_unique.h" #include "gromacs/mdtypes/iforceprovider.h" #include "gromacs/mdtypes/imdmodule.h" #include "gromacs/mdtypes/imdoutputprovider.h" @@ -139,7 +140,7 @@ ForceProviders *MDModules::initForceProviders() { GMX_RELEASE_ASSERT(impl_->forceProviders_ == nullptr, "Force providers initialized multiple times"); - impl_->forceProviders_.reset(new ForceProviders); + impl_->forceProviders_ = compat::make_unique(); impl_->field_->initForceProviders(impl_->forceProviders_.get()); return impl_->forceProviders_.get(); } diff --git a/src/gromacs/onlinehelp/helpwritercontext.cpp b/src/gromacs/onlinehelp/helpwritercontext.cpp index dcc655e3d2..61bc1b9168 100644 --- a/src/gromacs/onlinehelp/helpwritercontext.cpp +++ b/src/gromacs/onlinehelp/helpwritercontext.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by + * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -50,6 +50,7 @@ #include #include +#include "gromacs/compat/make_unique.h" #include "gromacs/onlinehelp/helpformat.h" #include "gromacs/utility/exceptions.h" #include "gromacs/utility/gmxassert.h" @@ -455,7 +456,7 @@ class HelpWriterContext::Impl "Accessing console formatter for non-console output"); if (!consoleOptionsFormatter_) { - consoleOptionsFormatter_.reset(new TextTableFormatter()); + consoleOptionsFormatter_ = compat::make_unique(); consoleOptionsFormatter_->setFirstColumnIndent(1); consoleOptionsFormatter_->addColumn(nullptr, 7, false); consoleOptionsFormatter_->addColumn(nullptr, 18, false); diff --git a/src/gromacs/options/options.cpp b/src/gromacs/options/options.cpp index f063820c22..9f9486aeea 100644 --- a/src/gromacs/options/options.cpp +++ b/src/gromacs/options/options.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2010,2011,2012,2014,2015,2016,2017, by the GROMACS development team, led by + * Copyright (c) 2010,2011,2012,2014,2015,2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -45,6 +45,7 @@ #include +#include "gromacs/compat/make_unique.h" #include "gromacs/options/abstractoption.h" #include "gromacs/options/abstractoptionstorage.h" #include "gromacs/options/optionsection.h" @@ -113,7 +114,7 @@ OptionSectionImpl::addSectionImpl(const AbstractOptionSection §ion) // Make sure that there are no duplicate sections. GMX_RELEASE_ASSERT(findSection(name) == nullptr, "Duplicate subsection name"); std::unique_ptr storage(section.createStorage()); - subsections_.push_back(SectionPointer(new OptionSectionImpl(managers_, std::move(storage), name))); + subsections_.push_back(compat::make_unique(managers_, std::move(storage), name)); return subsections_.back().get(); } diff --git a/src/gromacs/selection/parsetree.cpp b/src/gromacs/selection/parsetree.cpp index 2db9ae1035..9ec2750989 100644 --- a/src/gromacs/selection/parsetree.cpp +++ b/src/gromacs/selection/parsetree.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by + * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -229,6 +229,7 @@ #include +#include "gromacs/compat/make_unique.h" #include "gromacs/selection/selection.h" #include "gromacs/utility/cstringutil.h" #include "gromacs/utility/exceptions.h" @@ -357,9 +358,9 @@ SelectionParserParameter::SelectionParserParameter( const char *name, SelectionParserValueListPointer values, const SelectionLocation &location) - : name_(name != nullptr ? name : ""), location_(location), - values_(values ? std::move(values) - : SelectionParserValueListPointer(new SelectionParserValueList)) + : name_(name != nullptr ? name : ""), + location_(location), + values_(values ? std::move(values) : compat::make_unique()) { } diff --git a/src/gromacs/selection/selectioncollection.cpp b/src/gromacs/selection/selectioncollection.cpp index 7b9b17073d..de4e8416aa 100644 --- a/src/gromacs/selection/selectioncollection.cpp +++ b/src/gromacs/selection/selectioncollection.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by + * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -50,6 +50,7 @@ #include #include +#include "gromacs/compat/make_unique.h" #include "gromacs/onlinehelp/helpmanager.h" #include "gromacs/onlinehelp/helpwritercontext.h" #include "gromacs/options/basicoptions.h" @@ -91,7 +92,7 @@ SelectionCollection::Impl::Impl() sc_.top = nullptr; gmx_ana_index_clear(&sc_.gall); sc_.mempool = nullptr; - sc_.symtab.reset(new SelectionParserSymbolTable); + sc_.symtab = compat::make_unique(); gmx_ana_index_clear(&requiredAtoms_); gmx_ana_selmethod_register_defaults(sc_.symtab.get()); } @@ -725,7 +726,7 @@ std::unique_ptr initStatusWriter(TextOutputStream *statusStream) std::unique_ptr statusWriter; if (statusStream != nullptr) { - statusWriter.reset(new TextWriter(statusStream)); + statusWriter = compat::make_unique(statusStream); statusWriter->wrapperSettings().setLineLength(78); } return statusWriter; diff --git a/src/gromacs/swap/swapcoords.cpp b/src/gromacs/swap/swapcoords.cpp index 2d579e4aec..0c2ccd800e 100644 --- a/src/gromacs/swap/swapcoords.cpp +++ b/src/gromacs/swap/swapcoords.cpp @@ -49,6 +49,7 @@ #include +#include "gromacs/compat/make_unique.h" #include "gromacs/domdec/domdec_struct.h" #include "gromacs/fileio/confio.h" #include "gromacs/fileio/gmxfio.h" @@ -1555,7 +1556,7 @@ void init_swapcoords( { if (oh->swapHistory == nullptr) { - oh->swapHistory = std::unique_ptr(new swaphistory_t {}); + oh->swapHistory = gmx::compat::make_unique(swaphistory_t {}); } swapstate = oh->swapHistory.get(); diff --git a/src/gromacs/utility/keyvaluetreetransform.cpp b/src/gromacs/utility/keyvaluetreetransform.cpp index cf4f32f963..7d138047b2 100644 --- a/src/gromacs/utility/keyvaluetreetransform.cpp +++ b/src/gromacs/utility/keyvaluetreetransform.cpp @@ -42,6 +42,7 @@ #include #include +#include "gromacs/compat/make_unique.h" #include "gromacs/utility/exceptions.h" #include "gromacs/utility/ikeyvaluetreeerror.h" #include "gromacs/utility/keyvaluetreebuilder.h" @@ -324,7 +325,7 @@ class KeyValueTreeTransformerImpl { GMX_RELEASE_ASSERT(rootRule_ == nullptr, "Cannot specify key match type after child rules"); - rootRule_.reset(new Rule(keyMatchType)); + rootRule_ = compat::make_unique(keyMatchType); } std::unique_ptr rootRule_; -- 2.11.4.GIT