Andrew C. Martin
bd0d9b9639
fix misspellings & gcc v3.4.6 warnings
...
1. fix typos / misspellings
- Fix misspelling within comments, variable/function names, stdout messages
- changes the name of an error code: ```stlBoundries``` changed to ```stlBoundaries```. Alias old name (```stlBoundries```) to the new one.
2. fix gcc v3.4.6 32bit & 64bit warnings
- fixes gcc v3.4.6 warnings, except for those in tinyxml and "-Wmissing-declarations" makefile warnings
- in Preprocessor::handleIncludes(), replace a ```vector <bool>``` with ```stack<bool>``` (see ```vector<bool>``` warning below).
- this is the only ```vector<bool>``` in the codebase
- ```vector <bool>``` is actually a case of template specialization, and is not recommended, according to the following links:
http://stackoverflow.com/q/6461487
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2160.html
http://stackoverflow.com/q/670308
- in the codebase before and after this change, testrunner SEGVs in a number of places on gcc v3.4.6, including ```Check::~Check()```, among others
- fc42fc95
fixes this particular runtime issue for DJGPP & __sun
2013-02-09 23:43:09 -07:00
Frank Zingsheim
b531195e08
Fixed #4547 (Improve check: Duplicate conditions in 'if' and related 'else { if'.)
...
Change tokenizer: "else if" -->> "else { if"
2013-02-04 21:12:12 +01:00
Daniel Marjamäki
e2faed355b
Fixed #4485 (False positive: Same expression of '-' when checking if float is inf)
2013-01-31 17:29:31 +01:00
Robert Reif
859793731d
SymbolDatabase: Refactor findFunction handling. Ticket: #4494
2013-01-28 06:47:48 +01:00
Zachary Blair
8647e4c0d0
Fixed a false positive in #4109 (if (c == 1) c == 0; Isn't picked up)
2013-01-18 16:34:15 -08:00
Zachary Blair
a1cbed3df8
Fixed #4109 (if (c == 1) c == 0; Isn't picked up)
2013-01-17 23:03:04 -08:00
rofl0r
623e30d677
fix unit test for varFuncNullUB
2013-01-15 20:45:53 +01:00
Daniel Marjamäki
d46789ee4a
varFuncNullUB: fixed false positive when non-variadic argument is NULL ( #4482 )
2013-01-14 06:44:52 +01:00
Daniel Marjamäki
2e56928834
Fixed #4482 (add test for UB due to usage of NULL in variadic functions)
2013-01-13 12:02:10 +01:00
Zachary Blair
f3c3b7c910
Fixed #4405 (False positive: Memory in freed twice (throw))
2013-01-05 19:02:19 -08:00
Reijo Tomperi
5d5f7085bf
Updating year 2012 -> 2013 to .cpp and .h files and man page.
2013-01-01 18:29:08 +02:00
Thomas Jarosch
1f87c6d669
Fix crash on empty brackets
...
Relevant parts from the backtrace:
2012-12-28 20:16:51 +01:00
Daniel Marjamäki
7e8019e474
Fixed #4403 (False positive 'Conversion of string literal <string> to bool always evaluates to true.' with BOOST_ASSERT)
2012-12-20 20:48:48 +01:00
PKEuS
068c695bd1
Fixed false positive when ternary operator is used: case A&&B?B:A:
2012-12-07 12:44:30 -08:00
PKEuS
0ac4c3baf4
New check: Find suspicious case labels like 'case A||B:'
2012-12-07 12:27:32 -08:00
PKEuS
65db8b8b9f
Fixed #4229
2012-12-07 11:45:20 -08:00
PKEuS
4737966caf
Unit test cleanup: Removed some empty lines and whitespaces before \n.
2012-12-06 10:19:22 -08:00
Daniel Marjamäki
bf91454136
Fixed #4224 (False positive: Comparison of a boolean with an integer (neglecting a cast))
2012-12-02 08:34:30 +01:00
Edoardo Prezioso
47f1220367
Remove useless preprocessor pieces from some testcases.
2012-11-30 20:28:30 +01:00
Daniel Marjamäki
79cd601ae7
Fixed #4356 (False positive at variable initialization)
2012-11-15 07:48:45 +01:00
Robert Reif
04d04c33c2
speed up checks by caching commonly looked up stuff in the symbol database (CheckOther). Ticket #4266
2012-11-14 18:12:33 +01:00
PKEuS
ce961578c2
New checks (inconclusive): Suspicious calculation with sizeof()
...
- Check for sizeof(ptr)/something: This indicates that programmer was trying to calculate array size, but sizeof(ptr) doesn't return the length of the memory area, but size of a pointer.
- Check for sizeof()*sizeof(): This indicates that programmer misunderstood what sizeof() does: It does return the length in bytes of the given variable, not e.g. the number of elements in an array.
2012-11-09 18:08:20 +01:00
PKEuS
aa2ad41629
Print message "Found calculation inside sizeof()" also for increment/decrement operator.
2012-11-06 11:39:47 -08:00
Zachary Blair
51d128c918
Fixed #2029 (free invalid address) by reporting previously-unreported errors as "inconclusive"
2012-11-05 21:02:51 -08:00
PKEuS
1c399c86ca
Improved fix for #4311 ; Added back support for "this." (fixes again #4291 )
...
Added TODO unit test for missing varid.
2012-11-03 21:16:05 +01:00
Daniel Marjamäki
6c2563c467
Fixed #4311 (False positive: warning (selfAssignment): Redundant assignment of 'm_bar' to itself.
2012-11-03 13:18:43 +01:00
PKEuS
a36e008967
Fixed #4314 : Using CheckNullPointer::isPointerDeRef() here is overkill and doesn't work as intended, since this function is designed to return 'false' if it isn't sure.
2012-11-03 10:25:32 +01:00
Daniel Marjamäki
e7483af028
Opposite inner conditions - made check 'experimental' because there are unsolved false positives.
2012-10-21 18:18:29 +02:00
Baris Demiray
d84d360afc
Fixed #4291 (Variable ID is not set when variable is accessed through 'this')
2012-10-19 06:18:13 +02:00
Daniel Marjamäki
61183e7896
astyle formatting
2012-10-08 16:23:05 +02:00
Alexander Mai
3656366c7e
Fixed #4257 (False Positive: String literal compared with variable - for non-pointer variable)
2012-10-07 16:26:03 +02:00
PKEuS
c17853949d
Fixed scope handling problems with CheckOther::checkComparisonOfFuncReturningBool(), removed its experimental status.
2012-09-29 11:23:30 +02:00
Daniel Marjamäki
52be4a5925
Disabled checkComparisonOfBoolWithBool since there are false positives. Ticket #2617
2012-09-28 19:11:36 +02:00
Daniel Marjamäki
ff4f8b58f3
Disable checkComparisonOfFuncReturningBool check because of false warnings. Ticket #2617
2012-09-28 18:51:10 +02:00
Mohit Mate
9e297c95f2
Fixed #2617 (improve check: comparing boolean with '<')
2012-09-26 18:18:36 +02:00
XhmikosR
3c14e4b52a
test: tabs to spaces, remove trailing spaces and extra empty lines at the end of files
2012-09-17 13:51:40 +02:00
PKEuS
5237ed2de9
Message refactorization: checkother.cpp
2012-09-16 19:44:02 +02:00
PKEuS
9a624576f4
Revert "CheckOther::clarifyStatement: improved message to show what's the 'bad' and the 'good' expression."
...
This reverts commit f8591f9004
.
2012-09-15 20:19:02 +02:00
Arpit Chaudhary
67e40a85e5
Improved check for shifting by negative values and removed false positives
2012-09-05 16:09:40 +02:00
Nilesh Kumar
c7633fc73c
Fixed #3645
2012-09-05 13:48:00 +02:00
Zachary Blair
8546bcc94e
Fixed #2029 (new check: free invalid address)
2012-09-04 23:31:23 -07:00
Edoardo Prezioso
f8591f9004
CheckOther::clarifyStatement: improved message to show what's the 'bad' and the 'good' expression.
2012-09-04 02:07:55 +02:00
anuraggarg011
b156c727b0
Fixed #3939 : Support ****foo++;
2012-09-03 17:10:27 +02:00
Ankita Gupta
c3a65dca40
Fixed #3793 (improve check: calculation in sizeof)
2012-09-03 15:56:10 +02:00
PKEuS
27cafd495a
Don't bailout for noreturn functions in checkRedundantAssignments outside switch.
2012-09-03 12:03:30 +02:00
PKEuS
b6c1528566
Test case for #4135
2012-09-03 11:32:15 +02:00
PKEuS
2d64b69cf4
New check: Detect redundant assignment to a variable and redundant copying to a buffer
...
This check partially replaces the check for redundant assignments in switch
2012-09-02 13:09:32 +02:00
pranav1509
6f6baa67e4
Added more patterns to redundant condition check.
2012-09-01 13:39:32 +02:00
PKEuS
6893948c72
Bugfix: Reset property info when Token::link() is set (< can be a bracket or a comparison operator). Fixes #4075 .
2012-08-26 10:23:16 +02:00
PKEuS
808c3468c9
New check: detect suspicious comparison of string literal with char* variable
...
Bugfix: Update Token type when varId is set
2012-08-24 14:25:17 +02:00
PKEuS
76fbcce13f
Restored (intentional) content of screwed up commits 1bcdf4ce3d
and 674f7980d519712ff16d8f874dfe55a84deb4b5b:
...
- New check (Inconclusive): Array filled incompletely with memset/memcpy/memmove
-- This check only warns if the number of elements is given as size in bytes to memset, memcpy or memmove and if the size of an element is larger than 1 Byte. It does not warn for random numbers
- New check: Detect ineffective statements like '*foo++;' (Should be: '(*foo)++;')
Sorry for the inconveniences.
2012-08-24 11:28:50 +02:00
Edoardo Prezioso
0f1accc2da
Revert latest two commits as they break the compilation and the style. PKEuS???
2012-08-24 00:10:19 +02:00
PKEuS
1bcdf4ce3d
New check: Detect ineffective statements like '*foo++;' (Should be: '(*foo)++;')
2012-08-23 12:28:40 -07:00
PKEuS
674f7980d5
New check (Inconclusive): Array filled incompletely with memset/memcpy/memmove.
...
This check only warns if the number of elements is given as size in bytes to memset, memcpy or memmove and if the size of an element is larger than 1 Byte. It does not warn for random numbers
2012-08-23 11:27:00 -07:00
PKEuS
4d2104ca08
Made a TODO from failing tests - Simplification of known variables is not smart enough to handle operator>> properly-
2012-08-22 16:44:41 +02:00
PKEuS
6364f43b7a
Fixed compiler error introduced recently.
2012-08-22 16:41:11 +02:00
Arpit Chaudhary
7c8da17c44
Added check for detecting if a variable or number is shifted by negative right operand. Statements like:
...
int i = -1;
a << i;
would result in an error message stating undefined behavior.
2012-08-22 15:44:20 +02:00
Kumar Ashwani
afe030ce9b
Fixed #2628 : Detect redudant usage of operator++/-- in switch.
2012-08-22 14:40:57 +02:00
Edoardo Prezioso
2b5cd2effc
Fixed G++ [-Wparentheses] warning. This also fixed #4073 (Crash on self assignment).
2012-08-21 20:15:04 +02:00
PKEuS
b4b5c80db9
Improved check: Added message when checking sign of a pointer.
2012-08-21 03:28:02 -07:00
PKEuS
b641a10e35
Fixed false negative: memset(foo, 0, sizeof(&foo)); is as suspicious as memset(foo, 0, sizeof(foo));
2012-08-20 10:08:18 -07:00
PKEuS
a243983242
Refactorized type handling in CheckIO and CheckOther:
...
- Added several types (std::) to isComplexType
- Types in namespace std:: are considered to have no side-effects (solved one TODO)
- Scope of a pointer can be limited without side effects
2012-08-20 08:57:28 -07:00
PKEuS
452f95cea0
More robust template detection in clarifyCondition check based on Token::link. ( #3818 )
...
Create links between < and > only on non-C code.
AStyle fix
2012-08-02 04:03:01 -07:00
Ettl Martin
98d608231d
spelling fixes
2012-07-31 23:35:56 +02:00
PKEuS
26a2379f9f
Fixed false positive #3941 .
2012-07-29 06:39:43 -07:00
PKEuS
9834888f19
Removed some duplicate tests and a redundant variable
2012-07-25 01:34:54 -07:00
PKEuS
ae6201d289
Fixed false positive "Parameter 'x' is passed as a value" for types like std::vector<T>::size_type ( #3986 )
2012-07-23 01:41:20 -07:00
Zhao Qifa
188d2e143d
add a performance checker for const assignment
2012-07-22 09:17:00 +02:00
PKEuS
41fecb2e6d
Fixed evaluation of redundant conditions ( #3972 )
2012-07-13 06:01:19 -07:00
PKEuS
43c060b630
Removed preprocessor directives from tests that aren't preprocessed before being tokenized.
2012-07-07 11:21:08 -07:00
Robert Morin
25c1cc4c8e
Improve check: warn when comparing boolean value with < <= > >=. Ticket: #2617
2012-07-03 06:39:13 +02:00
Daniel Marjamäki
162a430354
Fixed #3868 (false positive: (style) Same expression on both sides of '|'.)
2012-06-23 19:54:15 +02:00
Daniel Marjamäki
3db58bb57f
Reviewed C handling in CheckOther::clarifyCondition, never treat x<..> as a template in C files.
2012-06-23 07:29:49 +02:00
Daniel Marjamäki
8aba801360
Fixed #3800 (False negative: Self-assignement of variable declared as 'extern')
2012-06-22 11:23:50 +02:00
Zachary Blair
fa2bca1e09
Ticket #3876 : Improved check by only bailing of loops that contain break or continue
2012-06-16 13:11:09 -07:00
Daniel Marjamäki
89b1b4ea6e
Fixed #3892 (False positive: 'if (var >= 0.0) then if (var >= 0.0) always returns true
2012-06-15 16:54:02 +02:00
Zachary Blair
e2348560e4
Fixed Ticket #3876 (Error (double free) detected that can't possibly happen)
2012-06-10 17:50:31 -07:00
Ettl Martin
c9cb492bc7
#3874 added missing testcase to avoid false positives
2012-06-10 18:36:19 +02:00
Ettl Martin
d7c1907601
added tests for duplicated branches. Inspired by http://www.viva64.com/en/b/0149/ ( Comparision between PVS-Studio and cppcheck): Errors detected in Quake 3: Arena by PVS-Studio: Fragement 2
2012-05-30 01:30:37 +02:00
Ettl Martin
474dccf8ad
added a testcase for detecting duplicate if else branches.
2012-05-29 09:22:42 +02:00
Zachary Blair
2bd171dded
Fixed #3794 (New check: Missing break in switch (duplicate bitwise operation))
2012-05-28 21:19:22 -07:00
PKEuS
e2bab4b6a3
Implemented Function::nestedIn to be able to identify the scope the function belongs to, even if Function::functionScope.functionOf is not available.
...
Refactorized usage of SymbolDatabase in checkOther:
- Don't copy Function instances in checkExpressionRange
- Simplifications by more accurate usage of information in database
2012-05-24 08:40:43 -07:00
PKEuS
97c4af44ca
Refactorizations in checkOther:
...
- More accurate usage of symbolDatabase to reduce code and false negatives
- Avoided unnecessary construction of pattern string
- Only search for class/struct definition before usage
2012-05-24 06:34:59 -07:00
Daniel Marjamäki
77e9106ec0
Fixed #3634 (False positive: compareBoolExpressionWithInt when using boost::tuples)
2012-05-22 19:01:21 +02:00
PKEuS
b81eafe0dc
Splitted CheckIO from CheckOther.
2012-05-20 02:57:07 -07:00
Daniel Marjamäki
f803a18d50
Fixed #3749 (false positive: same expression on both sides of operator)
2012-05-17 07:26:57 +02:00
Ettl Martin
8a7b141246
added testcase for ticket 3689
2012-05-14 09:57:30 +02:00
PKEuS
06a77679d4
Refactorizations:
...
- Added support for pointers in self assignement check
- Removed redundant for loop in checknullpointer.cpp
- Fixed warning about signed/unsigned mismatch in cppcheck.cpp by making Settings::_maxConfig unsigned
2012-05-11 10:38:19 -07:00
PKEuS
ec00824fd3
Fixed #3357 :
...
- Print "inconclusive" tag in cli
- Fixed inconclusive handling in checkbufferoverrun.cpp
- Merged reportInconclusiveError into reportError by adding an additional parameter "bool inconclusive" which is false per default
2012-05-06 10:37:41 -07:00
Ettl Martin
bb8342fbb4
fixed misspelled word 'Comparision' --> 'Comparison'
2012-04-26 23:04:55 +02:00
PKEuS
5ac7552e4e
New check: Comparision of modulo results that are always true/false.
2012-04-26 15:23:47 +02:00
PKEuS
6a37c36ee8
Fixed #3741
...
Removed redundant nullpointer check (cppcheck catch)
2012-04-18 16:35:04 +02:00
PKEuS
8e5949c6ce
Added several C++11 algorithms and containers to CheckStl
...
Added pattern "> %varid%" to CheckStl::stlBoundries()
Fixed message in checkOther (#1320 )
2012-04-17 12:54:01 +02:00
Ettl Martin
7be01da8e9
fixed ticket 3693. Added modulus operator to Mathlib + unittests. Added a test to checkother to ensure the testcase of ticket 3693 does not trigger an error message.
2012-04-12 14:02:09 +02:00
Daniel Marjamäki
66227c4da0
Fixed #3609 (clarifyCondition delivers false positives when using Windows-Traits as a template)
2012-04-08 18:07:11 +02:00
PKEuS
b0f571b25c
Fixed #3383 : If there is an empty line between subsequent break statements, only issue a message for inconclusive checking
2012-04-05 10:38:29 +02:00
PKEuS
c1fc7a2218
Improved CheckOther::checkComparisonOfBoolWithInt and CheckOther::checkComparisonOfBoolExpressionWithInt:
...
- Added support for comparision of bool constant with number constant (-> fixed #1877 ) and integer variable with boolean expression
- Moved a check from checkComparisonOfBoolWithInt to checkComparisonOfBoolExpressionWithInt
- Generalized some patterns
- Made error message more accurate concnerning the "neither 0 nor 1" part.
- Reduced number of Token::Match calls
2012-04-02 15:45:51 +02:00
PKEuS
033e4a2c1f
Fixed #3676 .
2012-04-02 11:21:04 +02:00
PKEuS
4f1f6e1824
Improved simplification of calculations:
...
- Use more generic patterns
- Look on operator precedence more consequently
-> Made a TODO test case from a test case that worked previously, because the calculation is simplified so that the problem isn't detected any more.
Changed comment "Coding style checks" to "Checks", because it didn't fit
2012-03-27 21:29:50 +02:00
PKEuS
989ac449e4
Made invalidPointerCast message inconclusive for casting from floating point type* to char* ( Fixed #3639 )
2012-03-25 12:55:39 +02:00