Commit 1b2bb933 authored by Daniel Pfeifer's avatar Daniel Pfeifer
Browse files

Remove redundant c_str() calls.

Run clang-tidy's readability-redundant-string-cstr checker.
Ignore findings in kwsys.
parent acd8a730
......@@ -414,8 +414,8 @@ int main(int argc, char const* const* argv)
for (generatorIt = generators.GetGeneratorsList().begin();
generatorIt != generators.GetGeneratorsList().end(); ++generatorIt) {
cmDocumentationEntry e;
e.Name = generatorIt->first.c_str();
e.Brief = generatorIt->second.c_str();
e.Name = generatorIt->first;
e.Brief = generatorIt->second;
v.push_back(e);
}
doc.SetSection("Generators", v);
......
......@@ -1622,7 +1622,7 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
return false;
}
prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory().c_str();
prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory();
// DPI file should appear in build directory
std::string daGlob;
......
......@@ -68,7 +68,7 @@ void cmCTestGenericHandler::Initialize()
t_StringToString::iterator it;
for (it = this->PersistentOptions.begin();
it != this->PersistentOptions.end(); ++it) {
this->Options[it->first] = it->second.c_str();
this->Options[it->first] = it->second;
}
}
......
......@@ -422,7 +422,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
if (cmSystemTools::FileExists(
this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str())) {
this->MemoryTester =
this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str();
this->CTest->GetCTestConfiguration("MemoryCheckCommand");
std::string testerName =
cmSystemTools::GetFilenameName(this->MemoryTester);
// determine the checker type
......@@ -438,47 +438,41 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
}
} else if (cmSystemTools::FileExists(
this->CTest->GetCTestConfiguration("PurifyCommand").c_str())) {
this->MemoryTester =
this->CTest->GetCTestConfiguration("PurifyCommand").c_str();
this->MemoryTester = this->CTest->GetCTestConfiguration("PurifyCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
} else if (cmSystemTools::FileExists(
this->CTest->GetCTestConfiguration("ValgrindCommand")
.c_str())) {
this->MemoryTester =
this->CTest->GetCTestConfiguration("ValgrindCommand").c_str();
this->MemoryTester = this->CTest->GetCTestConfiguration("ValgrindCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
} else if (cmSystemTools::FileExists(
this->CTest->GetCTestConfiguration("BoundsCheckerCommand")
.c_str())) {
this->MemoryTester =
this->CTest->GetCTestConfiguration("BoundsCheckerCommand").c_str();
this->CTest->GetCTestConfiguration("BoundsCheckerCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
}
if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
"AddressSanitizer") {
this->MemoryTester =
this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::ADDRESS_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
}
if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
"ThreadSanitizer") {
this->MemoryTester =
this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::THREAD_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
}
if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
"MemorySanitizer") {
this->MemoryTester =
this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::MEMORY_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
}
if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
"UndefinedBehaviorSanitizer") {
this->MemoryTester =
this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::UB_SANITIZER;
this->LogWithPID = true; // even if we give the log file the pid is added
}
......
......@@ -424,7 +424,7 @@ bool cmCTestRunTest::StartTest(size_t total)
this->TestResult.Status = cmCTestTestHandler::BAD_COMMAND;
this->TestResult.TestCount = this->TestProperties->Index;
this->TestResult.Name = this->TestProperties->Name;
this->TestResult.Path = this->TestProperties->Directory.c_str();
this->TestResult.Path = this->TestProperties->Directory;
if (args.size() >= 2 && args[1] == "NOT_AVAILABLE") {
this->TestProcess = new cmProcess;
......@@ -502,7 +502,7 @@ void cmCTestRunTest::ComputeArguments()
if (this->TestHandler->MemCheck) {
cmCTestMemCheckHandler* handler =
static_cast<cmCTestMemCheckHandler*>(this->TestHandler);
this->ActualCommand = handler->MemoryTester.c_str();
this->ActualCommand = handler->MemoryTester;
this->TestProperties->Args[1] = this->TestHandler->FindTheExecutable(
this->TestProperties->Args[1].c_str());
} else {
......
......@@ -485,7 +485,7 @@ int cmCTestScriptHandler::ExtractVariables()
// if the dashboard root isn't specified then we can compute it from the
// this->SourceDir
if (this->CTestRoot.empty()) {
this->CTestRoot = cmSystemTools::GetFilenamePath(this->SourceDir).c_str();
this->CTestRoot = cmSystemTools::GetFilenamePath(this->SourceDir);
}
// the script may override the minimum continuous interval
......
......@@ -74,7 +74,7 @@ public:
}
foundFile = true;
inSource = false;
filename = getValue(line, 0).c_str();
filename = getValue(line, 0);
} else if ((line.find("coverage") != line.npos) && foundFile &&
inSource) {
/*
......
......@@ -121,7 +121,7 @@ bool cmParseGTMCoverage::FindFunctionInMumpsFile(std::string const& filepath,
std::string line;
int linenum = 0;
while (cmSystemTools::GetLineFromStream(in, line)) {
std::string::size_type pos = line.find(function.c_str());
std::string::size_type pos = line.find(function);
if (pos == 0) {
char nextchar = line[function.size()];
if (nextchar == ' ' || nextchar == '(' || nextchar == '\t') {
......
......@@ -76,7 +76,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(
return;
}
lg->GetMakefile()->AddCMakeOutputFile(outputFileName.c_str());
lg->GetMakefile()->AddCMakeOutputFile(outputFileName);
this->Files.push_back(outputFileName);
outputFiles[outputFileName] = outputContent;
......@@ -114,7 +114,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
if (this->InputIsContent) {
inputContent = this->Input;
} else {
lg->GetMakefile()->AddCMakeDependFile(this->Input.c_str());
lg->GetMakefile()->AddCMakeDependFile(this->Input);
cmSystemTools::GetPermissions(this->Input.c_str(), perm);
cmsys::ifstream fin(this->Input.c_str());
if (!fin) {
......
......@@ -958,7 +958,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule(
if (emittedTargets.insert(name).second) {
path = "... ";
path += name;
lg->AppendEcho(commands, path.c_str());
lg->AppendEcho(commands, path);
}
}
}
......@@ -969,7 +969,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule(
o != localHelp.end(); ++o) {
path = "... ";
path += *o;
lg->AppendEcho(commands, path.c_str());
lg->AppendEcho(commands, path);
}
lg->WriteMakeRule(ruleFileStream, "Help Target", "help", no_depends,
commands, true);
......
......@@ -159,9 +159,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
buildEcho += linkLanguage;
buildEcho += " executable ";
buildEcho += targetOutPath;
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(),
cmLocalUnixMakefileGenerator3::EchoLink,
&progress);
this->LocalGenerator->AppendEcho(
commands, buildEcho, cmLocalUnixMakefileGenerator3::EchoLink, &progress);
}
// Build a list of compiler flags and linker flags.
......
......@@ -337,10 +337,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
buildEcho += " library ";
break;
}
buildEcho += targetOutPath.c_str();
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(),
cmLocalUnixMakefileGenerator3::EchoLink,
&progress);
buildEcho += targetOutPath;
this->LocalGenerator->AppendEcho(
commands, buildEcho, cmLocalUnixMakefileGenerator3::EchoLink, &progress);
}
const char* forbiddenFlagVar = 0;
......
......@@ -311,7 +311,7 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()(
std::string copyEcho = "Copying OS X content ";
copyEcho += output;
this->Generator->LocalGenerator->AppendEcho(
commands, copyEcho.c_str(), cmLocalUnixMakefileGenerator3::EchoBuild);
commands, copyEcho, cmLocalUnixMakefileGenerator3::EchoBuild);
std::string copyCommand = "$(CMAKE_COMMAND) -E copy ";
copyCommand += this->Generator->Convert(input, cmOutputConverter::NONE,
cmOutputConverter::SHELL);
......@@ -469,7 +469,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
buildEcho += lang;
buildEcho += " object ";
buildEcho += relativeObj;
this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(),
this->LocalGenerator->AppendEcho(commands, buildEcho,
cmLocalUnixMakefileGenerator3::EchoBuild,
&progress);
}
......@@ -676,8 +676,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
preprocessEcho += " source to ";
preprocessEcho += objI;
this->LocalGenerator->AppendEcho(
commands, preprocessEcho.c_str(),
cmLocalUnixMakefileGenerator3::EchoBuild);
commands, preprocessEcho, cmLocalUnixMakefileGenerator3::EchoBuild);
std::string preprocessRuleVar = "CMAKE_";
preprocessRuleVar += lang;
......@@ -724,8 +723,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
assemblyEcho += " source to assembly ";
assemblyEcho += objS;
this->LocalGenerator->AppendEcho(
commands, assemblyEcho.c_str(),
cmLocalUnixMakefileGenerator3::EchoBuild);
commands, assemblyEcho, cmLocalUnixMakefileGenerator3::EchoBuild);
std::string assemblyRuleVar = "CMAKE_";
assemblyRuleVar += lang;
......@@ -1073,7 +1071,7 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile(
cmLocalUnixMakefileGenerator3::EchoProgress progress;
this->MakeEchoProgress(progress);
this->LocalGenerator->AppendEcho(
commands, comment.c_str(), cmLocalUnixMakefileGenerator3::EchoGenerate,
commands, comment, cmLocalUnixMakefileGenerator3::EchoGenerate,
&progress);
}
}
......
......@@ -445,7 +445,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
name_of_def_file += ".def ";
vars["LINK_FLAGS"] += " /DEF:";
vars["LINK_FLAGS"] += this->GetLocalGenerator()->ConvertToOutputFormat(
name_of_def_file.c_str(), cmOutputConverter::SHELL);
name_of_def_file, cmOutputConverter::SHELL);
}
}
......@@ -572,13 +572,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
std::string cmd = cmakeCommand;
cmd += " -E __create_def ";
cmd += this->GetLocalGenerator()->ConvertToOutputFormat(
name_of_def_file.c_str(), cmOutputConverter::SHELL);
name_of_def_file, cmOutputConverter::SHELL);
cmd += " ";
cmNinjaDeps objs = this->GetObjects();
std::string obj_list_file = name_of_def_file;
obj_list_file += ".objs";
cmd += this->GetLocalGenerator()->ConvertToOutputFormat(
obj_list_file.c_str(), cmOutputConverter::SHELL);
obj_list_file, cmOutputConverter::SHELL);
preLinkCmdLines.push_back(cmd);
// create a list of obj files for the -E __create_def to read
cmGeneratedFileStream fout(obj_list_file.c_str());
......
......@@ -963,7 +963,7 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
cmsys::ofstream infoFile(outputFile.c_str(), std::ios::app);
if (!infoFile) {
std::string error = "Internal CMake error when trying to open file: ";
error += outputFile.c_str();
error += outputFile;
error += " for writing.";
cmSystemTools::Error(error.c_str());
return;
......
......@@ -965,7 +965,7 @@ void cmState::Directory::SetCurrentSource(std::string const& dir)
loc, this->DirectoryState->CurrentSourceDirectoryComponents);
this->ComputeRelativePathTopSource();
this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc.c_str());
this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc);
}
const char* cmState::Directory::GetCurrentBinary() const
......@@ -984,7 +984,7 @@ void cmState::Directory::SetCurrentBinary(std::string const& dir)
loc, this->DirectoryState->CurrentBinaryDirectoryComponents);
this->ComputeRelativePathTopBinary();
this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc.c_str());
this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc);
}
void cmState::Snapshot::SetListFile(const std::string& listfile)
......@@ -1380,8 +1380,8 @@ void cmState::Snapshot::InitializeFromParent_ForSubdirsCommand()
this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory());
this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory());
this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", currentSrcDir.c_str());
this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", currentBinDir.c_str());
this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", currentSrcDir);
this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", currentBinDir);
}
cmState::Directory::Directory(
......
......@@ -196,8 +196,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// If error occurs we want to continue copying next files.
bool return_value = 0;
for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
if (!cmSystemTools::CopyADirectory(args[cc].c_str(),
args[args.size() - 1].c_str())) {
if (!cmSystemTools::CopyADirectory(args[cc], args[args.size() - 1])) {
std::cerr << "Error copying directory from \"" << args[cc]
<< "\" to \"" << args[args.size() - 1] << "\".\n";
return_value = 1;
......
......@@ -51,7 +51,7 @@ main(int ac, char **av)
}
if (!logfile.empty())
cmSystemTools::Touch(logfile.c_str(), true);
cmSystemTools::Touch(logfile, true);
}
return RETVAL;
......
......@@ -81,14 +81,14 @@ int testGeneratedFileStream(int, char* [])
cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ",
file1.c_str());
}
cmSystemTools::RemoveFile(file1.c_str());
cmSystemTools::RemoveFile(file2.c_str());
cmSystemTools::RemoveFile(file3.c_str());
cmSystemTools::RemoveFile(file4.c_str());
cmSystemTools::RemoveFile(file1tmp.c_str());
cmSystemTools::RemoveFile(file2tmp.c_str());
cmSystemTools::RemoveFile(file3tmp.c_str());
cmSystemTools::RemoveFile(file4tmp.c_str());
cmSystemTools::RemoveFile(file1);
cmSystemTools::RemoveFile(file2);
cmSystemTools::RemoveFile(file3);
cmSystemTools::RemoveFile(file4);
cmSystemTools::RemoveFile(file1tmp);
cmSystemTools::RemoveFile(file2tmp);
cmSystemTools::RemoveFile(file3tmp);
cmSystemTools::RemoveFile(file4tmp);
return failed;
}
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