Commit Graph

577 Commits

Author SHA1 Message Date
Oliver Stöneberg bd1ae69b00
cleaned up includes based on `include-what-you-use` (#4599) 2023-03-02 21:50:14 +01:00
Oliver Stöneberg 8f5f06add7
some `Tokenizer` construction and related other cleanups (#4799) 2023-03-02 21:48:14 +01:00
Michael Drake d651b6baf1
dump: Fix concurrency problem with dump files (#4757)
* dump: Fix concurrency problem with dump files

This adds the process ID for the cppcheck process to the filenames
of the .dump and .ctu-info files that the process generates.

So
  lib/cppcheck.cpp.dump
becomes
  lib/cppcheck.cpp.<PID>.dump

For example:
  lib/cppcheck.cpp.2637871.dump

The reason for this change is that if there is a buildsystem which
supports concurrency, multiple instances of cppcheck may be run for
the same file.  For example, if the same file is compiled in multiple
build variants, or for multiple targets.

If running the MISRA plugin over such a project with concurrency
enabled in the buildsystem, the plugin ends up crashing as multiple
jobs attempt to create/trample/delete the same files while other
jobs are using them.

For more information see:
    https://sourceforge.net/p/cppcheck/discussion/general/thread/02c757b4af/

* dump: Include pid in filename if dump not explicit

Only change the dump and ctu-info filenames to include the PID if
they are being generated due to an addon.

This means that existing scripts that use `--dump` will still work
if they depend on the previous naming behaviour. The more robust
filenames containing the pid will be used when the dump files are
used as an internal implementation detail for passing data to addons.

However this means that anything that does explicitly use `--dump`
will be susceptible to concurrency problems.

* test: Update addon dump file test to account for pid

This test causes a dump file to be created by enabling the misra
addon. Since the dump files now include the cppcheck process pid
this test had to be updated to account for the change.
2023-02-13 20:54:21 +01:00
Oliver Stöneberg 8ef14dad98
fixed and enabled `performance-faster-string-find` clang-tidy warning (#4769) 2023-02-08 21:01:51 +01:00
Oliver Stöneberg 14e78e1800
greatly improved error handling in Cppcheck project file parsing / some cleanups (#4752) 2023-02-08 20:30:43 +01:00
Daniel Marjamäki 464fbe8d53 Update copyright year 2023-01-28 10:16:34 +01:00
Oliver Stöneberg a8fd5cbaf4
added `entrypoint` to library configuration and got rid of hard-coded ones (#4691) 2023-01-18 20:52:33 +01:00
Daniel Marjamäki f8c4354d2e Cleanup *.ctu-info files that are not needed anymore after analysis 2023-01-18 17:32:14 +01:00
Oliver Stöneberg d3a2cdc26c
converted (undocumented) define `MAXTIME` into (undocumented) command-line options `--checks-max-time=`, `--template-max-time=` and `--typedef-max-time=` (#4661) 2022-12-30 21:21:05 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible (#4662) 2022-12-30 15:13:47 +01:00
Oliver Stöneberg 3c68b9b29f
use `cbegin()` and `cend()` with `const_ierator` loops (#4658) 2022-12-20 20:32:16 +01:00
Daniel Marjamäki 7aae78fed3 Refactoring: Remove unused parameter for AnalyzerInfo::reportErr 2022-12-11 21:27:16 +01:00
Daniel Marjamäki ad8c1e26f0 dump: output language to dumpfile 2022-11-20 12:30:09 +01:00
Daniel Marjamäki 15d3e510e1 ValueFlow: throw TerminateException in valueFlowGenericForward in case analysis is terminated 2022-11-12 12:47:54 +01:00
Oliver Stöneberg 9f7a725983
added environment variable `UNUSEDFUNCTION_ONLY` to make sure only the `unusedFunction` check is being executed (#4362) 2022-10-06 20:54:24 +02:00
Oliver Stöneberg cff1cd9cda
applied clang-tidy `misc-const-correctness` fixes for POD types, iterators and references (#4529)
* applied `misc-const-correctness` fixes for POD types and iterators

* applied `misc-const-correctness` fixes for references
2022-10-02 07:12:40 +02:00
Oliver Stöneberg eeb6db05f1
avoid some unnecessary object creations and copies (#4493) 2022-09-29 21:47:17 +02:00
Oliver Stöneberg 10426f6707
cppcheck.cpp: only call `getFileInfo()` if necessary (#4510) 2022-09-27 20:04:35 +02:00
Oliver Stöneberg dc03a50414
some small cleanups and refactorings (#4488)
* moved `plistFile` from `ErrorLogger` to `CppCheck`

* got rid of global CWE objects

* lib/CMakeLists.txt: suppress some `-Wfloat-equal` clang warning in matchcompiled builds as well

* lib/CMakeLists.txt: moved a loop into proper block

* test/CMakeLists.txt: simplified `add_fixture`

* test/CMakeLists.txt: moved `fixture_cost`

* fixed `naming-privateMemberVariable` selfcheck warning
2022-09-24 11:59:13 +02:00
Oliver Stöneberg 339484d2a1
mitigated and enabled more clang-tidy warnings (#4470)
* fixed some `performance-inefficient-string-concatenation` clang-tidy warnings

* fixed and enabled `modernize-replace-random-shuffle` clang-tidy warning

* fixed and enabled `bugprone-suspicious-string-compare` clang-tidy warning

* mitigated and enabled `readability-non-const-parameter` clang-tidy warnings

* clang-tidy.md: documented some disabled checks

* mitigated and enabled `performance-unnecessary-value-param` clang-tidy warnings
2022-09-16 18:58:59 +02:00
Oliver Stöneberg b3ec225480
iwyu.yml: use `debian:unstable` to always get latest include-what-you-use / cleaned up includes (#4466)
* iwyu.yml: use debian:unstable to always get latest include-what-you-use

* cleaned up includes based on include-what-you-use

* mitigated include-what-you-use false positives
2022-09-16 07:15:49 +02:00
Oliver Stöneberg 76d1b9f31a
avoid unnecessary copies with `emplace_back()` (#4450)
* avoid unnecessary copies with `emplace_back()`

* cmdlineparser.cpp: suppress `accessMoved` selfcheck false positives
2022-09-10 11:25:15 +02:00
Oliver Stöneberg d46ea7ba86
avoid unnecessary copies with `push_back()` and `push_front()` (#4451) 2022-09-08 09:21:35 +02:00
Oliver Stöneberg 847391ea2d
some minor optimizations (#4449)
* cppcheck.cpp: reduced scope of a variable

* cppcheck.cpp: removed unnecessary severity checks

* cppcheck.cpp: avoid unnecessary copy

* templatesimplifier.cpp: perform early exit in loop in `expandTemplate()`
2022-09-07 19:19:04 +02:00
Daniel Marjamäki 5d267000e2 GUI: configuration of premium features 2022-08-22 21:11:28 +02:00
Oliver Stöneberg 16f598c409
added missing `sstream` includes (#4381) 2022-08-19 10:16:23 +02:00
Oliver Stöneberg 98b9f2cbf1
reduced scope of some variables and avoided some copies (#4328) 2022-08-16 22:28:39 +02:00
Oliver Stöneberg b65b47d3a8
enabled and fixed `modernize-pass-by-value` clang-tidy warnings (#4169) 2022-07-28 22:51:45 +02:00
Oliver Stöneberg d6eb3a8f40
some changes for clang/clang-tidy 15 (#4310) 2022-07-26 15:30:53 +02:00
Daniel Marjamäki db155a59c1 Tokenizer: remove simplifyTokenList2 2022-07-18 16:20:36 +02:00
Daniel Marjamäki a93c2c5263 cppcheck: keep ctu-info files if there is a cppcheck build dir 2022-07-12 10:14:37 +02:00
chrchr-github 47c2a01392
Fix #11166 inefficient way to remove last character from std::string (#4267)
* Fix #11166 inefficient way to remove last character from std::string

* Format

* Modify message, add test

* Format

* Fix another warning
2022-07-11 23:07:37 +02:00
Oliver Stöneberg c9c1f83a69
use `emptyString` more consistently (#4034) 2022-07-10 10:57:29 +02:00
Daniel Marjamäki a71a647c39 Fix syntax error 2022-07-07 19:45:47 +02:00
Daniel Marjamäki e1d3e6f72e Catch internal error during whole program analysis 2022-07-07 19:14:18 +02:00
Daniel Marjamäki b888f9cf92 use hash instead of checksum to check if content is changed 2022-07-07 12:16:01 +02:00
Daniel Marjamäki 8255e32540 cppcheck build dir: do not produce invalid dump file if code is unchanged and checking is skipped. 2022-06-12 11:08:28 +02:00
Daniel Marjamäki 86a8d88729 Tokenizer: Remove simplification of math functions from simplifyTokenList2 2022-06-08 09:58:11 +02:00
Daniel Marjamäki 54ec666739 provide more details when executing addons fails 2022-05-18 08:36:20 +02:00
Falital e8a96932e1
Don't add suppressed errors to plist output (#4038) 2022-04-26 17:39:39 +02:00
Daniel Marjamäki 8f386e15fd Remove bug hunting. This feature will be provided in Cppcheck premium. 2022-04-11 07:31:33 +02:00
Jens Yllman 34a11c1673
Fix unmatched suppression (#5704) (#3886) 2022-03-30 19:24:53 +02:00
chrchr-github 172aafdeb8
Fix #7908 FN: redundant assignment in loop (#3650) 2022-02-22 09:51:44 +01:00
José Martins c8211ec6f6
Fix check for misra addon in executeAddons. (#3819)
In the CppCheck::executeAddons function, a check that specifically tests
for the misra add-on, was not taking into account the cases when the
addon is identified with the '.py' extension or indirectly via json.
This resulted in the add-on not being executed a second time which is
needed to detected some of the misra violations. By using the AddonInfo
class name field, the addon name is uniformized for all these cases and
the add-on executed a second time.

Signed-off-by: Jose Martins <josemartins90@gmail.com>
2022-02-13 11:58:42 +01:00
Oliver Stöneberg 047930fd17
removed some unused/unread member variables (and related code) found by CLion "Unused global declaration" inspection (#3808) 2022-02-07 15:34:34 +01:00
Daniel Marjamäki 3989408738 Update copyright year 2022-02-05 11:45:17 +01:00
Oliver Stöneberg 171da2e6f9
avoid dependency on transitive includes - based on include-what-you-use (#3757) 2022-01-27 19:03:20 +01:00
Daniel Marjamäki d2dd4e54b9 Fix execution of executable addons from GUI 2021-12-15 19:27:02 +01:00
Daniel Marjamäki d0e68e0d77 misra; add rule 17.3 2021-12-11 12:42:15 +01:00
Oliver Stöneberg cc1a18806c
use -Weverything for clang in CMake / fixed some warnings (#3519) 2021-10-24 11:06:48 +02:00