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
Simon Martin
5119ae84b8
Ticket #7805 : Ignore enumerators when simplifying known variables.
2016-12-17 14:05:26 +01:00
Daniel Marjamäki
31337dda27
ValueFlow: Better handling of && and || in for loop to avoid FP
2016-12-11 21:19:24 +01:00
Daniel Marjamäki
d4f2512421
Tokenizer::simplifyKnownVariables: Added bailout when pointer alias is simplified and loop is encountered
2016-12-11 19:12:23 +01:00
Frank Zingsheim
e0d4720e19
Fix #7829 (false-positive: knownConditionTrueFalse linked to virtual method)
...
Return values of virtual functions in valueflow are only possible values
since function might be overloaded.
2016-12-11 10:44:05 +01:00
Daniel Marjamäki
87abe1174f
floatConversionOverflow: Avoid warnings when 255.5 is converted to unsigned char etc.
2016-12-10 23:14:40 +01:00
Daniel Marjamäki
b098d5fbd6
ValueFlow: We need better handling of casts
2016-12-10 22:09:01 +01:00
Daniel Marjamäki
2ca85a1c40
dump: add isUnsigned/isSigned
2016-12-09 22:31:47 +01:00
Daniel Marjamäki
ea905c9a36
Unused Functions: use buildDir if specified. Otherwise use old approach.
2016-12-09 20:11:20 +01:00
Daniel Marjamäki
23280c366d
try to make Travis happy by fixing Cppcheck warning
2016-12-08 23:12:59 +01:00
Daniel Marjamäki
e9d950d4f5
Cppcheck build dir: Better handling when --project is used
2016-12-08 22:46:44 +01:00
PKEuS
120fe2e4d6
Fixed false positive: The function 'operatorstd::string' is never used. ( #7853 )
2016-12-08 13:54:54 +01:00
bug22
3bb6a27988
Fixed #7791 (Cppcheck does not expand Visual Studio macros):
...
--project option will now accumulate defines/includes of all applicable
item definition groups, and will push back FileSetting items per project
configurations only
2016-12-07 18:03:46 +02:00
PKEuS
cfac3b457d
Several small refactorizations
2016-12-06 22:12:02 +01:00
PKEuS
718fcfda46
Several small refactorizations
2016-12-06 20:02:43 +01:00
PKEuS
40401534d7
Refactorized Library
2016-12-06 14:50:27 +01:00
PKEuS
2f6350a0d0
Refactorized Library
2016-12-06 14:09:28 +01:00
PKEuS
6dfbddef43
Avoid std::string::pop_back() as long as travis uses an ancient standard library version
2016-12-05 22:55:57 +01:00
PKEuS
6e8ac13325
Refactorization:
...
- Optimized std::string usage
- Replaced list by vector
- Moved iterator into loop head
- Ran AStyle
2016-12-05 17:45:34 +01:00
PKEuS
d665641a76
Refactorizations:
...
- use std::string::pop_back() and std::string::back()
- pass argument as const std::string&
- Moved iterator into for loop head
2016-12-05 14:50:01 +01:00
Matthias Krüger
7197456c23
CheckCondition::checkIncorrectLogicOperator(): if we encounter a condition like 'A && (!A || B)', print the actual equivalent ('A && B') in the --verbose message.
2016-12-05 13:39:20 +01:00
Daniel Marjamäki
5df8e7f50c
Fixed #7596 (ValueFlow: better handling for 'x*(1-x-1)')
2016-12-04 22:39:59 +01:00
Daniel Marjamäki
1137c1e6b8
--project: fixing vcxproj load
2016-12-04 19:15:04 +01:00
Daniel Marjamäki
8b18b6229e
--project: refactorings
2016-12-04 18:50:59 +01:00
Daniel Marjamäki
c12cb69cc2
ValueType: Handle function pointers
2016-12-04 16:02:50 +01:00
Daniel Marjamäki
9c69546d72
Fixed #7842 (Preprocessor::getConfigs: #error in #ifndef not handled well)
2016-12-03 11:59:48 +01:00
orbitcowboy
04d6b05da9
preprocessor: It is more efficient to seek for a single character rather than a string.
2016-12-01 17:54:45 +01:00
orbitcowboy
4a439b9308
It is more efficient to provide a character instead of a string when searching for a single character. This has been fixed in various places.
2016-11-30 12:01:22 +01:00
orbitcowboy
8a45c3192b
There is not need to clear a string directly after its creation.
2016-11-30 10:39:14 +01:00
amai2012
f66e7fb379
#7833 UB: member call on null pointer when --dumping configuration with unknown value
2016-11-28 18:19:19 +01:00
PKEuS
36d12d7866
SymbolDatabase: Function::retDef should not point at "static" or "extern"
2016-11-28 17:23:39 +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
Daniel Marjamäki
b6cba4a55c
Fixed #7784 (Token: can't be both type and variable)
2016-11-26 22:39:47 +01:00
Matthias Krüger
b3ace258ab
there is no need to have "if(tok && Token::Match(tok,..." since Token::Match checks "tok" by itselfs already.
2016-11-26 17:22:30 +01:00
Daniel Marjamäki
a198422f0e
Fixed Coverity warning. Coverity assumes that 'bits < 64' means that bits can be 63. That is not true here but anyway I think the code needed to be fixed.
2016-11-25 15:19:18 +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
Daniel Marjamäki
8be50fd822
--project: loading props when relative paths are given
2016-11-24 08:11:51 +01:00
Daniel Marjamäki
a61f4e9c94
Fixed #7831 (false-positive: terminateStrncpy)
2016-11-24 07:04:58 +01:00
Matthias Krüger
cf24ea5221
fix #7783 : false positive knownConditionTrueFalse on assert(0 && "message").
2016-11-23 21:54:38 +01:00
Matthias Krüger
01e5f14bf8
CheckClass::virtualDestructorError and a variation of CheckNullPointer::nullPointerError would print inconclusive,warning messages altough no --enable=warning was given. Fix.
2016-11-23 00:13:09 +01:00
Daniel Marjamäki
0b3751520b
Add a check for float conversion overflows
2016-11-22 22:37:13 +01:00
PKEuS
02d8f691f8
Fixed false positive: Do not show useInitializationList message for enums
2016-11-22 12:09:30 +01:00
Daniel Marjamäki
d40f4e4a55
Fixed #7778 (valueFlowAfterAssign: alias)
2016-11-21 17:26:36 +01:00
Daniel Marjamäki
21364b4401
Refactoring fix for #7816
2016-11-21 13:54:59 +01:00
amai2012
933815ee54
#7816 Segmentation fault at Tokenizer::simplifyAttribute() for stand-alone void. Throw syntax error on incomplete code
2016-11-21 12:19:47 +01:00
Daniel Marjamäki
9043436e67
Visual Studio: Improved --project handling.
2016-11-20 22:44:50 +01:00
Matthias Krüger
4cf85b72b6
CheckOther::checkAccessOfMovedVariable: don't warn if --enable=warning is not given.
2016-11-20 18:44:37 +01:00
Daniel Marjamäki
74fa69fe5e
Fixed #7821 (syntax error, first token is &)
2016-11-20 17:59:50 +01:00
Daniel Marjamäki
4388435ce1
Revert "checkautovariable: fix #7818 , crash when accessing nullpointer tok2->next()."
...
This reverts commit a5d32aa7a5
.
2016-11-20 17:21:56 +01:00
Daniel Marjamäki
c329887bfe
use const
2016-11-20 15:44:20 +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
Matthias Krüger
b6614d0aa4
valueflow: bail out earlier when encountering divisions by zero. Fixes #7819 .
...
This caused valueflow to actually try to divide by zero, detected by UBSAN.
2016-11-20 14:38:35 +01:00
Daniel Marjamäki
5b377ea2e4
Fixed #7821 (segmentation fault, invalid last token)
2016-11-20 14:15:51 +01:00
Daniel Marjamäki
1235815ae9
SymbolDatabase: refactoring condition
2016-11-18 22:01:15 +01:00
PKEuS
5344a5e098
Fixed race condition by properly constructing a local CheckUnusedFunctions instance in CppCheck::processFile(). Instantiating Checks is dangerous!
2016-11-18 21:09:41 +01:00
Daniel Marjamäki
2f27a0c8f6
Revert "SymbolDatabase: refactoring condition"
...
I don't see why, but this did not work well on appveyor.
This reverts commit 5d7a4d51ad
.
2016-11-17 22:53:03 +01:00
Daniel Marjamäki
79fc332511
Fixed #7810 (SymbolDatabase: method with redundant scope info)
2016-11-17 22:45:50 +01:00
Daniel Marjamäki
5d7a4d51ad
SymbolDatabase: refactoring condition
2016-11-17 22:20:01 +01:00
Matthias Krüger
a5d32aa7a5
checkautovariable: fix #7818 , crash when accessing nullpointer tok2->next().
...
Not test case added yet because I failed to add it as .h files to testgarbage.
2016-11-16 14:46:37 +01:00
Daniel Marjamäki
7d7212c465
--cppcheck-build-dir: generate unique analyzeinfo filenames when source files have same names
2016-11-14 20:50:08 +01:00
Daniel Marjamäki
3b57273ef1
Fix Cppcheck warnings
2016-11-14 07:21:10 +01:00
Daniel Marjamäki
1e31c6c01c
ValueFlow: Extended handling of float values
2016-11-14 06:42:52 +01:00
Daniel Marjamäki
e1e9eacccc
ValueFlow: Added float type
2016-11-13 22:59:56 +01:00
Daniel Marjamäki
4732667488
ValueFlow: allow more value types
2016-11-13 22:33:39 +01:00
Daniel Marjamäki
7ebfb10edd
Fixed #7806 (ValueFlow: better handling of subfunction with early return)
2016-11-13 18:19:51 +01:00
Daniel Marjamäki
ee56fbe3a1
Fixed #7791 (Cppcheck does not expand Visual Studio macros)
2016-11-13 12:16:09 +01:00
Daniel Marjamäki
621c1e59c6
--project: handle SolutionDir and ProjectDir. This is a partial fix for #7791 . custom build macros are still not handled.
2016-11-11 16:22:14 +01:00
Daniel Marjamäki
4de5dc75aa
Fixed #7807 (false positive: (error) Signed integer overflow for expression 'int32_max-1'.)
2016-11-07 22:29:40 +01:00
Daniel Marjamäki
1245f1d621
Unused Functions: Fix checking when --cppcheck-build-dir is used.
2016-11-07 21:49:58 +01:00
Daniel Marjamäki
ac7b351d1e
ValueFlow: Don't calculate x<<64 and x>>64
2016-11-06 20:40:58 +01:00
Daniel Marjamäki
dd69d5eabe
ValueFlow: Don't calculate result when there is UB
2016-11-06 17:42:01 +01:00
Daniel Marjamäki
483fd8682a
cleanup redundant info in comment. ticket numbers can be looked up with git blame. if the code says there is a syntax error then a comment that says 'invalid code' isn't much clarification.
2016-11-06 16:49:25 +01:00
Alexander Mai
ee11f0974a
#7769 segmentation fault at setTokenValue() on invalid code.
2016-11-06 14:20:58 +01:00
Daniel Marjamäki
b607e83648
Try to fix travis
2016-11-05 21:45:31 +01:00
Daniel Marjamäki
350e5a7142
UnusedFunctions: Perform checking using analyzeinfo
2016-11-05 21:26:56 +01:00
Frank Zingsheim
19706b3464
Fix #7789 (Missing error messages in repeated check on compile_commands.json in cppcheck-gui)
2016-11-05 20:14:01 +01:00
Daniel Marjamäki
ece4b1a06f
Fix ValueFlow
2016-11-05 09:59:48 +01:00
Daniel Marjamäki
f280061ff8
signed int overflow: warn about intmax+1
2016-11-05 09:29:52 +01:00
Daniel Marjamäki
2885a75ea6
ValueFlow: handle ~ in setTokenValue
2016-11-05 09:29:22 +01:00
Matthias Krüger
13bfe873f6
resolve mismatching tag reported by clang4.0-dev
...
was:
In file included from lib/checkunusedfunctions.cpp:21:
lib/checkunusedfunctions.h:114:15: warning: struct 'FunctionDecl' was previously declared as a class [-Wmismatched-tags]
std::list<struct FunctionDecl> _functionDecl;
^
lib/checkunusedfunctions.h:108:23: note: previous use is here
class CPPCHECKLIB FunctionDecl {
^
lib/checkunusedfunctions.h:114:15: note: did you mean class here?
std::list<struct FunctionDecl> _functionDecl;
^~~~~~
class
1 warning generated.
2016-11-04 15:51:36 +01:00
orbitcowboy
919f8ac323
Fixed typos. There are no real changes.
2016-11-04 15:01:05 +01:00
Daniel Marjamäki
223ce04986
Merge pull request #841 from zingsheim/FunctionParameter
...
Function parameter
2016-11-01 21:58:52 +01:00
Daniel Marjamäki
0e9810b7f6
CheckStl: validation of iterators returned from functions
2016-11-01 14:08:42 +01:00
Frank Zingsheim
d4f01583b6
Fixed TODO (check if function parameter is non-const reference etc..) by common function
2016-11-01 14:06:30 +01:00
Matthias Krüger
892a81055d
CheckUnusedFunctions::analyzerInfo(): remove unused parameter 'filename'.
...
Was:
lib/checkunusedfunctions.cpp: In member function ‘std::__cxx11::string CheckUnusedFunctions::analyzerInfo(const string&) const’:
lib/checkunusedfunctions.cpp:292:67: warning: unused parameter ‘filename’ [-Wunused-parameter]
std::string CheckUnusedFunctions::analyzerInfo(const std::string &filename) const
^~~~~~~~
2016-11-01 13:34:26 +01:00
Frank Zingsheim
34e8ed6e31
Fix travis; fix [lib/checkunusedfunctions.h:110]: (style) Class 'FunctionDecl' has a constructor with 1 argument that is not explicit.
2016-11-01 11:18:03 +01:00
Daniel Marjamäki
e77d76525e
CheckUnusedFunction: generate better analyzerinfo
2016-10-31 20:43:57 +01:00
orbitcowboy
4e3fdedff9
templatesimplifier: Improved const correctness. There are no functional changes.
2016-10-31 17:24:15 +01:00
orbitcowboy
2f8a24764f
tokenize: Improved const correctness. There are no functional changes.
2016-10-31 17:18:27 +01:00
orbitcowboy
b3c60bf6b2
tokenize: Improved const correctness. There are no functional changes.
2016-10-31 16:11:11 +01:00
orbitcowboy
a81920cae1
checkunusedvar: Check pointer against NULL before dereferencing it.
2016-10-31 15:57:34 +01:00
Frank Zingsheim
a91c54df72
Remove unused enums ValueFlow::Value::ValueKind::Max and ValueFlow::Value::ValueKind::Min
2016-10-30 09:44:52 +01:00
Daniel Marjamäki
2c3232affa
cppcheck-build-dir: Use settings and cppcheck version in checksum so results will be recalculated if cppcheck is upgraded or there is significant changes on the command line.
2016-10-29 22:40:44 +02:00
orbitcowboy
bc32ccc894
CheckUninitVar::isFunctionParUsage: Avoid implicit conversion from type bool to int.
2016-10-29 21:41:55 +02:00
orbitcowboy
960a0c6b11
Token: Improved const correctness of findsimplematch() and findmatch(). There are no functional changes.
2016-10-29 21:37:45 +02:00
Daniel Marjamäki
e76710c906
Revert "Revert "Fix potential uninitialized variable in Tokenizer::simplifyTypedef""
...
It does not _fix_ any potential uninitialized variable. So I reverted this. However I think that as a refactoring it was ok.
This reverts commit 5b2e4891c4
.
2016-10-29 19:04:10 +02:00
Daniel Marjamäki
d092631645
Disable VS warnings
2016-10-29 18:32:39 +02:00
Daniel Marjamäki
5b2e4891c4
Revert "Fix potential uninitialized variable in Tokenizer::simplifyTypedef"
...
This reverts commit bed2f66302
.
2016-10-29 18:29:05 +02:00
Daniel Marjamäki
7001aa1e81
Try to fix VS errors about std::to_string()
2016-10-29 18:18:29 +02:00
Frank Zingsheim
bed2f66302
Fix potential uninitialized variable in Tokenizer::simplifyTypedef
2016-10-29 17:05:51 +02:00
Daniel Marjamäki
26cae60110
Try to fix VS compile error. Add analyzeinfo.cpp.
2016-10-29 16:20:20 +02:00
Daniel Marjamäki
75f50e0bf8
try to fix VS compile error for std::uint32_t
2016-10-29 15:55:03 +02:00
Daniel Marjamäki
faa32fd51d
Fix Cppcheck warnings and remove Travis suppressions
2016-10-29 15:50:08 +02:00
Daniel Marjamäki
a860c4c231
refactoring checksum calculations for --cppcheck-build-dir
2016-10-29 15:35:31 +02:00
Daniel Marjamäki
eeee630f77
fix cppcheck warnings
2016-10-29 12:35:14 +02:00
Daniel Marjamäki
9ff3e85899
Added --cppcheck-build-dir flag
2016-10-29 12:18:11 +02:00
Daniel Marjamäki
324f68ca36
rename function
2016-10-28 12:10:19 +02:00
Daniel Marjamäki
9c1a08ca84
move std function information from checkstl to std.cfg
2016-10-27 19:24:24 +02:00
Daniel Marjamäki
0b76aa0f24
checkstl: refactoring. make data static instead of anonymous.
2016-10-27 18:54:15 +02:00
Daniel Marjamäki
892596681b
Try to make Travis happy
2016-10-27 11:53:37 +02:00
Daniel Marjamäki
f6a5f6bb61
CheckStl::mismatchingContainers: Refactoring, use Library instead of hardcoding
2016-10-27 10:25:45 +02:00
Harald Scheidl
0de47f709e
Fixed #7755 (false positive: member variable is not initialized in the constructor)
2016-10-26 10:39:53 +02:00
Robert Reif
4216b26b8c
Fixed #7775 (crash at valueFlowSetConstantValue)
2016-10-26 10:36:02 +02:00
Daniel Marjamäki
08a618c476
Library: Add <iterator> element in <function> <arg>. Not used by any checks yet.
2016-10-25 23:07:18 +02:00
Daniel Marjamäki
f973a9a9d5
SymbolDatabase: Refactoring handling of library-function return type
2016-10-23 23:20:36 +02:00
Daniel Marjamäki
c8f831b70d
Library: Allow that type of function return is specified. Fixes #7668 .
2016-10-23 23:04:15 +02:00
Robert Reif
f25d205999
Fixed #7767 (SymbolDatabase: function not analysed when unknown macros are in front of function definition)
2016-10-22 22:29:18 +02:00
Daniel Marjamäki
8a0f3009ff
ValueFlow: inner and outer function return values
2016-10-22 17:22:57 +02:00
Daniel Marjamäki
77cd6c194f
ValueFlow: Set 'known' property for function return values
2016-10-22 12:24:15 +02:00
Daniel Marjamäki
86a620a3b4
ValueFlow: Better handling of function return value when there are 0 parameters
2016-10-20 16:10:55 +02:00
Daniel Marjamäki
a85eacc157
cstyleCast: don't warn about '(const Variable *)nullptr'
2016-10-18 22:56:33 +02:00
Daniel Marjamäki
efa3aba32a
Remove Tokenizer::simplifyNull()
2016-10-18 21:44:02 +02:00
Daniel Marjamäki
9cea2d6dfa
Tokenizer: Removed simplifications of standard functions that should be handled through configuration.
2016-10-18 19:25:58 +02:00
Dmitry-Me
d2e667ae7b
Put apostrophes consistent with other similar messages
2016-10-18 15:45:08 +03:00
Daniel Marjamäki
fae4a4dacf
Fixed #7668 (ValueFlow: return value from abs)
2016-10-17 13:05:19 +02:00
Daniel Marjamäki
1b7766c7bd
astyle formatting
2016-10-16 19:03:14 +02:00
Daniel Marjamäki
90ed7634b8
MathLib: fix for octal char literal '\200'
2016-10-16 13:42:20 +02:00
Daniel Marjamäki
5175bf88d6
Platform: Fix type limits calculations. sizeof=>bit
2016-10-16 12:00:33 +02:00
Daniel Marjamäki
c70987b727
ValueType: fix type of integer literals
2016-10-16 11:36:22 +02:00
Daniel Marjamäki
7fb812f415
Fixed #7752 (ValueFlow: no conditional value, probably because condition is in ternary operator and/or in function call.)
2016-10-16 07:15:28 +02:00
Daniel Marjamäki
ad74421526
Fixed #7756 (ValueFlow: fix bug in valueAfterAssign, same variable in lhs and rhs)
2016-10-15 19:09:50 +02:00
Daniel Marjamäki
d09a8dde57
Improved char literal handling. In the 'normal' tokenlist these should not be simplified to integer literals.
2016-10-12 10:20:24 +02:00
Miika-Petteri Matikainen
26816ed954
Fixes preprocessor regression causing hang
...
Cppcheck 1.76 introduced a regression in preprocessor which causes
the following code to hang:
$ cat > test.c << EOF
#ifndef Y
#else
#endif
EOF
$ cppcheck -D BAR --force test.c
Checking test.c ...
^C
This used to work with version 1.75. Git bisect reveals that this
regression was caused by commit:
ff036c8742
This commit fixes the regression by avoiding infinite loop in
hasDefine(). If cfg is empty string "", we can skip the whole loop
and exit early.
2016-10-11 19:56:13 +03:00
orbitcowboy
fe08abb76f
Improved Doxygen comments. There are no functional changes.
2016-10-11 13:51:46 +02:00
PKEuS
1715969f6f
Support prefix-increment/decrement in CheckAutoVariables::assignFunctionArg() ( #3177 )
2016-10-10 21:34:40 +02:00
PKEuS
1227a3f596
Improved check: Complain if a variable is modified but not used again
2016-10-10 21:27:40 +02:00
Harald Scheidl
04421f5601
check if AST is not null before accessing it
2016-10-09 18:21:23 +02:00
Daniel Marjamäki
e0e53cbd66
alwaysTrueFalse: Don't warn when condition is 0 or 1
2016-10-09 15:20:43 +02:00
Daniel Marjamäki
af5dd2c29e
New check: Pointer overflow (null pointer subtracted)
2016-10-09 15:15:29 +02:00
Harald Scheidl
58eb644003
Improved Check: Warn about number and char literals in boolean expressions ( #7750 )
2016-10-09 13:21:00 +02:00
Daniel Marjamäki
0e785e435e
charLiteralWithCharPtrCompare: Improved warning to catch any char literal
2016-10-09 11:39:20 +02:00
PKEuS
e417e15567
Set version to 1.76.99/1.77 dev
2016-10-09 10:33:03 +02:00
PKEuS
54959d1932
CheckLeakAutoVar: Distinguish between new and new[] ( #888 )
2016-10-09 10:28:19 +02:00
Daniel Marjamäki
0afe745c94
1.76: Update version
2016-10-08 18:40:36 +02:00
PKEuS
e1a21a8bb1
Fixed internal warnings
2016-10-08 11:34:25 +02:00
Harald Scheidl
9f1b70fa04
new can initialize memory, don't warn in this case ( #7623 )
2016-10-08 10:03:09 +02:00
Daniel Marjamäki
bcbc8ef017
Fixed #7747 (Syntax error when setting the bitcount of an enum defined inside a struct)
2016-10-04 15:57:43 +02:00
Daniel Marjamäki
02402eeea4
Make simplifyBitfields() a bit more strict
2016-10-04 15:33:50 +02:00