Prepare compilerplugins for C++23 if consteval
...for which clang::IfStmt::getCond returns null Change-Id: I8b86a033d52de87dedbdf6d867f2b3d3f57c1b5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148979 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -46,15 +46,19 @@ private:
|
|||||||
|
|
||||||
bool SimplifyDynamicCast::TraverseIfStmt(IfStmt* ifStmt)
|
bool SimplifyDynamicCast::TraverseIfStmt(IfStmt* ifStmt)
|
||||||
{
|
{
|
||||||
auto condExpr = ifStmt->getCond()->IgnoreParenImpCasts();
|
CXXDynamicCastExpr const* dynamicCastExpr = nullptr;
|
||||||
auto dynamicCastExpr = dyn_cast<CXXDynamicCastExpr>(condExpr);
|
if (Expr const* condExpr = ifStmt->getCond())
|
||||||
if (!dynamicCastExpr)
|
|
||||||
{
|
{
|
||||||
if (auto binaryOp = dyn_cast<BinaryOperator>(condExpr))
|
condExpr = condExpr->IgnoreParenImpCasts();
|
||||||
|
dynamicCastExpr = dyn_cast<CXXDynamicCastExpr>(condExpr);
|
||||||
|
if (!dynamicCastExpr)
|
||||||
{
|
{
|
||||||
if (binaryOp->getOpcode() == BO_NE)
|
if (auto binaryOp = dyn_cast<BinaryOperator>(condExpr))
|
||||||
dynamicCastExpr
|
{
|
||||||
= dyn_cast<CXXDynamicCastExpr>(binaryOp->getLHS()->IgnoreParenImpCasts());
|
if (binaryOp->getOpcode() == BO_NE)
|
||||||
|
dynamicCastExpr
|
||||||
|
= dyn_cast<CXXDynamicCastExpr>(binaryOp->getLHS()->IgnoreParenImpCasts());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Decl const* subExprDecl = nullptr;
|
Decl const* subExprDecl = nullptr;
|
||||||
|
@@ -131,14 +131,20 @@ public:
|
|||||||
|
|
||||||
bool PreTraverseIfStmt(IfStmt* stmt)
|
bool PreTraverseIfStmt(IfStmt* stmt)
|
||||||
{
|
{
|
||||||
contextuallyConvertedExprs_.push_back(stmt->getCond()->IgnoreParenImpCasts());
|
if (auto const cond = stmt->getCond())
|
||||||
|
{
|
||||||
|
contextuallyConvertedExprs_.push_back(cond->IgnoreParenImpCasts());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PostTraverseIfStmt(IfStmt*, bool)
|
bool PostTraverseIfStmt(IfStmt* stmt, bool)
|
||||||
{
|
{
|
||||||
assert(!contextuallyConvertedExprs_.empty());
|
if (stmt->getCond() != nullptr)
|
||||||
contextuallyConvertedExprs_.pop_back();
|
{
|
||||||
|
assert(!contextuallyConvertedExprs_.empty());
|
||||||
|
contextuallyConvertedExprs_.pop_back();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -262,8 +262,10 @@ bool UnnecessaryParen::VisitParenExpr(const ParenExpr* parenExpr)
|
|||||||
|
|
||||||
bool UnnecessaryParen::VisitIfStmt(const IfStmt* ifStmt)
|
bool UnnecessaryParen::VisitIfStmt(const IfStmt* ifStmt)
|
||||||
{
|
{
|
||||||
handleUnreachableCodeConditionParens(ifStmt->getCond());
|
if (auto const cond = ifStmt->getCond()) {
|
||||||
VisitSomeStmt(ifStmt, ifStmt->getCond(), "if");
|
handleUnreachableCodeConditionParens(cond);
|
||||||
|
VisitSomeStmt(ifStmt, cond, "if");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user