P4C
The P4 Compiler
Loading...
Searching...
No Matches
coverage.h
1#ifndef MIDEND_COVERAGE_H_
2#define MIDEND_COVERAGE_H_
3
4#include <set>
5#include <vector>
6
7#include "ir/ir.h"
8#include "ir/visitor.h"
9#include "lib/source_file.h"
10
16
17namespace P4::Coverage {
18
21 bool operator()(const IR::Node *s1, const IR::Node *s2) const;
22};
23
27 bool coverStatements = false;
29 bool coverTableEntries = false;
31 bool coverActions = false;
32
34 bool onlyCoveringTests = false;
35};
36
39using CoverageSet = std::set<const IR::Node *, SourceIdCmp>;
40
43class CollectNodes : public Inspector {
45 CoverageSet coverableNodes;
46
48 CoverageOptions coverageOptions;
49
51 bool preorder(const IR::AssignmentStatement *stmt) override;
52 bool preorder(const IR::MethodCallStatement *stmt) override;
53 bool preorder(const IR::ExitStatement *stmt) override;
54
56 bool preorder(const IR::Entry *entry) override;
57
59 bool preorder(const IR::P4Action *act) override;
60
61 public:
62 explicit CollectNodes(CoverageOptions coverageOptions);
63
66};
67
69void printCoverageReport(const CoverageSet &all, const CoverageSet &visited);
70
72void logCoverage(const CoverageSet &all, const CoverageSet &visited, const CoverageSet &new_);
73
74} // namespace P4::Coverage
75
76#endif /* MIDEND_COVERAGE_H_ */
Definition coverage.h:43
const CoverageSet & getCoverableNodes()
Definition coverage.cpp:91
Definition node.h:95
Definition visitor.h:400
Definition coverage.cpp:7
bool coverStatements
Cover IR::Statement.
Definition coverage.h:27
bool onlyCoveringTests
Skip tests which do not increase coverage.
Definition coverage.h:34
void printCoverageReport(const CoverageSet &all, const CoverageSet &visited)
Produces detailed final coverage log.
Definition coverage.cpp:59
bool coverActions
Cover IR::P4Action.
Definition coverage.h:31
std::set< const IR::Node *, SourceIdCmp > CoverageSet
Definition coverage.h:39
void logCoverage(const CoverageSet &all, const CoverageSet &visited, const CoverageSet &new_)
Logs nodes from new_ which have not yet been visited (are not members of visited).
Definition coverage.cpp:80
bool coverTableEntries
Cover IR::Entry.
Definition coverage.h:29
Specifies general options and which IR nodes to track with this particular visitor.
Definition coverage.h:25
Utility function to compare IR nodes in a set. We use their source info.
Definition coverage.h:20