Readd branch information
This commit is contained in:
parent
91fbb3bbbd
commit
905dcb160c
@ -28,7 +28,6 @@ bool OperationFinderAstVisitor::VisitBinaryOperator(clang::BinaryOperator* op)
|
||||
{
|
||||
assert(_context);
|
||||
|
||||
if (!op->isCompoundAssignmentOp())
|
||||
_op_finder->processArithmetic(op, _context->getSourceManager());
|
||||
|
||||
return true;
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user