compilerplugins/clang/constfields.cxx | 10 ++++++---- compilerplugins/clang/constvars.cxx | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-)
New commits: commit 134edb2f4a06398e2725628200292b816d79bbb9 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Wed Feb 9 21:17:01 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Wed Feb 9 22:59:23 2022 +0100 clang::IfStmt::getCond can return null ...for C++23 consteval if statements. (These caused CompilerTest_compilerplugins_clang tail fail with > clang++: include/llvm/Support/Casting.h:104: static bool llvm::isa_impl_cl<clang::DeclRefExpr, const clang::Expr *>::doit(const From *) [To = clang::DeclRefExpr, From = const clang::Expr *]: Assertion `Val && "isa<> used on a null pointer"' failed. assertions.) Change-Id: I095469c8327f91107110e5ed426b95bb41ae26b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129740 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/compilerplugins/clang/constfields.cxx b/compilerplugins/clang/constfields.cxx index 1833fd056d6c..c576d00bd9f5 100644 --- a/compilerplugins/clang/constfields.cxx +++ b/compilerplugins/clang/constfields.cxx @@ -322,11 +322,13 @@ bool ConstFields::TraverseFunctionDecl(FunctionDecl* functionDecl) bool ConstFields::TraverseIfStmt(IfStmt* ifStmt) { FieldDecl const* memberFieldDecl = nullptr; - Expr const* cond = ifStmt->getCond()->IgnoreParenImpCasts(); - if (auto memberExpr = dyn_cast<MemberExpr>(cond)) + if (Expr const* cond = ifStmt->getCond()) { - if ((memberFieldDecl = dyn_cast<FieldDecl>(memberExpr->getMemberDecl()))) - insideConditionalCheckOfMemberSet.push_back(memberFieldDecl); + if (auto memberExpr = dyn_cast<MemberExpr>(cond->IgnoreParenImpCasts())) + { + if ((memberFieldDecl = dyn_cast<FieldDecl>(memberExpr->getMemberDecl()))) + insideConditionalCheckOfMemberSet.push_back(memberFieldDecl); + } } bool ret = RecursiveASTVisitor::TraverseIfStmt(ifStmt); if (memberFieldDecl) diff --git a/compilerplugins/clang/constvars.cxx b/compilerplugins/clang/constvars.cxx index f89301fed205..e496d5f0ad15 100644 --- a/compilerplugins/clang/constvars.cxx +++ b/compilerplugins/clang/constvars.cxx @@ -272,11 +272,13 @@ bool ConstVars::TraverseFunctionDecl(FunctionDecl* functionDecl) bool ConstVars::TraverseIfStmt(IfStmt* ifStmt) { VarDecl const* varDecl = nullptr; - Expr const* cond = ifStmt->getCond()->IgnoreParenImpCasts(); - if (auto declRefExpr = dyn_cast<DeclRefExpr>(cond)) + if (Expr const* cond = ifStmt->getCond()) { - if ((varDecl = dyn_cast<VarDecl>(declRefExpr->getDecl()))) - insideConditionalCheckOfVarSet.push_back(varDecl); + if (auto declRefExpr = dyn_cast<DeclRefExpr>(cond->IgnoreParenImpCasts())) + { + if ((varDecl = dyn_cast<VarDecl>(declRefExpr->getDecl()))) + insideConditionalCheckOfVarSet.push_back(varDecl); + } } bool ret = RecursiveASTVisitor::TraverseIfStmt(ifStmt); if (varDecl)