commit b8592c937a051c404df96deeaa65ce1d33fc6895
parent f313fe8f434dee394f2e11625c591f2adb578a4b
Author: Kyle Milz <kyle@0x30.net>
Date: Thu, 11 Aug 2016 19:55:22 -0600
src: don;t traverse macros
Diffstat:
6 files changed, 50 insertions(+), 44 deletions(-)
diff --git a/src/inst_visitor.cc b/src/inst_visitor.cc
@@ -26,7 +26,13 @@ RewriteASTVisitor::TraverseStmt(clang::Stmt *s)
if (s == NULL)
return true;
- if (m_SM.isInMainFile(s->getLocStart()) == false)
+ clang::SourceLocation start_loc = s->getLocStart();
+ if (m_SM.isInMainFile(start_loc) == false)
+ return false;
+
+ // Instrumenting statement conditions in macros works perfectly.
+ // Instrumenting binary operators in macros does not work well.
+ if (clang::Lexer::isAtStartOfMacroExpansion(start_loc, m_SM, m_lopt))
return false;
RecursiveASTVisitor<RewriteASTVisitor>::TraverseStmt(s);
diff --git a/tt/ccitrunrun.t b/tt/ccitrunrun.t
@@ -79,14 +79,14 @@ Totals:
736 Lines of instrumentation header
3 Functions called 'main'
222 Function definitions
- 226 If statements
- 33 For loops
+ 205 If statements
+ 27 For loops
12 While loops
- 4 Switch statements
- 99 Return statement values
- 1248 Call expressions
- 22343 Total statements
- 184 Errors rewriting source
+ 3 Switch statements
+ 89 Return statement values
+ 1097 Call expressions
+ 16820 Total statements
+ 6 Errors rewriting source
EOF
system("$ENV{CITRUN_TOOLS}/citrun-check /usr/ports/pobj/ccitrunrun-* > check.out");
diff --git a/tt/git.t b/tt/git.t
@@ -308,15 +308,15 @@ Totals:
12192 Lines of instrumentation header
100 Functions called 'main'
6015 Function definitions
- 18733 If statements
- 1767 For loops
- 1117 While loops
- 81 Do while loops
- 294 Switch statements
- 7664 Return statement values
- 36340 Call expressions
- 839628 Total statements
- 7375 Errors rewriting source
+ 16473 If statements
+ 1497 For loops
+ 1025 While loops
+ 71 Do while loops
+ 272 Switch statements
+ 6825 Return statement values
+ 30619 Call expressions
+ 528856 Total statements
+ 1530 Errors rewriting source
EOF
system("$ENV{CITRUN_TOOLS}/citrun-check /usr/ports/pobj/git-* > check.out");
diff --git a/tt/mutt.t b/tt/mutt.t
@@ -139,15 +139,15 @@ Totals:
6976 Lines of instrumentation header
102 Functions called 'main'
1711 Function definitions
- 7536 If statements
- 658 For loops
- 470 While loops
- 52 Do while loops
- 147 Switch statements
- 2715 Return statement values
- 11739 Call expressions
- 358282 Total statements
- 5826 Errors rewriting source
+ 4895 If statements
+ 484 For loops
+ 326 While loops
+ 37 Do while loops
+ 104 Switch statements
+ 1956 Return statement values
+ 6894 Call expressions
+ 153801 Total statements
+ 558 Errors rewriting source
EOF
system("$ENV{CITRUN_TOOLS}/citrun-check /usr/ports/pobj/mutt-* > check.out");
diff --git a/tt/nvi.t b/tt/nvi.t
@@ -151,15 +151,15 @@ Totals:
3680 Lines of instrumentation header
2 Functions called 'main'
658 Function definitions
- 3255 If statements
- 347 For loops
- 58 While loops
- 12 Do while loops
- 161 Switch statements
- 1728 Return statement values
- 3476 Call expressions
- 196364 Total statements
- 3118 Errors rewriting source
+ 1711 If statements
+ 176 For loops
+ 33 While loops
+ 6 Do while loops
+ 100 Switch statements
+ 979 Return statement values
+ 1646 Call expressions
+ 49388 Total statements
+ 353 Errors rewriting source
EOF
system("$ENV{CITRUN_TOOLS}/citrun-check /usr/ports/pobj/nvi-* > check.out");
diff --git a/tt/openssl.t b/tt/openssl.t
@@ -721,15 +721,15 @@ Totals:
24064 Lines of instrumentation header
43 Functions called 'main'
6722 Function definitions
- 25118 If statements
- 1482 For loops
- 476 While loops
- 76 Do while loops
- 333 Switch statements
- 10646 Return statement values
- 30962 Call expressions
- 1021053 Total statements
- 16352 Errors rewriting source
+ 15969 If statements
+ 877 For loops
+ 277 While loops
+ 47 Do while loops
+ 275 Switch statements
+ 7438 Return statement values
+ 18751 Call expressions
+ 419379 Total statements
+ 2912 Errors rewriting source
EOF
system("$ENV{CITRUN_TOOLS}/citrun-check /usr/ports/pobj/openssl-* > check.out");