Commit 5731ec30 authored by wahikihiki's avatar wahikihiki Committed by Brad King

clang-tidy: fix warnings from version 7

Fix some warnings that are new since clang-tidy version 4, and update
`.clang-tidy` to suppress the rest.
parent 1dc85a66
......@@ -21,15 +21,18 @@ modernize-*,\
-modernize-use-using,\
performance-*,\
-performance-inefficient-string-concatenation,\
-performance-inefficient-vector-operation,\
readability-*,\
-readability-function-size,\
-readability-identifier-naming,\
-readability-implicit-bool-cast,\
-readability-implicit-bool-conversion,\
-readability-inconsistent-declaration-parameter-name,\
-readability-named-parameter,\
-readability-redundant-declaration,\
-readability-redundant-member-init,\
-readability-simplify-boolean-expr,\
-readability-static-accessed-through-instance,\
"
HeaderFilterRegex: 'Source/cm[^/]*\.(h|hxx|cxx)$'
...
......@@ -21,8 +21,8 @@ AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& varNames,
, VarTypes(varTypes)
{
this->setupUi(this);
for (int i = 0; i < NumTypes; i++) {
this->Type->addItem(TypeStrings[i]);
for (auto const& elem : TypeStrings) {
this->Type->addItem(elem);
}
QWidget* cb = new QCheckBox();
QWidget* path = new QCMakePathEditor();
......
......@@ -684,7 +684,7 @@ cmELF::cmELF(const char* fname)
std::unique_ptr<cmsys::ifstream> fin(new cmsys::ifstream(fname));
// Quit now if the file could not be opened.
if (!fin.get() || !*fin) {
if (!fin || !*fin) {
this->ErrorMessage = "Error opening input file.";
return;
}
......
......@@ -79,7 +79,7 @@ bool cmExportFileGenerator::GenerateImportFile()
ap->SetCopyIfDifferent(true);
foutPtr = std::move(ap);
}
if (!foutPtr.get() || !*foutPtr) {
if (!foutPtr || !*foutPtr) {
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
e << "cannot write to file \"" << this->MainImportFile << "\": " << se;
......
......@@ -2824,7 +2824,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
std::string algo = i->substr(0, pos);
expectedHash = cmSystemTools::LowerCase(i->substr(pos + 1));
hash = std::unique_ptr<cmCryptoHash>(cmCryptoHash::New(algo.c_str()));
if (!hash.get()) {
if (!hash) {
std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: ";
err += algo;
this->SetError(err);
......
......@@ -38,7 +38,7 @@ bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// Remove the function blocker for this scope or bail.
std::unique_ptr<cmFunctionBlocker> fb(
mf.RemoveFunctionBlocker(this, lff));
if (!fb.get()) {
if (!fb) {
return false;
}
......
......@@ -4379,8 +4379,7 @@ const char* impliedValue<const char*>(const char* /*unused*/)
return "";
}
template <>
std::string impliedValue<std::string>(
std::string /*unused*/) // NOLINT(clang-tidy)
std::string impliedValue<std::string>(std::string /*unused*/) // NOLINT(*)
{
return std::string();
}
......
......@@ -112,7 +112,7 @@ std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string& lit)
std::string cmGlobalNinjaGenerator::EncodePath(const std::string& path)
{
std::string result = path; // NOLINT(clang-tidy)
std::string result = path;
#ifdef _WIN32
if (this->IsGCCOnWindows())
std::replace(result.begin(), result.end(), '\\', '/');
......@@ -254,7 +254,7 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild(
bool restat, const cmNinjaDeps& outputs, const cmNinjaDeps& deps,
const cmNinjaDeps& orderOnly)
{
std::string cmd = command; // NOLINT(clang-tidy)
std::string cmd = command; // NOLINT(*)
#ifdef _WIN32
if (cmd.empty())
// TODO Shouldn't an empty command be handled by ninja?
......@@ -1940,7 +1940,7 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
cm.SetHomeOutputDirectory(dir_top_bld);
std::unique_ptr<cmGlobalNinjaGenerator> ggd(
static_cast<cmGlobalNinjaGenerator*>(cm.CreateGlobalGenerator("Ninja")));
if (!ggd.get() ||
if (!ggd ||
!ggd->WriteDyndepFile(dir_top_src, dir_top_bld, dir_cur_src, dir_cur_bld,
arg_dd, arg_ddis, module_dir,
linked_target_dirs)) {
......
......@@ -39,7 +39,7 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// Remove the function blocker for this scope or bail.
std::unique_ptr<cmFunctionBlocker> fb(
mf.RemoveFunctionBlocker(this, lff));
if (!fb.get()) {
if (!fb) {
return false;
}
......
......@@ -2342,7 +2342,7 @@ cmMakefile::AppleSDK cmMakefile::GetAppleSDKType() const
{ "watchsimulator", AppleSDK::WatchSimulator },
};
for (auto entry : sdkDatabase) {
for (auto const& entry : sdkDatabase) {
if (sdkRoot.find(entry.name) == 0 ||
sdkRoot.find(std::string("/") + entry.name) != std::string::npos) {
return entry.sdk;
......
......@@ -37,7 +37,7 @@ bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
// Remove the function blocker for this scope or bail.
std::unique_ptr<cmFunctionBlocker> fb(
mf.RemoveFunctionBlocker(this, lff));
if (!fb.get()) {
if (!fb) {
return false;
}
......
......@@ -2596,7 +2596,7 @@ bool cmake::Open(const std::string& dir, bool dryRun)
std::unique_ptr<cmGlobalGenerator> gen(
this->CreateGlobalGenerator(fullName));
if (!gen.get()) {
if (!gen) {
std::cerr << "Error: could create CMAKE_GENERATOR \"" << fullName
<< "\"\n";
return false;
......
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