Commit Graph

60 Commits

Author SHA1 Message Date
Oliver Stöneberg 639a4131c4
changed `bool_to_string()` to return `const char*` instead and use it in more cases (#5385) 2023-09-11 11:34:22 +02:00
Oliver Stöneberg 91070ca794
utils.h: added `startsWith()` and started using it (#5381)
This makes the code much more readable. It also makes it less prone to
errors because we do not need to specify the length of the string to
match and the returnvalue is clear.

The code with the bad returnvalue check was never executed and I added a
test to show that.
2023-09-08 19:30:25 +02:00
Daniel Marjamäki c3136dbc2a
Refactor: The code to generate id string from pointer can be simplified (#5382) 2023-08-31 23:14:28 +02:00
Oliver Stöneberg 0fadf9ed25
sped up `Tokenizer::dump()` (#5009)
Scanning the `cli` folder with `DISABLE_VALUEFLOW=1` `Tokenizer::dump()`
will consume almost 25% of the total Ir count when an addon is
specified. This is mainly caused by the usage of `std::ostream`.

Encountered while profiling #4958.
2023-08-31 11:54:46 +02:00
Oliver Stöneberg f5e51eace7
do not use string-to-integer conversions without error handling (#4906) 2023-04-08 22:29:09 +02:00
Daniel Marjamäki 464fbe8d53 Update copyright year 2023-01-28 10:16:34 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible (#4662) 2022-12-30 15:13:47 +01:00
Paul Fultz II b4d455df48
Fix 11349: FP negativeIndex for clamped array index (#4627)
* Fix 11349: FP negativeIndex for clamped array index

* Format

* Use emplace_back

* Use default constructor
2022-12-13 07:50:01 +01:00
chrchr-github 3273e51fd5
Fix #10412 FN useStlAlgorithm with iterators (#4157) 2022-10-16 13:46:26 +02:00
Oliver Stöneberg d1bfae989e
fixed handling of incomplete char/string literals in `isPrefixStringCharLiteral()` - also optimized it a bit (#4541)
* fixed handling of incomplete char/string literals in `isPrefixStringCharLiteral()` - also optimized it a bit / added tests for `isStringLiteral()` and `isCharLiteral()`

* utils.h: early out in `isStringCharLiteral()` to avoid the loop
2022-10-09 11:19:19 +02:00
Oliver Stöneberg d6f1d7bb23
replaced `static const`/fixed `std::vector` containers with `std::array` (#4440) 2022-09-27 20:06:15 +02:00
Oliver Stöneberg b9e07e918e
enabled and fixed `readability-named-parameter` clang-tidy warnings (#4487) 2022-09-27 20:03:25 +02:00
Oliver Stöneberg 31d704e4bc
cppcheckexecutor.cpp: extracted platform-dependent code into separate files (#4359) 2022-08-16 22:03:44 +02:00
Oliver Stöneberg 8f728cb4b6
added (partial) support for specifying C++23 and support more "-std" options (#3212) 2022-04-15 16:17:36 +02:00
Oliver Stöneberg 6e57cc4323
small utils.h cleanup (#3821) 2022-02-11 19:44:08 +01:00
Daniel Marjamäki 3989408738 Update copyright year 2022-02-05 11:45:17 +01:00
Leon De Andrade 5b52f4946a
Implement support for passing multiple file filters (#3479) 2021-11-23 22:51:45 +01:00
Paul Fultz II 7621fee3d4
Refactor: Use ValueFlow::Value for ProgramMemory execute instead of integers (#3477) 2021-10-04 07:53:58 +02:00
chrchr-github 0c16e346f1
Minor: add endsWith() template, empy() check (#3472) 2021-09-28 20:34:21 +02:00
Paul Fultz II b0b3f7ec2d
Fix 10464: FP: knownConditionTrueFalse (#3452) 2021-09-09 07:49:56 +02:00
Paul Fultz II 7f358b2bed
Format with uncrustify (#3388) 2021-08-07 20:51:18 +02:00
Oliver Stöneberg 6397e29f84
cleaned up includes based on include-what-you-use (#3141) 2021-04-03 21:30:50 +02:00
Daniel Marjamäki 42437277dc Update Copyright year 2021-03-21 20:58:32 +01:00
Daniel Marjamäki 1858465bca astyle formatting
[ci skip]
2021-01-12 21:28:56 +01:00
Paul Fultz II b1c56d33ac
Fix issue 9133: Invalid iterator; vector::push_back, functions (#3008) 2021-01-11 18:47:38 +01:00
PKEuS a9cea9ad7c Fixed compilation (next attempt): Added more missing includes 2020-05-19 08:53:38 +02:00
PKEuS 793ed68029 Refactorization: Moved code from header to source
- from utils.h to new utils.cpp
- from token.h to token.cpp
- from valueflow.h to valueflow.cpp
- from errorlogger.h to errorlogger.cpp
2020-05-19 08:35:12 +02:00
versat 2fd2edd3f9 astyle formatting
[ci skip]
2020-05-14 18:18:14 +02:00
Oliver Stöneberg a0317477c9
utils.h: avoid unnecessary string creation in isStringCharLiteral() (#2638)
* utils.h: avoid unnecessary string creation in isStringCharLiteral()

reduces Ir from 541 to 63 in a test

* dmake
2020-05-14 14:45:35 +02:00
Daniel Marjamäki 08ddd84780 Update copyright year 2020-05-10 11:16:32 +02:00
Daniel Marjamäki 3e0218299b Revert "Update copyright year"
This reverts commit 6eec6c4bd5.
2020-05-10 11:13:05 +02:00
Daniel Marjamäki 6eec6c4bd5 Update copyright year 2020-05-10 11:11:34 +02:00
Daniel Marjamäki b3e192a4e1 astyle formatting
[ci skip]
2020-01-24 21:34:47 +01:00
Aleksandr Serbin 11993ed999 Ticket 5607: Allow to exclude folders with glob pattern (#2498) 2020-01-24 07:06:09 +01:00
Rikard Falkeborn 297360920a Keep prefix in string and char literals (#2272)
Keeping the prefix in the token allows cppcheck to print the correct
string and char literals in debug and error messages.

To achieve this, move some of the helper functions from token.cpp to
utils.h so that checks that look at string and char literals can reuse
them. This is a large part of this commit.

Note that the only user visible change is that when string and char
literals are printed in error messages, the prefix is now included.

For example:

	int f() {
		return test.substr( 0 , 4 ) == U"Hello" ? 0 : 1 ;
	};

now prints U"Hello" instead of "Hello" in the error message.
2019-10-16 11:41:33 +02:00
Daniel Marjamäki c32261c737 Updated copyright year 2019-09-01 11:49:43 +02:00
Daniel Marjamäki 2da75d5af4 Split up Cppcheck attribute. low and high values can be specified separately and they can be used for variables also. 2019-07-24 15:08:26 +02:00
Paul Fultz II 4c3191e577 Lower recursion limit when using asan (#2013) 2019-07-24 09:57:53 +02:00
Daniel Marjamäki 36d7e8a361 Add 'nonneg' macro 2019-07-14 11:40:44 +02:00
Daniel Marjamäki 58c91c4645 Revert "Refactoring endsWith utility function"
This reverts commit d300d1f61b.
2018-07-25 16:14:43 +02:00
Daniel Marjamäki d300d1f61b Refactoring endsWith utility function 2018-07-25 07:43:50 +02:00
PKEuS e2002db78d Replaced make_container by C++11 initializer lists 2018-04-08 23:03:44 +02:00
Daniel Marjamäki 7e4dba6a7e Updated copyright year 2018-03-31 20:59:09 +02:00
Daniel Marjamäki 96167ffa51 Compatibility fixes for gcc 4.5 2018-03-29 17:37:06 +02:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
orbitcowboy d9ef5c5a85 Improved const correctness of local variables. 2017-10-01 14:24:37 +02:00
Daniel Marjamäki 406ddc5c10 cleanup dead code, spotted by dmitry-me! 2017-09-30 23:05:42 +02:00
Daniel Marjamäki 9ce23203cc Fix includes 2017-09-30 12:45:25 +02:00
Daniel Marjamäki 885f8452e4 reuse case insensitive string comparison function 2017-09-30 11:25:46 +02:00
Ayaz Salikhov 4bbc830a85 Fix warnings 2017-07-17 10:13:11 +03:00