Readd branch information
This commit is contained in:
parent
91fbb3bbbd
commit
905dcb160c
@ -28,8 +28,7 @@ bool OperationFinderAstVisitor::VisitBinaryOperator(clang::BinaryOperator* op)
|
|||||||
{
|
{
|
||||||
assert(_context);
|
assert(_context);
|
||||||
|
|
||||||
if (!op->isCompoundAssignmentOp())
|
_op_finder->processArithmetic(op, _context->getSourceManager());
|
||||||
_op_finder->processArithmetic(op, _context->getSourceManager());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,7 +72,7 @@ int main(int argc, const char** argv)
|
|||||||
|
|
||||||
OperationFinderAstAction action(&op_finder);
|
OperationFinderAstAction action(&op_finder);
|
||||||
|
|
||||||
assert(!Tool.run(newFrontendActionFactory(&action).get()));
|
Tool.run(newFrontendActionFactory(&action).get());
|
||||||
|
|
||||||
if (!OutputFile.getValue().empty())
|
if (!OutputFile.getValue().empty())
|
||||||
storage.toFile(OutputFile.getValue());
|
storage.toFile(OutputFile.getValue());
|
||||||
|
|||||||
@ -27,16 +27,13 @@ class GCovFile:
|
|||||||
lines: List[GCovLine] = []
|
lines: List[GCovLine] = []
|
||||||
|
|
||||||
for line in file["lines"]:
|
for line in file["lines"]:
|
||||||
lines.append(GCovLine(line["line_number"], line["count"]))
|
|
||||||
|
|
||||||
# Branch specific identification. TODO! later.
|
# Branch specific identification. TODO! later.
|
||||||
#if len(line["branches"]):
|
lines.append(GCovLine(line["line_number"], line["count"]))
|
||||||
# # GCov reports branches in reverse order to our parser.
|
if len(line["branches"]):
|
||||||
# branch_number = len(line["branches"])
|
# GCov reports branches in reverse order to our parser.
|
||||||
# for branch in line["branches"]:
|
branch_number = len(line["branches"])
|
||||||
# lines.append(GCovLine(line["line_number"], branch["count"], branch_number))
|
for branch in line["branches"]:
|
||||||
# branch_number -= 1
|
lines.append(GCovLine(line["line_number"], branch["count"], branch_number))
|
||||||
#else:
|
branch_number -= 1
|
||||||
# lines.append(GCovLine(line["line_number"], line["count"])))
|
|
||||||
|
|
||||||
self.files[name] = lines
|
self.files[name] = lines
|
||||||
|
|||||||
@ -28,8 +28,8 @@ class OpSummarizer:
|
|||||||
for op_log in op_lines:
|
for op_log in op_lines:
|
||||||
# TODO: revise this. Need a special case for for-loop clauses
|
# TODO: revise this. Need a special case for for-loop clauses
|
||||||
# or branching in general.
|
# or branching in general.
|
||||||
#if op_log.branch_number != gcov_line.branch_number:
|
if op_log.branch_number != gcov_line.branch_number:
|
||||||
# continue
|
continue
|
||||||
|
|
||||||
unique_op = op_log.entry
|
unique_op = op_log.entry
|
||||||
|
|
||||||
@ -69,6 +69,7 @@ if __name__ == "__main__":
|
|||||||
summarizer = OpSummarizer(args.gcov, args.finder)
|
summarizer = OpSummarizer(args.gcov, args.finder)
|
||||||
|
|
||||||
total_count = {}
|
total_count = {}
|
||||||
|
total_num = 0
|
||||||
|
|
||||||
for file_name in args.files:
|
for file_name in args.files:
|
||||||
ops = summarizer.count_operations(file_name)
|
ops = summarizer.count_operations(file_name)
|
||||||
@ -77,9 +78,12 @@ if __name__ == "__main__":
|
|||||||
print(f"Unique operations for file {file_name}:")
|
print(f"Unique operations for file {file_name}:")
|
||||||
for uop, count in ops.items():
|
for uop, count in ops.items():
|
||||||
print(f"\t{count}: {uop}")
|
print(f"\t{count}: {uop}")
|
||||||
|
total_num += count
|
||||||
|
|
||||||
print("---------")
|
print("---------")
|
||||||
|
|
||||||
|
print(f"Total count: {total_num}")
|
||||||
|
|
||||||
if args.output:
|
if args.output:
|
||||||
with open(args.output, "w") as outfile:
|
with open(args.output, "w") as outfile:
|
||||||
json.dump(total_count, outfile)
|
json.dump(total_count, outfile)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user