diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h --- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h @@ -231,8 +231,8 @@ /// example, a model may capture a type and its related functions. class DataflowModel : public Environment::ValueModel { public: - /// Return value indicates whether the model processed the `Stmt`. - virtual bool transfer(const Stmt *Stmt, Environment &Env) = 0; + /// Return value indicates whether the model processed the `Element`. + virtual bool transfer(const CFGElement *Element, Environment &Env) = 0; }; } // namespace dataflow diff --git a/clang/include/clang/Analysis/FlowSensitive/Models/ChromiumCheckModel.h b/clang/include/clang/Analysis/FlowSensitive/Models/ChromiumCheckModel.h --- a/clang/include/clang/Analysis/FlowSensitive/Models/ChromiumCheckModel.h +++ b/clang/include/clang/Analysis/FlowSensitive/Models/ChromiumCheckModel.h @@ -26,7 +26,7 @@ class ChromiumCheckModel : public DataflowModel { public: ChromiumCheckModel() = default; - bool transfer(const Stmt *Stmt, Environment &Env) override; + bool transfer(const CFGElement *Element, Environment &Env) override; private: /// Declarations for `::logging::CheckError::.*Check`, lazily initialized. diff --git a/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp --- a/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp +++ b/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp @@ -50,7 +50,11 @@ return CheckDecls.contains(&D); } -bool ChromiumCheckModel::transfer(const Stmt *Stmt, Environment &Env) { +bool ChromiumCheckModel::transfer(const CFGElement *Element, Environment &Env) { + auto CS = Element->getAs(); + if (!CS) + return false; + auto Stmt = CS->getStmt(); if (const auto *Call = dyn_cast(Stmt)) { if (const auto *M = dyn_cast(Call->getDirectCallee())) { if (isCheckLikeMethod(CheckDecls, *M)) { diff --git a/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp b/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp --- a/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp @@ -120,9 +120,7 @@ static NoopLattice initialElement() { return NoopLattice(); } void transfer(const CFGElement *E, NoopLattice &, Environment &Env) { - if (auto S = E->getAs()) { - M.transfer(S->getStmt(), Env); - } + M.transfer(E, Env); } private: