This is an archive of the discontinued LLVM Phabricator instance.

[clang][analyzer] Improve documentation of StdCLibraryFunctionArgs checker (NFC)
ClosedPublic

Authored by balazske on Apr 28 2023, 7:06 AM.

Details

Summary

Documentation is made more exact, term "constraint" is removed entirely,
description of checker option is corrected.

Diff Detail

Event Timeline

balazske created this revision.Apr 28 2023, 7:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2023, 7:06 AM
balazske requested review of this revision.Apr 28 2023, 7:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2023, 7:06 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Szelethus requested changes to this revision.May 15 2023, 5:53 AM
Szelethus added inline comments.
clang/docs/analyzer/checkers.rst
2495–2496

This makes sense to me, and likely all of us knowledgable about symbolic execution (and clang in particular), but make little sense to end users. Could you add an example to ease reading?

"For instance, if the argument to <fn> must be in between 0 and 255. If the value of the argument is unknown, the analyzer will assume that it is in this interval, even if warnings for this checker are disabled. Similarly, if a function mustn't be called with a null pointer but it is, analysis will stop on that execution path (similarly to a division by zero), with or without a warning."

2495–2496

Restriction is not a bad word, but lets ease into it a bit.

"You can think of this checker as defining restrictions (pre- and postconditions) on standard library functions. Preconditions are checked, and when they are violated, a warning is emitted. Post conditions are added to the analysis, e.g. that the return value must be no greater than 255."

2496–2529

We should create an option or something the actual list of functions we model. This is the prime example of unsustainable documenting.

2513

Isn't this something that we either do or do not enable by default? My memory betrays me.

This revision now requires changes to proceed.May 15 2023, 5:53 AM
balazske updated this revision to Diff 522192.May 15 2023, 7:53 AM

Applied review suggestions, removed the list of functions.

balazske marked 2 inline comments as done.May 15 2023, 8:02 AM
balazske added inline comments.
clang/docs/analyzer/checkers.rst
2496–2529

Such function lists are used at documentation of other checkers, but I am not sure if it is good to add such a long list here. Probably the "DisplayLoadedSummaries" option of apiModeling.StdCLibraryFunctions checker can be used, this lists only the actually found functions (that have available declaration and are enabled), and the console output needs to be observed to see the list. And this option is currently not documented.

2513

Currently ModelPOSIX is false by default.

Szelethus accepted this revision.May 17 2023, 7:06 AM
Szelethus added inline comments.
clang/docs/analyzer/checkers.rst
2476–2477
2496–2529

Such function lists are used at documentation of other checkers

Is it possible that those lists are not really expected to change? We do expect the list for this checker to grow, do we not?

This revision is now accepted and ready to land.May 17 2023, 7:06 AM
balazske updated this revision to Diff 523072.May 17 2023, 8:57 AM
balazske marked an inline comment as done.

Applied another review suggestion.

balazske added inline comments.May 18 2023, 12:35 AM
clang/docs/analyzer/checkers.rst
2496–2529

At first look not all other checkers check every possible function, only the most common ones, it looks possible to extend these. Some have an incomplete list in the documentation. My concern was if an user want to know if a specific function is checked or not.

gamesh411 accepted this revision.May 18 2023, 1:22 AM