ClearBlue
SummaryMapper.h
1 //
2 // Created by yongchao on 12/20/22.
3 //
4 
5 #ifndef CLEARBLUE_SUMMARYMAPPER_H
6 #define CLEARBLUE_SUMMARYMAPPER_H
7 
8 #include <map>
9 #include <set>
10 
11 #include <llvm/Support/Debug.h>
12 
13 #include "Checker/PSA/SymbolicSummary.h"
14 #include "Checker/PSA/TraceSummary.h"
15 
16 class SummaryMapper;
17 
19 typedef struct {
21  std::set<TraceSummary *> ParamSummarySet;
22 
24  std::set<TraceSummary *> ErSrcSummarySet;
25 
28  std::set<TraceSummary *> SrcWpSummarySet;
29 
31  std::set<TraceSummary *> CSOutSummarySet;
32 
34  std::map<const SEGReturnNode *, SymbolicSummary *> RetValSummaryMap;
35 
38  SummaryMapper *SailfishSummaryMapper = nullptr;
40 
42 private:
47  std::map<std::pair<Instruction *, bool>,
48  std::vector<std::set<TransferSummary *>>>
49  TransferSmryMap;
50 
51  std::map<std::pair<Instruction *, bool>,
52  std::vector<std::set<SourceSummary *>>>
53  SourceSmryMap;
54 
55  std::map<std::pair<Instruction *, bool>,
56  std::vector<std::set<InputSummary *>>>
57  InputSmryMap;
58 
59  std::map<std::pair<Instruction *, bool>,
60  std::vector<std::set<OutputSummary *>>>
61  OutputSmryMap;
63 
64 public:
65  SummaryMapper(Function *F);
66 
67  ~SummaryMapper() {}
68 
69  void index(Instruction *CallSite, std::set<TraceSummary *> &ParamSummarySet);
70 
71 public:
72  const std::set<InputSummary *> *queryInputSummary(Instruction *, bool,
73  size_t) const;
74  const std::set<TransferSummary *> *queryTransferSummary(Instruction *, bool,
75  size_t) const;
76  const std::set<SourceSummary *> *querySourceSummary(Instruction *, bool,
77  size_t) const;
78  const std::set<OutputSummary *> *queryOutputSummary(Instruction *, bool,
79  size_t) const;
80 
81  bool hasInputSummary(Instruction *, bool, size_t) const;
82  bool hasTransferSummary(Instruction *, bool, size_t) const;
83  bool hasSourceSummary(Instruction *, bool, size_t) const;
84  bool hasOutputSummary(Instruction *, bool, size_t) const;
85 
86  std::map<std::pair<Instruction *, bool>,
87  std::vector<std::set<SourceSummary *>>>::iterator
88  source_summary_begin() {
89  return SourceSmryMap.begin();
90  }
91 
92  std::map<std::pair<Instruction *, bool>,
93  std::vector<std::set<SourceSummary *>>>::iterator
94  source_summary_end() {
95  return SourceSmryMap.end();
96  }
97 };
98 
99 #endif // CLEARBLUE_SUMMARYMAPPER_H
SailfishSummary::RetValSummaryMap
std::map< const SEGReturnNode *, SymbolicSummary * > RetValSummaryMap
Recording the symbolic summary of each return node.
Definition: SummaryMapper.h:34
SailfishSummary::ErSrcSummarySet
std::set< TraceSummary * > ErSrcSummarySet
Recording value-flow summaries starting from an error-specific source.
Definition: SummaryMapper.h:24
SailfishSummary::CSOutSummarySet
std::set< TraceSummary * > CSOutSummarySet
Recording value-flow summaries starting from a call-site output.
Definition: SummaryMapper.h:31
SailfishSummary::SrcWpSummarySet
std::set< TraceSummary * > SrcWpSummarySet
Definition: SummaryMapper.h:28
SummaryMapper
Definition: SummaryMapper.h:41
SailfishSummary::ParamSummarySet
std::set< TraceSummary * > ParamSummarySet
Recording value-flow summaries starting from a function parameter.
Definition: SummaryMapper.h:21
SailfishSummary
Various summaries generated for each function in pipelined PSA checker.
Definition: SummaryMapper.h:19