[PATCH] D130305: [clang][dataflow] Refactor ApplyBuiltinTransfer field out into DataflowAnalysisOptions struct
Sam Estep via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 21 14:33:32 PDT 2022
samestep created this revision.
Herald added subscribers: martong, tschuett, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
samestep requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Depends On D130304 <https://reviews.llvm.org/D130304>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D130305
Files:
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
Index: clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
+++ clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
@@ -30,6 +30,14 @@
namespace clang {
namespace dataflow {
+struct DataflowAnalysisOptions {
+ /// Determines whether to apply the built-in transfer functions.
+ // FIXME: Remove this option once the framework supports composing analyses
+ // (at which point the built-in transfer functions can be simply a standalone
+ // analysis).
+ bool ApplyBuiltinTransfer;
+};
+
/// Type-erased lattice element container.
///
/// Requirements:
@@ -42,16 +50,15 @@
/// Type-erased base class for dataflow analyses built on a single lattice type.
class TypeErasedDataflowAnalysis : public Environment::ValueModel {
- /// Determines whether to apply the built-in transfer functions.
- // FIXME: Remove this option once the framework supports composing analyses
- // (at which point the built-in transfer functions can be simply a standalone
- // analysis).
- bool ApplyBuiltinTransfer;
+ DataflowAnalysisOptions Options;
public:
- TypeErasedDataflowAnalysis() : ApplyBuiltinTransfer(true) {}
+ TypeErasedDataflowAnalysis()
+ : TypeErasedDataflowAnalysis(/*ApplyBuiltinTransfer=*/true) {}
TypeErasedDataflowAnalysis(bool ApplyBuiltinTransfer)
- : ApplyBuiltinTransfer(ApplyBuiltinTransfer) {}
+ : Options({ApplyBuiltinTransfer}) {}
+ TypeErasedDataflowAnalysis(DataflowAnalysisOptions Options)
+ : Options(Options) {}
virtual ~TypeErasedDataflowAnalysis() {}
@@ -80,7 +87,7 @@
/// Determines whether to apply the built-in transfer functions, which model
/// the heap and stack in the `Environment`.
- bool applyBuiltinTransfer() const { return ApplyBuiltinTransfer; }
+ bool applyBuiltinTransfer() const { return Options.ApplyBuiltinTransfer; }
};
/// Type-erased model of the program at a given program point.
Index: clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
+++ clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
@@ -32,6 +32,9 @@
: DataflowAnalysis<NoopAnalysis, NoopLattice>(Context,
ApplyBuiltinTransfer) {}
+ NoopAnalysis(ASTContext &Context, DataflowAnalysisOptions Options)
+ : DataflowAnalysis<NoopAnalysis, NoopLattice>(Context, Options) {}
+
static NoopLattice initialElement() { return {}; }
void transfer(const Stmt *S, NoopLattice &E, Environment &Env) {}
Index: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
@@ -65,6 +65,9 @@
explicit DataflowAnalysis(ASTContext &Context) : Context(Context) {}
explicit DataflowAnalysis(ASTContext &Context, bool ApplyBuiltinTransfer)
: TypeErasedDataflowAnalysis(ApplyBuiltinTransfer), Context(Context) {}
+ explicit DataflowAnalysis(ASTContext &Context,
+ DataflowAnalysisOptions Options)
+ : TypeErasedDataflowAnalysis(Options), Context(Context) {}
ASTContext &getASTContext() final { return Context; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130305.446634.patch
Type: text/x-patch
Size: 3509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220721/46a0281e/attachment.bin>
More information about the cfe-commits
mailing list