This is an archive of the discontinued LLVM Phabricator instance.

[clang][analyzer] Added partial wide character support to CStringChecker
ClosedPublic

Authored by balazske on Jul 19 2022, 7:49 AM.

Details

Summary

Support for functions wmemcpy, wcslen, wcsnlen is added to the checker.
Documentation and tests are updated and extended with the new functions.

Diff Detail

Event Timeline

balazske created this revision.Jul 19 2022, 7:49 AM
Herald added a reviewer: NoQ. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
balazske requested review of this revision.Jul 19 2022, 7:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 7:49 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Nice improvement and the tests are meaningful!

clang/test/Analysis/cstring.c

Hadn't we have already a test file for this checker? What about string.c and bstring.c? You might have added redundant test cases in the new test file.

clang/test/Analysis/cstring.c
36

Could you please elaborate why this does not work with str?

68–69

I think, this would deserve a FIXME comment.

balazske updated this revision to Diff 446385.Jul 21 2022, 1:33 AM

Fix in overlap check, replaced test file.

I did not found the existing tests in other files, now all tests for the "non-wide" functions are copied for the "wide" functions. I do not like fully this solution but a single test file with macros for wide and non-wide case is probably not better.

balazske added inline comments.Jul 21 2022, 1:59 AM
clang/test/Analysis/wstring.c
385 ↗(On Diff #446385)

The problem may be that the global constant is not encountered as statement when a function is analyzed.

martong accepted this revision.Jul 22 2022, 1:38 AM

Okay, thanks for the update. LGTM!

clang/test/Analysis/wstring.c
385 ↗(On Diff #446385)

Do we have the same problem in the non-wide case?

This revision is now accepted and ready to land.Jul 22 2022, 1:38 AM
balazske added inline comments.Jul 22 2022, 5:24 AM
clang/test/Analysis/wstring.c
385 ↗(On Diff #446385)

Yes (the previous "cstring.c" file contained that test). The problem looks fixable if the string length is computed at first use, not at the variable declaration.