Null pointer to standard functions


I would like to develop more checkers that detect when null is passed to standard functions that don’t allow null.

There is already a checker that does this for functions that has non null attributes (NonNullParamChecker). Other functions such as fopen does not have that attribute so they need a separate checker unless the correct way is to add the nonnull attribute to these functions.

If they shouldn’t have that attribute I propose that we write a new checker for the new functions with a checker design that uses a specification where standard functions is specified. It is specified if a function allow null. Other properties can be specified too. The checker will then use this specification to check the function calls.

I have written a proof-of-concept checker that works this way.

PassNull.diff (4.63 KB)

Would it be easier/nicer to add the attribute to the standard library? (The attribute is supported by GCC, I believe, so it wouldn’t be a matter of just adding it for Clang’s sake)


— Marshall

P.S. If you send me a list, I will work on it.