diff --git a/op-finder-lib/src/OperationFinderAstVisitor.cpp b/op-finder-lib/src/OperationFinderAstVisitor.cpp index eb93195..5965741 100644 --- a/op-finder-lib/src/OperationFinderAstVisitor.cpp +++ b/op-finder-lib/src/OperationFinderAstVisitor.cpp @@ -28,8 +28,7 @@ bool OperationFinderAstVisitor::VisitBinaryOperator(clang::BinaryOperator* op) { assert(_context); - if (!op->isCompoundAssignmentOp()) - _op_finder->processArithmetic(op, _context->getSourceManager()); + _op_finder->processArithmetic(op, _context->getSourceManager()); return true; } diff --git a/op-finder/main.cpp b/op-finder/main.cpp index b1a2dab..4e03204 100644 --- a/op-finder/main.cpp +++ b/op-finder/main.cpp @@ -72,7 +72,7 @@ int main(int argc, const char** argv) OperationFinderAstAction action(&op_finder); - assert(!Tool.run(newFrontendActionFactory(&action).get())); + Tool.run(newFrontendActionFactory(&action).get()); if (!OutputFile.getValue().empty()) storage.toFile(OutputFile.getValue()); diff --git a/op-summarizer/gcovreader.py b/op-summarizer/gcovreader.py index 17c7cc9..56268df 100644 --- a/op-summarizer/gcovreader.py +++ b/op-summarizer/gcovreader.py @@ -27,16 +27,13 @@ class GCovFile: lines: List[GCovLine] = [] for line in file["lines"]: - lines.append(GCovLine(line["line_number"], line["count"])) - # Branch specific identification. TODO! later. - #if len(line["branches"]): - # # GCov reports branches in reverse order to our parser. - # branch_number = len(line["branches"]) - # for branch in line["branches"]: - # lines.append(GCovLine(line["line_number"], branch["count"], branch_number)) - # branch_number -= 1 - #else: - # lines.append(GCovLine(line["line_number"], line["count"]))) + lines.append(GCovLine(line["line_number"], line["count"])) + if len(line["branches"]): + # GCov reports branches in reverse order to our parser. + branch_number = len(line["branches"]) + for branch in line["branches"]: + lines.append(GCovLine(line["line_number"], branch["count"], branch_number)) + branch_number -= 1 self.files[name] = lines diff --git a/op-summarizer/opsummarizer.py b/op-summarizer/opsummarizer.py index 303ddb7..1d22be7 100644 --- a/op-summarizer/opsummarizer.py +++ b/op-summarizer/opsummarizer.py @@ -28,8 +28,8 @@ class OpSummarizer: for op_log in op_lines: # TODO: revise this. Need a special case for for-loop clauses # or branching in general. - #if op_log.branch_number != gcov_line.branch_number: - # continue + if op_log.branch_number != gcov_line.branch_number: + continue unique_op = op_log.entry @@ -69,6 +69,7 @@ if __name__ == "__main__": summarizer = OpSummarizer(args.gcov, args.finder) total_count = {} + total_num = 0 for file_name in args.files: ops = summarizer.count_operations(file_name) @@ -77,9 +78,12 @@ if __name__ == "__main__": print(f"Unique operations for file {file_name}:") for uop, count in ops.items(): print(f"\t{count}: {uop}") + total_num += count print("---------") + print(f"Total count: {total_num}") + if args.output: with open(args.output, "w") as outfile: json.dump(total_count, outfile)