Commit 995d6be1 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'clang-tidy-fixes'

3fab1fef cmNinjaNormalTargetGenerator: make sure comments match parameter names
7b94a7ad cmCommandArgumentsHelper: simplify boolean expression
782fcbb9 Use CM_NULLPTR
809ca6c8 Use braces around statements
516f8edb Avoid else after return
d9f5d3c5 Remove redundant get() call on smart pointer
3fda1094 Mark overridden functions with CM_OVERRIDE
parents 31d63ac8 3fab1fef
......@@ -42,9 +42,9 @@ bool cmCMakeHostSystemInformationCommand::InitialPass(
result_list += ";";
}
std::string value;
if (!this->GetValue(info, key, value))
if (!this->GetValue(info, key, value)) {
return false;
}
result_list += value;
}
......
......@@ -24,23 +24,27 @@ bool cmCMakePolicyCommand::InitialPass(std::vector<std::string> const& args,
if (args[0] == "SET") {
return this->HandleSetMode(args);
} else if (args[0] == "GET") {
}
if (args[0] == "GET") {
return this->HandleGetMode(args);
} else if (args[0] == "PUSH") {
}
if (args[0] == "PUSH") {
if (args.size() > 1) {
this->SetError("PUSH may not be given additional arguments.");
return false;
}
this->Makefile->PushPolicy();
return true;
} else if (args[0] == "POP") {
}
if (args[0] == "POP") {
if (args.size() > 1) {
this->SetError("POP may not be given additional arguments.");
return false;
}
this->Makefile->PopPolicy();
return true;
} else if (args[0] == "VERSION") {
}
if (args[0] == "VERSION") {
return this->HandleVersionMode(args);
}
......@@ -148,7 +152,8 @@ bool cmCMakePolicyCommand::HandleVersionMode(
if (args.size() <= 1) {
this->SetError("VERSION not given an argument");
return false;
} else if (args.size() >= 3) {
}
if (args.size() >= 3) {
this->SetError("VERSION given too many arguments");
return false;
}
......
......@@ -524,9 +524,8 @@ void CCONV* cmGetSource(void* arg, const char* name)
i = cmCPluginAPISourceFiles.insert(entry).first;
}
return (void*)i->second;
} else {
return CM_NULLPTR;
}
return CM_NULLPTR;
}
void* CCONV cmAddSource(void* arg, void* arg2)
......@@ -574,12 +573,11 @@ const char* CCONV cmSourceFileGetProperty(void* arg, const char* prop)
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
if (cmSourceFile* rsf = sf->RealSourceFile) {
return rsf->GetProperty(prop);
} else {
if (!strcmp(prop, "LOCATION")) {
return sf->FullPath.c_str();
}
return sf->Properties.GetPropertyValue(prop);
}
if (!strcmp(prop, "LOCATION")) {
return sf->FullPath.c_str();
}
return sf->Properties.GetPropertyValue(prop);
}
int CCONV cmSourceFileGetPropertyAsBool(void* arg, const char* prop)
......@@ -587,9 +585,8 @@ int CCONV cmSourceFileGetPropertyAsBool(void* arg, const char* prop)
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
if (cmSourceFile* rsf = sf->RealSourceFile) {
return rsf->GetPropertyAsBool(prop) ? 1 : 0;
} else {
return cmSystemTools::IsOn(cmSourceFileGetProperty(arg, prop)) ? 1 : 0;
}
return cmSystemTools::IsOn(cmSourceFileGetProperty(arg, prop)) ? 1 : 0;
}
void CCONV cmSourceFileSetProperty(void* arg, const char* prop,
......
......@@ -57,14 +57,7 @@ bool cmCommandArgument::MayFollow(const cmCommandArgument* current) const
if (this->ArgumentsBeforeEmpty) {
return true;
}
std::set<const cmCommandArgument*>::const_iterator argIt =
this->ArgumentsBefore.find(current);
if (argIt != this->ArgumentsBefore.end()) {
return true;
}
return false;
return this->ArgumentsBefore.find(current) != this->ArgumentsBefore.end();
}
bool cmCommandArgument::KeyMatches(const std::string& key) const
......
......@@ -249,20 +249,19 @@ bool cmConditionEvaluator::GetBooleanValueOld(
// Old IsTrue behavior for single argument.
if (arg == "0") {
return false;
} else if (arg == "1") {
}
if (arg == "1") {
return true;
} else {
const char* def = this->GetDefinitionIfUnquoted(arg);
return !cmSystemTools::IsOff(def);
}
} else {
// Old GetVariableOrNumber behavior.
const char* def = this->GetDefinitionIfUnquoted(arg);
if (!def && atoi(arg.c_str())) {
def = arg.c_str();
}
return !cmSystemTools::IsOff(def);
}
// Old GetVariableOrNumber behavior.
const char* def = this->GetDefinitionIfUnquoted(arg);
if (!def && atoi(arg.c_str())) {
def = arg.c_str();
}
return !cmSystemTools::IsOff(def);
}
//=========================================================================
......@@ -274,7 +273,8 @@ bool cmConditionEvaluator::GetBooleanValueWithAutoDereference(
// Use the policy if it is set.
if (this->Policy12Status == cmPolicies::NEW) {
return GetBooleanValue(newArg);
} else if (this->Policy12Status == cmPolicies::OLD) {
}
if (this->Policy12Status == cmPolicies::OLD) {
return GetBooleanValueOld(newArg, oneArg);
}
......
......@@ -565,9 +565,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
if (copyFileError.empty()) {
this->Makefile->IssueMessage(cmake::FATAL_ERROR, emsg.str());
return -1;
} else {
copyFileErrorMessage = emsg.str();
}
copyFileErrorMessage = emsg.str();
}
}
......
......@@ -159,10 +159,9 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
if (cmds[i].empty()) {
this->SetError(" given COMMAND argument with no value.");
return false;
} else {
// Add the null terminating pointer to the command argument list.
cmds[i].push_back(CM_NULLPTR);
}
// Add the null terminating pointer to the command argument list.
cmds[i].push_back(CM_NULLPTR);
}
// Parse the timeout string.
......
......@@ -45,24 +45,25 @@ public:
protected:
// Implement virtual methods from the superclass.
virtual void GeneratePolicyHeaderCode(std::ostream&) {}
virtual void GeneratePolicyFooterCode(std::ostream&) {}
virtual void GenerateImportHeaderCode(std::ostream& os,
const std::string& config = "");
virtual void GenerateImportFooterCode(std::ostream& os);
virtual void GenerateImportTargetCode(std::ostream& os,
const cmGeneratorTarget* target);
virtual void GenerateExpectedTargetsCode(std::ostream& os,
const std::string& expectedTargets);
virtual void GenerateImportPropertyCode(std::ostream& os,
const std::string& config,
cmGeneratorTarget const* target,
ImportPropertyMap const& properties);
virtual void GenerateMissingTargetsCheckCode(
std::ostream& os, const std::vector<std::string>& missingTargets);
virtual void GenerateInterfaceProperties(
void GeneratePolicyHeaderCode(std::ostream&) CM_OVERRIDE {}
void GeneratePolicyFooterCode(std::ostream&) CM_OVERRIDE {}
void GenerateImportHeaderCode(std::ostream& os,
const std::string& config = "") CM_OVERRIDE;
void GenerateImportFooterCode(std::ostream& os) CM_OVERRIDE;
void GenerateImportTargetCode(std::ostream& os,
const cmGeneratorTarget* target) CM_OVERRIDE;
void GenerateExpectedTargetsCode(
std::ostream& os, const std::string& expectedTargets) CM_OVERRIDE;
void GenerateImportPropertyCode(std::ostream& os, const std::string& config,
cmGeneratorTarget const* target,
ImportPropertyMap const& properties)
CM_OVERRIDE;
void GenerateMissingTargetsCheckCode(
std::ostream& os,
const std::vector<std::string>& missingTargets) CM_OVERRIDE;
void GenerateInterfaceProperties(
cmGeneratorTarget const* target, std::ostream& os,
const ImportPropertyMap& properties);
const ImportPropertyMap& properties) CM_OVERRIDE;
};
#endif
......@@ -51,7 +51,8 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
if (args[0] == "PACKAGE") {
return this->HandlePackage(args);
} else if (args[0] == "EXPORT") {
}
if (args[0] == "EXPORT") {
this->ExportSetName.Follows(CM_NULLPTR);
this->ArgumentGroup.Follows(&this->ExportSetName);
} else {
......
......@@ -37,36 +37,37 @@ public:
protected:
// Implement virtual methods from the superclass.
virtual void GeneratePolicyHeaderCode(std::ostream&) {}
virtual void GeneratePolicyFooterCode(std::ostream&) {}
virtual void GenerateImportHeaderCode(std::ostream& os,
const std::string& config = "");
virtual void GenerateImportFooterCode(std::ostream& os);
virtual void GenerateImportTargetCode(std::ostream& os,
const cmGeneratorTarget* target);
virtual void GenerateExpectedTargetsCode(std::ostream& os,
const std::string& expectedTargets);
virtual void GenerateImportPropertyCode(std::ostream& os,
const std::string& config,
cmGeneratorTarget const* target,
ImportPropertyMap const& properties);
virtual void GenerateMissingTargetsCheckCode(
std::ostream& os, const std::vector<std::string>& missingTargets);
virtual void GenerateInterfaceProperties(
void GeneratePolicyHeaderCode(std::ostream&) CM_OVERRIDE {}
void GeneratePolicyFooterCode(std::ostream&) CM_OVERRIDE {}
void GenerateImportHeaderCode(std::ostream& os,
const std::string& config = "") CM_OVERRIDE;
void GenerateImportFooterCode(std::ostream& os) CM_OVERRIDE;
void GenerateImportTargetCode(std::ostream& os,
const cmGeneratorTarget* target) CM_OVERRIDE;
void GenerateExpectedTargetsCode(
std::ostream& os, const std::string& expectedTargets) CM_OVERRIDE;
void GenerateImportPropertyCode(std::ostream& os, const std::string& config,
cmGeneratorTarget const* target,
ImportPropertyMap const& properties)
CM_OVERRIDE;
void GenerateMissingTargetsCheckCode(
std::ostream& os,
const std::vector<std::string>& missingTargets) CM_OVERRIDE;
void GenerateInterfaceProperties(
cmGeneratorTarget const* target, std::ostream& os,
const ImportPropertyMap& properties);
virtual void GenerateImportPrefix(std::ostream& os);
virtual void LoadConfigFiles(std::ostream&);
virtual void GenerateRequiredCMakeVersion(std::ostream& os,
const char* versionString);
virtual void CleanupTemporaryVariables(std::ostream&);
virtual void GenerateImportedFileCheckLoop(std::ostream& os);
virtual void GenerateImportedFileChecksCode(
const ImportPropertyMap& properties) CM_OVERRIDE;
void GenerateImportPrefix(std::ostream& os) CM_OVERRIDE;
void LoadConfigFiles(std::ostream&) CM_OVERRIDE;
void GenerateRequiredCMakeVersion(std::ostream& os,
const char* versionString) CM_OVERRIDE;
void CleanupTemporaryVariables(std::ostream&) CM_OVERRIDE;
void GenerateImportedFileCheckLoop(std::ostream& os) CM_OVERRIDE;
void GenerateImportedFileChecksCode(
std::ostream& os, cmGeneratorTarget* target,
ImportPropertyMap const& properties,
const std::set<std::string>& importedLocations);
virtual bool GenerateImportFileConfig(const std::string& config,
std::vector<std::string>&);
const std::set<std::string>& importedLocations) CM_OVERRIDE;
bool GenerateImportFileConfig(const std::string& config,
std::vector<std::string>&) CM_OVERRIDE;
};
#endif
......@@ -64,7 +64,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
ap->SetCopyIfDifferent(true);
foutPtr = ap;
}
std::ostream& fout = *foutPtr.get();
std::ostream& fout = *foutPtr;
if (!fout) {
cmSystemTools::Error("Error Writing ", this->Filename.c_str());
......
......@@ -108,7 +108,7 @@ public:
}
cmExternalMakefileProjectGenerator* CreateExternalMakefileProjectGenerator()
const
const CM_OVERRIDE
{
T* p = new T;
p->SetName(GetName());
......
......@@ -104,19 +104,25 @@ bool cmFileCommand::InitialPass(std::vector<std::string> const& args,
std::string subCommand = args[0];
if (subCommand == "WRITE") {
return this->HandleWriteCommand(args, false);
} else if (subCommand == "APPEND") {
}
if (subCommand == "APPEND") {
return this->HandleWriteCommand(args, true);
} else if (subCommand == "DOWNLOAD") {
}
if (subCommand == "DOWNLOAD") {
return this->HandleDownloadCommand(args);
} else if (subCommand == "UPLOAD") {
}
if (subCommand == "UPLOAD") {
return this->HandleUploadCommand(args);
} else if (subCommand == "READ") {
}
if (subCommand == "READ") {
return this->HandleReadCommand(args);
} else if (subCommand == "MD5" || subCommand == "SHA1" ||
subCommand == "SHA224" || subCommand == "SHA256" ||
subCommand == "SHA384" || subCommand == "SHA512") {
}
if (subCommand == "MD5" || subCommand == "SHA1" || subCommand == "SHA224" ||
subCommand == "SHA256" || subCommand == "SHA384" ||
subCommand == "SHA512") {
return this->HandleHashCommand(args);
} else if (subCommand == "STRINGS") {
}
if (subCommand == "STRINGS") {
return this->HandleStringsCommand(args);
} else if (subCommand == "GLOB") {
return this->HandleGlobCommand(args, false);
......@@ -594,8 +600,9 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
// how many octets are there?
unsigned int num_utf8_bytes = 0;
for (unsigned int j = 0; num_utf8_bytes == 0 && j < 3; j++) {
if ((c & utf8_check_table[j][0]) == utf8_check_table[j][1])
if ((c & utf8_check_table[j][0]) == utf8_check_table[j][1]) {
num_utf8_bytes = j + 2;
}
}
// get subsequent octets and check that they are valid
......@@ -1408,11 +1415,14 @@ bool cmFileCopier::Install(const char* fromFile, const char* toFile)
if (cmSystemTools::SameFile(fromFile, toFile)) {
return true;
} else if (cmSystemTools::FileIsSymlink(fromFile)) {
}
if (cmSystemTools::FileIsSymlink(fromFile)) {
return this->InstallSymlink(fromFile, toFile);
} else if (cmSystemTools::FileIsDirectory(fromFile)) {
}
if (cmSystemTools::FileIsDirectory(fromFile)) {
return this->InstallDirectory(fromFile, toFile, match_properties);
} else if (cmSystemTools::FileExists(fromFile)) {
}
if (cmSystemTools::FileExists(fromFile)) {
return this->InstallFile(fromFile, toFile, match_properties);
}
return this->ReportMissing(fromFile);
......@@ -3129,20 +3139,20 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
if (i >= args.size()) {
this->Makefile->IssueMessage(cmake::FATAL_ERROR, merr);
return false;
}
if (args[i] == "FUNCTION") {
guard = GUARD_FUNCTION;
} else if (args[i] == "FILE") {
guard = GUARD_FILE;
} else if (args[i] == "PROCESS") {
guard = GUARD_PROCESS;
} else {
if (args[i] == "FUNCTION") {
guard = GUARD_FUNCTION;
} else if (args[i] == "FILE") {
guard = GUARD_FILE;
} else if (args[i] == "PROCESS") {
guard = GUARD_PROCESS;
} else {
std::ostringstream e;
e << merr << ", but got:\n \"" << args[i] << "\".";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
std::ostringstream e;
e << merr << ", but got:\n \"" << args[i] << "\".";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
} else if (args[i] == "RESULT_VARIABLE") {
++i;
if (i >= args.size()) {
......@@ -3259,7 +3269,8 @@ bool cmFileCommand::HandleTimestampCommand(
if (args.size() < 3) {
this->SetError("sub-command TIMESTAMP requires at least two arguments.");
return false;
} else if (args.size() > 5) {
}
if (args.size() > 5) {
this->SetError("sub-command TIMESTAMP takes at most four arguments.");
return false;
}
......
......@@ -37,9 +37,8 @@ cmFileLockResult cmFileLock::Release()
if (lockResult == 0) {
return cmFileLockResult::MakeOk();
} else {
return cmFileLockResult::MakeSystem();
}
return cmFileLockResult::MakeSystem();
}
cmFileLockResult cmFileLock::OpenFile()
......@@ -47,18 +46,16 @@ cmFileLockResult cmFileLock::OpenFile()
this->File = ::open(this->Filename.c_str(), O_RDWR);
if (this->File == -1) {
return cmFileLockResult::MakeSystem();
} else {
return cmFileLockResult::MakeOk();
}
return cmFileLockResult::MakeOk();
}
cmFileLockResult cmFileLock::LockWithoutTimeout()
{
if (this->LockFile(F_SETLKW, F_WRLCK) == -1) {
return cmFileLockResult::MakeSystem();
} else {
return cmFileLockResult::MakeOk();
}
return cmFileLockResult::MakeOk();
}
cmFileLockResult cmFileLock::LockWithTimeout(unsigned long seconds)
......
......@@ -321,7 +321,8 @@ bool cmFindBase::CheckForVariableInCache()
this->AlreadyInCacheWithoutMetaInfo = true;
}
return true;
} else if (cached) {
}
if (cached) {
const char* hs =
state->GetCacheEntryProperty(this->VariableName, "HELPSTRING");
this->VariableDocumentation = hs ? hs : "(none)";
......
......@@ -378,9 +378,8 @@ std::string cmFindLibraryCommand::FindNormalLibrary()
{
if (this->NamesPerDir) {
return this->FindNormalLibraryNamesPerDir();
} else {
return this->FindNormalLibraryDirsPerName();
}
return this->FindNormalLibraryDirsPerName();
}
std::string cmFindLibraryCommand::FindNormalLibraryNamesPerDir()
......@@ -428,9 +427,8 @@ std::string cmFindLibraryCommand::FindFrameworkLibrary()
{
if (this->NamesPerDir) {
return this->FindFrameworkLibraryNamesPerDir();
} else {
return this->FindFrameworkLibraryDirsPerName();
}
return this->FindFrameworkLibraryDirsPerName();
}
std::string cmFindLibraryCommand::FindFrameworkLibraryNamesPerDir()
......
......@@ -1308,18 +1308,16 @@ bool cmFindPackageCommand::CheckPackageRegistryEntry(const std::string& fname,
outPaths.AddPath(fname);
}
return true;
} else {
// The path does not exist. Assume the stream content is
// associated with an old package that no longer exists, and
// delete it to keep the package registry clean.
return false;
}
} else {
// The first line in the stream is not the full path to a file or
// directory. Assume the stream content was created by a future
// version of CMake that uses a different format, and leave it.
return true;
// The path does not exist. Assume the stream content is
// associated with an old package that no longer exists, and
// delete it to keep the package registry clean.
return false;
}
// The first line in the stream is not the full path to a file or
// directory. Assume the stream content was created by a future
// version of CMake that uses a different format, and leave it.
return true;
}
void cmFindPackageCommand::FillPrefixesCMakeSystemVariable()
......@@ -1628,9 +1626,8 @@ private:
{
if (this->UseSuffixes) {
return this->FPC->SearchDirectory(fullPath);
} else {
return this->FPC->CheckDirectory(fullPath);
}
return this->FPC->CheckDirectory(fullPath);
}
cmFindPackageCommand* FPC;
bool UseSuffixes;
......@@ -1653,9 +1650,8 @@ bool cmFileListGeneratorBase::Consider(std::string const& fullPath,
{
if (this->Next.get()) {
return this->Next->Search(fullPath + "/", listing);
} else {
return listing.Visit(fullPath + "/");
}
return listing.Visit(fullPath + "/");
}
class cmFileListGeneratorFixed : public cmFileListGeneratorBase
......
......@@ -136,9 +136,8 @@ std::string cmFindPathCommand::FindNormalHeader()
if (cmSystemTools::FileExists(tryPath.c_str())) {
if (this->IncludeFileInPath) {
return tryPath;
} else {
return *p;
}
return *p;
}
}
}
......
......@@ -140,9 +140,8 @@ std::string cmFindProgramCommand::FindNormalProgram()
{
if (this->NamesPerDir) {
return this->FindNormalProgramNamesPerDir();
} else {
return this->FindNormalProgramDirsPerName();
}
return this->FindNormalProgramDirsPerName();
}
std::string cmFindProgramCommand::FindNormalProgramNamesPerDir()
......
......@@ -81,10 +81,9 @@ bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// restore the variable to its prior value
mf.AddDefinition(this->Args[0], oldDef.c_str());
return true;
} else {
// close out a nested foreach
this->Depth--;
}
// close out a nested foreach
this->Depth--;
}
// record the command
......
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