Page MenuHomePhabricator

[clang][analyzer] Errno modeling code refactor (NFC).
ClosedPublic

Authored by balazske on Aug 15 2022, 1:30 AM.

Details

Summary

Some of the code used in StdLibraryFunctionsChecker is applicable to
other checkers, this is put into common functions. Errno related
parts of the checker are simplified and renamed. Documentations in
errno_modeling functions are updated.

This change makes it available to have more checkers that perform
modeling of some standard functions. These can set the errno state
with common functions and the bug report messages (note tags) can
look similar.

Diff Detail

Event Timeline

balazske created this revision.Aug 15 2022, 1:30 AM
Herald added a reviewer: NoQ. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
balazske requested review of this revision.Aug 15 2022, 1:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2022, 1:30 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
steakhal accepted this revision.Aug 15 2022, 3:51 AM

Approved with nits. Thanks!

clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp
267

The same applies for these.

298

I would prefer returning nullptr explicitly here.

304–307

I believe you should use Twine() for chaining string slices.

clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
83

It seems like you are already within this namespace. You don't need to explicitly qualify this.

clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
405

Why don't you = default it if the body is actually empty?

416

I find this name much more appealing than it was before! Thanks.

This revision is now accepted and ready to land.Aug 15 2022, 3:51 AM
balazske updated this revision to Diff 453231.Aug 17 2022, 1:34 AM
balazske marked 4 inline comments as done.

Small improvements.

balazske marked an inline comment as done.Aug 17 2022, 8:20 AM
martong accepted this revision.Aug 31 2022, 8:30 AM

LGTM!

This revision was automatically updated to reflect the committed changes.