Author: Pasquale Riello Date: 2024-08-02T15:32:47+02:00 New Revision: 28d4149ba0c1748f570fecb683fb1fda62bfd974
URL: https://github.com/llvm/llvm-project/commit/28d4149ba0c1748f570fecb683fb1fda62bfd974 DIFF: https://github.com/llvm/llvm-project/commit/28d4149ba0c1748f570fecb683fb1fda62bfd974.diff LOG: [clang][dataflow] Fix casting in `ChromiumCheckModel`. (#101640) `getDirectCallee()` may return a null pointer if the callee is not a `FunctionDecl` (for example when using function pointers), this requires to use `dyn_cast_or_null` instead of `dyn_cast`. Added: Modified: clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp Removed: ################################################################################ diff --git a/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp index 5ac71e1d6bf64..77d817dafe837 100644 --- a/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp +++ b/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp @@ -56,7 +56,8 @@ bool ChromiumCheckModel::transfer(const CFGElement &Element, Environment &Env) { return false; auto Stmt = CS->getStmt(); if (const auto *Call = dyn_cast<CallExpr>(Stmt)) { - if (const auto *M = dyn_cast<CXXMethodDecl>(Call->getDirectCallee())) { + if (const auto *M = + dyn_cast_or_null<CXXMethodDecl>(Call->getDirectCallee())) { if (isCheckLikeMethod(CheckDecls, *M)) { // Mark this branch as unreachable. Env.assume(Env.arena().makeLiteral(false)); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits