clang-tidy: fix warnings in macOS-only code

This commit is contained in:
Brad King 2018-11-27 13:19:45 -05:00
parent f49efe283e
commit cb6229b8b8
7 changed files with 19 additions and 23 deletions

View File

@ -533,7 +533,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
cmSystemTools::ExpandListArgument(cpack_dmg_languages, languages);
}
cmGeneratedFileStream ofs(sla_r.c_str());
cmGeneratedFileStream ofs(sla_r);
ofs << "#include <CoreServices/CoreServices.r>\n\n";
if (oldStyle) {
ofs << SLAHeader;

View File

@ -169,7 +169,7 @@ int cmCPackOSXX11Generator::PackageFiles()
numTries--;
}
if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile.c_str());
cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << dmgCmd.str() << std::endl
<< "# Output:" << std::endl
<< output << std::endl;

View File

@ -307,7 +307,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
numTries--;
}
if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile.c_str());
cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << dmgCmd.str() << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
@ -475,7 +475,7 @@ bool cmCPackPackageMakerGenerator::RunPackageMaker(const char* command,
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Done running package maker" << std::endl);
if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile.c_str());
cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << command << std::endl
<< "# Output:" << std::endl
<< output << std::endl;

View File

@ -151,7 +151,7 @@ bool cmCPackProductBuildGenerator::RunProductBuild(const std::string& command)
this->GeneratorVerbose, cmDuration::zero());
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" << std::endl);
if (!res || retVal) {
cmGeneratedFileStream ofs(tmpFile.c_str());
cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << command << std::endl
<< "# Output:" << std::endl
<< output << std::endl;

View File

@ -216,12 +216,11 @@ static bool cmOSXInstall(std::string const& dir, std::string const& tool)
if (symlink(tool.c_str(), link.c_str()) == 0) {
std::cerr << "Linked: '" << link << "' -> '" << tool << "'\n";
return true;
} else {
int err = errno;
std::cerr << "Failed: '" << link << "' -> '" << tool
<< "': " << strerror(err) << "\n";
return false;
}
int err = errno;
std::cerr << "Failed: '" << link << "' -> '" << tool
<< "': " << strerror(err) << "\n";
return false;
}
static int cmOSXInstall(std::string dir)
{

View File

@ -589,8 +589,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
this->CurrentReRunCMakeMakefile += "/CMakeScripts";
cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile.c_str());
this->CurrentReRunCMakeMakefile += "/ReRunCMake.make";
cmGeneratedFileStream makefileStream(
this->CurrentReRunCMakeMakefile.c_str());
cmGeneratedFileStream makefileStream(this->CurrentReRunCMakeMakefile);
makefileStream.SetCopyIfDifferent(true);
makefileStream << "# Generated by CMake, DO NOT EDIT\n\n";
@ -1404,7 +1403,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
fname += ".";
fname += cmSystemTools::LowerCase(llang);
{
cmGeneratedFileStream fout(fname.c_str());
cmGeneratedFileStream fout(fname);
fout << "\n";
}
if (cmSourceFile* sf = mf->GetOrCreateSource(fname)) {
@ -1666,7 +1665,7 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
{
std::string makefileName = makefileBasename;
makefileName += configName;
cmGeneratedFileStream makefileStream(makefileName.c_str());
cmGeneratedFileStream makefileStream(makefileName);
if (!makefileStream) {
return;
}
@ -2864,8 +2863,7 @@ bool cmGlobalXCodeGenerator::CreateGroups(
}
// Add the file to the list of sources.
std::string const& source = sf->GetFullPath();
cmSourceGroup* sourceGroup =
mf->FindSourceGroup(source.c_str(), sourceGroups);
cmSourceGroup* sourceGroup = mf->FindSourceGroup(source, sourceGroups);
cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup);
std::string key = GetGroupMapKeyFromPath(gtgt, source);
this->GroupMap[key] = pbxgroup;
@ -2878,8 +2876,7 @@ bool cmGlobalXCodeGenerator::CreateGroups(
listfile += "/CMakeLists.txt";
cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(listfile);
std::string const& source = sf->GetFullPath();
cmSourceGroup* sourceGroup =
mf->FindSourceGroup(source.c_str(), sourceGroups);
cmSourceGroup* sourceGroup = mf->FindSourceGroup(source, sourceGroups);
cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup);
std::string key = GetGroupMapKeyFromPath(gtgt, source);
this->GroupMap[key] = pbxgroup;
@ -3251,7 +3248,7 @@ void cmGlobalXCodeGenerator::ComputeObjectDirArch(cmMakefile* mf)
void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
std::vector<cmXCodeObject*>& targets)
{
cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile.c_str());
cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile);
if (!makefileStream) {
cmSystemTools::Error("Could not create",
this->CurrentXCodeHackMakefile.c_str());
@ -3392,7 +3389,7 @@ void cmGlobalXCodeGenerator::OutputXCodeProject(
xcodeDir += ".xcodeproj";
cmSystemTools::MakeDirectory(xcodeDir.c_str());
std::string xcodeProjFile = xcodeDir + "/project.pbxproj";
cmGeneratedFileStream fout(xcodeProjFile.c_str());
cmGeneratedFileStream fout(xcodeProjFile);
fout.SetCopyIfDifferent(true);
if (!fout) {
return;
@ -3469,7 +3466,7 @@ void cmGlobalXCodeGenerator::OutputXCodeWorkspaceSettings(
std::string workspaceSettingsFile = xcodeSharedDataDir;
workspaceSettingsFile += "/WorkspaceSettings.xcsettings";
cmGeneratedFileStream fout(workspaceSettingsFile.c_str());
cmGeneratedFileStream fout(workspaceSettingsFile);
fout.SetCopyIfDifferent(true);
if (!fout) {
return;

View File

@ -35,7 +35,7 @@ void cmXCodeScheme::WriteXCodeSharedScheme(const std::string& xcProjDir,
xcodeSchemeFile += this->TargetName;
xcodeSchemeFile += ".xcscheme";
cmGeneratedFileStream fout(xcodeSchemeFile.c_str());
cmGeneratedFileStream fout(xcodeSchemeFile);
fout.SetCopyIfDifferent(true);
if (!fout) {
return;
@ -216,7 +216,7 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout,
if (!arguments.empty()) {
xout.StartElement("CommandLineArguments");
for (auto argument : arguments) {
for (auto const& argument : arguments) {
xout.StartElement("CommandLineArgument");
xout.BreakAttributes();