On 30/01/14 06:32, Gregory Szorc wrote: > Building a style verifier for C++ is hard. You inevitably have to build > it on top of an existing parser (like Clang) or cobble something hacky > together [1], at which point you are chasing the language evolution and > all kinds of one-offs.
I wrote one using the Haskell Language.C library which parses preprocessed output but I no longer have the code. Someone who can actually program in Haskell could do it very easily. You just do some simple pattern matching on the AST. The hard part (at least for me) would be the build system changes to get the preprocessed output. > I think it would be much easier to have the verifier be a derivative of > the formatting tool. Ideally the formatter would emit reasons/policies > why it is changing something. In read-only mode, it would behave as a > verifier. The Clang project might be receptive to this enhancement if it > were proposed to them. I haven't looked hard enough at the clang-format code to work out how hard it would be. Eclipse CDT has support for refactoring including changing variable names. It doesn't work spectacularly well and I expect that is because it is actually a hard problem. It is also partly because Eclipse doesn't have all the information that our build system currently has. I don't think we should attempt style rewriting. One thing I wanted to explain is why I have focussed on clang-format-diff more than clang-format. My approach is to stop introducing ugliness so that we ratchet towards consistency. I suggest we do the same for style. The advantage of this approach is that it allows us to improve the tools as we go and avoids a flag day. Anthony _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform