Commit Graph

9438 Commits

Author SHA1 Message Date
IOBYTE 2a418fa0f5 Fixed #8466 (False Positive: Member variable is not initialized in the constructor. When using overloaded constructors) (#1141) 2018-04-02 18:32:45 +02:00
Daniel Marjamäki 1046ca2120 Improve check: Warn about virtual function calls in constructor/destructor 2018-04-02 15:31:47 +02:00
Daniel Marjamäki e492932f19 Improve check: Variable is not initialized in private constructor (C++11 or later) 2018-04-02 15:26:15 +02:00
PKEuS 32a2060f14 Set version to 1.83.99/1.84 dev
Updated copyright year in version.h
2018-04-02 15:21:37 +02:00
Daniel Marjamäki 9f92685b92 SymbolDatabase: Throw InternalError if parsing fails 2018-04-02 13:14:48 +02:00
Daniel Marjamäki c0272fc2ef Fixed #8259 (Don't combine &= for anonymous reference parameters) 2018-04-01 10:27:16 +02:00
Daniel Marjamäki 7260be81a6 Update version 2018-03-31 21:25:29 +02:00
Daniel Marjamäki 7e4dba6a7e Updated copyright year 2018-03-31 20:59:09 +02:00
Daniel Marjamäki 4af2e517b9 Fixed #8465 (SymbolDatabase: bailout if there is 'struct A::B ab[5];') 2018-03-31 17:54:47 +02:00
Daniel Marjamäki ecfb4fd26c Fix --dump output 2018-03-31 10:27:34 +02:00
Daniel Marjamäki da4fc25fee Fixed #8432 (Problem with dump files and non-ASCII characters) 2018-03-30 22:34:55 +02:00
Daniel Marjamäki 95ccd9483b gcc 4.5 compatibility 2018-03-30 20:57:25 +02:00
Daniel Marjamäki dbe962ad5d Compatibility fix for gcc 4.5 2018-03-29 22:00:04 +02:00
Daniel Marjamäki 96167ffa51 Compatibility fixes for gcc 4.5 2018-03-29 17:37:06 +02:00
Daniel Marjamäki 1bc8f7f29a astyle formatting 2018-03-29 17:25:20 +02:00
Paul Fultz II 70da3acb70 Add foreach emulation for older compilers (#1138) 2018-03-29 04:51:22 +02:00
Daniel Marjamäki 210b921062 Fixed #8462 (AST: no ast created for 'e = { std::move(address),httpPort, (httpsPort) };') 2018-03-27 13:44:28 +02:00
Daniel Marjamäki e65a5529ad astyle formatting
[ci skip]
2018-03-24 12:30:11 +01:00
Paul 43be20a824 Check more opposite conditions 2018-03-24 07:58:37 +01:00
IOBYTE 5bc039b7da Fix #6367 and #8439 (improve sizeof value flow support) (#1132) 2018-03-23 08:28:12 +01:00
Daniel Marjamäki 5a444f764b Fixed one more syntax error FP related to #8390 2018-03-22 15:20:37 +01:00
Daniel Marjamäki 3d4b773fd1 Fixed #8390 (Syntax error from an MSVC internal header) 2018-03-22 09:07:58 +01:00
Daniel Marjamäki 1ae75303a7 micro optimisation, use const reference 2018-03-19 09:53:14 +01:00
Daniel Marjamäki 7699f6432b Fixed #8288 (valueFlowGlobalVar: compound assignments) 2018-03-18 19:53:33 +01:00
Daniel Marjamäki f7d537ea26 Null pointers: better detection of null pointer dereference 2018-03-18 19:02:30 +01:00
Daniel Marjamäki ec6133aea2 Fixed #8182 (False positive uninitvar - variable initialized in function in ternary expression) 2018-03-16 19:13:48 +01:00
Paul Fultz II 166e4cafcd Check for functions calls in sizeof calculations (#1111)
* Check for functions calls in sizeof calculations

* Use seperate message and id for sizeofFunction

* Check for overloads

* Using decltype with a function should not be an error

* Fix warning

* Fix false positives when running pass the close paren

* Fix test error

* Try to fix more false positives

* Traverse using astOperand2

* Only check first argument

* Update fixes from feedback from PR
2018-03-15 10:24:17 +01:00
Daniel Marjamäki 814828f436 dump: save if variable is const 2018-03-14 11:54:23 +01:00
Daniel Marjamäki 2c3cd402ba Thread safety: changed local static variable 'count' to member variable 2018-03-14 09:41:27 +01:00
Daniel Marjamäki 9800e82d13 GUI: Allow that platform is selected in project dialog 2018-03-13 13:07:10 +01:00
Daniel Marjamäki 0d2171a553 astyle formatting 2018-03-12 13:43:04 +01:00
Daniel Marjamäki 31dd4ed787 use early continue 2018-03-12 12:50:33 +01:00
Daniel Marjamäki c0e14d0a5d Added doxygen comment 2018-03-12 12:49:27 +01:00
Daniel Marjamäki 3ef3a6088d astyle formatting 2018-03-12 10:19:55 +01:00
Hinterwaeldlers a9b1f4c640 Taking care of operation overloading functions (#1108) 2018-03-12 10:25:30 +01:00
Daniel Marjamäki 46307df9b6 Renamed method 2018-03-11 15:06:08 +01:00
Daniel Marjamäki 380ecc408f Fixed #8418 (AST: wrong ast for throw expression) 2018-03-10 22:30:21 +01:00
amai2012 b1d943894b Copy platforms/ directory to bin/ 2018-02-27 09:09:12 +01:00
Sebastian 54d1490c89 platform.cpp: Fix that platform files on Windows are not found (#1096)
* platform.cpp: Fix that platform files on Windows are not found

I suggested this change here:
https://trac.cppcheck.net/ticket/8242#comment:7

* Use fromNativeSeparators() and only search for forwardslash
2018-02-26 13:51:02 +01:00
Daniel Marjamäki 1628405869 Fix internal warning 2018-02-24 22:35:37 +01:00
Daniel Marjamäki 7701e4594a ValueFlowBeforeCondition: Fix wrong value in do-while condition when there is a break in the loop body 2018-02-24 22:07:34 +01:00
orbitcowboy b7b376d901 checkTypes: Take into account type promotion to integer. 2018-02-19 23:55:38 +01:00
orbitcowboy b1b3164259 checktype: Added handling of 'short'-type and added test cases. 2018-02-18 21:09:19 +01:00
orbitcowboy 50844aa7fc checkType: Take into account the size of char. 2018-02-18 14:28:48 +01:00
Daniel Marjamäki 5c44580528 Refactoring, use early continue and make code a bit more specific. 2018-02-16 22:59:38 +01:00
IOBYTE fcde1d80e9 Fix #8382 (Syntax error when scanning code with template and attribute) (#1089)
* Fix #8382 (Syntax error when scanning code with template and attribute)

This commit only addresses #8382. There are issues concerning which
versions of C++ should be supported and also generic C++ 14 attribute
support which can be revisited later.

* Remove all C++ style attributes.

Remove all C++ style attributes when C++ version is 11 or greater.
Rename simplify function to simplifyCPPAttributes.
Handle more cases of roreturn function attribute.
2018-02-16 22:25:51 +01:00
Daniel Marjamäki 03a222e926 Platform: Improve testability of platform file loading 2018-02-15 21:01:34 +01:00
orbitcowboy b86b7175cb cli:platforms: Added missing sizeof Boolean variable handling when platform file is loaded from XML. 2018-02-13 11:27:50 +01:00
orbitcowboy 1906067aac cli:platforms: Fixed wrong loading of platform info. 2018-02-13 10:41:15 +01:00
Daniel Marjamäki 69b50b274c Try to make Travis happy 2018-02-11 22:54:14 +01:00
Daniel Marjamäki e62b9bdc77 Fixed #8348 (ValueFlow: wrong Uninit value with abort() in else-branch) 2018-02-11 22:14:44 +01: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 f5b91ffca8 Platform: Fix CFGDIR handling 2018-02-10 22:24:40 +01:00
Daniel Marjamäki db274e8308 Fix testrunner in cygwin 2018-02-10 15:34:49 +01:00
Simon Martin 66d16b51f0 Ticket #8352: Properly detect AST cycles. (#1060) 2018-02-10 14:39:57 +01:00
Daniel Marjamäki 7c33207a72 astyle formatting
[ci skip]
2018-02-09 21:43:44 +01:00
Lauri Nurmi e0e664f996 Fix permissions of certain non-executable files (#1083)
mode 0755 => 0644
2018-02-09 19:46:38 +01:00
Matthias Krüger b71c945ac4 fix build (CFG_DIR => CFGDIR) and run dmake. 2018-02-09 17:44:26 +01:00
Daniel Marjamäki 780bd7e63e More flexible loading of platform files, when using --platform it should not be necessary to provide the full path 2018-02-09 16:22:22 +01:00
Daniel Marjamäki 85d8bbacb8 integerOverflow: Separate id for conditional integer overflows 2018-02-07 12:49:56 +01:00
Daniel Marjamäki 58066b1f0c Remove whole program analysis from 'uninitialized variables' and 'null pointer dereference' checkers. I think this logic can more or less be added in ValueFlow instead and then all ValueFlow checkers should get whole program analysis. 2018-02-06 14:56:17 +01:00
Daniel Marjamäki 71511f3131 Refactor f487182 2018-02-06 08:59:36 +01:00
Daniel Marjamäki 13daaac264 astyle formatting
[ci skip]
2018-02-06 08:10:28 +01:00
Ivan Maidanski f487182075 Suppressed unused functions should not lead to nonzero exit code (#1026) (#1078)
This is a fix of commit 97ffec8.
2018-02-06 07:44:53 +01:00
Daniel Marjamäki 8a3c25210d SymbolDatabase: Remove useless break. As far as I know Tokenizer::syntaxError() throws an exception and therefore the break after the function call is unreachable 2018-02-05 23:28:33 +01:00
Alexander Mai 68eb6c4e6f Refactoring: Add Tokenizer::findGarbageCode to time report. The method now calls syntaxError instead of returning an invalid token 2018-02-05 21:47:33 +01:00
Daniel Marjamäki dbc6771a0b Uninitialized variables: Fix FP for unknown macro like 'list_for_each' 2018-02-04 22:30:08 +01:00
Matthias Krüger f009cfc845 fix some typos found by codespell. 2018-02-04 20:53:43 +01:00
Daniel Marjamäki 4998248501 Null pointers: Fixed false positives when running whole program analysis. Copied the fix from the CheckUninitVar::isUnsafeFunction. 2018-02-04 15:29:57 +01:00
Jørgen Kvalsvik a61f21d1b6 Accept nested templates in tokenizer-simplify (#1070)
The following snippet triggerd the error:

template<typename DerivedT>
template<typename T>
auto ComposableParserImpl<DerivedT>::operator|( T const &other ) const -> Parser {
    return Parser() | static_cast<DerivedT const &>( *this ) | other;
}

Whenever simplifyFunctionParameters was called on a templated class'
templated member function (and probably any nested template), the
tokenizer would recognise it as a syntax error, assuming that return
type *must* come after a template<> token.
2018-02-04 09:48:37 +01:00
Daniel Marjamäki d47b7726fa Uninitialized variables: Fix potential false positives in subfunction if there is early return or conditional writes 2018-02-04 09:40:57 +01:00
Daniel Marjamäki 1fe59faecb changed message ids for uninitvar/nullpointer errors that was found by whole program analysis 2018-02-03 16:05:07 +01:00
IOBYTE d721c6aca5 Fixed #8386 (syntax error not found (segmentation fault)) (#1081) 2018-02-03 15:50:05 +01:00
orbitcowboy 82c963d3a2 symboldatabase: Fix null pointer dereference, introduced by ee1ba85e15 (comments). 2018-02-02 08:45:13 +01:00
orbitcowboy ee1ba85e15
symboldatabase: Fix potential null pointer dereference (#1072)
There is a  potential `nullPointer` dereference in symboldatabase. This PR attempts to fix this. Additionally, this could be detected by Cppcheck as well. 

Here is a reduced and compilable testcase, where Cppcheck fails to detect a potential `nullPointer` dereference:

```
class Scope
{
public:
    bool bar();
    int *definedType;
};

int f(Scope *new_scope)
{
    int ret = 1;
    if (new_scope)
    {
        if (new_scope->bar())
        {
            if (!new_scope->definedType) {} // check for null
            ret = *new_scope->definedType; // dereference
        }
    }
    return ret;
}
```
The corresponding ticket on track, addressing the false negative: https://trac.cppcheck.net/ticket/8375
2018-01-31 11:00:42 +01:00
orbitcowboy f5e6ef9fd2
checkio: Fixed potential usage of invalid iterator. (#1066)
* checkio: Fixed potential usage of invalid iterator.

* formatted the code.

A ticket about FN (invalidIterator1) is created at https://trac.cppcheck.net/ticket/8373
2018-01-30 08:43:15 +01:00
Daniel Marjamäki f5a11a6510 UninitVar: Speedup whole program analysis a bit 2018-01-29 15:15:35 +01:00
orbitcowboy fb7f1efc49 token: Fixed potential null pointer dereference. (#1062) 2018-01-28 14:27:01 +01:00
Daniel Marjamäki 21a35de0d2 Tokenizer: Refactoring garbage check 2018-01-27 22:26:43 +01:00
David Hallas 4d18d3948f Fixes issue with case inside switch that is not a compound statement (#1031)
* Fixes issue with case inside switch that is not a compound statement was treated as garbage

This fixes an issue with the check for case keywords outside of switch
detection that would treat a case statement inside a switch that is not
a compound statement as garbage, but this is perfectly valid C++. This
construct is used in several libraries, i.e. Google Test.

* Tweak check and handle missing semicolon

Tweaks the check with feedback from danmar.
Handle the case where there is no semicolon and document it with a unit
test.
2018-01-27 22:21:26 +01:00
Daniel Marjamäki 5b6ec49a6f Pointer overflow: Fixed false positive 2018-01-27 22:09:43 +01:00
Daniel Marjamäki 189e0b3890 Fix Cppcheck warning about uninitialized variable 2018-01-27 22:05:29 +01:00
Daniel Marjamäki bc40f5041d Fixed #6356 (Improve checking: pointer arithmetic "ab.a + 100" overrun) 2018-01-27 15:39:39 +01:00
Daniel Marjamäki c110770481 Fixed #8325 (False negative: address of auto variable being returned when assigned to another variable first) 2018-01-27 14:48:45 +01:00
orbitcowboy 27d9aaa8f5 checkother: Removed statement that is always true. (#1059) 2018-01-26 22:49:07 +01:00
Simon Martin 71ba513bdb Ticket #8361: Fix false positive in Tokenizer::findGarbageCode. (#1061) 2018-01-26 22:06:07 +01:00
Daniel Marjamäki 3ebedcd7f5 Fixed VS crash for torture test 2018-01-26 16:05:43 +01:00
Daniel Marjamäki a5f202360a Fixed crash for garbage code, found by fuzzing 2018-01-26 09:34:27 +01:00
Daniel Marjamäki cb297a00fc Auto variables: Assign address of local variable to global pointer (#6825) 2018-01-25 22:50:41 +01:00
Daniel Marjamäki 9109956c8c UninitVar: Improve whole program analysis, used isVariableUsage() 2018-01-25 21:49:21 +01:00
Daniel Marjamäki 51c2ded23f Fix crash 2018-01-25 19:42:50 +01:00
Daniel Marjamäki 1b3248b0fc Dont write syntax error for lambda functions 2018-01-25 17:47:27 +01:00
Daniel Marjamäki 4d66609173 Fix Cppcheck warning, uninitialized member variable 2018-01-25 17:29:08 +01:00
Daniel Marjamäki f73da16e94 Revert "UninitVar: Better checking in whole program analysis"
This reverts commit b2bdc2687b.
2018-01-25 17:05:57 +01:00
Daniel Marjamäki b2bdc2687b UninitVar: Better checking in whole program analysis 2018-01-25 15:56:46 +01:00
Daniel Marjamäki c04557eb73 Fix crashes detected with fuzzing 2018-01-25 15:53:58 +01:00
Daniel Marjamäki ce60b326f4 Whole program analysis: Improved handling of nested calls 2018-01-24 22:53:14 +01:00
Daniel Marjamäki 599e038282 AutoVariables: Warn when address of local array is assigned to global pointer and pointer is not reassigned 2018-01-24 21:33:58 +01:00
IOBYTE 8ce496a127 Fix possible null pointer dereference cppcheck warning. (#1056) 2018-01-24 21:19:52 +01:00
Daniel Marjamäki 96e387a486 Fixed #8351 (segmentation fault on objective C code) 2018-01-24 18:06:11 +01:00
IOBYTE 558e0757c2 Fix simplifyTypedef crash on lambda. (#1054) 2018-01-24 15:04:33 +01:00
Daniel Marjamäki 0f561d0ed6 Fix crashes for garbage code, found by fuzzing 2018-01-24 13:53:03 +01:00
IOBYTE 4710d80a40 Fix #5766 (FP: typedef array throws off parser) (#1052)
* Fix #5766 (FP: typedef array throws off parser)

* Fix travis build.
2018-01-24 09:51:22 +01:00
IOBYTE e6d285d3ca Fixed #8357 (crash: cmake Tests/CMakeLib/testUTF8.cxx --debug --verbose) (#1046) 2018-01-22 08:06:56 +01:00
Daniel Marjamäki 512b9f512c Refactoring whole program analysis for CheckUninitVar and CheckNullPointer 2018-01-21 22:56:46 +01:00
IOBYTE 3159d151d3 Fix symbol database crash on template type aliases by ignoring them. (#1045) 2018-01-21 21:22:26 +01:00
Daniel Marjamäki 351b382a7b Null pointers: Whole program analysis 2018-01-21 19:51:15 +01:00
Martin Ettl 17a54681b8 tokenize: simplify empty string creation string("")->string(). 2018-01-21 16:36:57 +01:00
Alexey Eryomenko 913fdf44b6 member access operators are allowed inside the embedded SQL block when (#1043)
passing arguments for a query
2018-01-21 15:58:12 +01:00
Daniel Marjamäki ea63e52d98 UninitVar: Improved function/method matching in whole program analysis 2018-01-21 10:40:35 +01:00
IOBYTE 5673348215 Fixed #8350 (False positive: enum class static_cast to int is treated as non-primitive when type inference is used) (#1042) 2018-01-21 07:26:37 +01:00
orbitcowboy ec0cc4e29c templatesimplifier: Removed redundant local string variable. (#1041) 2018-01-20 22:26:48 +01:00
orbitcowboy bf201328d1
Merge pull request #1039 from orbitcowboy/master
checkstring: Cleanup not needed variable.
2018-01-20 14:59:01 +01:00
Simon Martin b4f32206af Ticket #8337: Fix false positive in copy constructor detection. (#1040) 2018-01-20 14:46:09 +01:00
Martin Ettl 9816358e8b Cleanup not needed variable. 2018-01-19 22:41:51 +01:00
Simon Martin 8878e6dd0d Ticket #8333: Properly report a syntax error for functions with invalid parameter types. (#1030) 2018-01-18 08:51:35 +01:00
Daniel Marjamäki c7c9b3cd65 Fixed Cppcheck warning about using const reference to avoid data copying 2018-01-15 22:31:15 +01:00
Daniel Marjamäki a0a04be011 Fix Cppcheck warning about mismatching argument names 2018-01-15 22:25:55 +01:00
Daniel Marjamäki b08c1868bc Fixed Cppcheck warning 2018-01-15 22:03:23 +01:00
Daniel Marjamäki c331a10fa7 Refactorings, and try to ensure that analyzer info is stored/loaded properly 2018-01-15 19:12:31 +01:00
Daniel Marjamäki f2b2e87fb6 Uninitialized Variables: some additional tweaks. Try to fix Travis 2018-01-15 17:35:21 +01:00
Daniel Marjamäki 100887429d Uninitialized variables: Whole program analysis for function calls 2018-01-15 15:54:09 +01:00
Daniel Marjamäki 2f508c0bba 1.82: Updated versions 2018-01-14 16:25:17 +01:00
Daniel Marjamäki af26f00e04 gui: update copyright message in about dialog 2018-01-14 15:46:20 +01:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
amai2012 2ef7c35cfd Function isIterator() did not to set returned parameter always 2018-01-12 09:36:14 +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
IOBYTE 03603c85cf Fixed #8331 (stack overflow: daca: firefox-58.0b14) (#1027) 2018-01-12 08:19:21 +01:00
Daniel Marjamäki 6fd157e93b ValueFlow: Template arguments have 'possible' values 2018-01-11 14:22:27 +01:00
Daniel Marjamäki bbeff99cc3 Fixed #6930 (Token: need function that says if the token comes from instantiated template argument) 2018-01-11 09:41:22 +01:00
Daniel Marjamäki 323e9ab509 astyle formatting
[ci skip]
2018-01-11 09:31:16 +01:00
IOBYTE cefb2131c7 Add support for simple c++ 11 type ailases like: using INT = int; (#1024)
* Add support for simple c++ 11 type ailases like: using INT = int;

Only types supported by ValueType are supported. Complex types like
function pointers are not supported. Template type aliases are not
supported.

* Fix crash when type in using type alias is simplified away.

This fixes a crash when size_t is replaced with unsigned long in: using
size_t = unsigned long; by the tokenizer.

This does not fix the problem where Tokenizer::simplifyPlatformTypes()
simplifies away size_t in other cases.  This is only a problem when the
new type is different from the platform type.
2018-01-10 22:16:18 +01:00
amai2012 b17807c568 #6572 False positive eraseDereference - in iterator class - flag error inconclusive if iterator is not STL type 2018-01-10 09:37:21 +01:00
PKEuS b684e1f202 Updated AStyle to version 3.0.1 2018-01-08 20:20:33 +01:00
Daniel Marjamäki fdbd6e688f Remove unused function 2018-01-08 18:55:00 +01:00
Iván Matellanes cfeea3d35c Fixed #7331: Detect copy and move constructors with default parameters (#1018) 2018-01-07 14:20:19 +01:00
Daniel Marjamäki 8c33a95b49 Refactoring: moved method from Tokenizer to TokenList 2018-01-07 14:07:34 +01:00
PKEuS c8010fdf42 Fixed crash on garbage code (#8307) 2018-01-07 13:11:56 +01:00
PKEuS 817f66d74d Fixed crash on garbage code (#8317) 2018-01-07 12:52:28 +01:00
Matthias Krüger eb58df236e CheckOther::accessMovedError() / accessMoved, accessForwarded warnings: put variable name into single quotes. 2018-01-07 10:57:19 +01:00
Daniel Marjamäki 83b87b54b4 Fixed #8191 (False positive iterators regression) 2018-01-06 22:25:13 +01:00
Daniel Marjamäki 61767d4932 Fixed #8125 (incorrect error iterators) 2018-01-06 16:08:12 +01:00
Daniel Marjamäki 98b45ffbc0 Fixed #8314 (TemplateSimplifer crash) 2018-01-06 15:16:03 +01:00
Daniel Marjamäki 943693acfb TemplateSimplifier: Improved code for template aliases 2018-01-06 08:40:06 +01:00
Martin Ettl e33fe91b1a Micro optimize std::string::find() calls searching for a single space. 2018-01-05 22:24:28 +01:00
Daniel Marjamäki d6dae27803 Fixed Cppcheck postincrement warnings 2018-01-05 17:29:40 +01:00
Daniel Marjamäki 2c5225af43 Fixed use-after-free found by asan 2018-01-05 17:06:02 +01:00
Daniel Marjamäki 04c57381ea Fixed #8315 (heap use after free: templatesimplifier) 2018-01-05 16:10:13 +01:00
Matthias Krüger 94790620d6 templatesimplifier: fix two warnings about nonexplicit constructors.
Was:
[lib/templatesimplifier.cpp:37]: (style) Class 'FindToken' has a constructor with 1 argument that is not explicit.
[lib/templatesimplifier.cpp:47]: (style) Class 'FindName' has a constructor with 1 argument that is not explicit.
2018-01-05 15:53:13 +01:00
Daniel Marjamäki f74c19bbed Refactoring lookups in TemplateSimplifier 2018-01-05 15:27:43 +01:00