Commit Graph

23418 Commits

Author SHA1 Message Date
Daniel Marjamäki ae1b9cb14e SymbolDatabase: Improved function matching in C code 2020-11-04 07:17:17 +01:00
Daniel Marjamäki 198bbc8a5a Clang import: Better type handling 2020-11-03 21:37:28 +01:00
Daniel Marjamäki eece8ee66b astyle formatting 2020-11-03 21:08:21 +01:00
Daniel Marjamäki 8956ecb5fc Clang import: Fixed data for inline static functions 2020-11-03 17:52:53 +01:00
Oliver Stöneberg 98946143f6
Fix #9964 (false positive: compareBoolExpressionWithInt with ASSERT_FALSE() and --library=googletest) (#2876) 2020-11-03 10:20:25 +01:00
Daniel Marjamäki e053066d8b Clang import: Fixed Variable::mTypeStartToken and Variable::mTypeEndToken for unnamed parameters 2020-11-02 20:58:43 +01:00
Oliver Stöneberg 488813d00f
added validateCFG and checkcfg targets to CMake / some refactorings (#2687) 2020-11-02 20:16:15 +01:00
Wolfgang Stöggl 4a2082e3c5
release-windows.yml: Remove redundant online-help (#2874)
The step "Create online-help" is not needed anymore since fa84b30.
The online-help files are generated now automatically during
qmake HAVE_QCHART=yes
2020-11-02 18:53:09 +01:00
Daniel Marjamäki a2a948a311 Clang Import; Better handling of derived classes 2020-11-01 20:32:42 +01:00
Daniel Marjamäki 70fc2a78e5 Fix Cppcheck warning 2020-11-01 18:04:13 +01:00
Daniel Marjamäki 9dc085c3ec Clang import: Improved handling of overloaded operators 2020-11-01 15:30:51 +01:00
Bernd Buschinski db3d9a79b5
Fix addons for installed cppcheck (#2873)
- getAddonFilePath is used with getDataDir, this works fine
  for a local build cppcheck, but not for a system installed one.
  As getDataDir reports the location relative to the executable (/usr/bin/)
  and the addons are localed in FILESDIR (/usr/share/cppcheck).
  Extend the search path by FILESDIR/addons to also make it work for
  the installed cppcheck version.
2020-11-01 15:11:28 +01:00
vilarion 2c34e660b3
Fix #9805 (False positive; Unused function (template)) (#2871)
* Add test
* Ignore templates with trailing return type as well
2020-11-01 15:10:02 +01:00
Rikard Falkeborn bd4dc364a7
mathlib: Refactor to use enum class (#2872) 2020-11-01 11:47:34 +01:00
Daniel Marjamäki 26e6eed189 Revert "AST: Adjust AST for variable declaration 'char var[] = str;'"
This reverts commit 376860f796.
2020-11-01 11:41:41 +01:00
Daniel Marjamäki 4094274723 TestClangImport: Fix tests 2020-11-01 11:33:01 +01:00
Daniel Marjamäki 5aab1f9692 Clang import: Improved handling of structs 2020-11-01 09:12:58 +01:00
Daniel Marjamäki 226e996e46 Clang import: Improved handling of empty structs/classes 2020-11-01 08:44:38 +01:00
Daniel Marjamäki 7804b28e70 AST: Tweaked debug output 2020-10-31 18:57:48 +01:00
Daniel Marjamäki c25ae59fbe AUTHORS: Added Lars Even Almaas 2020-10-31 18:01:57 +01:00
Daniel Marjamäki 10138feb29 AUTHORS: Add vilarion 2020-10-31 18:00:03 +01:00
Daniel Marjamäki 597a6eb99c Clang import: Fix Variable::mTypeStartToken for const argument 2020-10-31 17:43:36 +01:00
Daniel Marjamäki 5b156d20bd compare_ast_symdb.py: small fix and refactorings 2020-10-31 17:37:23 +01:00
Daniel Marjamäki 376860f796 AST: Adjust AST for variable declaration 'char var[] = str;' 2020-10-31 17:05:42 +01:00
Daniel Marjamäki 6cf571af97 compare_ast_symdb.py: improved script for comparing cppcheck/clang ast etc 2020-10-31 14:57:12 +01:00
Wolfgang Stöggl 661ff1e067
release-windows: Use current ProductVersion (#2867)
The filename of the daily built installer still contains 2.0 e.g.:
cppcheck-2.0.182-x64-Setup.msi
- Read the ProductVersion from productInfo.wxi and use it in the
file name of the cppcheck setup file.
- Add possibility to manually trigger this GitHub action using
  workflow_dispatch:
- Fix indentation, yamllint error:
  10:5 error wrong indentation: expected 6 but found 4 (indentation)
2020-10-31 12:23:24 +01:00
vilarion bc5ec38149
Fix #9806 (False positive: template function can be static) (#2868)
* Include detecting variadic template functions by matching against endTok instead of startTok.
* Add argument count check for variadic (template) member functions.
2020-10-31 10:02:15 +01:00
shaneasd a623168942
fix passedByValueError on enums (#2869) 2020-10-30 18:32:35 +01:00
Daniel Marjamäki b96f23a388 Fixed tools/compare_ast.py 2020-10-30 10:14:18 +01:00
Daniel Marjamäki 6d0b78433b astyle formatting 2020-10-29 21:43:56 +01:00
Daniel Marjamäki e044d6e219 Clang import: fixed AST for 'return new S()' 2020-10-29 21:43:35 +01:00
Daniel Marjamäki ef42b82a49 fix tools/compare_ast.py 2020-10-29 21:18:40 +01:00
Daniel Marjamäki 9ed4dc4199 Clang Import: Fix AST for 'new S;' 2020-10-29 20:52:09 +01:00
Rikard Falkeborn de19dc9e3e
Fix #8327 (Memleak with mmap return value check) (#2864)
Also fix a broken test case related to checking the return value -1
where socket was not defined in the library used in the tests.

This was tested running test-my-pr with 500 packages. The difference was
six fewer FPs.
2020-10-29 13:17:33 +01:00
Daniel Marjamäki 16f4f198eb Clang import: handle DefaultStmt 2020-10-29 09:48:35 +01:00
Daniel Marjamäki 40156365b8 Adjust cppcheck AST debug output a little bit. Write location for each AST tree 2020-10-28 21:41:21 +01:00
Georgy Komarov b87aaaac52
Fix and impove MISRA 6.1 and 6.2 rules (#2863) 2020-10-28 20:54:43 +01:00
Daniel Marjamäki 417bc5c732 tools; remove old script for comparing cppcheck and clang asts 2020-10-27 21:02:34 +01:00
Lars Even Almaas 79b9dd5345
MISRA Rule 6.1/6.2 Bit field check (#2861) 2020-10-27 16:00:19 +01:00
Daniel Marjamäki 4eb829933e Tokenizer: Fixed unwanted unknownMacro warning for decltype 2020-10-27 09:08:13 +01:00
Wolfgang Stöggl 1f6cb7a54b
Remove ./ from relative paths in online-help.qhp (#2860)
- Fixes the following errors, when opening online-help.qhc using Qt
  assistant: QTextBrowser: No document for
  qthelp://cppcheck.sourceforge.net/doc/./preferences.html
  etc.
- Furthermore, ./ is not used anymore in Qt documentation:
    https://doc.qt.io/qt-5/qtassistant-simpletextviewer-example.html
  It was used previously:
    https://doc.qt.io/archives/qt-4.8/qt-help-simpletextviewer-example.html
  Example:
    <section title="Find File" ref="./findfile.html">
    ->
    <section title="Find File" ref="findfile.html">
2020-10-26 10:07:47 +01:00
Even Rouault 6d4ca8e82f
qt.cfg: allow bool as second argument of setProperty() (#2859)
A QVariant can be constructed with a bool, so there is no reason to
forbid this.
2020-10-26 07:32:59 +01:00
Daniel Marjamäki 34c8334882 Fixed #9737 (False positive: unreadVariable) 2020-10-25 20:32:45 +01:00
Daniel Marjamäki 05514950af astyle formatting
[ci skip]
2020-10-25 07:12:30 +01:00
miltolstoy d55874ec37
checkunusedvar: handle initialization list (#2836) 2020-10-25 07:11:45 +01:00
Daniel Marjamäki eb2c0bb6ee Fix TestExprEngine 2020-10-24 22:53:15 +02:00
Daniel Marjamäki 3876b601d5 Fixed #9476 (Tokenizer: report unknown macro) 2020-10-24 22:12:10 +02:00
amai2012 2fa837c716
threadsafety shall not warn about const vars (in C++11) (#2847)
threadsafety shall not warn about const vars (in C++11) 
For C++03 a new id threadsafety-const was created.
2020-10-23 11:58:25 +02:00
Rikard Falkeborn d7a8e25d92
Fix #9647: Set correct enum value (#2856)
* Tokenize: Set varId for variables in enum

Set varIds in enum values. It was previously disabled in 5119ae84b8
to avoid issues with enums named the same as global variables. Take care
to only set varids to variables used to set the value of an enumerator,
not the enumerator itself. This is somewhat complicated by the fact that
at the time this happens, astOperand1(), astOperand2(), astParent() etc
are not set. The current implementation is not perfect, for example in
the code below, y will not have a varid set, but x and z will. This is
deemed sufficient for now.

            int x, y, z;
            enum E { a = f(x, y, z); };

* Fix #9647: Value of enums with variables as init values

C++ allows enum values to be set using constexprs, which cppcheck did
not handle before. To solve this, add a new pass to valueflow to update
enum values after global consts have been processed. In order to do so,
I moved all settings of enum values to valueflow. After setting the enum
values, we need another call to valueFlowNumber() to actually set users
of the enums.

There is still room for improvements, since each pass of
valueFlowGlobalConstVar() and valueFlowEnumValue() only sets variables
that are possible to set directly, and not if setting the value of a
variable allows us to set the value of another. For example

	constexpr int a = 5;
	constexpr int b = a + 5;
	enum E { X = a };
	constexpr E e = X;

Here both b and e will not have their values set, even though cppcheck
should be possible to figure out their values. That's for another PR
though.

This was tested by running test-my-pr.py with 500 packages. The only
difference was one error message in fairy-stockfish_11.1, where cppcheck
now printed the correct size of an array instead of 2147483648 which I
assume is some kind of default value. In that package, using a constexpr
when setting enum values is common, but as mentioned, there was no
change in the number of warnings.
2020-10-22 07:45:04 +02:00
Paul Fultz II 64638d82bb
Fix issue 9945: FP: containerOutOfBounds (#2845) 2020-10-22 07:41:52 +02:00