aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Analysis/FlowSensitive/DataflowValues.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-01-17 18:25:22 +0000
committerTed Kremenek <kremenek@apple.com>2008-01-17 18:25:22 +0000
commit79649dfed2fc4b8cf0f7b6890df69458dbceeb04 (patch)
tree7b8066966f019d89c91463b937c25c069db1bdab /include/clang/Analysis/FlowSensitive/DataflowValues.h
parenteed50586435ce4d2690f44ceabd69ad531d80970 (diff)
Added support to dataflow solver to (when requested) also record dataflow
values for the block-level expressions. Modified 'LiveVariables' to provide the option to clients to record liveness information for block-level expressions (using the above feature). Modified 'DeadStores' to conform to the new interface of 'LiveVariables'. Modified 'GRConstants' to compute liveness information for block-level expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46137 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/FlowSensitive/DataflowValues.h')
-rw-r--r--include/clang/Analysis/FlowSensitive/DataflowValues.h35
1 files changed, 34 insertions, 1 deletions
diff --git a/include/clang/Analysis/FlowSensitive/DataflowValues.h b/include/clang/Analysis/FlowSensitive/DataflowValues.h
index 1604b88e30..be0a960149 100644
--- a/include/clang/Analysis/FlowSensitive/DataflowValues.h
+++ b/include/clang/Analysis/FlowSensitive/DataflowValues.h
@@ -50,6 +50,7 @@ public:
typedef _AnalysisDirTag AnalysisDirTag;
typedef llvm::DenseMap<ProgramPoint, ValTy> EdgeDataMapTy;
typedef llvm::DenseMap<const CFGBlock*, ValTy> BlockDataMapTy;
+ typedef llvm::DenseMap<const Stmt*, ValTy> StmtDataMapTy;
//===--------------------------------------------------------------------===//
// Predicates.
@@ -73,6 +74,9 @@ private:
//===--------------------------------------------------------------------===//
public:
+ DataflowValues() : StmtDataMap(NULL) {}
+ ~DataflowValues() { delete StmtDataMap; }
+
/// InitializeValues - Invoked by the solver to initialize state needed for
/// dataflow analysis. This method is usually specialized by subclasses.
void InitializeValues(const CFG& cfg) {};
@@ -102,7 +106,24 @@ public:
const ValTy& getBlockData(const CFGBlock* B) const {
return const_cast<DataflowValues*>(this)->getBlockData(B);
- }
+ }
+
+ /// getStmtData - Retrieves the dataflow values associated with a
+ /// specified Stmt. If the dataflow analysis is a forward analysis,
+ /// this data corresponds to the point immediately after a Stmt.
+ /// If the analysis is a backwards analysis, it is associated with
+ /// the point before a Stmt. This data is only computed for block-level
+ /// expressions, and only when requested when the analysis is executed.
+ ValTy& getStmtData(const Stmt* S) {
+ assert (StmtDataMap && "Dataflow values were not computed for statements.");
+ typename StmtDataMapTy::iterator I = StmtDataMap->find(S);
+ assert (I != StmtDataMap->end() && "No data associated with statement.");
+ return I->second;
+ }
+
+ const ValTy& getStmtData(const Stmt* S) const {
+ return const_cast<DataflowValues*>(this)->getStmtData(S);
+ }
/// getEdgeDataMap - Retrieves the internal map between CFG edges and
/// dataflow values. Usually used by a dataflow solver to compute
@@ -117,6 +138,17 @@ public:
/// to the dataflow values at the end of the block.
BlockDataMapTy& getBlockDataMap() { return BlockDataMap; }
const BlockDataMapTy& getBlockDataMap() const { return BlockDataMap; }
+
+ /// getStmtDataMap - Retrieves the internal map between Stmts and
+ /// dataflow values.
+ StmtDataMapTy& getStmtDataMap() {
+ if (!StmtDataMap) StmtDataMap = new StmtDataMapTy();
+ return *StmtDataMap;
+ }
+
+ const StmtDataMapTy& getStmtDataMap() const {
+ return const_cast<DataflowValues*>(this)->getStmtDataMap();
+ }
/// getAnalysisData - Retrieves the meta data associated with a
/// dataflow analysis for analyzing a particular CFG.
@@ -132,6 +164,7 @@ public:
protected:
EdgeDataMapTy EdgeDataMap;
BlockDataMapTy BlockDataMap;
+ StmtDataMapTy* StmtDataMap;
AnalysisDataTy AnalysisData;
};