On 10/4/18 2:31 PM, Magnus Ihse Bursie wrote:>> 4 okt. 2018 kl. 10:57 skrev Martijn Verburg <martijnverb...@gmail.com>:
I like this initiative.  I'm wondering if some of these rules can be easily
codified or written into a jcheck style checker (ccheck?) so that Authors
can adhere to the conventions and not rely on a Human review to pick out
where that convention isn't met.

That's an interesting thought!

I googled around a bit, but could find no obvious candidate for doing such a 
check. In fact, parsing and analyzing C++ seems quite a hard problem, compared 
to many other languages. (Sad, but not really surprising.)

I found two possible routes to explore: cpplint [1], the official Google tool 
to verify that the Google C++ Style Guide [2] is followed, and Vera++ [3], a 
framework for creating scripts that can analyze and/or transform C++ code.

As usual there is of a third route, this one is "just a matter of programming" :)

The (probably) easiest way to enforce usage of only a subset of C++ is to write custom clang-tidy checks [0]. We could most likely write a couple of ASTMatchers [1] to watch out for features we do not want. It used to be very hard to use the clang tooling with HotSpot, but thanks to Robin Westberg's compile-commands patch [2] that just went in, this is no longer an issue.

Unfortunately I don't think requiring all contributors to install a custom version of clang-tidy with HotSpot checks is feasible, this is more something you would want to run in a CI setup.

Thanks,
Erik

[0]: https://clang.llvm.org/extra/clang-tidy/#writing-a-clang-tidy-check
[1]: http://clang.llvm.org/docs/LibASTMatchers.html
[2]: http://hg.openjdk.java.net/jdk/jdk/rev/804792ce736f

Reply via email to