Skip to content

Commit 28d4149

Browse files
authored
[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`.
1 parent e7ee21f commit 28d4149

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ bool ChromiumCheckModel::transfer(const CFGElement &Element, Environment &Env) {
5656
return false;
5757
auto Stmt = CS->getStmt();
5858
if (const auto *Call = dyn_cast<CallExpr>(Stmt)) {
59-
if (const auto *M = dyn_cast<CXXMethodDecl>(Call->getDirectCallee())) {
59+
if (const auto *M =
60+
dyn_cast_or_null<CXXMethodDecl>(Call->getDirectCallee())) {
6061
if (isCheckLikeMethod(CheckDecls, *M)) {
6162
// Mark this branch as unreachable.
6263
Env.assume(Env.arena().makeLiteral(false));

0 commit comments

Comments
 (0)