On 1/6/14, 10:54 AM, Trevor Saunders wrote:
On Mon, Jan 06, 2014 at 01:35:38PM -0500, Ehsan Akhgari wrote:
On 1/6/2014, 1:20 PM, Gregory Szorc wrote:
On 1/6/14, 7:12 AM, Ehsan Akhgari wrote:
With Birunthan's restless efforts in bug 784739, we have finally removed
the usage of NULL in our C++ code. Please stop using NULL in new C++
code,
and use nullptr instead!
Can we update the Clang plugin to emit an error (and turn the tree red)
if a NULL is detected in non-whitelisted file paths? It won't be
perfect, but it's better than nothing.
NULL is a preprocessor macro which means that by the time that the
semantic analysis phase is run, the compiler doesn't even see it.
This means that we need a new analysis phase on the lexer, which I
think is doable in a clang plugin (but Joshua can correct me if I'm
wrong.)
we could just use the poison pragma clang and gcc seem to support, but I
expect third party headers we include use null so that wouldn't actually
work (and neither would a plugin for the same reason).
Clang provides access to the low-level token stream [1]. This is
available via libclang (the C API) and the Python bindings and I'm
pretty sure you can access this info from plugins.
Each token is associated with a source location (file, line, column,
etc). So, you can tell it which files are allowed to contain certain
tokens and not fail the build if something like NULL is in 3rd party or
system headers.
You should also be able to scan the token stream to look for things like
missing braces on if blocks. Lots of possibilities.
[1] http://clang.llvm.org/doxygen/group__CINDEX__LEX.html
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform