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
..
2019-09-12 09:32:24 +02:00
2019-10-08 21:38:10 +02:00
2019-06-29 07:49:14 +02:00
2019-06-29 07:49:14 +02:00
2018-01-14 15:37:52 +01:00
2019-02-09 07:24:06 +01:00
2019-10-14 19:41:51 +02:00
2019-02-09 07:24:06 +01:00
2019-05-21 10:43:33 +02:00
2019-02-09 07:24:06 +01:00
2019-02-09 07:24:06 +01:00
2019-02-09 07:24:06 +01:00
2019-06-29 07:49:14 +02:00
2019-02-09 07:24:06 +01:00
2019-10-14 19:41:51 +02:00
2019-02-09 07:24:06 +01:00
2019-02-09 07:24:06 +01:00
2019-02-09 07:24:06 +01:00
2019-03-16 09:17:50 +01:00
2019-10-19 21:08:59 +02:00