CMake/Source/CTest/cmCTestMemCheckCommand.cxx
Sebastian Holtermann 3b2b02825d Source sweep: Replace std::ostringstream when used with a single append
This replaces `std::ostringstream`, when it is written to only once.
If the single written argument was numeric, `std::to_string` is used instead.
Otherwise, the single written argument is used directly instead of the
`std::ostringstream::str()` invocation.
2019-08-23 18:52:33 +02:00

53 lines
1.8 KiB
C++

/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestMemCheckCommand.h"
#include <string>
#include <vector>
#include "cmCTest.h"
#include "cmCTestMemCheckHandler.h"
#include "cmMakefile.h"
cmCTestMemCheckCommand::cmCTestMemCheckCommand()
{
this->Arguments[ctm_DEFECT_COUNT] = "DEFECT_COUNT";
this->Arguments[ctm_LAST] = nullptr;
this->Last = ctm_LAST;
}
cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler()
{
cmCTestMemCheckHandler* handler = this->CTest->GetMemCheckHandler();
handler->Initialize();
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "MemoryCheckSanitizerOptions",
"CTEST_MEMORYCHECK_SANITIZER_OPTIONS", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND",
this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "MemoryCheckCommandOptions",
"CTEST_MEMORYCHECK_COMMAND_OPTIONS", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "MemoryCheckSuppressionFile",
"CTEST_MEMORYCHECK_SUPPRESSIONS_FILE", this->Quiet);
handler->SetQuiet(this->Quiet);
return handler;
}
void cmCTestMemCheckCommand::ProcessAdditionalValues(
cmCTestGenericHandler* handler)
{
if (this->Values[ctm_DEFECT_COUNT] && *this->Values[ctm_DEFECT_COUNT]) {
this->Makefile->AddDefinition(
this->Values[ctm_DEFECT_COUNT],
std::to_string(
static_cast<cmCTestMemCheckHandler*>(handler)->GetDefectCount()));
}
}