[PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

Daniel Marjamäki via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 8 05:00:29 PST 2015


danielmarjamaki updated this revision to Diff 42164.
danielmarjamaki marked an inline comment as done.
danielmarjamaki added a comment.

Moved warning to clang-tidy.

In this patch I am more careful about function calls. Sometimes when it is technically possible to use const it's still not a good idea.

For instance when using the standard strstr C function:

  char * strstr ( const char *, const char * ); 
  
  void f(char *p) {  // <- p should not be const
        char *a = strstr(p, "a");
        *a = 0;
  }


http://reviews.llvm.org/D12359

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/NonConstParameterCheck.cpp
  clang-tidy/misc/NonConstParameterCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-non-const-parameter.rst
  test/clang-tidy/misc-non-const-parameter.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12359.42164.patch
Type: text/x-patch
Size: 16765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151208/bbf2fa70/attachment-0001.bin>


More information about the cfe-commits mailing list