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

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52935. etienneb added a comment. nit 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

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

2016-04-07 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. LG with one nit. Comment at: clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp:70 @@ +69,3 @@ +diag(SL->getLocStart(), "suspicious embedded NUL character"); +

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

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52930. etienneb marked 3 inline comments as done. etienneb added a comment. fix doc. http://reviews.llvm.org/D18783 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp clang

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

2016-04-07 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision. This revision now requires changes to proceed. Comment at: docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst:6 @@ +5,3 @@ + +Find occurences of string literal with embedded NUL character and validate +their usage. -

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

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52927. etienneb added a comment. nit 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

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

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52926. etienneb marked 2 inline comments as done. etienneb added a comment. Revert last diff (invalid patchset). http://reviews.llvm.org/D18783 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp clang-tidy/misc/StringLiteralWith

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

2016-04-07 Thread Alexander Kornienko via cfe-commits
alexfh added a comment. Wait, it looks like you've updated the patch from an incorrect branch: I see only clang-tidy/misc/MisplacedWideningCastCheck.cpp file here. http://reviews.llvm.org/D18783 ___ cfe-commits mailing list cfe-commits@lists.llvm.o

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

2016-04-07 Thread Alexander Kornienko via cfe-commits
alexfh added a comment. A couple of nits. Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:64 @@ -62,5 +63,3 @@ unsigned RHSWidth = getMaxCalculationWidth(Context, Bop->getRHS()); -if (Bop->getOpcode() == BO_Mul) - return LHSWidth + RHSWidth; -if (Bop

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

2016-04-06 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52856. etienneb added a comment. rebased. http://reviews.llvm.org/D18783 Files: clang-tidy/misc/MisplacedWideningCastCheck.cpp Index: clang-tidy/misc/MisplacedWideningCastCheck.cpp === ---

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

2016-04-06 Thread Etienne Bergeron via cfe-commits
etienneb added a comment. In http://reviews.llvm.org/D18783#393367, @LegalizeAdulthood wrote: > There are some APIs where a series of strings are passed as a single `char *` > with NUL separators between the strings and the last string is indicated by > two NUL characters in a row. For instanc

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

2016-04-06 Thread Richard via cfe-commits
LegalizeAdulthood added a subscriber: LegalizeAdulthood. LegalizeAdulthood added a comment. There are some APIs where a series of strings are passed as a single `char *` with NUL separators between the strings and the last string is indicated by two NUL characters in a row. For instance, see th

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

2016-04-06 Thread Etienne Bergeron via cfe-commits
etienneb added a comment. I finally get rid of the GetCharAt function. Comment at: clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp:22 @@ +21,3 @@ +static unsigned int GetCharAt(const StringLiteral *SL, size_t offset) { + if (offset >= SL->getLength()) return 0; + return

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

2016-04-06 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52793. etienneb added a comment. nits. 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

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

2016-04-06 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52791. etienneb marked 2 inline comments as done. etienneb added a comment. alexfh comments. http://reviews.llvm.org/D18783 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp

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

2016-04-06 Thread Alexander Kornienko via cfe-commits
alexfh added a comment. A couple of nits for now. Will take a closer look later. Comment at: clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp:22 @@ +21,3 @@ +static unsigned int GetCharAt(const StringLiteral *SL, size_t offset) { + if (offset >= SL->getLength()) return 0;

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

2016-04-06 Thread Joerg Sonnenberger via cfe-commits
On Tue, Apr 05, 2016 at 05:27:45PM +, Ben Craig via cfe-commits wrote: > bcraig added a subscriber: bcraig. > bcraig added a comment. > > Is this checker able to connect a std::string with a pre-declared string > literal (i.e. constant propagation)? For example... > > const char *bad_char

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

2016-04-05 Thread Etienne Bergeron via cfe-commits
etienneb added a comment. In http://reviews.llvm.org/D18783#392486, @bcraig wrote: > Is this checker able to connect a std::string with a pre-declared string > literal (i.e. constant propagation)? For example... > > const char *bad_chars = "\0\1\2\3"; > std::string bad_str = bad_chars; >

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

2016-04-05 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig. bcraig added a comment. Is this checker able to connect a std::string with a pre-declared string literal (i.e. constant propagation)? For example... const char *bad_chars = "\0\1\2\3"; std::string bad_str = bad_chars; I've had real code make that mistake

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

2016-04-05 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52710. etienneb added a comment. alpha ordering http://reviews.llvm.org/D18783 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp clang-tidy/misc/StringLiteralWithEmbeddedN

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

2016-04-05 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments. Comment at: docs/ReleaseNotes.rst:161 @@ -156,1 +160,3 @@ + truncation or invalid character escaping. + Fixed bugs: I think will be good idea to sort check alphabetically. At least I did so :-) http://reviews.llvm.org/D187

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

2016-04-05 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52708. etienneb added a comment. add missing reference in release-notes. http://reviews.llvm.org/D18783 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp clang-tidy/misc/S

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

2016-04-05 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko. Eugene.Zelenko added a comment. Please mention this check in docs/ReleaseNotes.rst. http://reviews.llvm.org/D18783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-b

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

2016-04-05 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52707. etienneb marked an inline comment as done. etienneb added a comment. fix comments. http://reviews.llvm.org/D18783 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp

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

2016-04-05 Thread Benjamin Kramer via cfe-commits
bkramer added a subscriber: bkramer. Comment at: clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp:21 @@ +20,3 @@ +// Retrieve the character at offset |offset| of the string literal |SL|. +static unsigned int GetCharAt(const StringLiteral *SL, size_t offset) { + if (offset >=

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

2016-04-04 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52653. etienneb added a comment. Fix list.rst (bad merge) http://reviews.llvm.org/D18783 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp clang-tidy/misc/StringLiteralWit

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

2016-04-04 Thread Etienne Bergeron via cfe-commits
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. ```