[PATCH] D133933: [clang][dataflow] Modify `transfer` in `DataflowModel` to take `CFGElement` as input instead of `Stmt`.
weiyi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 15 03:44:56 PDT 2022
wyt created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
wyt requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
To keep API of transfer functions consistent.
The single use of this transfer function in `ChromiumCheckModel` is also updated.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133933
Files:
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
clang/include/clang/Analysis/FlowSensitive/Models/ChromiumCheckModel.h
clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
Index: clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
===================================================================
--- clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
+++ 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<CFGStmt>()) {
- M.transfer(S->getStmt(), Env);
- }
+ M.transfer(E, Env);
}
private:
Index: clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
+++ 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 *Elt, Environment &Env) {
+ auto CS = Elt->getAs<CFGStmt>();
+ if (!CS)
+ return false;
+ auto Stmt = CS->getStmt();
if (const auto *Call = dyn_cast<CallExpr>(Stmt)) {
if (const auto *M = dyn_cast<CXXMethodDecl>(Call->getDirectCallee())) {
if (isCheckLikeMethod(CheckDecls, *M)) {
Index: clang/include/clang/Analysis/FlowSensitive/Models/ChromiumCheckModel.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/Models/ChromiumCheckModel.h
+++ 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 *Elt, Environment &Env) override;
private:
/// Declarations for `::logging::CheckError::.*Check`, lazily initialized.
Index: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
+++ 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 *Elt, Environment &Env) = 0;
};
} // namespace dataflow
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133933.460357.patch
Type: text/x-patch
Size: 2690 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220915/cf291bed/attachment.bin>
More information about the cfe-commits
mailing list