commit 31a7073c0dc115a514222f8ea11d210d55b3a60f
parent 7bcd4ee085b2763e4c39e6f2e3bfa9eac9dafc11
Author: kyle <kyle@0x30.net>
Date: Mon, 16 Jan 2017 22:47:38 -0700
inst: silence clang output easily noticeable from a large project
Diffstat:
24 files changed, 14 insertions(+), 53 deletions(-)
diff --git a/check.sh b/check.sh
@@ -31,10 +31,8 @@ fi
find $@ -name citrun.log -print0 | xargs -0 awk '
$0~/Found source file/ { summary[0] += 1 }
$0~/Link detected/ { summary[1] += 1 }
-$0~/Rewriting successful/ { summary[2] += 1 }
-$0~/Rewriting failed/ { summary[3] += 1 }
-$0~/Rewritten source compile successful/ { summary[4] += 1 }
-$0~/Rewritten source compile failed/ { summary[5] += 1 }
+$0~/Rewritten source compile successful/ { summary[2] += 1 }
+$0~/Rewritten source compile failed/ { summary[3] += 1 }
$0~/Lines of source code/ { totals[0] += $2 }
$0~/Milliseconds spent rewriting source/ { totals[1] += $2 }
@@ -53,13 +51,11 @@ $0~/Errors rewriting source/ { totals[12] += $2 }
END {
summary_desc[0] = "Source files used as input"
summary_desc[1] = "Application link commands"
- summary_desc[2] = "Rewrite successes"
- summary_desc[3] = "Rewrite failures"
- summary_desc[4] = "Rewritten source compile successes"
- summary_desc[5] = "Rewritten source compile failures"
+ summary_desc[2] = "Rewritten source compile successes"
+ summary_desc[3] = "Rewritten source compile failures"
print "Summary:"
- for (i = 0; i < 6; i++) {
+ for (i = 0; i < 4; i++) {
if (i != 0 && summary[i] == 0) continue
printf "%10i %s\n", summary[i], summary_desc[i]
}
diff --git a/inst_fe.cc b/inst_fe.cc
@@ -18,7 +18,7 @@
#include "lib.h" // citrun_major, citrun_minor
#include "prefix.h" // prefix
-#include <clang/Frontend/TextDiagnosticPrinter.h>
+#include <clang/Basic/Diagnostic.h> // IgnoringDiagConsumer
#include <clang/Tooling/CommonOptionsParser.h>
#include <clang/Tooling/Tooling.h>
#include <llvm/Support/raw_os_ostream.h>
@@ -236,23 +236,18 @@ InstFrontend::instrument()
Tool(op.getCompilations(), op.getSourcePathList());
//
- // Send tool diagnostics to the log with a prefix to tell it from the
- // rest.
+ // Ignore all errors/warnings by default.
+ // This makes Tool.run() always return 0 too.
//
- clang::DiagnosticOptions diag_opts;
- llvm::raw_os_ostream raw_ostream(m_log);
- clang::TextDiagnosticPrinter *printer =
- new clang::TextDiagnosticPrinter(raw_ostream, &diag_opts);
- printer->setPrefix("clang");
- Tool.setDiagnosticConsumer(printer);
+ Tool.setDiagnosticConsumer(new clang::IgnoringDiagConsumer());
std::unique_ptr<InstrumentActionFactory> f =
llvm::make_unique<InstrumentActionFactory>(m_log, m_is_citruninst, m_source_files);
- // Run the ClangTool over an InstrumentActionFactory, instrumenting and
- // writing modified source code in place.
- int ret = Tool.run(f.get());
- m_log << "Rewriting " << (ret ? "failed." : "successful.") << std::endl;
+ //
+ // Run instrumentation. All source files are processed here.
+ //
+ Tool.run(f.get());
// All of the time until now is the overhead citrun_inst adds.
std::chrono::high_resolution_clock::time_point now =
@@ -262,14 +257,7 @@ InstFrontend::instrument()
// This is as far as we go in citrun_inst mode.
if (m_is_citruninst)
- exit(ret);
-
- // If rewriting failed original source files may be in an
- // inconsistent state.
- if (ret) {
- restore_original_src();
- exec_compiler();
- }
+ exit(0);
}
//
diff --git a/t/e2e_ansi.t b/t/e2e_ansi.t
@@ -34,7 +34,6 @@ Instrumentation of '' finished:
1 Return statement values
3 Total statements
Modified source written successfully.
-Rewriting successful.
Forked compiler ''
Rewritten source compile successful
Restored ''
diff --git a/t/e2e_intent.t b/t/e2e_intent.t
@@ -60,7 +60,6 @@ Instrumentation of '' finished:
64 Total statements
7 Binary operators
Modified source written successfully.
-Rewriting successful.
Forked compiler ''
Rewritten source compile successful
Restored ''
diff --git a/t/e2e_link_multiple.t b/t/e2e_link_multiple.t
@@ -63,7 +63,6 @@ Instrumentation of '' finished:
1 Function definitions
2 Total statements
Modified source written successfully.
-Rewriting successful.
Forked compiler ''
Rewritten source compile successful
Restored ''
diff --git a/t/inst_basic_link.t b/t/inst_basic_link.t
@@ -26,7 +26,6 @@ Instrumentation of '' finished:
1 Return statement values
3 Total statements
Modified source written successfully.
-Rewriting successful.
Forked compiler ''
Rewritten source compile successful
Restored ''
diff --git a/t/inst_binop.t b/t/inst_binop.t
@@ -63,7 +63,6 @@ Instrumentation of '' finished:
7 Total statements
1 Binary operators
Modified source written successfully.
-Rewriting successful.
EOF
# Run the command.
diff --git a/t/inst_dowhile.t b/t/inst_dowhile.t
@@ -41,7 +41,6 @@ Instrumentation of '' finished:
11 Total statements
1 Binary operators
Modified source written successfully.
-Rewriting successful.
EOF
# Run the command.
diff --git a/t/inst_for.t b/t/inst_for.t
@@ -40,7 +40,6 @@ Instrumentation of '' finished:
15 Total statements
2 Binary operators
Modified source written successfully.
-Rewriting successful.
EOF
# Run the command.
diff --git a/t/inst_funcdef.t b/t/inst_funcdef.t
@@ -42,7 +42,6 @@ Instrumentation of '' finished:
1 Function definitions
1 Total statements
Modified source written successfully.
-Rewriting successful.
EOF
# Run the command.
diff --git a/t/inst_if.t b/t/inst_if.t
@@ -51,7 +51,6 @@ Instrumentation of '' finished:
21 Total statements
2 Binary operators
Modified source written successfully.
-Rewriting successful.
EOF
# Run the command.
diff --git a/t/inst_log.t b/t/inst_log.t
@@ -54,7 +54,6 @@ Instrumentation of '' finished:
58 Total statements
6 Binary operators
Modified source written successfully.
-Rewriting successful.
Forked compiler ''
Rewritten source compile successful
Restored ''
diff --git a/t/inst_macro.t b/t/inst_macro.t
@@ -40,7 +40,6 @@ Instrumentation of '' finished:
1 Return statement values
7 Total statements
Modified source written successfully.
-Rewriting successful.
EOF
# Run the command.
diff --git a/t/inst_return.t b/t/inst_return.t
@@ -51,7 +51,6 @@ Instrumentation of '' finished:
14 Total statements
1 Binary operators
Modified source written successfully.
-Rewriting successful.
EOF
# Run the command.
diff --git a/t/inst_srcext.t b/t/inst_srcext.t
@@ -23,7 +23,6 @@ Instrumentation of '' finished:
1 Return statement values
3 Total statements
Modified source written successfully.
-Rewriting successful.
EOF
for (@supported_exts) {
diff --git a/t/inst_switch.t b/t/inst_switch.t
@@ -54,7 +54,6 @@ Instrumentation of '' finished:
1 Return statement values
14 Total statements
Modified source written successfully.
-Rewriting successful.
EOF
# Run the command.
diff --git a/t/inst_two_src.t b/t/inst_two_src.t
@@ -40,7 +40,6 @@ Instrumentation of '' finished:
1 Return statement values
3 Total statements
Modified source written successfully.
-Rewriting successful.
Forked compiler ''
Rewritten source compile successful
Restored ''
diff --git a/t/inst_while.t b/t/inst_while.t
@@ -43,7 +43,6 @@ Instrumentation of '' finished:
18 Total statements
2 Binary operators
Modified source written successfully.
-Rewriting successful.
EOF
# Run the command.
diff --git a/t/wrap_cmake.t b/t/wrap_cmake.t
@@ -33,7 +33,6 @@ Instrumentation of '' finished:
1 Return statement values
3 Total statements
Modified source written successfully.
-Rewriting successful.
Forked compiler ''
Rewritten source compile successful
Restored ''
diff --git a/t/wrap_jam.t b/t/wrap_jam.t
@@ -37,7 +37,6 @@ Instrumentation of '' finished:
1 Return statement values
3 Total statements
Modified source written successfully.
-Rewriting successful.
Forked compiler ''
Rewritten source compile successful
Restored ''
diff --git a/t/wrap_make.t b/t/wrap_make.t
@@ -38,7 +38,6 @@ Instrumentation of '' finished:
1 Return statement values
3 Total statements
Modified source written successfully.
-Rewriting successful.
Forked compiler ''
Rewritten source compile successful
Restored ''
diff --git a/t/wrap_ninja.t b/t/wrap_ninja.t
@@ -44,7 +44,6 @@ Instrumentation of '' finished:
1 Return statement values
3 Total statements
Modified source written successfully.
-Rewriting successful.
Forked compiler ''
Rewritten source compile successful
Restored ''
diff --git a/t/wrap_nmake.t b/t/wrap_nmake.t
@@ -32,7 +32,6 @@ Instrumentation of '' finished:
1 Return statement values
3 Total statements
Modified source written successfully.
-Rewriting successful.
Forked compiler ''
Rewritten source compile successful
Restored ''
@@ -49,7 +48,6 @@ Instrumentation of '' finished:
1 Return statement values
3 Total statements
Modified source written successfully.
-Rewriting successful.
Forked compiler ''
Rewritten source compile successful
Restored ''
diff --git a/t/wrap_parallel.t b/t/wrap_parallel.t
@@ -40,7 +40,6 @@ my $check_good = <<EOF;
Summary:
4 Source files used as input
4 Application link commands
- 4 Rewrite successes
4 Rewritten source compile successes
Totals: