Commit Graph

1172 Commits

Author SHA1 Message Date
Daniel Marjamäki f20936ed8a Moved CheckOther::checkPassByReference to normal checking 2019-03-06 20:59:45 +01:00
Paul Fultz II e846312fed Check subtraction of pointers to different objects 2019-02-27 06:55:48 +01:00
Daniel Marjamäki 68062e3702 Fixed #8954 (false positive: Local variable x shadows outer variable) 2019-02-23 16:22:22 +01:00
Paul Fultz II fd3c1fd040 Fix issue 1777: Undefined Behavior: Comparing pointers to different objects
This uses the lifetime analysis to check when comparing pointer that point to different objects:

```cpp
int main(void)
{
    int foo[10];
    int bar[10];
    int diff;

    if(foo > bar)   // Undefined Behavior
    {
       diff = 1;
    }

    return 0;
}
```
2019-02-23 08:32:08 +01:00
Paul Fultz II 941dd79f0d Fix FP issue 8986: constArgument check warns for elements of const array (#1683) 2019-02-22 06:39:59 +01:00
Paul Fultz II cf1ad5087a Extend constStatement checker
This reworks constStatement to find more issues. It catches issue [8827](https://trac.cppcheck.net/ticket/8827):

```cpp
extern void foo(int,const char*,int);
void f(int value)
{
        foo(42,"test",42),(value&42);
}
```

It also catches from issue [8451](https://trac.cppcheck.net/ticket/8451):

```cpp
void f1(int x) {
    1;
    (1);
    (char)1;
    ((char)1);
    !x;
    (!x);
    ~x;
}
```

And also:

```cpp
void f(int x) {
    x;
}
```

The other examples are not caught due to incomplete AST.
2019-02-15 13:31:40 +01:00
rikardfalkeborn dc4e7cef88 Run simplifyPlatformTypes on library return types (#1672)
Add a call to simplifyPlatformTypes() in
SymbolDatabase::setValueTypeInTokenList() to simplify return types of
library configured functions. This fixes the FN in #8141. Regression
tests are added, both for the original issue and another FN in the comments.

In order to do that, move simplifyPlatformTypes() to TokenList from Tokenizer.
This is a pure refactoring and does not change any behaviour. The code was
literally copy-pasted from one file to another and in two places
'list.front()' was changed to 'front()'.

When adding the call to simplifyPlatformTypes(), the original type of
v.size() where v is a container is changed from 'size_t' to 'std::size_t'.
Tests are updated accordingly. It can be noted that if v is declared as
'class fred : public std::vector<int> {} v', the original type of 'v.size()'
is still 'size_t' and not 'std::size_t'.
2019-02-15 13:29:52 +01:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
Paul Fultz II d7c20b15e7 Fix FP with const argument when doing a variable and cast (#1649) 2019-02-07 14:59:09 +01:00
rikardfalkeborn 91de606243 TestOther: Shorter test cases (#1637)
* Remove newlines after check(
* Remove unneeded statements after if-statements

As an example, the previous test case

	check(
	    "bool foo(int x) {\n"
	    "  if (x < 0)"
	    "    return true;\n"
	    "  return false;\n"
	    "}");

is changed to

	check("void foo(int x) {\n"
	      "  if (x < 0) {}\n"
	      "}");
2019-01-31 23:57:05 +01:00
rikardfalkeborn 7779a9186e Use valueflow in unsigned less than zero checker (#1630)
The unsigned less than zero checker looked for patterns like "<= 0".
Switching to use valueflow improves the checker in a few aspects.

First, it removes false positives where instead of 0, the code is using
0L, 0U, etc. Instead of having to hard code the different variants of 0,
valueflow handles this automatically. This fixes FPs on the form

	uint32_t value = 0xFUL;
	void f() {
  		if (value < 0u)
		{
			value = 0u;
		}
	}

where 0u was previously not recognized by the checker. This fixes #8836.

Morover, it makes it possible to handle templates properly. In commit
fa076598ad, all warnings inside templates
were made inconclusive, since the checker had no idea if "0" came from
a template parameter or not.

This makes it possible to not warn for the following case which was
reported as a FP in #3233

	template<int n> void foo(unsigned int x) {
	if (x <= n);
	}
	foo<0>();

but give a warning for the following case

	template<int n> void foo(unsigned int x) {
	if (x <= 0);
	}

Previously, both these cases gave inconclusive warnings.

Finally, it makes it possible to give warnings for the following code:

	void f(unsigned x) {
		int y = 0;
		if (x <= y) {}
	}

Also, previously, the checker for unsigned variables larger than 0, the
checker used the string of the astoperand. This meant that for code like
the following:

	void f(unsigned x, unsigned y) {
		if (x -y >= 0) {}
	}

cppcheck would output

	[unsigned-expression-positive.c] (style) Unsigned variable '-' can't be negative so it is unnecessary to test it.

using expressionString() instead gives a better error message

        [unsigned-expression-positive.c] (style) Unsigned expression 'x-z' can't be negative so it is unnecessary to test it.
2019-01-31 09:30:29 +01:00
rikardfalkeborn 080c9d53af 8205 regression test (#1618)
* Fix trac ticket reference

* Add regression test for #8205

Ticket #8205 was fixed in f65cf220ba.
Add a test case to avoid regressions.
2019-01-24 07:20:26 +01:00
rikardfalkeborn 8356ec6774 Add regression test for #6906 and #7284 (#1614)
* Add regression test for #6906

Ticket #6906 was fixed in f65cf220ba.
Add a test to make sure there are no regressions.

* Add regression test for #7284

Ticket #7284 was fixed in 5d1fdf7958.
Add tests to avoid regressions.
2019-01-23 09:09:03 +01:00
Daniel Marjamäki 8dd641b8be Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
Daniel Marjamäki 19514331fb Fixed #8907 (unknown macro not detected) 2019-01-01 19:30:13 +01:00
Daniel Marjamäki a73e989d1a isConstVarExpression: Fix FPs when there is C++ cast 2019-01-01 11:34:44 +01:00
Daniel Marjamäki ac357a96f7 Fixed #7384 (confuses syntax with variable name / "variable '(' is less than zero") 2018-12-31 18:36:06 +01:00
Daniel Marjamäki bc34f0239d Disable the subfunction value flow analysis. It does not work well and needs to be rewritten. There are false positives. 2018-12-18 14:36:49 +01:00
Daniel Marjamäki fe38e256cc Fixed #7907 (FN: redundant assignment inside switchcase, overwritten by assignment outside of switch) 2018-12-17 16:10:47 +01:00
Daniel Marjamäki 858d9a18a7 Fixed #3857 (false negative: (style) Variable 'var' is assigned a value that is never used) 2018-12-17 15:16:47 +01:00
Paul Fultz II 9b973e652c Issue 8830: New check: Function argument evaluates to constant value
Add a check for function arguments that can be constant:

```cpp
extern void bar(int);
void f(int x) {
   bar((x & 0x01) >> 7); // function 'bar' is always called with a '0'-argument
}
```
2018-12-17 06:04:24 +01:00
Daniel Marjamäki 21eb1c5e22 FwdAnalysis: Fix false negatives for struct members 2018-12-16 18:32:34 +01:00
Daniel Marjamäki a16f694254 Revert "Fix issue 8884: Regression: False positive: Variable 'f' is reassigned a value before the old one has been used (#1513)"
This reverts commit 6953dddfa6.
2018-12-08 08:25:20 +01:00
Paul Fultz II 6953dddfa6 Fix issue 8884: Regression: False positive: Variable 'f' is reassigned a value before the old one has been used (#1513) 2018-12-08 07:33:51 +01:00
Daniel Marjamäki ba564076db Fixed #7907 (FN: redundant assignment inside switchcase, overwritten by assignment outside of switch) 2018-12-02 14:04:59 +01:00
Daniel Marjamäki 13c6489571 Redundant variable assignment: Fix FN for struct members 2018-11-27 18:22:22 +01:00
Daniel Marjamäki affd03f1d6 Minor tweak for redundantVariableAssignment 2018-11-26 11:16:50 +01:00
Daniel Marjamäki 0160f80ffe redundantVarAssignment: avoid FPs when loops are used 2018-11-25 10:32:30 +01:00
Daniel Marjamäki 22f736eae2 redundant variable assignments: avoid FPs for initializations 2018-11-25 08:49:09 +01:00
Daniel Marjamäki 2f66b31d43 redundantAssignmentInSwitch: fix false positive when there is goto 2018-11-24 21:39:01 +01:00
Daniel Marjamäki 866688c70a Rewriting redundantAssignment checker 2018-11-24 10:03:54 +01:00
Daniel Marjamäki a8cbbe0e16 Fixed #8816 (FP shadowLocal - variable shadows a template function?) 2018-11-19 07:00:15 +01:00
Daniel Marjamäki 58882b1f14 Fixed #8261 (False positive "Statements following return, break, continue, goto or throw will never be executed.") 2018-11-12 06:31:17 +01:00
Daniel Marjamäki 3f55707b30 Fixed #8064 (Taking the address of a moved variable is not accessing it) 2018-11-11 12:47:27 +01:00
Daniel Marjamäki 4cef2e94e7 Fixed #8368 (FP redundantAssignment - assignment has unknown side-effects) 2018-11-10 18:42:13 +01:00
orbitcowboy 1d5e797e6d testother: Fixed typos in tests. Replaced 'voif' with 'void'. 2018-11-04 14:46:22 +01:00
Paul Fultz II 2989c44f59 Enable checking duplicate expressions across associative operators (#1445)
* Enable checking duplicate expressions across associative operators

* Remove bitshift operators and check for streamRead
2018-10-21 07:09:20 +02:00
Daniel Marjamäki 29feaa5a51 Tokenizer: Avoid constant folding 2018-10-20 10:51:50 +02:00
Paul Fultz II 16c62281d0 Use followVar in checking duplicateBranch (#1423)
* Use isSameExpression for duplicate branches

* Add errorPath

* Add another test
2018-10-18 11:56:23 +02:00
Paul Fultz II 58d1de5814 Expand the duplicate variable assignment warnings when the inconclusive flag is used (#1433)
* Warn for more duplicate var expressions when inconclusive is set

* Fix issue with missing function name
2018-10-17 06:57:33 +02:00
Daniel Marjamäki 1245a036f7 Add check for shadow variables 2018-10-16 20:17:27 +02:00
rikardfalkeborn 75caf8e4de Fix #8230: FP unknown evaluation order on comma expression in while clause (#1415)
The while part of a do-while loop looks almost like a function call, so
extend the check for function calls to ignore while-statements.

Note that there was only an FP when checking c-code, since the check is
disabled for c++-code. Therefore, make sure the test cases are run on a
c-file.
2018-10-09 14:44:01 +02:00
Daniel Marjamäki aa58f41e6d Fixed #7152 (False positive for redundantAssignment after calling a lambda function) 2018-10-08 21:07:21 +02:00
Paul Fultz II e170a45230 Enable followVar for opposite expressions (#1404)
Enable followVar for opposite expressions
2018-10-04 21:17:47 +02:00
Paul Fultz II 4598995564 Enable followVar for duplicate ternary expressions (#1406) 2018-10-01 14:31:06 +02:00
Paul Fultz II f65cf220ba Fix false positives in unknownEvaluationOrder when using followVar (#1391)
Fix false positives in unknownEvaluationOrder when using followVar
2018-09-28 08:38:24 +02:00
Paul Fultz II 5bebeec224 Fix issue 8775: Dont follow aliased variables (#1390) 2018-09-24 06:37:47 +02:00
Daniel Marjamäki afe09f4d7a Temporarily comment out the followVariable() handling 2018-09-23 16:03:18 +02:00
Paul Fultz II 90a29d986b Fix issue 8730: Dont follow variables with unknown symbols (#1374) 2018-09-12 17:30:18 +02:00
Paul Fultz II f4f3f81e8f Fix issue 8741: Require pure when following variables in isSameExpression (#1373) 2018-09-09 07:08:32 +02:00
Paul Fultz II 5a2362b2a0 Fix issue 8738: Dont warn about multiconditions when value is known (#1369) 2018-09-07 15:02:34 +02:00
Paul Fultz II 2da958efb5 Fix issue 8722: Avoid duplicate messages due for followVar (#1367) 2018-09-06 06:55:36 +02:00
Paul Fultz II b46e25c18e Fix issue 8730: False positive: Opposite expression on both sides of && (#1366) 2018-09-05 18:07:01 +02:00
Paul Fultz II 08f301a0de Reenable followVar (#1363)
Reenable followVar
2018-09-05 05:53:33 +02:00
Paul Fultz II 93be440f92 Fix issue 8709: crash with switch statement with followVar (#1362)
* Fix crash with switch statement

* Update comment
2018-09-03 19:54:14 +02:00
Paul Fultz II 0e5fabf4dc Dont follow volatile variables (#1365) 2018-09-03 19:51:48 +02:00
Paul Fultz II 8353f94b93 Fix crashes in followVarExpression (#1358)
* Fix crashes in followVarExpression

* Add a regression test for issue 8717

* Skip reference declarations
2018-09-02 08:28:53 +02:00
Daniel Marjamäki a331206b44 Temporarily disable followVariableExpressions(), there are problems that should be fixed. 2018-09-01 08:32:06 +02:00
Daniel Marjamäki 7591616f43 Fixed #8710 (Update message duplicateExpression when operand is integer literal) 2018-08-30 18:28:34 +02:00
Paul Fultz II a5f4c5d0eb Improve message for same expressions (#1349)
* Improve message for same expressions

* Update message
2018-08-25 14:25:31 +02:00
Paul Fultz II c5154286da Fix issue 8687: false positive with same expression (#1336) 2018-08-13 12:55:41 +02:00
Paul Fultz II 80290a15e0 Fix FP with duplicate assign (#1330) 2018-08-08 08:31:31 +02:00
Daniel Marjamäki c3a44ce56b astyle formatting
[ci skip]
2018-08-07 18:06:51 +02:00
Paul Fultz II f603b529df Fix issue 8413: Condition is always false 'i=expr; if (i != expr) {}' (#1295)
* Follow variables when comparing same expression

* Remove assert include

* Dont follow function arguments

* Improve the checking to check more cases

* Add more tests

* Check if the variable is used inside a loop

* Follow both variables

* Only skip loops when variable is modified in scope

* Fix FP when followed variable is modified

* Dont follow arrays

* Skip pointer indirection

* Make recursive

* Improve checking more variables

* Fix test with sizeof

* Skip following operators

* Fix test when using sizeof

* Dont check every step

* Use early returns

* Update test to use a loop instead of conditional

* Add static

* Check variables are global

* Check local variables in another scope

* Fix issue with const pointers

* Distinguish between pointer indirection and multiply

* Use simple match

* Prevent crash with uniform initialization

* Use unary op and ast to detect pointer indirection

* Expand error message when expression do not match exactly

* Add errorpath to issameexpression

* Revert "Clarify warning message for 'Same expression on both sides of operator'"

This reverts commit 0e491b41a8.

* Check if the tokens are the same

* Report the operator and not the expressions
2018-08-07 09:32:16 +02:00
Daniel Marjamäki 0e491b41a8 Clarify warning message for 'Same expression on both sides of operator' 2018-08-05 10:48:02 +02:00
Daniel Marjamäki f9a5a114bb astyle formatting
[ci skip]
2018-07-25 07:44:06 +02:00
lordylike 12e58c8521 fix ticket 8570: passedByValue with member initializer list and std::move (#1316)
* fix ticket 8570

allow member initializer list variables that are moved to be non-const

* review feedback

* replace tabs with spaces in test code
2018-07-22 15:01:18 +02:00
Paul Fultz II 5d1fdf7958 Fix issue 7904: Handle double nots in isSameExpression (#1305)
* Fix issue 7904: Handle double nots in isSameExpression

* Skip checking double nots in assignments

* Use ast to check for double not
2018-07-15 11:30:02 +02:00
Daniel Marjamäki 03faa25d12 Conditions: Better handling of function calls 2018-07-08 15:58:04 +02:00
Daniel Marjamäki 24dd4c9c26 Restore code in checkVariableScope. Fixes false negative 2018-07-01 22:31:45 +02:00
Daniel Marjamäki 655a8b21b6 Fix false positive 'passedByValue' when address of argument is used 2018-06-23 23:25:06 +02:00
Daniel Marjamäki d0614b9b36 varScope: Fix false negatives for references 2018-06-22 22:51:03 +02:00
Daniel Marjamäki 593f7eee38 Fixed #8624 (Crash below CheckOther::checkDuplicateExpression) 2018-06-14 22:39:26 +02:00
Paul Fultz II daacf27c2e Fix false positive from issue 8612 (#1285) 2018-06-10 00:05:23 +02:00
Paul Fultz II 8d53bcfd63 Fix FP when using non-const members and also check return type of function (#1283) 2018-06-09 08:05:19 +02:00
Daniel Marjamäki 84f0a18053 passedByReference: avoid false positives for std::pair 2018-06-08 10:19:02 +02:00
Daniel Marjamäki 44c78d1770 passedByReference: avoid false positives for std::function 2018-06-08 08:40:14 +02:00
Daniel Marjamäki de09c117bf Fixed #8618 (False positive: shared_ptr is passed by reference by intention) 2018-06-07 22:39:21 +02:00
IOBYTE ce50df8047 Fix override warnings. (#1234) 2018-05-15 16:37:40 +02:00
Paul Fultz II 7ef714b0c6 Fix FP with duplicate assignments by checking if the expression is unique (#1223)
* Fix FP with duplicate assignments by checking if the expression is unique

* Use array of pointers

* Reorder scope condition
2018-05-13 20:20:55 +02:00
Paul Fultz II f5dbfce8ff Fix false positive with oppositeExpression when using binary op (#1211)
* Fix false positive with oppositeExpression when using binary op

* Simplify conditional
2018-05-08 20:43:57 +02:00
Paul Fultz II cac68c6b81 Fix FP when using - as a binary operator (#1201) 2018-05-04 07:58:30 +02:00
Paul Fultz II f191a3e753 Improve checking of opposite expressions (#1199)
* Improve checking of opposite expressions

* Fix some formatting
2018-05-02 06:32:33 +02:00
Daniel Marjamäki e1db4c0e2c astyle formatting
[ci skip]
2018-04-21 13:28:31 +02:00
Paul Fultz II d939c6015a Report opposite expressions (#1182)
* Report opposite expressions

* Skip assignment operator
2018-04-21 11:28:21 +02:00
Daniel Marjamäki d5fb529d4f Fixed #8492 (Improve message: parameter should be passed by reference) 2018-04-20 17:33:42 +02:00
PKEuS bbfcccf078 Refactorization: Replace several push_back-sequences by initializer lists 2018-04-09 09:41:24 +02:00
Paul Fultz II 95fc84a26b Find duplicate expressions assigned to the same variable (#1129)
* Check for duplicate assignments

* Improve checking of expression

* Add more tests

* Use simple match

* Improve robustness of check

* check for null

* Reduce side effects by checking for side effects

* Improve verbose message

* Reword the error message
2018-04-08 14:43:19 +02:00
amai b133d50ebe #6426 Regression now has platform dependent results 2018-04-04 16:07:07 +02:00
amai 7581231d9d #6426 FP duplicateExpressionTernary - (expr) ? ~0u : ~0ul. Add regression test 2018-04-04 14:31:48 +02:00
Daniel Marjamäki 7efc4dd26e astyle formatting
[ci skip]
2018-04-04 10:04:40 +02:00
Paul Fultz II bce5fe5cef Improve duplicate expressions in the ternary op by checking for equal values as well (#1134)
* Improve duplicate expressions in the ternary op by checking for equal values as well

* Use value instead of expression
2018-04-03 21:43:55 +02:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +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
Matthias Krüger eb58df236e CheckOther::accessMovedError() / accessMoved, accessForwarded warnings: put variable name into single quotes. 2018-01-07 10:57:19 +01:00
Andreas Pokorny b802b98136 Do not warn when unique pointers are passed by value
A unique pointer should only be passed by value or by const reference.
Passing by value means transferring ownership it makes no sense to have a pass by value Warning for unique_ptr

Signed-off-by: Andreas Pokorny <andreas.pokorny@siemens.com>
2017-07-25 11:17:56 +02:00
Daniel Marjamäki 0967700f4b Refactoring tests 2017-06-06 08:59:18 +02:00
Stas Cymbalov ff38cc5c13 Set struct size cutoff in passedByValue check to 2*sizeof_pointer
Struct arguments are either pushed to the stack or passed in the
registers. Since both methods operate on machine words it is logical to
tie the maximum size of a struct argument that doesn't trigger
passedByValue diagnostic to the size of the machine word.

Also guessed size of STL classes is set to 3*sizeof_pointer, this better
represents reality and ensures that structs containing them will still
trigger passedByValue.
2017-06-06 08:48:11 +02:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
uburuntu 3817384223 FIX: test: parameter 'settings' is always rewritten 2017-05-27 04:17:18 +02:00
Daniel Marjamäki 040d2f0012 Use simplecpp lexer in test cases 2017-05-18 21:52:31 +02:00
Daniel Marjamäki 7fd04cd8d0 Updated Token::expressionString(), write '->' instead of '.' 2017-04-30 14:22:18 +02:00
Daniel Marjamäki 101dc28afa Refactoring: Moved checkMemset.. from CheckOther to CheckFunctions 2017-04-23 07:53:41 +02:00
Daniel Marjamäki 50da7d4919 Tokenizer: Write syntax error if there is C++ code in C file. 2017-04-06 08:50:35 +02:00
Robert Reif 3dba1b1739 Tests for git pull request #882. 2017-03-25 15:46:25 -04:00
PKEuS 816106560a More conservative check for non-commutative operator+ in isSameExpression() (#7938) 2017-03-15 19:17:40 +01:00
PKEuS 00904ba32a Fixed false negatives in CheckOther::checkPassByReference() when assignment operator is used. 2017-03-07 21:49:28 +01:00
Daniel Marjamäki 59c1c76a97 Fixed #7466 (Reference variable does not count side-effects (FP variableScope)) 2017-03-03 19:07:00 +01:00
Matthias Krüger f80e888b7e run astyle
[ci-skip]
2017-01-31 16:22:31 +01:00
umanamente a012e5b5fb (Fixed #7846) Syntax error when using C++11 braced-initializer in function last argument
Add an optional extended description…
2017-01-23 12:50:36 +01:00
PKEuS 3022d74801 Do not suggest pass by reference for std::initializer_list 2017-01-19 11:14:55 +01:00
Robert Reif 139071d88b Fixed #7875 (New check: function declaration and definition argument names don't match) 2017-01-05 08:52:11 +01:00
Daniel Marjamäki 770abcf453 Fixed #5398 (False positive: Scope of variable can be reduced does not account for other variables not reduceable) 2016-12-26 14:14:40 +01:00
Daniel Marjamäki df6ae9f3b4 Fixed #7847 (Can't detect shift negative values when some op is executed) 2016-12-22 09:40:19 +01:00
Daniel Marjamäki 606bb78297 ValueFlow: Better handling of casts 2016-12-20 19:32:21 +01:00
Frank Zingsheim 9a871d33f7 Improve Fix #6180 ("reset" and "clear" clears the move status) 2016-12-17 16:39:30 +01:00
Frank Zingsheim f4ab45f13b Improve Fix #6180 (Do not warn about move if it is part of a reassignment of the variable) 2016-12-17 16:39:30 +01:00
Daniel Marjamäki 8cba02dc66 Readd test case I removed in b098d5fbd6 2016-12-11 21:24:12 +01:00
Daniel Marjamäki b098d5fbd6 ValueFlow: We need better handling of casts 2016-12-10 22:09:01 +01:00
PKEuS 2f6350a0d0 Refactorized Library 2016-12-06 14:09:28 +01:00
Stefan Weil 57b57428c2 Fix some typos in comments (found by codespell)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-27 11:40:42 +01:00
Matthias Krüger 213589ee68 ValueFlow: don't perform UB when a function returns shifts of/by negative values. Fixes #7814. 2016-11-24 23:23:47 +01:00
Frank Zingsheim c8ff96fe8f Fixed #6180 (Usage of variable after std::move or std::forward) 2016-11-20 15:14:49 +01:00
PKEuS e23dc5c1e2 Fixed wrong message shown if unused label appears directly after a switch() scope 2016-11-20 14:43:54 +01:00
orbitcowboy 919f8ac323 Fixed typos. There are no real changes. 2016-11-04 15:01:05 +01:00
Boris Egorov 0154d39bf6 Show struct member in unsignedLessThanZeroError warning
Before:
    [/tmp/test.c:8]: (style) Checking if unsigned variable '.' is less than zero.
    [/tmp/test.c:12]: (style) Checking if unsigned variable '.' is less than zero.

After:
    [/tmp/test.c:8]: (style) Checking if unsigned variable 'd.n' is less than zero.
    [/tmp/test.c:12]: (style) Checking if unsigned variable 'd.n' is less than zero.
2016-09-22 08:03:30 +07:00
Matthias Krüger 2f39ed6f88 redundantPointerOpError: put pointer name into single quotes in the error message. 2016-09-16 22:18:24 +02:00
Daniel Marjamäki 939b42df06 Fixed #7134 (False positive redundantAssignment - assignment to local variable of unknown type) 2016-08-29 03:48:08 +02:00
Daniel Marjamäki bd21cd7c85 Fixed #6309 (FP: checkRedundantAssignment should not warn for pointer alias) 2016-08-08 21:43:00 +02:00
Daniel Marjamäki e784901303 Fixed #6971 (False positive duplicateExpressionTernary - cast ignored) 2016-08-01 21:53:43 +02:00
PKEuS 92e3e802fb Attempt to fix travis build and testrunner failure 2016-07-28 20:59:09 +02:00
PKEuS 452ecc7ceb Improved check: Detect passedByValue even for arguments that are not declared as "const" 2016-07-28 19:37:10 +02:00
Daniel Marjamäki 0767284ca1 Fixed #7630 (FP: dead store, modifying array, index var modified) 2016-07-25 07:35:33 +02:00
Daniel Marjamäki ed4a47de45 Tokenizer: Improve syntax checking of switch,if,while 2016-07-22 16:54:24 +02:00
Daniel Marjamäki 03d2829fb9 Merge simplecpp branch 2016-07-20 12:21:00 +02:00
Daniel Marjamäki 0ddeac0429 refactor (use ast) and improve CheckOther::checkRedundantAssignment (warn about global variables unless they are volatile, handle arrays in lhs better) 2016-07-18 12:43:23 +02:00
Daniel Marjamäki d1f06ff47c Fixed #7175 (False positive performance warning (buffer overwritten before its old content has been used)) 2016-06-13 15:46:43 +02:00
Daniel Marjamäki 710e066a9a Fixed #6406 (VarId: struct member initialization) 2016-05-22 21:18:52 +02:00
PKEuS 0bf85f9aa5 ValueType: Support integers defined in libraries (#7394) 2016-05-04 15:39:56 +02:00
Robert Reif 100c4276ea Fixed #7424 (value type: wrong sign) 2016-03-18 10:30:57 +01:00
amai2012 9700dfead0 Testcase succeeds on Win32-VC-32bit, only 64bit needs to be fixed. 2016-03-01 22:32:27 +01:00
PKEuS b4b38fb7ce Use ValueType in CheckOther::invalidPointerCast()
False negative: operator new is currently not supported by ValueType.
2016-02-05 20:28:43 +01:00
PKEuS cc8c498ebb Moved a few tests to testgarbage.cpp 2016-02-04 09:10:20 +01:00
PKEuS 841f17776b Set ValueType for assignment operators, detect division by zero for %= and /= again (#7322) 2016-02-02 17:17:55 +01:00
PKEuS 9d2258677d Improved CheckOther::checkUnusedLabel(): Write a warning instead of a style message if it happens inside a switch() 2016-01-31 12:07:24 +01:00
Daniel Marjamäki 79aec559d5 Fixed #7243 (False positive unknownEvaluationOrder - comma operator inside while-clause) 2016-01-18 16:10:51 +01:00
Matthias Krüger 7b1710a44f redundantAssignment: change from severity 'performance' to 'style' since avoiding unneccessary stores is a basic optimization done by compilers. 2016-01-15 22:01:40 +01:00
Alexander Mai 7802517a69 #7285 wrong var name: memset() called to fill 0 bytes of '&' memset with pointer: remove var name from message. Correct some entries in posix.cfg. 2016-01-12 23:20:48 +01:00
Daniel Marjamäki b3208fb4b3 Fixed #7211 (False positive: Finding the same expression on both sides of an operator (enumconstant == 0)) 2016-01-10 11:21:43 +01:00
Daniel Marjamäki 79e663dd6f Settings: Remove '_' prefix for public member variables 2016-01-03 16:18:17 +01:00