Re: [cmake-developers] Integration of clang-tidy

2016-05-03 Thread Daniel Pfeifer
FYI: I have set up a dashboard build that shows the integration in
action: https://open.cdash.org/buildSummary.php?buildid=4349265

Most of the issues have fix-it hints which can be applied
automatically by clang-tidy.

On Thu, Apr 28, 2016 at 3:44 PM, Brad King  wrote:
> On 04/27/2016 06:48 PM, Daniel Pfeifer wrote:
>> It is unrelated. Clang-Tidy picks the interesting pieces from the
>> compiler command line and ignores the rest. Whether cc is given or not
>> makes no difference.
>> But maybe we should leave the decision what to pick to Clang-Tidy? It
>> may be clearer to forward the original command line unmodified.
>
> Applied, thanks!
>
>  Clang-Tidy: Give entire compiler command line to clant-tidy tool
>  https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=304ab71d
>
> -Brad
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] Integration of clang-tidy

2016-04-28 Thread Brad King
On 04/27/2016 06:48 PM, Daniel Pfeifer wrote:
> It is unrelated. Clang-Tidy picks the interesting pieces from the
> compiler command line and ignores the rest. Whether cc is given or not
> makes no difference.
> But maybe we should leave the decision what to pick to Clang-Tidy? It
> may be clearer to forward the original command line unmodified.

Applied, thanks!

 Clang-Tidy: Give entire compiler command line to clant-tidy tool
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=304ab71d

-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] Integration of clang-tidy

2016-04-27 Thread Daniel Pfeifer
On Wed, Apr 27, 2016 at 3:10 PM, Brad King  wrote:
> On 04/26/2016 05:32 PM, Daniel Pfeifer wrote:
>> This is a follow up patch:
>
> Thanks.
>
>> -tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin()+1, orig_cmd.end());
>> +tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin(), orig_cmd.end());
>
> What is the purpose of this hunk?  Does clang-tidy expect to be
> given the full compiler command line including "cc"?  This does
> not look related to the change described in the commit message.

It is unrelated. Clang-Tidy picks the interesting pieces from the
compiler command line and ignores the rest. Whether cc is given or not
makes no difference.
But maybe we should leave the decision what to pick to Clang-Tidy? It
may be clearer to forward the original command line unmodified.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] Integration of clang-tidy

2016-04-27 Thread Daniel Pfeifer
On Wed, Apr 27, 2016 at 10:47 PM, Gregor Jasny  wrote:
> Hallo Daniel,
>
> On 09/04/16 00:31, Daniel Pfeifer wrote:
>> I implemented the integration of `clang-tidy` along the lines of the
>> `include-what-you-use` integration.
>> There is a new `_CLANG_TIDY` target property that is initialized
>> with the value of the `CMAKE__CLANG_TIDY` variable.
>> It contains the command line for `clang-tidy` as a ;-list.
>
> I'm wondering what's the advantage of having this built-in support for
> clang tidy over using the generated compile command database instead?

The compile command database is just this: a database of compile
commands. It does not execute clang-tidy at all. To execute clang-tidy
for all source files that are listed in the database, you need a
separate tool.
There is this one, which requires Python:
https://llvm.org/svn/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py

Having this functionality built into CMake means:

* No additional dependencies.
* Warning messages inside your IDE.
* Warning messages on CDash.

Since clang-tidy is executed directly before the compiler for each
individual source file, you may set CMAKE_CXX_CLANG_TIDY to
"clang-tidy;-fix-errors" and successfully compile invalid code. :-)
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] Integration of clang-tidy

2016-04-27 Thread Gregor Jasny via cmake-developers
Hallo Daniel,

On 09/04/16 00:31, Daniel Pfeifer wrote:
> I implemented the integration of `clang-tidy` along the lines of the
> `include-what-you-use` integration.
> There is a new `_CLANG_TIDY` target property that is initialized
> with the value of the `CMAKE__CLANG_TIDY` variable.
> It contains the command line for `clang-tidy` as a ;-list.

I'm wondering what's the advantage of having this built-in support for
clang tidy over using the generated compile command database instead?

Thanks,
Gregor
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] Integration of clang-tidy

2016-04-27 Thread Brad King
On 04/26/2016 05:32 PM, Daniel Pfeifer wrote:
> This is a follow up patch:

Thanks.

> -tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin()+1, orig_cmd.end());
> +tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin(), orig_cmd.end());

What is the purpose of this hunk?  Does clang-tidy expect to be
given the full compiler command line including "cc"?  This does
not look related to the change described in the commit message.

I've applied the change without that hunk:

 Clang-Tidy: copy stdout to sterr; ignore original stderr
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=04d74a7f

Thanks,
-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] Integration of clang-tidy

2016-04-26 Thread Daniel Pfeifer
On Mon, Apr 11, 2016 at 5:26 PM, Brad King  wrote:
> On 04/08/2016 06:31 PM, Daniel Pfeifer wrote:
>> I implemented the integration of `clang-tidy` along the lines of the
>> `include-what-you-use` integration.
>> There is a new `_CLANG_TIDY` target property that is initialized
>> with the value of the `CMAKE__CLANG_TIDY` variable.
>> It contains the command line for `clang-tidy` as a ;-list.
>
> Nice.  The patch is very complete.  Applied:
>
>  Add options to run clang-tidy with the compiler
>  https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b2db0170

This is a follow up patch:

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.
From 53dc5b84eb6e39a6dac6eb8fab13dcf92d04ed35 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 | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 3c28c35..e9edac4 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -387,15 +387,19 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args)
 cmSystemTools::ExpandListArgument(tidy, tidy_cmd, true);
 tidy_cmd.push_back(sourceFile);
 tidy_cmd.push_back("--");
-tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin()+1, orig_cmd.end());
+tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin(), orig_cmd.end());
 
-// Run the tidy command line.
-if(!cmSystemTools::RunSingleCommand(tidy_cmd, 0, 0, , 0,
-cmSystemTools::OUTPUT_PASSTHROUGH))
+// Run the tidy command line.  Capture its stdout and hide its stderr.
+std::string stdOut;
+if(!cmSystemTools::RunSingleCommand(tidy_cmd, , 0, , 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.
-- 
2.8.0

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Re: [cmake-developers] Integration of clang-tidy

2016-04-11 Thread Brad King
On 04/08/2016 06:31 PM, Daniel Pfeifer wrote:
> I implemented the integration of `clang-tidy` along the lines of the
> `include-what-you-use` integration.
> There is a new `_CLANG_TIDY` target property that is initialized
> with the value of the `CMAKE__CLANG_TIDY` variable.
> It contains the command line for `clang-tidy` as a ;-list.

Nice.  The patch is very complete.  Applied:

 Add options to run clang-tidy with the compiler
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b2db0170

Thanks,
-Brad
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers