digitalmars.D - Custom checkers for Clang Static Analyzer [partially OT]
- bearophile (35/35) Nov 16 2012 The LLVM 2012 Developers' Meet...
The LLVM 2012 Developers' Meeting has released some more slides. LLVM "back-end" tools are directly used and usable by the LDC compiler, and even some of the Clang front-end-like parts designed for C/C++11 are probably adaptable for the LDC front-end/glue layers. The Clang Static Analyzer is a bug finding tool that can be extended with custom checkers. This talk shows how to write them, "Building a Checker in 24 hours", by Anna Zaks and Jordan Rose:http://llvm.org/devmtg/2012-11/Zaks-Rose-Checker24Hours.pdf Some ideas for potential checkers to implement, most of them are C++-specific, and many of them are not needed for idiomatic D code: http://clang-analyzer.llvm.org/potential_checkers.html Some of the ones I've appreciated (I think they are all usable in D): different.IdenticalExprBinOp different.IdenticalCondIfElseIf SuccessiveAssign different.IdenticalStmtThenElse different.CondOpIdenticalReturn different.LogicalOpUselessArg different.SameResLogicalExpr different.IntegerOverflow different.SignExtension optimization.PassConstObjByValue Such things are important, so I think that a new modern language should offer ways to write similar checkers in the language itself, in library code, instead of having to push them in an external tool like this Clang Static Analyzer. The good alternative is to not need similar checkers in the first place, because the language is designed more safely, or because it offers simpler ways to enforce such semantic safety, or both. Bye, bearophile
Nov 16 2012