commit 6afc1bd2f67bdc302322073d314cbfb11ac74307
parent 777f30057473e15558655029b40640e9ba93defb
Author: Kyle Milz <kyle@0x30.net>
Date: Wed, 10 Aug 2016 22:24:35 -0600
src: add a counter for system header statements
Diffstat:
8 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/check.in b/src/check.in
@@ -46,6 +46,7 @@ FINE[9]="Return statement values"
FINE[10]="Call expressions"
FINE[11]="Total statements"
FINE[12]="Errors rewriting source"
+FINE[13]="Statements in system headers"
fine_len=${#FINE[@]}
echo -n Checking .
diff --git a/src/inst_visitor.cc b/src/inst_visitor.cc
@@ -29,8 +29,10 @@ RewriteASTVisitor::TraverseStmt(clang::Stmt *s)
clang::SourceLocation start_loc = s->getLocStart();
clang::FullSourceLoc full_loc(start_loc, m_SM);
- if (full_loc.isInSystemHeader())
+ if (full_loc.isInSystemHeader()) {
+ m_counters[SYS_HEADER_STMT]++;
return false;
+ }
RecursiveASTVisitor<RewriteASTVisitor>::TraverseStmt(s);
return true;
diff --git a/src/inst_visitor.h b/src/inst_visitor.h
@@ -14,6 +14,7 @@ enum counters {
CALL_EXPR,
TOTAL_STMT,
REWRITE_ERROR,
+ SYS_HEADER_STMT,
NCOUNTERS
};
@@ -32,7 +33,8 @@ public:
"Return statement values",
"Call expressions",
"Total statements",
- "Errors rewriting source code"
+ "Errors rewriting source code",
+ "Statements in system headers"
}),
m_TheRewriter(R),
m_SM(R.getSourceMgr()),
diff --git a/t/inst_correct.t b/t/inst_correct.t
@@ -51,6 +51,7 @@ Totals:
5 Return statement values
4 Call expressions
58 Total statements
+ 13 Statements in system headers
EOF
cc -o fib fib.c
diff --git a/t/inst_for.t b/t/inst_for.t
@@ -46,6 +46,7 @@ Totals:
4 Function definitions
1 For loops
15 Total statements
+ 13 Statements in system headers
EOF
citrun-inst -c for.c
diff --git a/t/inst_if.t b/t/inst_if.t
@@ -62,6 +62,7 @@ Totals:
3 Return statement values
2 Call expressions
33 Total statements
+ 13 Statements in system headers
EOF
citrun-inst -c if.c
diff --git a/t/inst_log.t b/t/inst_log.t
@@ -60,6 +60,7 @@ Instrumentation of '' finished:
4 Return statement values
4 Call expressions
58 Total statements
+ 13 Statements in system headers
Modified source written successfully.
Instrumentation successful.
Running native compiler on modified source code.
diff --git a/t/inst_stdout.t b/t/inst_stdout.t
@@ -34,6 +34,7 @@ Totals:
1 Return statement values
1 Call expressions
9 Total statements
+ 8 Statements in system headers
EOF
cc -o hello hello.c