This is an archive of the discontinued LLVM Phabricator instance.

New warning for misuse of builtin compare functions.
Needs ReviewPublic

Authored by rtrieu on Jun 10 2015, 4:18 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

This warning catches misuse of builtin compare functions memcmp, strcmp, strncmp, strcasecmp, strncasecmp, and their __builtin_ equivalents. These functions return an int representing the relationship between two arguments. Some coders mistaken {-1, 0, 1} as the only three valid return values when the function can return any int value.

This warning is disabled for one of the static analysis tests since the static analyzer has the three return value assumption built in.

Diff Detail

Event Timeline

rtrieu updated this revision to Diff 27469.Jun 10 2015, 4:18 PM
rtrieu retitled this revision from to New warning for misuse of builtin compare functions..
rtrieu updated this object.
rtrieu edited the test plan for this revision. (Show Details)
rtrieu added a subscriber: Unknown Object (MLST).