Mike Goodwin wrote: > I have begun modifying sparse (read: adding in various hooks to the > preprocessing and parsing stages) in order to be able to use it as a > style checker. Checking rules such as order of includes, function and > variable naming ... etc. > > The style checking is intended to be for linux/driver modules and as > far as I am aware the only two freely available c parsers which can > parse all the headers in the linux kernel are those that are part of > sparse and gcc. As sparse is a lot simpler to modify it seems the > logical choice > > So I was wondering:- > 1) if anyone had used sparse similarly? Not that I know of. > 2) would it ever be desirable to have this kind of feature as a part of sparse? Yes! I'd love to see the frontend save enough information to do things like this, such as saving the tree of "#include"s. I don't know if these kinds of rules should go in the Sparse backend or in another backend using libsparse; if the former, you'll need to include options to turn these checks on, and they should likely default to "off" because they will vary between projects. In addition to the warnings you suggest, I'd love to see a warning for "Header not self-contained": a header does not #include all the headers it needs, and instead relied on the inclusion of another header first. > 3) is there anything wrong with this approach?! Not that I can see; I look forward to seeing your patches. - Josh Triplett
Attachment:
signature.asc
Description: OpenPGP digital signature