[PATCH] D18783: [clang-tidy] add new checker for string literal with NUL character.

Etienne Bergeron via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 4 18:27:59 PDT 2016


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

This patch add the support for detecting suspicious string
literals and their usage.

The following example shows a incorrect character escaping leading 
to an embedded NUL character. 
```
  std::string str = "\0x42";   // Should be "\x42".
```

The patch also add detection of truncated literal when a literal
is passed to a string constuctor.

http://reviews.llvm.org/D18783

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
  test/clang-tidy/misc-string-literal-with-embedded-nul.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18783.52652.patch
Type: text/x-patch
Size: 12552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160405/9440e0a1/attachment-0001.bin>


More information about the cfe-commits mailing list