[PATCH] D19118: [clang-tidy] Add checker for operations between integrals and pointers

Etienne Bergeron via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 14 08:30:06 PDT 2016


etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

This check is finding suspicious operations involving pointers and integral types; which are most likely bugs.

Examples:
subversion/v1_6/subversion/libsvn_subr/utf.c
```
static const char *
fuzzy_escape(const char *src, apr_size_t len, apr_pool_t *pool)
{
  [...]
   while (src_orig < src_end)
    {
      if (! svn_ctype_isascii(*src_orig) || src_orig == '\0')   // Should be *src_orig
        {
```

apache2/v2_2_23/modules/metadata/mod_headers.c
```
static char *parse_format_tag(apr_pool_t *p, format_tag *tag, const char **sa)
{
  [...]
    tag->arg = '\0';   // ERROR: tag->arg has type char*

    /* grab the argument if there is one */
    if (*s == '{') {
        ++s;
        tag->arg = ap_getword(p,&s,'}');
    }
```

http://reviews.llvm.org/D19118

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/PointerAndIntegralOperationCheck.cpp
  clang-tidy/misc/PointerAndIntegralOperationCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-pointer-and-integral-operation.rst
  test/clang-tidy/misc-pointer-and-integral-operation-cxx98.cpp
  test/clang-tidy/misc-pointer-and-integral-operation.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19118.53728.patch
Type: text/x-patch
Size: 12452 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160414/ca80ed9a/attachment-0001.bin>


More information about the cfe-commits mailing list