summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-11-01 13:14:19 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-11-01 13:14:19 (GMT)
commitba28e0405e4a41158395323ace1dd0075934233e (patch)
tree97b13904923aa0a2a77c98f96cc03024e78225a3 /Source
parent9ceef25ee2ebf6315e4c13dfc7102850c2807228 (diff)
parent5214bb354b508cafc859b4a05b4e5f8ed44767e0 (diff)
downloadCMake-ba28e0405e4a41158395323ace1dd0075934233e.zip
CMake-ba28e0405e4a41158395323ace1dd0075934233e.tar.gz
CMake-ba28e0405e4a41158395323ace1dd0075934233e.tar.bz2
Merge topic 'clang-tidy'
5214bb35 Avoid some copies 602b78aa Remove redundant c_str() calls c58c739d Use the empty method to check for emptiness
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAuxSourceDirectoryCommand.cxx2
-rw-r--r--Source/cmBuildCommand.cxx3
-rw-r--r--Source/cmCoreTryCompile.cxx10
-rw-r--r--Source/cmExportInstallAndroidMKGenerator.cxx2
-rw-r--r--Source/cmFLTKWrapUICommand.cxx4
-rw-r--r--Source/cmFileCommand.cxx4
-rw-r--r--Source/cmFileMonitor.cxx7
-rw-r--r--Source/cmFileMonitor.h2
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx2
-rw-r--r--Source/cmIncludeCommand.cxx4
-rw-r--r--Source/cmInstallCommand.cxx2
-rw-r--r--Source/cmLoadCommandCommand.cxx8
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx19
-rw-r--r--Source/cmServerProtocol.cxx6
-rw-r--r--Source/cmSetPropertyCommand.cxx2
-rw-r--r--Source/cmSourceGroupCommand.cxx2
-rw-r--r--Source/cmSubdirCommand.cxx6
-rw-r--r--Source/cmTryRunCommand.cxx5
-rw-r--r--Source/cmUseMangledMesaCommand.cxx2
-rw-r--r--Source/cmWriteFileCommand.cxx2
20 files changed, 46 insertions, 48 deletions
diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx
index 04e1a0b..ecff0c3 100644
--- a/Source/cmAuxSourceDirectoryCommand.cxx
+++ b/Source/cmAuxSourceDirectoryCommand.cxx
@@ -44,7 +44,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass(
// Load all the files in the directory
cmsys::Directory dir;
- if (dir.Load(tdir.c_str())) {
+ if (dir.Load(tdir)) {
size_t numfiles = dir.GetNumberOfFiles();
for (size_t i = 0; i < numfiles; ++i) {
std::string file = dir.GetFile(static_cast<unsigned long>(i));
diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx
index d03b8c4..6836151 100644
--- a/Source/cmBuildCommand.cxx
+++ b/Source/cmBuildCommand.cxx
@@ -90,8 +90,7 @@ bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
std::string makecommand =
this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand(
- target, configuration.c_str(), "",
- this->Makefile->IgnoreErrorsCMP0061());
+ target, configuration, "", this->Makefile->IgnoreErrorsCMP0061());
this->Makefile->AddDefinition(variable, makecommand.c_str());
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index a1de074..b7d2196 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -40,7 +40,7 @@ static std::string const kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES =
int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
bool isTryRun)
{
- this->BinaryDirectory = argv[1].c_str();
+ this->BinaryDirectory = argv[1];
this->OutputFile = "";
// which signature were we called with ?
this->SrcFileSignature = true;
@@ -149,13 +149,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
}
}
} else if (doing == DoingOutputVariable) {
- outputVariable = argv[i].c_str();
+ outputVariable = argv[i];
doing = DoingNone;
} else if (doing == DoingCopyFile) {
- copyFile = argv[i].c_str();
+ copyFile = argv[i];
doing = DoingNone;
} else if (doing == DoingCopyFileError) {
- copyFileError = argv[i].c_str();
+ copyFileError = argv[i];
doing = DoingNone;
} else if (doing == DoingSources) {
sources.push_back(argv[i]);
@@ -163,7 +163,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
this->SrcFileSignature = false;
projectName = argv[i].c_str();
} else if (i == 4 && !this->SrcFileSignature) {
- targetName = argv[i].c_str();
+ targetName = argv[i];
} else {
std::ostringstream m;
m << "try_compile given unknown argument \"" << argv[i] << "\".";
diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx
index f9f5f3a..2069785 100644
--- a/Source/cmExportInstallAndroidMKGenerator.cxx
+++ b/Source/cmExportInstallAndroidMKGenerator.cxx
@@ -26,7 +26,7 @@ void cmExportInstallAndroidMKGenerator::GenerateImportHeaderCode(
std::string installDir = this->IEGen->GetDestination();
os << "LOCAL_PATH := $(call my-dir)\n";
size_t numDotDot = cmSystemTools::CountChar(installDir.c_str(), '/');
- numDotDot += (installDir.size() > 0) ? 1 : 0;
+ numDotDot += installDir.empty() ? 0 : 1;
std::string path;
for (size_t n = 0; n < numDotDot; n++) {
path += "/..";
diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx
index 1f0ce8d..1e8ca06 100644
--- a/Source/cmFLTKWrapUICommand.cxx
+++ b/Source/cmFLTKWrapUICommand.cxx
@@ -82,8 +82,8 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
no_working_dir);
cmSourceFile* sf = this->Makefile->GetSource(cxxres);
- sf->AddDepend(hname.c_str());
- sf->AddDepend(origname.c_str());
+ sf->AddDepend(hname);
+ sf->AddDepend(origname);
this->GeneratedSourcesClasses.push_back(sf);
}
}
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 6285894..ac76191 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2600,7 +2600,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// Do not return error for compatibility reason.
std::string err = "Unexpected argument: ";
err += *i;
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, err.c_str());
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, err);
}
++i;
}
@@ -2884,7 +2884,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
// Do not return error for compatibility reason.
std::string err = "Unexpected argument: ";
err += *i;
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, err.c_str());
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, err);
}
++i;
diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx
index b55341b..9844306 100644
--- a/Source/cmFileMonitor.cxx
+++ b/Source/cmFileMonitor.cxx
@@ -247,7 +247,10 @@ public:
void StopWatching() final {}
- void AppendCallback(cmFileMonitor::Callback cb) { CbList.push_back(cb); }
+ void AppendCallback(cmFileMonitor::Callback const& cb)
+ {
+ this->CbList.push_back(cb);
+ }
std::string Path() const final
{
@@ -310,7 +313,7 @@ cmFileMonitor::~cmFileMonitor()
}
void cmFileMonitor::MonitorPaths(const std::vector<std::string>& paths,
- Callback cb)
+ Callback const& cb)
{
for (const auto& p : paths) {
std::vector<std::string> pathSegments;
diff --git a/Source/cmFileMonitor.h b/Source/cmFileMonitor.h
index e05f48d..48169b8 100644
--- a/Source/cmFileMonitor.h
+++ b/Source/cmFileMonitor.h
@@ -17,7 +17,7 @@ public:
~cmFileMonitor();
using Callback = std::function<void(const std::string&, int, int)>;
- void MonitorPaths(const std::vector<std::string>& paths, Callback cb);
+ void MonitorPaths(const std::vector<std::string>& paths, Callback const& cb);
void StopMonitoring();
std::vector<std::string> WatchedFiles() const;
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 17d49e8..90caaf9 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -963,7 +963,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule(
(type == cmStateEnums::OBJECT_LIBRARY) ||
(type == cmStateEnums::GLOBAL_TARGET) ||
(type == cmStateEnums::UTILITY)) {
- std::string name = target->GetName();
+ std::string const& name = target->GetName();
if (emittedTargets.insert(name).second) {
path = "... ";
path += name;
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index 0f7799e..12e0c9a 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -69,7 +69,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
module += ".cmake";
std::string mfile = this->Makefile->GetModulesFile(module.c_str());
if (!mfile.empty()) {
- fname = mfile.c_str();
+ fname = mfile;
}
}
@@ -111,7 +111,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
}
std::string listFile = cmSystemTools::CollapseFullPath(
- fname.c_str(), this->Makefile->GetCurrentSourceDirectory());
+ fname, this->Makefile->GetCurrentSourceDirectory());
if (optional && !cmSystemTools::FileExists(listFile.c_str())) {
if (!resultVarName.empty()) {
this->Makefile->AddDefinition(resultVarName, "NOTFOUND");
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 7bf9462..bf59e88 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -986,7 +986,7 @@ bool cmInstallCommand::HandleDirectoryMode(
std::ostringstream e;
e << args[0] << " does not allow \"" << args[i]
<< "\" after PATTERN or REGEX.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
exclude_from_all = true;
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index e042b07..b6743f1 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -208,7 +208,7 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
}
// Try to find the program.
- std::string fullPath = cmSystemTools::FindFile(moduleName.c_str(), path);
+ std::string fullPath = cmSystemTools::FindFile(moduleName, path);
if (fullPath == "") {
std::ostringstream e;
e << "Attempt to load command failed from file \"" << moduleName << "\"";
@@ -237,14 +237,14 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
// find the init function
std::string initFuncName = args[0] + "Init";
CM_INIT_FUNCTION initFunction =
- (CM_INIT_FUNCTION)cmsys::DynamicLoader::GetSymbolAddress(
- lib, initFuncName.c_str());
+ (CM_INIT_FUNCTION)cmsys::DynamicLoader::GetSymbolAddress(lib,
+ initFuncName);
if (!initFunction) {
initFuncName = "_";
initFuncName += args[0];
initFuncName += "Init";
initFunction = (CM_INIT_FUNCTION)(
- cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName.c_str()));
+ cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName));
}
// if the symbol is found call it to set the name on the
// function blocker
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index 32b0a92..7a17f2c 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -180,33 +180,30 @@ protected:
while (cmSystemTools::GetLineFromStream(fin, line)) {
if (cmHasLiteralPrefix(line.c_str(), "#include")) {
// if it is an include line then create a string class
- std::string currentline = line;
- size_t qstart = currentline.find('\"', 8);
+ size_t qstart = line.find('\"', 8);
size_t qend;
// if a quote is not found look for a <
if (qstart == std::string::npos) {
- qstart = currentline.find('<', 8);
+ qstart = line.find('<', 8);
// if a < is not found then move on
if (qstart == std::string::npos) {
- cmSystemTools::Error("unknown include directive ",
- currentline.c_str());
+ cmSystemTools::Error("unknown include directive ", line.c_str());
continue;
} else {
- qend = currentline.find('>', qstart + 1);
+ qend = line.find('>', qstart + 1);
}
} else {
- qend = currentline.find('\"', qstart + 1);
+ qend = line.find('\"', qstart + 1);
}
// extract the file being included
- std::string includeFile =
- currentline.substr(qstart + 1, qend - qstart - 1);
+ std::string includeFile = line.substr(qstart + 1, qend - qstart - 1);
// see if the include matches the regular expression
if (!this->IncludeFileRegularExpression.find(includeFile)) {
if (this->Verbose) {
std::string message = "Skipping ";
message += includeFile;
message += " for file ";
- message += info->FullPath.c_str();
+ message += info->FullPath;
cmSystemTools::Error(message.c_str(), CM_NULLPTR);
}
continue;
@@ -520,7 +517,7 @@ bool cmOutputRequiredFilesCommand::InitialPass(
const cmDependInformation* info = md.FindDependencies(this->File.c_str());
if (info) {
// write them out
- FILE* fout = cmsys::SystemTools::Fopen(this->OutputFile.c_str(), "w");
+ FILE* fout = cmsys::SystemTools::Fopen(this->OutputFile, "w");
if (!fout) {
std::string err = "Can not open output file: ";
err += this->OutputFile;
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index 857ce39..853704b 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -82,7 +82,7 @@ static void getCMakeInputs(const cmGlobalGenerator* gg,
std::vector<std::string>* tmpFiles)
{
const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/';
- const std::vector<cmMakefile*> makefiles = gg->GetMakefiles();
+ std::vector<cmMakefile*> const& makefiles = gg->GetMakefiles();
for (auto it = makefiles.begin(); it != makefiles.end(); ++it) {
const std::vector<std::string> listFiles = (*it)->GetListFiles();
@@ -850,7 +850,7 @@ static Json::Value DumpTargetsList(
return result;
}
-static Json::Value DumpProjectList(const cmake* cm, const std::string config)
+static Json::Value DumpProjectList(const cmake* cm, std::string const& config)
{
Json::Value result = Json::arrayValue;
@@ -1059,7 +1059,7 @@ cmServerResponse cmServerProtocol1_0::ProcessGlobalSettings(
}
static void setBool(const cmServerRequest& request, const std::string& key,
- std::function<void(bool)> setter)
+ std::function<void(bool)> const& setter)
{
if (request.Data[key].isNull()) {
return;
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index 79221c8..60c198a 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -342,7 +342,7 @@ bool cmSetPropertyCommand::HandleCacheMode()
return false;
}
} else if (this->PropertyName == "TYPE") {
- if (!cmState::IsCacheEntryType(this->PropertyValue.c_str())) {
+ if (!cmState::IsCacheEntryType(this->PropertyValue)) {
std::ostringstream e;
e << "given invalid CACHE entry TYPE \"" << this->PropertyValue << "\"";
this->SetError(e.str());
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index ff3ec7f..3f20d4e 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -69,7 +69,7 @@ bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args,
src += "/";
src += args[i];
}
- src = cmSystemTools::CollapseFullPath(src.c_str());
+ src = cmSystemTools::CollapseFullPath(src);
sg->AddGroupFile(src);
} else {
std::ostringstream err;
diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx
index 55761bf..3727dfa 100644
--- a/Source/cmSubdirCommand.cxx
+++ b/Source/cmSubdirCommand.cxx
@@ -31,12 +31,10 @@ bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args,
// if they specified a relative path then compute the full
std::string srcPath =
- std::string(this->Makefile->GetCurrentSourceDirectory()) + "/" +
- i->c_str();
+ std::string(this->Makefile->GetCurrentSourceDirectory()) + "/" + *i;
if (cmSystemTools::FileIsDirectory(srcPath)) {
std::string binPath =
- std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" +
- i->c_str();
+ std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" + *i;
this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false);
}
// otherwise it is a full path
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 9457d5b..c4fc94e 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -86,8 +86,9 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv,
// although they could be used together, don't allow it, because
// using OUTPUT_VARIABLE makes crosscompiling harder
- if (this->OutputVariable.size() && (!this->RunOutputVariable.empty() ||
- !this->CompileOutputVariable.empty())) {
+ if (!this->OutputVariable.empty() &&
+ (!this->RunOutputVariable.empty() ||
+ !this->CompileOutputVariable.empty())) {
cmSystemTools::Error(
"You cannot use OUTPUT_VARIABLE together with COMPILE_OUTPUT_VARIABLE "
"or RUN_OUTPUT_VARIABLE. Please use only COMPILE_OUTPUT_VARIABLE and/or "
diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx
index ffeaa51..3e72d75 100644
--- a/Source/cmUseMangledMesaCommand.cxx
+++ b/Source/cmUseMangledMesaCommand.cxx
@@ -108,5 +108,5 @@ void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(const char* source,
fin.close();
fout.close();
cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(), outFile.c_str());
- cmSystemTools::RemoveFile(tempOutputFile.c_str());
+ cmSystemTools::RemoveFile(tempOutputFile);
}
diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx
index b3ac31c..96c8e27 100644
--- a/Source/cmWriteFileCommand.cxx
+++ b/Source/cmWriteFileCommand.cxx
@@ -65,7 +65,7 @@ bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& args,
overwrite ? std::ios::out : std::ios::app);
if (!file) {
std::string error = "Internal CMake error when trying to open file: ";
- error += fileName.c_str();
+ error += fileName;
error += " for writing.";
this->SetError(error);
return false;