This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Make NonNullParamChecker as dependency for StdCLibraryFunctionsChecker
ClosedPublic

Authored by martong on May 5 2020, 7:43 AM.

Details

Summary

If a given parameter in a FunctionDecl has a nonull attribute then the NonNull
constraint in StdCLibraryFunctionsChecker has the same effect as
NonNullParamChecker. I think it is better to emit diagnostics from the simpler
checker. By making NonNullParamChecker as a dependency, in these cases it will
be the first to emit a diagnostic and to stop the analysis on that path.

Diff Detail

Event Timeline

martong created this revision.May 5 2020, 7:43 AM
Szelethus accepted this revision.May 5 2020, 8:59 AM

I'm a bit unsure about the naming, because it's not technically true that NonNullParamChecker is a dependency of StdCLibraryFunctionsChecker. The actual relationship is different, because we only want to change the evaluation order, but then again, you can argue that this is in fact a dependency. So its like whatever, LGTM :^). Could you just drop a // NOTE: though about this?

This revision is now accepted and ready to land.May 5 2020, 8:59 AM

If a given parameter in a FunctionDecl has a nonull attribute then the NonNull constraint in StdCLibraryFunctionsChecker has the same effect as NonNullParamChecker.

Wait, where the diagnostic is coming from? My point is, the user should be able to turn apiModeling.StdCLibraryFunctions on, while suppressing all the null related diagnostics. Is this possible now? Is this possible after this change?
As long as it is possible to separately turn on modeling independently form the diagnostics, it looks good to me.

If a given parameter in a FunctionDecl has a nonull attribute then the NonNull constraint in StdCLibraryFunctionsChecker has the same effect as NonNullParamChecker.

Wait, where the diagnostic is coming from?

StdCLibraryFunctionArgs are responsible for emitting diags. This is a subchecker of StdCLibraryFunctions, and can be disabled separately.

My point is, the user should be able to turn apiModeling.StdCLibraryFunctions on, while suppressing all the null related diagnostics. Is this possible now? Is this possible after this change?

Yes, in both cases (before and after this change). By enabling StdCLibraryFunctions and disabling StdCLibraryFunctionArgs and also disabling NonNullParamChecker. (But the last one is in core, so the user should not do that.) This patch changes only the order evaluation order, from now on NonNullParamChecker's callbacks will be called earlier.

As long as it is possible to separately turn on modeling independently form the diagnostics, it looks good to me.

Yes, that is possible, so I consider this as an LGTM :)

This revision was automatically updated to reflect the committed changes.