[PATCH] New warning for misuse of builtin compare functions.

Richard Trieu rtrieu at google.com
Wed Jun 10 16:18:06 PDT 2015


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.

http://reviews.llvm.org/D10374

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Analysis/string.c
  test/Sema/warn-builtin-compare.c

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10374.27469.patch
Type: text/x-patch
Size: 14172 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150610/322581bc/attachment.bin>


More information about the cfe-commits mailing list