94 Source_Info_Schema_Logger logger;
95 std::string manifestPath;
97#ifdef BF_P4C_LOGGING_SOURCE_INFO_LOGGING_H_DEBUG
98 std::map<std::string, std::map<unsigned, std::set<std::string>>> sourceCoverage;
102 explicit SourceInfoLogging(
const std::string &outdir,
const std::string &filename,
105 sourceInfo(sourceInfo),
106 logger((outdir +
"/" + filename).c_str(), SOURCE_INFO_SCHEMA_VERSION,
107 sourceInfo.sourceRoot) {
108 manifestPath = filename;
110 for (
const auto &symbol : sourceInfo.symbols) {
111 logger.append(symbol);
113#ifdef BF_P4C_LOGGING_SOURCE_INFO_LOGGING_H_DEBUG
114 sourceCoverage[symbol->get_declaration()->get_file()]
115 [symbol->get_declaration()->get_line()]
116 .insert(std::string(symbol->get_symbol_name()) +
"(" +
117 symbol->get_symbol_type() +
")");
118 for (
auto *ref : symbol->get_references()) {
119 sourceCoverage[ref->get_file()][ref->get_line()].insert(
120 std::string(symbol->get_symbol_name()) +
"(" + symbol->get_symbol_type() +
")");
124#ifdef BF_P4C_LOGGING_SOURCE_INFO_LOGGING_H_DEBUG
125 for (
auto file : sourceCoverage) {
126 for (
auto line : file.second) {
127 std::cout <<
"COVERAGE ";
128 if (!file.first.empty() && file.first.front() !=
'/')
129 std::cout << sourceInfo.sourceRoot <<
"/";
130 std::cout << file.first <<
":" << line.first;
131 for (
auto ref : line.second) {
132 std::cout <<
" " << ref;
134 std::cout << std::endl;
140 bool preorder(
const IR::Node *)
override {
return false; }
141 void end_apply()
override;