Commit Graph

550 Commits

Author SHA1 Message Date
Daniel Marjamäki b6833b525f Clang import 2020-01-25 17:01:17 +01:00
Daniel Marjamäki 6beadd9eb9 Restore cppcheck.cpp 2020-01-25 16:14:56 +01:00
Daniel Marjamäki f911495db3 Clang import; Handle clang-9 while loop better 2020-01-25 16:10:13 +01:00
Daniel Marjamäki 0929c3cced Cleanup code, CppCheck::checkNormalTokens executes the bug hunting code 2020-01-24 20:37:24 +01:00
Daniel Marjamäki 7db54bde6f Run normal checks on --clang output 2020-01-24 18:04:39 +01:00
Daniel Marjamäki bdc621b7a3 Clang import; MaterializeTemporaryExpr 2020-01-20 21:27:49 +01:00
versat 0cf82d6d45 cppcheck.cpp: Fix reserved name "stderr"
Using "stderr" as variable name results in build errors on Windows.
2020-01-20 11:12:23 +01:00
Daniel Marjamäki 8ac2cdd9ff Clang import; If there are syntax errors then abort analysis 2020-01-19 17:30:57 +01:00
Daniel Marjamäki 0eccffe8e3 --clang; require that --cppcheck-build-dir. output files are needed. 2020-01-19 12:33:17 +01:00
Daniel Marjamäki f7a30fc99f Rename Verification => Bughunting 2020-01-18 07:25:57 +01:00
Daniel Marjamäki 7820b5dbcc Rename 'Verification' to 'Bug hunting' 2020-01-14 21:17:07 +01:00
Daniel Marjamäki 1e207e42c5 CppCheck: Try to handle '"' properly in split() 2020-01-12 17:13:26 +01:00
Daniel Marjamäki 380cc78077 Clang; Run ValueFlow 2020-01-11 14:00:41 +01:00
Daniel Marjamäki 6b983a9587 Revert ValueFlow changes, there was unexpected problems in testrunner 2020-01-11 13:11:19 +01:00
Daniel Marjamäki 052eaba632 Clang; run ValueFlow analysis 2020-01-11 13:04:51 +01:00
Daniel Marjamäki 9c38a659a1 Clang import; Fixed CXXConstructExpr without child 2020-01-11 12:16:48 +01:00
Daniel Marjamäki 4c778e0999 Clang import; Rename files/namespace 2020-01-10 16:29:06 +01:00
Daniel Marjamäki 729fca8728 Clang import; handle locations better, only expand function bodies in source file 2020-01-10 14:59:34 +01:00
Daniel Marjamäki 34a26c7dd7 Clang import; Pass include paths to clang 2020-01-09 19:15:01 +01:00
Daniel Marjamäki 98e700e30d Clang import; Tweaks 2020-01-09 14:13:39 +01:00
Daniel Marjamäki 90e7a94ff4 Clang importer; Allow throw 2020-01-09 13:58:14 +01:00
Daniel Marjamäki 3d2d4c5cbd Clang import; Tweaks 2020-01-09 10:49:47 +01:00
Daniel Marjamäki c4c929a6a7 Clang import: StringLiteral, funcdecl3, determine includes with clang -v 2020-01-08 16:36:51 +01:00
Daniel Marjamäki 0b765cd253 Clang importing; Use ValueFlow 2020-01-05 19:21:13 +01:00
Daniel Marjamäki 211af1d4fe Clang import: debug output 2020-01-05 16:58:13 +01:00
Daniel Marjamäki bc17b9a1be Importing Clang ast dump: Run ValueFlow analysis 2020-01-05 16:23:02 +01:00
Daniel Marjamäki b03bdfaf72 Import Clang ast dump (experimental) 2020-01-05 15:12:53 +01:00
Daniel Marjamäki 4b4f7ea60b Verification; Updated report 2019-12-27 19:05:22 +01:00
Daniel Marjamäki caab1e61bb Fixed #9542 (Better error handling for --addon) 2019-12-17 12:00:01 +01:00
Maksim Derbasov 68a67a910e Remove .dump file after plugins execution (#2451) 2019-12-17 08:40:59 +01:00
Sebastian 95696ead23
Catch preprocessor errors possibly issued during loading files (#2430)
* Also catch preprocessor errors possibly issued during loading files

Currently only errors that are issued during preprocessing are caught.

* Bump simplecpp, implement suggestions

Use return value checking instead of catching an exception for calling
Preprocessor::loadFiles().
Handle new enum value simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND
where the corresponding enum is used in Cppcheck.

* Use "noloc" location if an explicit include can not be opened
2019-12-09 19:16:55 +01:00
Sebastian c990d10ffa
Check for JSON error when parsing addon .json files + fixes (#2374)
* cppcheck.cpp: Check for JSON error when parsing addon .json files

This fixes that errors in JSON files given via `--addon=*.json` are
silently ignored and maybe only a part of the JSON file is used.
Now the error message which picojson can return is checked and a
corresponding error message is returned again by getAddonInfo().

* naming.json: Fix missing comma

* CLI: Fix naming violations detected by addon naming.py via naming.json

* Addon naming: Add argument for validating names of constants

* LIB: Rename functions/variables so they are valid, loosen naming rules

* GUI: Fix naming violations
2019-11-20 15:37:09 +01:00
Daniel Marjamäki 81fff2edf1 Fixed #9464 (Import compile database; only check given configuration) 2019-11-09 17:51:42 +01:00
Oliver Stöneberg 9028b4a81d do not access static methods through instance (#2189) 2019-09-20 21:54:30 +02:00
Daniel Marjamäki 2d651b09fc 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
Daniel Marjamäki a5ba82c2d3 Fixed #9260 (--template=gcc does not work correctly with -j) 2019-08-18 16:33:32 +02:00
Daniel Marjamäki d95f29b23a Fixed test/cli 2019-08-18 12:51:32 +02:00
Daniel Marjamäki 2d9a131817 Refactoring: Rename variables. Do not use leading _. Renamed 'col' to 'column' 2019-08-18 12:19:05 +02:00
Daniel Marjamäki a17f2a6f05 Compiling/Installing : The CFGDIR parameter was removed. Use FILESDIR instead. 2019-08-17 10:53:07 +02:00
Daniel Marjamäki 6a260929e2 CLI: error id from addon is <addon>-<id> 2019-08-10 07:43:47 +02:00
amai2012 b0fbbb5aa7 Convert SHOWTIME_MODES to enum class 2019-07-31 22:35:51 +02:00
Daniel Marjamäki d11d6f112e Detect shadowed arguments 2019-07-17 17:08:42 +02:00
Daniel Marjamäki 341406ab17 Fixed Cppcheck warning; ::AddonInfo::getFullPath can be static 2019-06-29 07:59:55 +02:00
Daniel Marjamäki c97dc79815 --addon: Use json for addon output 2019-06-24 19:29:43 +02:00
Daniel Marjamäki de9c999d79 Better handling of spaces in paths 2019-06-22 19:20:15 +02:00
Daniel Marjamäki 59c7be307c Travis: Fix test/cli testing 2019-06-16 19:11:12 +02:00
Daniel Marjamäki ba0a75881a Refactor AddonInfo::getAddonInfo 2019-06-16 15:46:20 +02:00
eivindt 44670005ea Record C/CPP/Posix Standard used for cppcheck in dump file / use this for misra checking (#1782)
* Add cmd parameter for choosing between C90 and C99

Misra specifies different requirements to the uniqueness of
macros/enums/variables depending on what C standard
that's being used.

* Add standards configuration to each dump file

Read standards config from misra addon to decide what rules to use.

* Posix as standard setting should be deprecated.  Don't include this in the xml

* Rewritten to use a switch
2019-06-14 12:06:57 +02:00
eivindt 5dd7dacfd7 Fix small error using correct name for addon script when specified in json file (#1881) 2019-06-13 14:11:21 +02:00
Daniel Marjamäki b3a46e72dc Fix and test syntaxError suppression 2019-05-01 11:54:13 +02:00
Daniel Marjamäki 2e694f38c8 Refactoring; Use const reference instead of const 2019-04-29 08:53:36 +02:00
Daniel Marjamäki 45e5edce16 Fixed Cppcheck shadowVariable warning 2019-04-28 12:04:44 +02:00
Daniel Marjamäki ece13033b2 dmake: use -isystem for externals to avoid compiler warnings 2019-04-19 14:52:49 +02:00
Daniel Marjamäki a18025c95d test/cli: tweaks for running it in windows 2019-04-14 15:53:32 +02:00
Daniel Marjamäki b94f4176f1 test/cli: execute addon 2019-04-14 15:00:03 +02:00
Daniel Marjamäki b1b5b27b4e addons: write column in error message(s) 2019-04-13 10:22:13 +02:00
Daniel Marjamäki 2015f25a84 addon: Fix parsing of addon output 2019-04-10 18:28:46 +02:00
Daniel Marjamäki cf6f886a68 Addons: try to create dump file in cppcheck build dir 2019-04-09 07:05:41 +02:00
Daniel Marjamäki 1f68e038be Addons: Describe running addons from cppcheck in the manual 2019-04-08 21:31:38 +02:00
Daniel Marjamäki 44dcbda88e Addons: Fixed handling of addon configuration 2019-04-08 19:42:16 +02:00
Daniel Marjamäki 4bb06eceeb astyle formatting
[ci skip]
2019-04-08 18:53:14 +02:00
Daniel Marjamäki 50a5763cf5 Addons: Make it possible to configure any addon with json 2019-04-08 18:07:23 +02:00
Daniel Marjamäki a508b2abfd Addons: Add same handling in Windows as in Linux 2019-04-07 19:53:34 +02:00
Daniel Marjamäki bf9006737a Addons: Adding support in Cppcheck CLI to execute addons 2019-04-07 17:01:59 +02:00
Daniel Marjamäki a3257349b9 astyle formatting
[ci skip]
2019-03-17 10:50:06 +01:00
Daniel Marjamäki c7155a8e08 Removed '--experimental-fast' flag 2019-03-17 08:19:56 +01:00
Daniel Marjamäki 3dc34f1515 Disable all simplified checks 2019-03-16 09:17:50 +01:00
Daniel Marjamäki 4f232e41dd Add --experimental-fast option 2019-02-09 14:40:50 +01:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
Daniel Marjamäki 23599428cb Clarify Cppcheck output 2019-02-03 19:49:27 +01:00
Daniel Marjamäki 437800f46d CLI: Added --max-ctu-depth 2019-02-03 17:51:36 +01:00
Daniel Marjamäki 04d3672bde Fixed #7203 (Better syntax error, handle array declaration with @) 2019-01-01 09:45:41 +01:00
Daniel Marjamäki 271763e680 CTU: Refactoring 2018-12-25 21:11:23 +01:00
Daniel Marjamäki c7993df4ff Refactoring; Use range for loops 2018-12-25 11:47:45 +01:00
Daniel Marjamäki d97851b9db change severity for 'unknown macro' to error for now. 2018-11-13 21:08:45 +01:00
Daniel Marjamäki 152be6df63 Report 'unknown macro' as information message with id unknownMacro 2018-11-13 20:14:56 +01:00
Daniel Marjamäki 307a19d17e Refactoring: Use range for loop 2018-11-05 09:49:28 +01:00
alex babafd75e3 Added support for -U option to the GUI. 2018-10-09 15:05:05 +02:00
orbitcowboy e25bf187ad Attempt to fix regression for pcre_free_study(). 2018-09-26 08:07:26 +02:00
orbitcowboy bdb136de02 PCRE: Fixed unintended message when HAVE_RULES=yes was set. 2018-09-24 09:00:09 +02:00
Daniel Marjamäki 3a007cbcbf astyle formatting
[ci skip]
2018-09-23 17:04:52 +02:00
orbitcowboy 29d7872440
Improvements for PCRE API usage (HAVE_RULES=yes) (#1384)
* PCRE: added pcre_study to improve regex matching speed.

* PCRE: catch return values from pcre_exec and return an error message in case it fails.

* Formatted the code. There are no functional changes intended.

* PCRE: decode internal PCRE error messages.

* Integrating comments from PR.

* PCRE: Use pcre_study() only in case PCRE_CONFIG_JIT is defined.

* PCRE: Fixed potential resource leak. In case prce_compile worked, but pcre_study() returns an error, the allocated resources by pcre_compile() can be freed.

* Make travis happy.

* PCRE: Improved output message format.

* PCRE: Attempt to be compliant to older PCRE versions and fix travis build.
2018-09-23 14:27:46 +02:00
Daniel Marjamäki 0dfedd977e CppCheck: Minor tweak. Do no clear internalErrorFound, instead ensure that it's not written upon suppression 2018-09-10 06:02:01 +02:00
Daniel Marjamäki 509cb35168 astyle formatting
[ci skip]
2018-09-08 15:19:32 +02:00
tam do thanh 7ad09b44c3 Ticket 7792: Suppression both exit_code and syntaxError when call cppcheck suppressions (#1345) 2018-09-08 11:09:49 +02:00
Kevin Kendzia c5ebf26f9f cppcheck.cpp: fix suppression of syntaxError (#1333)
* cppcheck.cpp: fix suppression of syntaxError

* test: add supression test for syntaxError while file read
2018-08-17 10:05:25 +02:00
Daniel Marjamäki 223a116f24 The checksum in analyzer info files will now depend on the suppressions 2018-08-09 09:27:26 +02:00
Daniel Marjamäki ddbe4b89b5 Renamed --debug to --debug-simplified 2018-08-05 11:19:20 +02:00
Daniel Marjamäki e962f57a99 Rename private member variables 2018-06-17 19:20:07 +02:00
Daniel Marjamäki fe0bd8ff6c Renamed exitcode to mExitCode 2018-06-17 07:43:25 +02:00
Daniel Marjamäki 6ff6f0ae45 Renamed cfg to mCurrentConfig 2018-06-17 07:40:13 +02:00
Daniel Marjamäki cb0bea1749 Renamed _simplify 2018-06-17 07:37:10 +02:00
Daniel Marjamäki b90d1bc020 Renamed member fileInfo to mFileInfo 2018-06-17 07:36:05 +02:00
Daniel Marjamäki c5e0576961 Renamed analyzerInformation 2018-06-17 07:31:34 +02:00
Daniel Marjamäki 54ba0e58c1 Renamed _useGlobalSuppressions 2018-06-17 07:29:07 +02:00
Daniel Marjamäki b992b4a4f0 Renamed _errorList 2018-06-16 23:31:16 +02:00
Daniel Marjamäki 79ffe1d4fc Rename _tokenizer, _settings, _errorLogger 2018-06-16 16:10:28 +02:00
orbitcowboy 33777c5b72 Improved const correcntess of local variables. 2018-05-29 13:24:48 +02:00
Daniel Marjamäki d7dfa29864 Preprocessor: only throw errors upon request. 2018-05-28 14:11:59 +02:00
Daniel Marjamäki 2ffbb37cee modernize cppcheck.cpp, use range for loops 2018-05-22 23:22:46 +02:00
Daniel Marjamäki 2b14b71c93 Updated output when Cppcheck fails to find valid configurations 2018-05-17 10:27:05 +02:00
amai2012 7062df5d78 #8585 --check-config aborts due to unhandled simplecpp::Output exception 2018-05-17 08:59:10 +02:00
Daniel Marjamäki 6bd4bdb0f9 Updated 'noValidConfiguration' message. It should not write this message when there is no code. It should be possible to see the preprocessor errors otherwise it is hard to fix the configuration. 2018-05-15 15:42:54 +02:00
PKEuS 3d860e6f36 Bump simplecpp 2018-05-14 13:00:22 +02:00
Daniel Marjamäki 1e7c1841f7 Fixed #8515 (Wrong info message about unmatched suppression) 2018-05-11 09:01:24 +02:00
Daniel Marjamäki c266688784 Fix syntax error 2018-05-08 10:21:03 +02:00
Daniel Marjamäki 315dc2ad8a only show information message when information messages are enabled 2018-05-08 09:47:14 +02:00
Daniel Marjamäki 0bff08ca44 Fixed #1378 (#error macro makes unrelated errors undetectable) 2018-05-06 22:02:23 +02:00
rebnridgway 995b496ddf Add suppressions to the XML dump (#1166)
* Added parsing suppressions from dump xml.

* Added code to dump suppressions to an xml file

* Added declaration for dump function

* Suppressions will now be written to the xml file when a dump is requested

* Fixed syntax error

* Removed excess whitespace

* Fixed indentation to be consistent

* Fixed indentation to be consistent

* Fixed indentation to be consistent

* Added missing include for ErrorLogger::toXml

* Fixed suggestions from pull request #1166

Switched to using ranged for loop to iterate through suppressions.
Made the line number attribute optional, rather than 0 if not specified.  This means when Python deserialises it it will be None, which is more pythonic.

* Implemented checking suppressions in reportError

This modification expects suppressions and a function to be called to write a line of output to be passed in.  The function checks if any of the suppressions match the warning (with the new Suppression.isMatch function) and if so returns None.  This change maintains the old behaviour of returning the warning text, but adds the possibility of returning None if the warning was suppressed.

* Fixed code quality warnings

* Removed more extraneous whitespace
2018-04-24 22:19:24 +02:00
Daniel Marjamäki 8cc7131ee9 Rename CppCheck::processFile to CppCheck::checkFile 2018-04-21 13:28:26 +02:00
PKEuS b596b0d549 Refactorization: pass std::string directly to std::*fstream 2018-04-11 09:50:42 +02:00
PKEuS b15cc3f236 Refactorization: Replace several push_back-sequences by initializer lists 2018-04-09 09:54:39 +02:00
Daniel Marjamäki a0906140a6 Suppressions: New extensible Suppressions xml format that allow more attributes. To start with it also allows symbolName. 2018-04-09 06:43:48 +02:00
IOBYTE d68f07e50c Add purgedConfiguration to list of error ids. (#1087)
purgedConfiguration was not showing up in the GUI supression list.
2018-02-10 22:30:49 +01:00
Daniel Marjamäki db274e8308 Fix testrunner in cygwin 2018-02-10 15:34:49 +01:00
Daniel Marjamäki 71511f3131 Refactor f487182 2018-02-06 08:59:36 +01:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
Ivan Maidanski 97ffec85c0 Fixed #7502 (Correct exit code if never used function is found) (#1026) 2018-01-12 08:24:01 +01:00
PKEuS b684e1f202 Updated AStyle to version 3.0.1 2018-01-08 20:20:33 +01:00
baltth 6cbd69bf2d Fix define parsing from compile_command.json (#1013)
* Define value parsing from compile_commands.json

* Handle escaping in defined values

* Added test for importCompileCommands

* Added used defines for imported projects

* Fixed unnecessary string literals
2017-12-26 13:04:27 +01:00
Ayaz Salikhov be2c65eb58 Simplify int vs bool 2017-10-08 07:54:39 +02:00
Daniel Marjamäki 5c7cf584ef bump simplecpp 2017-09-12 22:42:10 +02:00
Ayaz Salikhov b8cd7dbb5c Use nullptr instead of 0 or NULL (#936) 2017-08-09 20:00:26 +02:00
Daniel Marjamäki 9861240e79 ImportProject: Only expose Cppcheck Visual Studio defines for Cppcheck 2017-08-08 22:27:08 +02:00
Daniel Marjamäki 5fa7a4edc4 GUI: save dumpfiles in buildDir if possible 2017-08-03 22:54:38 +02:00
Daniel Marjamäki 61eccd7070 Fix dump 2017-08-03 18:03:59 +02:00
Daniel Marjamäki 1961d6d0f7 CppCheck: make sure preprocessor syntax errors are reported 2017-05-28 20:34:58 +02:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
uburuntu d41d091c07 ENH: perfomance: seeking of one char is more efficiently 2017-05-27 04:15:54 +02:00
Daniel Marjamäki 899615c1e4 update simplecpp includes
[ci skip]
2017-05-18 22:26:07 +02:00
Daniel Marjamäki 9d08cbf4d2 Fix 'make checkcfg' 2017-05-18 22:10:08 +02:00
Daniel Marjamäki 340c687cbf Revert "Use 'Stringification => Tokenizer' until some issues have been fixed"
This reverts commit c2727691a4.
2017-05-18 21:53:25 +02:00
Daniel Marjamäki c2727691a4 Use 'Stringification => Tokenizer' until some issues have been fixed 2017-05-18 09:33:41 +02:00
Daniel Marjamäki bc12a0b21f Handle empty token list better (for instance when Preprocessor::validateCfg() see problem) 2017-05-17 22:30:20 +02:00
Daniel Marjamäki 1f4b84379d Fix for #pragma asm 2017-05-17 21:58:46 +02:00
Daniel Marjamäki 59335f80d2 Try to fix windows build. Reduce header dependencies 2017-05-17 15:38:31 +02:00
Daniel Marjamäki 6230919976 Skip 'Stringification => Tokenize' step 2017-05-17 14:57:54 +02:00
Daniel Marjamäki 6967d68137 Add --plist-output argument 2017-05-16 14:07:23 +02:00
PKEuS 3432257390 Removed deprecated command --append 2017-05-14 11:57:04 +02:00
Daniel Marjamäki b3b0a796b9 dump: fix xml format 2017-04-15 12:38:00 +02:00
Daniel Marjamäki e71b428740 dump: Add platform info and valueType info 2017-04-15 12:25:44 +02:00
Daniel Marjamäki 174bcc8d34 Misra: Add rule 16.3 2017-04-14 10:46:35 +02:00
PKEuS b1f4bd7504 Refactorization: Reimplemented Settings::_enabled as a bitfeld instead of std::set (#7995) 2017-04-11 11:49:26 +02:00
Daniel Marjamäki 6e0af5d01f MISRA 19 and 28 2017-04-09 10:11:54 +02:00
Daniel Marjamäki 70a7915173 CppCheck: Improve output when first configuration is not empty. 2017-04-06 19:52:21 +02:00
Daniel Marjamäki a8788d7fc7 Fix Cppcheck warning 2017-03-30 11:20:04 +02:00
Daniel Marjamäki cc3ef7bbe8 Fix so array access out of bounds for external arrays are detected again 2017-03-30 10:14:17 +02:00
PKEuS 2f0db369f0 Refactorization: Avoid construction of empty strings by using emptyString 2017-03-01 10:50:50 +01:00
Daniel Marjamäki e9d950d4f5 Cppcheck build dir: Better handling when --project is used 2016-12-08 22:46:44 +01:00
PKEuS 5344a5e098 Fixed race condition by properly constructing a local CheckUnusedFunctions instance in CppCheck::processFile(). Instantiating Checks is dangerous! 2016-11-18 21:09:41 +01:00