From 04d74a7f891dc01b2a9c6b1388f303af9404c49b Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Tue, 26 Apr 2016 22:50:54 +0200 Subject: [PATCH] Clang-Tidy: copy stdout to sterr; ignore original stderr Clang-Tidy writes the number of warnings, the number of suppressed warnings, and instructions on how to suppress warnings to stderr. Since each source file is checked individually, this repetitive information is disturbing and should be suppressed. The actual warning messages are written to stdout. Some IDEs (eg. QtCreator) analyze only stderr for issues. Redirecting Clang-Tidy's stdout to stderr makes sure the warnings are correctly displayed. --- Source/cmcmd.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 3c28c35cb..0b9518c93 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -389,13 +389,17 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) tidy_cmd.push_back("--"); tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin()+1, orig_cmd.end()); - // Run the tidy command line. - if(!cmSystemTools::RunSingleCommand(tidy_cmd, 0, 0, &ret, 0, - cmSystemTools::OUTPUT_PASSTHROUGH)) + // Run the tidy command line. Capture its stdout and hide its stderr. + std::string stdOut; + if(!cmSystemTools::RunSingleCommand(tidy_cmd, &stdOut, 0, &ret, 0, + cmSystemTools::OUTPUT_NONE)) { std::cerr << "Error running '" << tidy_cmd[0] << "'\n"; return 1; } + + // Output the stdout from clang-tidy to stderr + std::cerr << stdOut; } // Now run the real compiler command and return its result value.