cppcheck/lib
Rikard Falkeborn 5c061c1c12 Set correct type and size of string and char literals (#2275)
* Set correct type and size of string and char literals

Use that string and char literal tokens store the prefix. This makes
it possible to distinghuish between different type of string literals
(i.e., utf8 encoded strings, utf16, wide strings, etc) which have
different type.

When the tokens holding the string and character values have the correct
type, it is possible to improve Token::getStrSize() to give the correct
result for all string types. Previously, it would return the number of
characters in the string, i.e., it would give the wrong size unless
the type of the string was char*.

Since strings now can have different size (in number of bytes) and
length (in number of elements), add a new helper function that returns
the number of characters. Checkers have been updated to use the correct
functions.

Having the size makes it possible to find more problems with prefixed
strings, and to reduce false positives, for example in the buffer
overflow checker.

Also, improve the stringLiteralWrite error message to also print the
prefix of the string (if there is one).

* Add comment and update string length
2019-10-20 07:11:57 +02:00
..
CMakeLists.txt CMake: Find header in externals, e.g. externals/picojson.h 2019-04-22 18:52:02 +02:00
analyzerinfo.cpp Update Copyright 2019-06-29 07:49:14 +02:00
analyzerinfo.h
astutils.cpp Fix #9262 (False positive on variable assignment when putting enum in namespace) 2019-10-19 21:41:50 +02:00
astutils.h Extend lifetime checking to temporaries (#2242) 2019-10-08 09:28:39 +02:00
check.cpp Updated copyright year 2019-09-01 11:49:43 +02:00
check.h deleted methods should be public (#2193) 2019-09-20 21:58:09 +02:00
check64bit.cpp
check64bit.h
checkassert.cpp
checkassert.h added missing OVERRIDE usage and removed redundant virtual (#2190) 2019-09-20 21:57:16 +02:00
checkautovariables.cpp Extend lifetime checking to temporaries (#2242) 2019-10-08 09:28:39 +02:00
checkautovariables.h Extend lifetime checking to temporaries (#2242) 2019-10-08 09:28:39 +02:00
checkbool.cpp Fix false negatives in checkBitwiseOnBoolean (#2220) 2019-10-06 09:57:31 +02:00
checkbool.h Fix false negatives in checkBitwiseOnBoolean (#2220) 2019-10-06 09:57:31 +02:00
checkboost.cpp
checkboost.h
checkbufferoverrun.cpp Set correct type and size of string and char literals (#2275) 2019-10-20 07:11:57 +02:00
checkbufferoverrun.h Fix Cppcheck warnings 2019-06-15 13:01:45 +02:00
checkclass.cpp Revert "#9391 Detecting uninited member variables with default ctor (#2249)" 2019-10-09 08:17:47 +02:00
checkclass.h Renamed safeClassRefMember => unsafeClassRefMember 2019-08-13 20:58:31 +02:00
checkcondition.cpp Fix issue 9351: false negative: (style) Condition '...' is always true (#2201) 2019-09-23 08:49:04 +02:00
checkcondition.h Add impossible values to ValueFlow (#2186) 2019-09-20 15:06:37 +02:00
checkexceptionsafety.cpp
checkexceptionsafety.h
checkfunctions.cpp Replace 'unsigned' with 'nonneg' in checkfunctions 2019-07-16 08:49:02 +02:00
checkfunctions.h Replace 'unsigned' with 'nonneg' in checkfunctions 2019-07-16 08:49:02 +02:00
checkinternal.cpp CheckInternal: Extend redundant null pointer check before Token::Match() (#1789) 2019-04-06 07:44:44 +02:00
checkinternal.h
checkio.cpp Fix issue 2153: valueFlowAfterCondition: struct member (#2228) 2019-09-30 21:04:43 +02:00
checkio.h replace 'unsigned' with 'nonneg' in checkio 2019-07-16 08:37:26 +02:00
checkleakautovar.cpp Fix #7031 (improve error message for memory related warnings) (#2204) 2019-09-22 21:50:02 +02:00
checkleakautovar.h Fix #7031 (improve error message for memory related warnings) (#2204) 2019-09-22 21:50:02 +02:00
checkmemoryleak.cpp leakNoReturnVar: Don't break early (#2095) 2019-08-23 06:33:00 +02:00
checkmemoryleak.h Memleak: Refactor check to separate function (#2079) 2019-08-13 13:00:59 +02:00
checknullpointer.cpp Move necessary code into valuetype (#2265) 2019-10-12 11:40:02 +02:00
checknullpointer.h
checkother.cpp Fixed #9261 (Inconsistent violation report between using global enum and namespaced enum.) 2019-10-20 07:07:38 +02:00
checkother.h Created redundantInitialization id 2019-08-25 09:45:39 +02:00
checkpostfixoperator.cpp
checkpostfixoperator.h
checksizeof.cpp Update Copyright 2019-06-29 07:49:14 +02:00
checksizeof.h
checkstl.cpp Add impossible values to ValueFlow (#2186) 2019-09-20 15:06:37 +02:00
checkstl.h added missing OVERRIDE usage and removed redundant virtual (#2190) 2019-09-20 21:57:16 +02:00
checkstring.cpp Set correct type and size of string and char literals (#2275) 2019-10-20 07:11:57 +02:00
checkstring.h Checkstring fixes (#1783) 2019-04-06 06:54:38 +02:00
checktype.cpp Fix severity of c++14 shifts with too many bits (#2213) 2019-09-25 20:16:04 +02:00
checktype.h Clarify signConversion warning message 2019-08-05 12:41:08 +02:00
checkuninitvar.cpp Fix issue 2153: valueFlowAfterCondition: struct member (#2228) 2019-09-30 21:04:43 +02:00
checkuninitvar.h Fix issue 8785: ValueFlow: Track pointer alias 2019-09-03 17:16:15 +02:00
checkunusedfunctions.cpp Fixed #8580 (False positive: unused function (lambda)) 2019-04-27 17:17:51 +02:00
checkunusedfunctions.h Silence unused variable warning (#2223) 2019-09-27 08:19:45 +02:00
checkunusedvar.cpp Fixed #9234 (FP unreadVariable - assignment via iterator) 2019-08-04 10:21:16 +02:00
checkunusedvar.h Disable all simplified checks 2019-03-16 09:17:50 +01:00
checkvaarg.cpp
checkvaarg.h added missing OVERRIDE usage and removed redundant virtual (#2190) 2019-09-20 21:57:16 +02:00
config.h sync (#1835) 2019-05-17 09:31:41 +02:00
cppcheck.cpp do not access static methods through instance (#2189) 2019-09-20 21:54:30 +02:00
cppcheck.h added missing OVERRIDE usage and removed redundant virtual (#2190) 2019-09-20 21:57:16 +02:00
cppcheck.natvis
cppcheck.vcxproj Add exprengine.cpp to VisualStudio solution 2019-09-18 21:56:31 +02:00
cppcheck.vcxproj.filters Add exprengine.cpp to VisualStudio solution 2019-09-18 21:56:31 +02:00
ctu.cpp Add impossible values to ValueFlow (#2186) 2019-09-20 15:06:37 +02:00
ctu.h CTU: Add 'column' 2019-09-12 10:46:33 +02:00
errorlogger.cpp use range loops / constness (#2181) 2019-09-19 20:29:33 +02:00
errorlogger.h Fixed #9260 (--template=gcc does not work correctly with -j) 2019-08-18 16:33:32 +02:00
exprengine.cpp ExprEngine: Improved handling of struct member assignments in loops 2019-10-14 22:04:12 +02:00
exprengine.h Fix #9399 (Build Failure on x86: error: unknown type name '__int128_t') (#2254) 2019-10-09 10:25:21 +02:00
importproject.cpp Various clang-tidy fixes (#2192) 2019-09-25 15:25:19 +02:00
importproject.h astyle formatting 2019-08-12 12:54:25 +02:00
lib.pri ExprEngine: Add new experimental path-sensitive data flow analysis. Initially used for 'verification' but could possibly later be used as a complement in the normal analysis. The code is work-in-progress and hacky! 2019-09-17 21:00:59 +02:00
library.cpp Library: added 'stdtype' attribute in <podtype> element so we can configure standard types better 2019-09-29 16:48:25 +02:00
library.h Library: added 'stdtype' attribute in <podtype> element so we can configure standard types better 2019-09-29 16:48:25 +02:00
matchcompiler.h
mathlib.cpp Keep prefix in string and char literals (#2272) 2019-10-16 11:41:33 +02:00
mathlib.h
path.cpp Various clang-tidy fixes (#2192) 2019-09-25 15:25:19 +02:00
path.h
pathmatch.cpp
pathmatch.h
pcrerules.pri
platform.cpp use range loops / constness (#2181) 2019-09-19 20:29:33 +02:00
platform.h Updated copyright year 2019-09-01 11:49:43 +02:00
preprocessor.cpp Various clang-tidy fixes (#2192) 2019-09-25 15:25:19 +02:00
preprocessor.h
settings.cpp ExprEngine: Add --debug-verify, fixed handling of global arrays 2019-09-29 15:00:54 +02:00
settings.h ExprEngine: Add --debug-verify, fixed handling of global arrays 2019-09-29 15:00:54 +02:00
standards.h Various clang-tidy fixes (#2192) 2019-09-25 15:25:19 +02:00
suppressions.cpp Fix Cppcheck warning: Suppressions::dump can be const 2019-06-29 07:53:32 +02:00
suppressions.h Fix Cppcheck warning: Suppressions::dump can be const 2019-06-29 07:53:32 +02:00
symboldatabase.cpp Set correct type and size of string and char literals (#2275) 2019-10-20 07:11:57 +02:00
symboldatabase.h Extend lifetime checking to temporaries (#2242) 2019-10-08 09:28:39 +02:00
templatesimplifier.cpp avoid some unnecessary copies in emplace_back() calls (#2194) 2019-09-28 20:22:46 +02:00
templatesimplifier.h template simplifier: ignore friend templates (#2122) 2019-09-01 09:56:33 +02:00
timer.cpp Updated copyright year 2019-09-01 11:49:43 +02:00
timer.h Convert SHOWTIME_MODES to enum class 2019-07-31 22:35:51 +02:00
token.cpp Set correct type and size of string and char literals (#2275) 2019-10-20 07:11:57 +02:00
token.h Set correct type and size of string and char literals (#2275) 2019-10-20 07:11:57 +02:00
tokenize.cpp Set correct type and size of string and char literals (#2275) 2019-10-20 07:11:57 +02:00
tokenize.h fix using type aliases in out of class destructors (#2250) 2019-10-08 19:30:41 +02:00
tokenlist.cpp Fixed #9382 (Hang: CheckLeakAutoVar pellepl/spiffs/src/spiffs_hydrogen.c) 2019-10-06 09:52:05 +02:00
tokenlist.h template simplifier: fix new daca crashes (#2093) 2019-08-17 07:38:07 +02:00
utils.h Keep prefix in string and char literals (#2272) 2019-10-16 11:41:33 +02:00
valueflow.cpp Set correct type and size of string and char literals (#2275) 2019-10-20 07:11:57 +02:00
valueflow.h Set correct type and size of string and char literals (#2275) 2019-10-20 07:11:57 +02:00
version.h Set version to 1.89.99/1.90 dev 2019-09-02 15:44:40 +02:00
version.rc