From a1a957d328f70ee437507a93cb435fdc3a0aa85c Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 29 Aug 2024 20:03:01 +0200 Subject: [PATCH] fixed `-Wpointer-bool-conversion` Clang compiler warnings --- lib/checkcondition.cpp | 2 -- lib/reverseanalyzer.cpp | 2 +- lib/valueflow.cpp | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index a1a71c5675c..0c5c10a803c 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -834,8 +834,6 @@ static std::string innerSmtString(const Token * tok) { if (!tok) return "if"; - if (!tok->astTop()) - return "if"; const Token * top = tok->astTop(); if (top->str() == "(" && top->astOperand1()) return top->astOperand1()->str(); diff --git a/lib/reverseanalyzer.cpp b/lib/reverseanalyzer.cpp index 04aba5bc203..d8b2def1216 100644 --- a/lib/reverseanalyzer.cpp +++ b/lib/reverseanalyzer.cpp @@ -295,7 +295,7 @@ namespace { if (!condTok) break; Analyzer::Action condAction = analyzeRecursive(condTok); - const bool inLoop = condTok->astTop() && Token::Match(condTok->astTop()->previous(), "for|while ("); + const bool inLoop = Token::Match(condTok->astTop()->previous(), "for|while ("); // Evaluate condition of for and while loops first if (inLoop) { if (Token::findmatch(tok->link(), "goto|break", tok)) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index c19799ea412..06d43e11e43 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -7086,7 +7086,7 @@ static void valueFlowContainerSize(const TokenList& tokenlist, !Token::Match(nameToken, "%name% (")) continue; } - if (nameToken->astTop() && Token::Match(nameToken->astTop()->previous(), "for|while")) + if (Token::Match(nameToken->astTop()->previous(), "for|while")) known = !isVariableChanged(var, settings); std::vector values{ValueFlow::Value{size}}; values.back().valueType = ValueFlow::Value::ValueType::CONTAINER_SIZE;