Daniel Marjamäki
ed8cdddcf5
Tokenizer: execute the simplifyIfNot and simplifyIfNotNull in the normal token list. ticket #2642
2011-04-02 21:21:05 +02:00
Daniel Marjamäki
29422b8552
clarify precedence: made the short message shorter
2011-04-02 17:27:36 +02:00
Daniel Marjamäki
8a28a63e68
Merge commit 'elfring/2679d'
2011-04-02 14:16:14 +02:00
Markus Elfring
8cde24597f
Determination of rule support in CMake scripts (bug #2679 , #2524 )
...
The support for check rules will be automatically included in the generated
software if build settings were accordingly selected for PCRE.
https://sourceforge.net/apps/trac/cppcheck/ticket/2679
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
2011-04-02 13:25:18 +02:00
Daniel Marjamäki
ea57e10c7f
Tokenizer::simplifyCalculations: simplify division result if it's a whole number, even though it doesn't have precedence
2011-04-02 12:52:11 +02:00
Daniel Marjamäki
855b01cd5a
Clarify precedence 'a*b?c:d' : warn for addition, subtraction and division also. tried to clarify the message more
2011-04-02 11:43:20 +02:00
Daniel Marjamäki
f34e9e6623
Tokenizer: better simplification of calculations in conditions
2011-04-02 11:08:58 +02:00
Robert Reif
64fa7bf8d4
symbol database: add support for anonymous struct and union
2011-03-31 20:54:23 -04:00
Robert Reif
a39444a40f
change CheckClass::operatorEqToSelf to make better use of the symbol database
2011-03-31 19:53:35 -04:00
Robert Reif
cf65a73c47
fix CheckClass::operatorEq to check return type more closely (to match check description)
2011-03-31 19:40:28 -04:00
Daniel Marjamäki
0dbf5c6151
fixed doxygen warnings about undocumented function parameters
2011-03-31 19:16:43 +02:00
Robert Reif
faaff942d2
symbol database: improve function argument count and default argument count
2011-03-30 21:59:43 -04:00
Robert Reif
d17a204096
symbol database: get function argument count using argument list size rather than counting commas
2011-03-30 21:14:24 -04:00
Daniel Marjamäki
b8cda19ca6
Fixed #2655 (false positive: (warning) Redundant code: Found a statement that begins with numeric constant)
2011-03-30 21:57:01 +02:00
Lieven de Cock
97328f08de
Improve/cleanup Path::removeQuotationMarks().
2011-03-30 21:46:41 +03:00
Daniel Marjamäki
ae2a8d839b
Fixed #2693 (__declspec attribute not removed properly)
2011-03-30 19:49:55 +02:00
Stefan Weil
675e63b6a7
Spell checks
2011-03-30 16:45:31 +02:00
Stefan Weil
0e4cf7a2d6
Spell checks
2011-03-30 16:44:16 +02:00
Robert Reif
ce934f03a4
symbol database: handle default values for function arguments properly
2011-03-29 23:16:13 -04:00
Robert Reif
9612573d8e
add support for array of unnamed struct and union to symbol database
2011-03-29 19:48:12 -04:00
Kimmo Varis
4d4b28b075
Remove './' at begin of path in Path::simplifyPath.
...
The './' is not needed at begin of path for files we check. And it
only makes paths longer. This also makes it easier to match paths.
2011-03-29 20:53:18 +03:00
Daniel Marjamäki
0a2f11c2cd
Fixed #2695 (False positive: null pointer dereference and ternary operator (?:))
2011-03-29 18:45:32 +02:00
Robert Reif
b31da161a7
more support for anonymous struct to symbol database
2011-03-29 07:47:39 -04:00
Robert Reif
678486f0db
add support for anonymous struct to symbol database
2011-03-29 07:08:59 -04:00
Robert Reif
e9a23d9cb5
fix #2692 (False positive: if parsed as function in operator >>)
2011-03-28 20:02:06 -04:00
Robert Reif
1aca09a8bf
add support for checking struct/class member container in CheckStl::size()
2011-03-28 19:31:23 -04:00
Kimmo Varis
b889f663ae
Add Path::removeQuotationMarks() to clean path.
2011-03-28 22:14:19 +03:00
Daniel Marjamäki
a1dba61cee
Null pointer: prefer longer error message that says 'otherwise condition at line X is redundant'
2011-03-28 18:48:27 +02:00
Daniel Marjamäki
7426bd3daf
Null pointer: prefer longer error message that says 'otherwise condition at line X is redundant'
2011-03-28 18:44:25 +02:00
Daniel Marjamäki
4a7b60942b
Fixed #2691 (False positive: struct dereference and check (switch-break))
2011-03-28 17:28:21 +02:00
Robert Reif
31f8ff723b
skip nested anonymous unions when searching for variables in symbol database
2011-03-27 18:37:31 -04:00
Daniel Marjamäki
57056bcf61
Fixed #2689 (False positive: Possible null pointer dereference)
2011-03-27 21:29:49 +02:00
Robert Reif
dd5e15b40c
output a debug message when a member variable is used that has a varid of 0
2011-03-27 14:27:14 -04:00
Robert Reif
1e1434e191
make member variable change detection simpler and more accurate for CheckClass::checkConst
2011-03-27 13:59:12 -04:00
Robert Reif
20853fe273
add anonymous union support to the symbol database
2011-03-27 13:48:41 -04:00
Daniel Marjamäki
c87037c29d
Fixed #2674 (False positive: possible null pointer dereference (check if pointer is null in one function, dereference it in another function))
2011-03-27 11:04:58 +02:00
Daniel Marjamäki
e89f6d6ec0
Fixed #2660 (False positive: Variable 'v' is assigned a value that is never used)
2011-03-27 08:19:09 +02:00
Daniel Marjamäki
3c2d3ca3a4
Fixed #2653 (segmentation fault of cppcheck 'x=b=0;')
2011-03-26 12:20:23 +01:00
Daniel Marjamäki
7d9872a134
Tokenizer::setVarId: Prevent that wrong varid is given when uncertain. Ticket: #2680
2011-03-26 10:05:07 +01:00
Daniel Marjamäki
0ff5320d19
CMake: There is no need for PCRE when building the lib
2011-03-26 09:33:21 +01:00
Daniel Marjamäki
2b1277aa64
Fixed #2680 (setVarId: variables with class qualification don't get varid)
2011-03-26 08:56:41 +01:00
Robert Reif
c27ecf5aeb
only break when we know we are inc/dec a member variable in CheckClass::checkConstFunc
2011-03-25 23:22:28 -04:00
Robert Reif
168db82fd6
better checking of assignment to array element in CheckClass::checkConstFunc
2011-03-25 23:02:13 -04:00
Robert Reif
f8e1735b0f
add support to CheckClass::checkConstFunc for ++/-- array elements
2011-03-25 22:37:32 -04:00
Robert Reif
ca50bc7850
move 2 CheckClass helper functions to follow externally called functions so code matches comments
2011-03-25 22:21:40 -04:00
Markus Elfring
9301ee28a8
Added CMake files
2011-03-25 07:14:53 +01:00
Robert Reif
710eb8ffd9
add support for global namespace to Tokenizer::simplifyVarDecl()
2011-03-24 23:06:20 -04:00
Robert Reif
fc258164cd
fix #2675 (false positive: syntax error)
2011-03-24 22:26:42 -04:00
Robert Reif
d643918761
symbol database: add a link from a Function to its Function Scope namd make function parameters belong to Function Scope
2011-03-24 22:08:18 -04:00
Daniel Marjamäki
74105f5d83
Fixed #2673 (false positive: memory leak (address stored in list))
2011-03-24 17:14:12 +01:00
Robert Reif
61e720c82b
fix #1288 (Use of memset on struct - nested structs not handled)
2011-03-23 21:58:58 -04:00
Robert Reif
cbc81e20f5
fix Tokenizer::simplifyVarDecl() template assignment
2011-03-23 21:15:49 -04:00
Robert Reif
7e3e5d628d
better fix for #2672 (False positive: function can be const, nested classes declared in one line)
2011-03-23 20:19:32 -04:00
Daniel Marjamäki
5f36ede4f5
Fixed #2662 (Segfault: overloaded function call function with same name)
2011-03-23 18:45:47 +01:00
Robert Reif
3259239dfe
fix #2672 (False positive: function can be const, nested classes declared in one line)
2011-03-23 07:48:18 -04:00
Robert Reif
14c07e988e
fix pointer/reference check in CheckClass::noMemset symbol database conversion
2011-03-22 22:29:39 -04:00
Robert Reif
5314cc02b2
convert remainder of CheckClass::noMemset to use symbol database
2011-03-22 22:23:57 -04:00
Robert Reif
468a983db1
use the symbol database to look up base classes in CheckClass::noMemset check
2011-03-22 21:24:28 -04:00
Robert Reif
d36ed9aff1
fix #2670 (False positive: function can be const, overloaded functions)
2011-03-22 19:23:36 -04:00
Robert Reif
5cdd635701
run astyle
2011-03-22 19:20:05 -04:00
Ettl Martin
8308fb72e3
fixed performance issues, found by selfcheck with cppcheck.
2011-03-22 23:15:15 +01:00
Ettl Martin
ff1de4c896
extended checkmemoryleak-whitelist
2011-03-22 22:13:29 +01:00
Zachary Blair
f89f0c748f
Fixed #2665 (Slightly sped-up how Token::Match() parses patterns)
2011-03-22 00:15:12 -07:00
Robert Reif
c043e6e1a2
fix
2011-03-21 20:57:17 -04:00
Robert Reif
dc0dfea079
fix invalid bitfield match and simplification that created invalid code
2011-03-21 20:17:14 -04:00
Robert Reif
15fc071514
add virtual base class support to symbol database
2011-03-21 20:03:41 -04:00
Robert Reif
3c5134bb21
run astyle
2011-03-21 19:59:53 -04:00
Ettl Martin
7e31c91a79
extended checkmemoryleak white list
2011-03-21 23:59:43 +01:00
Ettl Martin
38cf9f26df
#2667 added open(), _open() and _wopen() function to checkmemoryleak whitelist, incl. unittests;
2011-03-21 23:20:46 +01:00
Ettl Martin
78bcb07e19
#2667 added perror to checkmemoryleak white list; added unit-tests.
2011-03-21 17:43:26 +01:00
Ettl Martin
f242cb639e
#2668 fixed memory leak ( freopen() )
2011-03-21 15:12:21 +01:00
Ettl Martin
a975301ce4
#2659 added chown,chmod and chdir functions to checkmemoryleak white list; added unittests for each case;
2011-03-21 00:07:37 +01:00
Ettl Martin
01249d4f48
#2659 added access()-function to checkmemoryleak white-list and provided untittests.
2011-03-20 23:39:44 +01:00
Ettl Martin
7afc0978c2
#2659 added stat function to white list and provide unit tests.
2011-03-20 22:17:51 +01:00
Ettl Martin
ab6888dbfe
fixed ticket 2659: added lstat function to white list; provided unit-tests.
2011-03-20 21:52:25 +01:00
Robert Reif
2277cb6965
fix #2663 (False negative: function can be const (changing unknown or uninitialised variable))
2011-03-20 13:29:52 -04:00
Robert Reif
41d80b5c8d
fix #2664 (False negative: function can be const (using type from another namespace))
2011-03-20 12:53:37 -04:00
Daniel Marjamäki
27506b4231
Fixed #2661 (False positive: object destroyed immediately)
2011-03-20 09:55:26 +01:00
Daniel Marjamäki
2613780b85
Fixed #2662 (Segfault: overloaded function call function with same name)
2011-03-20 09:16:52 +01:00
Robert Reif
fc13854095
fix #1280 (Pointer to function support)
2011-03-19 16:21:26 -04:00
Robert Reif
92316e5745
fix #1987 (Internal error:: CheckClass::SpaceInfo::getVarList found variable 'element_size' with varid 0.)
2011-03-19 16:00:43 -04:00
Daniel Marjamäki
2dcd0128b0
Fixed #2213 (false negative: resource leak (calling allocating subfunction twice))
2011-03-19 14:05:22 +01:00
Daniel Marjamäki
31af3a64bc
Tokenizer::setVarId: Fixed problem with same variable name in multiple classes
2011-03-19 11:09:51 +01:00
Daniel Marjamäki
45a3828da7
Tokenizer::setVarId: Better handling of class declarations when variable usage comes before variable declaration
2011-03-19 09:04:03 +01:00
Robert Reif
afc7fd82ed
#2630 (segmentation fault of cppcheck (template <typedef A>)
2011-03-18 20:44:58 -04:00
Robert Reif
1de35c168d
fix #2657 (segmentation fault of cppcheck ( gcc-testsuite: return f(){} ))
2011-03-17 20:10:56 -04:00
Robert Reif
7b63da4964
fix #2651 (Segmentation fault (typedef))
2011-03-17 20:00:49 -04:00
Daniel Marjamäki
dab09aedee
Fixed #2648 (Tokenizer::simplifyTemplates: Segmentation fault (gcc-testsuite))
2011-03-17 21:45:03 +01:00
Robert Reif
7e04ea0859
fix removal of throw() from const functions
2011-03-16 19:54:52 -04:00
Daniel Marjamäki
fec9edf628
Tokenizer::simplifyTemplates: First simple fix for problems when using sizeof in template parameter
2011-03-16 22:16:30 +01:00
Robert Reif
f7cbc90c84
fix #2581 (### Internal error in Cppcheck. Please report it.)
2011-03-15 23:28:45 -04:00
Robert Reif
47531dd99c
fix #2637 (segmentation fault of cppcheck ( {} const const ))
2011-03-15 22:33:14 -04:00
Robert Reif
ba0b3e6451
fix #2651 function typedef with extra ()s
2011-03-15 19:24:30 -04:00
Greg Hewgill
fa868e44ae
Support use of 'this->' when checking operator=() return type
2011-03-15 20:19:30 +13:00
Robert Reif
3babf6a9eb
look for function prototypes but don't save them in the symbol database yet
2011-03-13 22:59:25 -04:00
Robert Reif
47a90851f1
save pointer to Function info in function scope in symboldatabase
2011-03-13 21:18:49 -04:00
Robert Reif
836fadcb6a
save location of using directive (not used yet)
2011-03-13 21:01:33 -04:00
Daniel Marjamäki
07fe361964
Fixed #2638 (Tokenizer::setVarId : varid is wrongly given when unknown macro is used)
2011-03-13 17:52:45 +01:00
Daniel Marjamäki
3e1df1b463
Clarify condition: re-enabled check
2011-03-13 12:16:55 +01:00
Daniel Marjamäki
f26bc6a75c
Fixed #2621 (Segmentation fault for GCC statement expression)
2011-03-13 10:34:54 +01:00
Daniel Marjamäki
384729204f
Refactoring: Use SymbolDatabase to determine if variable is a iterator
2011-03-13 09:48:53 +01:00
Daniel Marjamäki
85daa26fdf
Refactoring: Use symbol database to get variable type
2011-03-13 08:48:38 +01:00
Daniel Marjamäki
ed11a9e3cb
Fixed #2639 (False positive: confusion between struct and function)
2011-03-13 08:38:40 +01:00
Robert Reif
27f4b8b88b
Convert CheckClass::noMemset to use the symbol database to lookup types. This adds better support for namespaces and nested classes.
2011-03-12 22:41:21 -05:00
Robert Reif
51662eeedd
save start parentheses of global functions
2011-03-12 20:35:52 -05:00
Daniel Marjamäki
f3728c0b76
Fixed #2647 (False positive: Possible null pointer dereference (member function call))
2011-03-12 20:57:19 +01:00
Daniel Marjamäki
6bd56dbe20
Fixed #2643 (False positive: iterator increment and insert)
2011-03-12 20:29:54 +01:00
Robert Reif
6a2848e50f
fix another false negative introduced by fix for #2641
2011-03-12 12:27:19 -05:00
Robert Reif
384bd96766
fix false negative introduced by fix for #2641
2011-03-12 11:42:58 -05:00
Daniel Marjamäki
0a28b7309f
Fixed #2641 (False positive: Possible null pointer dereference (global pointer, function call))
2011-03-12 15:02:06 +01:00
Daniel Marjamäki
29ab409af5
Merge branch '2390b' of https://github.com/elfring/cppcheck into elfring-2390b
2011-03-12 11:58:24 +01:00
Greg Hewgill
2716b856f4
throwing an exception is a valid immediate exit from switch
2011-03-12 07:27:31 +13:00
Robert Reif
79f0fe7d1c
refactor symbol database and checks to use list of Scope rather than list of Scope pointers
2011-03-10 19:43:29 -05:00
Greg Hewgill
256e7dee21
Allow suppressing all warnings (using *) for specified file or files
2011-03-10 22:00:48 +13:00
Greg Hewgill
1ec6a642dc
Revert "Check for memset on nested structs (ticket #1288 )"
...
Turns out this fix is incomplete.
This reverts commit a084697410
.
2011-03-10 20:19:31 +13:00
Daniel Marjamäki
e94ebd829d
suspicious condition: commented out the check temporarily - there are some false positives I'll need to fix
2011-03-09 22:29:50 +01:00
Daniel Marjamäki
db48158b28
Suspicious condition: Added new check for conditions that contains assignment+comparison
2011-03-09 22:20:14 +01:00
Daniel Marjamäki
5a0ec56fc2
Fixed #2632 (segmentation fault of cppcheck ( void>(); void>() ))
2011-03-09 21:25:44 +01:00
Daniel Marjamäki
bea3875386
Fixed #2607 (segmentation fault of cppcheck ( struct C {} {} x))
2011-03-09 21:00:28 +01:00
Daniel Marjamäki
be33f6b945
Fixed #2635 (False positive: resource leak)
2011-03-09 19:53:59 +01:00
Greg Hewgill
a084697410
Check for memset on nested structs (ticket #1288 )
2011-03-09 23:02:49 +13:00
Greg Hewgill
3883afcbf4
Check for memset on objects with virtual functions (ticket #607 )
2011-03-09 22:10:39 +13:00
Greg Hewgill
70b4076111
refactor noMemset so it recursively checks parent classes for non-memset-compatible things
2011-03-09 21:29:30 +13:00
Robert Reif
7a7257f200
fix #2630 (segmentation fault of cppcheck ( typedef ... )
2011-03-08 20:24:57 -05:00
Robert Reif
c457179ce6
fix null pointer dereference found by clang++ --analyze
2011-03-08 20:14:46 -05:00
Daniel Marjamäki
0b8581e717
Fixed #2620 (Tokenizer::setVarId : wrong handling of member function parameters)
2011-03-08 20:41:41 +01:00
Daniel Marjamäki
bf2362d558
Fixed #2634 (False positive: buffer access out of bounds)
2011-03-08 19:49:56 +01:00
Robert Reif
d74ae3b0f0
copy all flag fields in a Token
2011-03-07 20:04:25 -05:00
Robert Reif
e305a155af
convert CheckStl::size() to use symbol database, fix false positives, and remove inconclusive
2011-03-07 19:49:43 -05:00
Daniel Marjamäki
a177fc4b24
Preprocessor: made sure string::iterator is valid after string::erase
2011-03-07 22:00:30 +01:00
Daniel Marjamäki
06abaf95a5
Incorrect string compare: reduce noise when using strncmp on string literal
2011-03-07 21:37:13 +01:00
Daniel Marjamäki
7496cd412c
Fixed #2631 (Tokenizer::simplifyTemplates: template usage 'std::cout << (foo<double>(r));')
2011-03-07 21:21:06 +01:00
Daniel Marjamäki
8e571c04e4
Fixed #2633 (False positive: Memory leak for tree node)
2011-03-07 20:17:52 +01:00
Robert Reif
d678e4424c
fix #2630 (segmentation fault of cppcheck ( typedef y x () x ))
2011-03-06 18:59:56 -05:00
Daniel Marjamäki
a77993db75
Refactoring of the CheckNullPointer::isPointer. Use the symbol database. Ticket: #2629
2011-03-06 21:23:33 +01:00
Daniel Marjamäki
e26a7819d3
Symbol database: variable fix. ticket: #2629
2011-03-06 21:21:42 +01:00
Daniel Marjamäki
80235b0d53
astyle formatting
2011-03-06 21:15:58 +01:00
Daniel Marjamäki
f53ff27b71
Tokenizer::simplifyTemplates: better handling of '(foo<double>())'. Ticket: #2631
2011-03-06 21:15:42 +01:00
Daniel Marjamäki
6648267ab8
Revert "Tokenizer::simplifyTemplates: better handling of '(foo<double>())'. Ticket: #2631 "
...
This reverts commit de31ec1e44
.
2011-03-06 21:07:06 +01:00
Greg Hewgill
7daa6b9370
Always pass unsigned char to ::isspace to prevent runtime error in MSVC
2011-03-07 07:58:44 +13:00
Daniel Marjamäki
de31ec1e44
Tokenizer::simplifyTemplates: better handling of '(foo<double>())'. Ticket: #2631
2011-03-06 10:28:51 -08:00
Daniel Marjamäki
10db7c4a48
error logger: explain the severities better
2011-03-06 14:26:02 +01:00
Kimmo Varis
080603148c
Document error message severities.
2011-03-06 14:29:52 +02:00
Daniel Marjamäki
ca4015f905
CheckMemoryLeak: Refactoring the code
2011-03-06 09:42:16 +01:00
Daniel Marjamäki
779dba9160
Fixed #2612 (segmentation fault of cppcheck ( <><< ))
2011-03-06 09:33:46 +01:00
Robert Reif
0debba4409
finish fixing #2624 (better function pointer support needed)
2011-03-05 21:41:58 -05:00
Robert Reif
7d2fb2ecde
partial fix for #2624 (better function pointer support needed)
2011-03-05 20:48:28 -05:00
Greg Hewgill
b9df7735c5
switchCaseFallThrough is now an inconclusive check
2011-03-06 13:06:30 +13:00
Greg Hewgill
c8394909c0
Relax detection of 'fall through' comment so it only adds a suppression if it immediately precedes 'case' or 'default'
2011-03-06 12:14:10 +13:00
Greg Hewgill
8c245cfd2f
switchCaseFallThrough is now a coding style check (ticket #2623 )
2011-03-06 09:43:27 +13:00