--- /dev/null
+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
"-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
#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"
frames_.reserve(newSize);
while (frames_.size() < newSize)
{
- frames_.push_back(FramePointer(new AnalysisDataStorageFrameData(this, nextIndex_)));
+ frames_.push_back(compat::make_unique<AnalysisDataStorageFrameData>(this, nextIndex_));
++nextIndex_;
}
// The unused frame should not be included in the count.
#include <algorithm>
+#include "gromacs/compat/make_unique.h"
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/gmxlib/network.h"
#include "gromacs/math/utilities.h"
double blockLength = 0;
/* Construct the force correlation object. */
forceCorrelationGrid_ =
- gmx::compat::make_unique<CorrelationGrid>(state_.points().size(), ndim(),
- blockLength, CorrelationGrid::BlockLengthMeasure::Time,
- awhParams.nstSampleCoord*mdTimeStep);
+ compat::make_unique<CorrelationGrid>(state_.points().size(), ndim(),
+ blockLength, CorrelationGrid::BlockLengthMeasure::Time,
+ awhParams.nstSampleCoord*mdTimeStep);
- writer_ = std::unique_ptr<BiasWriter>(new BiasWriter(*this));
+ writer_ = compat::make_unique<BiasWriter>(*this);
}
}
#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"
void HelpExportReStructuredText::startModuleExport()
{
- indexFile_.reset(
- new TextWriter(
- outputRedirector_->openTextOutputFile("fragments/byname.rst")));
+ indexFile_ = compat::make_unique<TextWriter>(
+ outputRedirector_->openTextOutputFile("fragments/byname.rst"));
indexFile_->writeLine(formatString("* :doc:`%s </onlinehelp/%s>` - %s",
binaryName_.c_str(), binaryName_.c_str(),
RootHelpText::title));
- manPagesFile_.reset(
- new TextWriter(
- outputRedirector_->openTextOutputFile("conf-man.py")));
+ manPagesFile_ = compat::make_unique<TextWriter>(
+ outputRedirector_->openTextOutputFile("conf-man.py"));
manPagesFile_->writeLine("man_pages = [");
}
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<TextWriter>(
+ outputRedirector_->openTextOutputFile("fragments/bytopic.rst"));
+ manPagesFile_ = compat::make_unique<TextWriter>(
+ outputRedirector_->openTextOutputFile("fragments/bytopic-man.rst"));
}
void HelpExportReStructuredText::exportModuleGroup(
#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"
broadcastArguments(argc, argv);
try
{
- g_commandLineContext.reset(new CommandLineProgramContext(*argc, *argv));
+ g_commandLineContext = compat::make_unique<CommandLineProgramContext>(*argc, *argv);
setProgramContext(g_commandLineContext.get());
- g_libFileFinder.reset(new DataFileFinder());
+ g_libFileFinder = compat::make_unique<DataFileFinder>();
g_libFileFinder->setSearchPathFromEnv("GMXLIB");
setLibraryFileFinder(g_libFileFinder.get());
}
*
* 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.
#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"
void ShellCompletionWriter::startCompletions()
{
- impl_->file_.reset(new TextWriter(impl_->binaryName_ + "-completion.bash"));
+ impl_->file_ = compat::make_unique<TextWriter>(impl_->binaryName_ + "-completion.bash");
}
void ShellCompletionWriter::writeModuleCompletions(
#include <cmath>
#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"
// If we start from a checkpoint file, we already have an edsamHistory struct
if (oh->edsamHistory == nullptr)
{
- oh->edsamHistory = std::unique_ptr<edsamhistory_t>(new edsamhistory_t {});
+ oh->edsamHistory = gmx::compat::make_unique<edsamhistory_t>(edsamhistory_t {});
}
edsamhistory_t *EDstate = oh->edsamHistory.get();
#endif
#include <array>
+#include <memory>
#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"
{
if (deltaH == nullptr)
{
- enerhist->deltaHForeignLambdas.reset(new delta_h_history_t);
+ enerhist->deltaHForeignLambdas = gmx::compat::make_unique<delta_h_history_t>();
deltaH = enerhist->deltaHForeignLambdas.get();
}
deltaH->dh.resize(numDeltaH);
{
GMX_RELEASE_ASSERT(bRead, "do_cpt_awh should not be called for writing without an AwhHistory");
- awhHistoryLocal = std::shared_ptr<gmx::AwhHistory>(new gmx::AwhHistory());
+ awhHistoryLocal = std::make_shared<gmx::AwhHistory>();
awhHistory = awhHistoryLocal.get();
}
if (headerContents->flags_enh && observablesHistory->energyHistory == nullptr)
{
- observablesHistory->energyHistory = std::unique_ptr<energyhistory_t>(new energyhistory_t {});
+ observablesHistory->energyHistory = gmx::compat::make_unique<energyhistory_t>();
}
ret = do_cpt_enerhist(gmx_fio_getxdr(fp), TRUE,
headerContents->flags_enh, observablesHistory->energyHistory.get(), nullptr);
if (headerContents->nED > 0 && observablesHistory->edsamHistory == nullptr)
{
- observablesHistory->edsamHistory = std::unique_ptr<edsamhistory_t>(new edsamhistory_t {});
+ observablesHistory->edsamHistory = gmx::compat::make_unique<edsamhistory_t>(edsamhistory_t {});
}
ret = do_cpt_EDstate(gmx_fio_getxdr(fp), TRUE, headerContents->nED, observablesHistory->edsamHistory.get(), nullptr);
if (ret)
if (headerContents->flags_awhh != 0 && state->awhHistory == nullptr)
{
- state->awhHistory = std::shared_ptr<gmx::AwhHistory>(new gmx::AwhHistory());
+ state->awhHistory = std::make_shared<gmx::AwhHistory>();
}
ret = do_cpt_awh(gmx_fio_getxdr(fp), TRUE,
headerContents->flags_awhh, state->awhHistory.get(), nullptr);
if (headerContents->eSwapCoords != eswapNO && observablesHistory->swapHistory == nullptr)
{
- observablesHistory->swapHistory = std::unique_ptr<swaphistory_t>(new swaphistory_t {});
+ observablesHistory->swapHistory = gmx::compat::make_unique<swaphistory_t>(swaphistory_t {});
}
ret = do_cpt_swapstate(gmx_fio_getxdr(fp), TRUE, headerContents->eSwapCoords, observablesHistory->swapHistory.get(), nullptr);
if (ret)
AwhGraphSelection awhGraphSelection = (moreGraphs ? AwhGraphSelection::All : AwhGraphSelection::Pmf);
EnergyUnit energyUnit = (kTUnit ? EnergyUnit::KT : EnergyUnit::KJPerMol);
awhReader =
- std::unique_ptr<AwhReader>(new AwhReader(ir.awhParams,
- nfile, fnm,
- awhGraphSelection,
- energyUnit, BOLTZ*ir.opts.ref_t[0],
- block));
+ gmx::compat::make_unique<AwhReader>(ir.awhParams,
+ nfile, fnm,
+ awhGraphSelection,
+ energyUnit, BOLTZ*ir.opts.ref_t[0],
+ block);
}
awhReader->processAwhFrame(*block, frame->t, oenv);
}
}
- nbv->listParams = std::unique_ptr<NbnxnListParameters>(new NbnxnListParameters(ir->rlist));
+ nbv->listParams = gmx::compat::make_unique<NbnxnListParameters>(ir->rlist);
setupDynamicPairlistPruning(mdlog, ir, mtop, box, nbv->grp[0].kernel_type, fr->ic,
nbv->listParams.get());
#include <cassert>
#include <cmath>
+#include "gromacs/compat/make_unique.h"
#include "gromacs/fileio/enxio.h"
#include "gromacs/mdlib/mdebin.h"
#include "gromacs/mdtypes/energyhistory.h"
{
if (enerhist->deltaHForeignLambdas == nullptr)
{
- enerhist->deltaHForeignLambdas.reset(new delta_h_history_t);
+ enerhist->deltaHForeignLambdas = gmx::compat::make_unique<delta_h_history_t>();
enerhist->deltaHForeignLambdas->dh.resize(dhc->ndh);
}
{
top = dd_init_local_top(top_global);
- stateInstance = gmx::compat::make_unique<t_state>();
+ stateInstance = compat::make_unique<t_state>();
state = stateInstance.get();
dd_init_local_state(cr->dd, state_global, state);
}
if (observablesHistory->energyHistory == nullptr)
{
- observablesHistory->energyHistory = std::unique_ptr<energyhistory_t>(new energyhistory_t {});
+ observablesHistory->energyHistory = compat::make_unique<energyhistory_t>();
}
/* Set the initial energy history in state by updating once */
update_energyhistory(observablesHistory->energyHistory.get(), mdebin);
#include <algorithm>
#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"
if (SIMMASTER(cr))
{
/* Only the master rank has the global state */
- globalState = std::unique_ptr<t_state>(new t_state);
+ globalState = compat::make_unique<t_state>();
/* Read (nearly) all data required for the simulation */
read_tpx_state(ftp2fn(efTPR, nfile, fnm), inputrec, globalState.get(), &mtop);
{
if (!MASTER(cr))
{
- globalState = std::unique_ptr<t_state>(new t_state);
+ globalState = compat::make_unique<t_state>();
}
broadcastStateWithoutDynamics(cr, globalState.get());
}
/*
* 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.
#include <memory>
#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"
{
GMX_RELEASE_ASSERT(impl_->forceProviders_ == nullptr,
"Force providers initialized multiple times");
- impl_->forceProviders_.reset(new ForceProviders);
+ impl_->forceProviders_ = compat::make_unique<ForceProviders>();
impl_->field_->initForceProviders(impl_->forceProviders_.get());
return impl_->forceProviders_.get();
}
/*
* 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.
#include <string>
#include <vector>
+#include "gromacs/compat/make_unique.h"
#include "gromacs/onlinehelp/helpformat.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
"Accessing console formatter for non-console output");
if (!consoleOptionsFormatter_)
{
- consoleOptionsFormatter_.reset(new TextTableFormatter());
+ consoleOptionsFormatter_ = compat::make_unique<TextTableFormatter>();
consoleOptionsFormatter_->setFirstColumnIndent(1);
consoleOptionsFormatter_->addColumn(nullptr, 7, false);
consoleOptionsFormatter_->addColumn(nullptr, 18, false);
/*
* 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.
#include <utility>
+#include "gromacs/compat/make_unique.h"
#include "gromacs/options/abstractoption.h"
#include "gromacs/options/abstractoptionstorage.h"
#include "gromacs/options/optionsection.h"
// Make sure that there are no duplicate sections.
GMX_RELEASE_ASSERT(findSection(name) == nullptr, "Duplicate subsection name");
std::unique_ptr<IOptionSectionStorage> storage(section.createStorage());
- subsections_.push_back(SectionPointer(new OptionSectionImpl(managers_, std::move(storage), name)));
+ subsections_.push_back(compat::make_unique<OptionSectionImpl>(managers_, std::move(storage), name));
return subsections_.back().get();
}
/*
* 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.
#include <exception>
+#include "gromacs/compat/make_unique.h"
#include "gromacs/selection/selection.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
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<SelectionParserValueList>())
{
}
/*
* 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.
#include <string>
#include <vector>
+#include "gromacs/compat/make_unique.h"
#include "gromacs/onlinehelp/helpmanager.h"
#include "gromacs/onlinehelp/helpwritercontext.h"
#include "gromacs/options/basicoptions.h"
sc_.top = nullptr;
gmx_ana_index_clear(&sc_.gall);
sc_.mempool = nullptr;
- sc_.symtab.reset(new SelectionParserSymbolTable);
+ sc_.symtab = compat::make_unique<SelectionParserSymbolTable>();
gmx_ana_index_clear(&requiredAtoms_);
gmx_ana_selmethod_register_defaults(sc_.symtab.get());
}
std::unique_ptr<TextWriter> statusWriter;
if (statusStream != nullptr)
{
- statusWriter.reset(new TextWriter(statusStream));
+ statusWriter = compat::make_unique<TextWriter>(statusStream);
statusWriter->wrapperSettings().setLineLength(78);
}
return statusWriter;
#include <string>
+#include "gromacs/compat/make_unique.h"
#include "gromacs/domdec/domdec_struct.h"
#include "gromacs/fileio/confio.h"
#include "gromacs/fileio/gmxfio.h"
{
if (oh->swapHistory == nullptr)
{
- oh->swapHistory = std::unique_ptr<swaphistory_t>(new swaphistory_t {});
+ oh->swapHistory = gmx::compat::make_unique<swaphistory_t>(swaphistory_t {});
}
swapstate = oh->swapHistory.get();
#include <typeindex>
#include <vector>
+#include "gromacs/compat/make_unique.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/ikeyvaluetreeerror.h"
#include "gromacs/utility/keyvaluetreebuilder.h"
{
GMX_RELEASE_ASSERT(rootRule_ == nullptr,
"Cannot specify key match type after child rules");
- rootRule_.reset(new Rule(keyMatchType));
+ rootRule_ = compat::make_unique<Rule>(keyMatchType);
}
std::unique_ptr<Rule> rootRule_;