PKEuS
719304a8fc
Added internal check for || and | inside Token::Match patterns.
2014-07-02 15:51:18 +02:00
PKEuS
b4f0869a71
Reduced Token::Match complexity, better support for complex patterns
2014-07-02 15:25:41 +02:00
PKEuS
817d32f791
Fixed and cleaned up Token::Match engine
2014-07-02 15:25:19 +02:00
Dmitry-Me
b38e43ebae
Negation not needed anymore.
2014-07-02 11:12:39 +04:00
Zachary D. Blair
f6523e384b
Fixed 4979 (Doesn't allow any ordering of int modifiers)
2014-07-01 23:59:04 -07:00
PKEuS
3d0ebe196b
Several improvements to CheckUnusedVar::checkFunctionVariableUsage_iterateScopes():
...
- Use AST in some places
- Fixed misusage of Token::isStandardType (fixes false negative)
- Removed some redundant conditions
2014-07-02 00:18:40 +02:00
Daniel Marjamäki
5e9e90b1c1
Fixed Token::Match pattern. In x|y|.. patterns, all %cmd% should be placed before plain-text operands.
2014-07-01 15:55:29 +02:00
Dmitry-Me
454dd0a736
Break the loop once the result can no longer change.
2014-07-01 17:16:45 +04:00
Daniel Marjamäki
b7d7633b97
ValueFlow: Improved analysis after switch
2014-06-30 17:56:42 +02:00
Daniel Marjamäki
f1762f9ed6
Fixed #5939 (fp: Possible null pointer dereference, after check against NULL in for loop)
2014-06-30 07:26:48 +02:00
Daniel Marjamäki
df799f97c5
valueFlowBefore: better analysis of conditional assignment
2014-06-30 00:02:49 +02:00
Daniel Marjamäki
4f43e4f9aa
Fixed #5959 (ValueFlow: return value from subfunction)
2014-06-29 18:04:38 +02:00
Daniel Marjamäki
893996d182
Fixed #5937 (ValueFlow: wrong analysis of calculations with different variable operands)
2014-06-29 10:57:39 +02:00
Daniel Marjamäki
41baffdda1
Fixed #5850 (Wrong Message on self assignment)
2014-06-28 15:26:22 +02:00
Daniel Marjamäki
ab08883332
Merge pull request #351 from simartin/ticket_5952
...
Ticket #5952 : Simplify redundant parentheses in pointer variable declarations
2014-06-28 12:20:27 +02:00
Daniel Marjamäki
9eaadc81e2
Fixed #5861 (valueFlowSubFunction: fp for float value)
2014-06-28 12:04:20 +02:00
Daniel Marjamäki
46479ced7e
Library: Handle FIlE_NOT_FOUND better
2014-06-28 10:22:35 +02:00
Daniel Marjamäki
6f2c8a8236
Fixed #5931 (arrayIndexOutOfBoundsCond id reported instead of arrayIndexOutOfBounds)
2014-06-28 10:09:53 +02:00
Simon Martin
7b942650c2
Ticket #5952 : Simplify redundant parentheses in pointer variable declarations.
2014-06-28 09:36:51 +02:00
Daniel Marjamäki
6c8558c112
CheckBufferOverrun: Removed old for-loop handling. This is handled through ValueFlow from now on.
2014-06-27 06:46:42 +02:00
Alexander Mai
b6a40fceb7
Fix some compiler warnings
2014-06-26 20:34:07 +02:00
Daniel Marjamäki
036b2f8ccf
CheckBufferOverrun: Added bufferOverrun2 that is based on ValueFlow/SymbolDatabase/Ast from the start. Replaced some old checking.
2014-06-26 17:36:20 +02:00
Daniel Marjamäki
72992c7973
AST: fixed ast for '++i;'
2014-06-26 17:31:57 +02:00
PKEuS
7ea7ee0005
Store Token::_originalName on heap, since it is only used for a small amount of Tokens (reduce memory usage of TokenList by ~12% (x64))
2014-06-26 11:51:02 +02:00
PKEuS
ec1bd420a7
Refactorizations optimizing std::string usage:
...
1) Added global static const std::string emptyString; object:
-> Replaces some static variables in functions which might be not threadsafe
-> Avoids constructor call (std::string::string(""))
-> Even functions that return an empty string in some branches can return by reference now.
Added to config.h to ensure that it is available everywhere
2) Added overloads for TestFixture::assertEquals for the most common use cases:
-> Moves conversion from const char[] to std::string into a function, reducing code duplication in binary.
2014-06-26 11:51:02 +02:00
PKEuS
feefa4c626
Speedup checking large amounts of arrays ( #5615 ) by avoiding Token::Match calls in CheckBufferOverrun::checkScope(2).
...
-> Decreased entire checking time on a subset of the attached file by 66% (MSVC12, x64, non-matchcompiled)
2014-06-26 11:51:02 +02:00
PKEuS
e13de2681e
SymbolDatabase: 'const' can't be the name of a variable - fix use after free #5882
2014-06-26 09:19:57 +02:00
PKEuS
e80104327a
AST: Fixed detection of operator new/delete - don't hang when C code is checked as C++ ( #5910 )
2014-06-26 09:19:57 +02:00
PKEuS
b20f87faf2
Optimized Tokenizer::simplifyPlatformTypes() once more: Another 3% improvement on Windows.
...
-> All Token::Match strings are uppercase, so check Token::isUpperCaseName() to avoid comparisons with very slow long Token::Match strings (idea from amai)
Removed duplicate Token::Match call in symboldatabase.cpp
2014-06-25 20:42:59 +02:00
PKEuS
360fd4a565
Speedup Tokenizer::simplifyMathFunctions() and Tokenizer::simplifyPlatformTypes()
...
-> Speedup on entire checking time (TortoiseSVN code) by 3% (MSVC12, x64, not matchcompiled). Probably only measurable when checking code with Windows platform.
2014-06-25 17:00:59 +02:00
Daniel Marjamäki
5af96c2dd8
Fixed #5947 (valueFlowForward: forward conditions not handled properly)
2014-06-25 16:00:56 +02:00
Daniel Marjamäki
c77786a745
valueFlowAfterCondition: wrong analysis for floats
2014-06-25 06:17:44 +02:00
PKEuS
ac4e727da7
Removed redundant code (replaced by libaries, should fix #5934 ).
2014-06-24 21:57:19 +02:00
PKEuS
3a89e5d65f
Fixed cppcheck warnings introduced by previous commit
2014-06-24 19:51:47 +02:00
Daniel Marjamäki
54aede9086
Fixed #5941 (ValueFlow: Wrong value in subfunction under ?)
2014-06-24 19:30:46 +02:00
PKEuS
1b5d127373
Cache results for TokenList::isC() and TokenList::isCPP() to avoid redundant calls to Path::isCPP()/isC(), which perform slow string operations (conversion to lowercase, substring, comparisons)
...
-> Speedup of 2% on self-checking cppcheck-core (MSVC12, x64, not matchcompiled)
2014-06-24 17:42:39 +02:00
PKEuS
2d54bace1b
Improved performance of CheckBufferOverrun::checkScope() ( #5944 ):
...
-> Speedup by 40% (MSVC12, x64, not matchcompiled) on the file attached to the ticket
2014-06-23 19:06:59 +02:00
Daniel Marjamäki
1ae6531c4c
Fixed #5923 (false positive: (error) Resource leak: fp (static file pointer))
2014-06-23 16:05:28 +02:00
Daniel Marjamäki
ae81b09b58
Refactoring: Move isScopeNoReturn implementation to library and reuse it both in ValueFlow and Tokenizer
2014-06-22 19:13:15 +02:00
Daniel Marjamäki
f78cbda2db
Refactoring: Removed CheckNullPointer::nullPointerByCheckAndDeRef and implemented needed analysis in ValueFlow instead.
2014-06-22 10:02:14 +02:00
Daniel Marjamäki
ef81bc363a
ValueFlow: analysis in condition.
2014-06-19 17:29:41 +02:00
Daniel Marjamäki
dec251ac44
ValueFlow: Refactoring. Use utility function isVariableChanged.
2014-06-19 05:41:19 +02:00
Daniel Marjamäki
84581817f6
ValueFlow: Improved valueFlowForward. RHS in assignment.
2014-06-18 21:07:01 +02:00
PKEuS
188f9b4509
Fixed #error handling:
...
- Reporting them once is enough
- Don't report them if --force is used - since we silently drop these configurations when we check multiple configurations. Without the fix, -f combined with -D resulted in #error being shown erroneously.
- No redundant preprocessor instance to report them
2014-06-18 17:57:31 +02:00
PKEuS
dcc646735d
Made static local variable non-static (thread-safety, #5934 )
2014-06-18 17:57:31 +02:00
Daniel Marjamäki
13761927ff
ValueFlow: better analysis in valueFlowAfterCondition of 'if|while ( %var% )' etc
2014-06-18 06:57:48 +02:00
Daniel Marjamäki
9999ce9468
ValueFlow: extend aftercondition analysis below conditional code
2014-06-18 05:51:23 +02:00
Alexander Mai
2e3f26ba58
Patch from Dmitry-Me: reorder checks so that cheaper ones go first, reuse previously computed values, return early on edge condition
2014-06-16 21:36:31 +02:00
amai2012
c61d2b9f41
#5926 Dangerous iterator comparison using operator< on 'std::deque'.
...
std::deque features a random access iterator, so warning stlBoundaries
is a false positive
2014-06-16 20:50:47 +02:00
Daniel Marjamäki
847bb44bdd
ValueFlow: Improved analysis after condition when ! operator is used
2014-06-16 16:39:41 +02:00
orbitcowboy
be49185471
Fixed #5925 : The first include in path.cpp is not path.h and astyle run.
2014-06-16 15:11:44 +02:00
orbitcowboy
76f3f67bcf
Fixed fsanitize=undefined: left shift of negative value -10000 in lib/templatesimplifier.cpp.
2014-06-16 10:58:41 +02:00
Daniel Marjamäki
0e971f2979
Merge pull request #341 from simartin/ticket_5268
...
Ticket #5268 : Properly detect function heads when in Tokenizer::simplifyEnum
2014-06-15 18:14:20 +02:00
Daniel Marjamäki
a27ca11b85
Fixed #5916 (ValueFlow: Add a valueFlowAfterCondition() function)
2014-06-15 16:47:01 +02:00
Simon Martin
efb12f0409
Ticket #5268 : Properly detect function heads when in Tokenizer::simplifyEnum.
2014-06-15 15:52:58 +02:00
Robert Reif
1f09cb0c30
Fixed #5807 (non virtual dtor in virtual class)
2014-06-14 12:55:20 +02:00
Daniel Marjamäki
17f1841fba
Merge pull request #339 from simartin/ticket_5868
...
Ticket #5868 : Ignore variables called like a typedef when substituting typedefs
2014-06-14 12:38:02 +02:00
PKEuS
8b9daadd25
Replaced static variable isCPP in Token (was not threadsafe):
...
- Encapsulate parameters passed through AST compiler functions in a struct
-> Reduces maintenance overhead when changing them
-> Contains parameter indicating if the file is C or C++
- Added eKeyword Token type (at the moment, only true for C++ keyword "delete", but should be set for other keywords as well)
2014-06-14 10:28:12 +02:00
Simon Martin
d588ed49b3
Ticket #5868 : Ignore variables called like a typedef when substituing typedefs.
2014-06-14 00:50:14 +02:00
Daniel Marjamäki
ad879320e5
ValueFlow: Fixed 'function call => calculation' value flow
2014-06-13 16:34:57 +02:00
orbitcowboy
5c2ed8450e
Revert my previous fix 28763fa020
and suppress gcc false positive warnings.
2014-06-13 15:46:43 +02:00
orbitcowboy
28763fa020
Libary: Fixed gcc warning -Wmissing-field-initializers
2014-06-13 13:17:08 +02:00
Alexander Mai
0f7071a000
Fix clang and coverity warnings
2014-06-12 20:03:11 +02:00
Daniel Marjamäki
86ef5f8ae7
CheckIO: Handle library types
2014-06-12 07:01:44 +02:00
Daniel Marjamäki
a4a6f3e1be
Tokenizer: Removed Tokenizer::simplifyConditionOperator(). Using the AST and ValueFlow, it should be much easier to parse ?: than before.
2014-06-10 19:30:13 +02:00
Dmitry-Me
6e1568a6db
Simplify code - bail out early, vreak loops early, reorder checks and declarations.
2014-06-09 13:35:30 +04:00
Daniel Marjamäki
42c3b3c89d
Library: Change range operator in validation pattern to ':'
2014-06-08 18:12:11 +02:00
Simon Martin
dc12a73987
Ticket #5907 : Properly handle extern declarations in Tokenizer::simplifyVarDecl.
2014-06-08 14:59:58 +02:00
Daniel Marjamäki
a41f6077e1
Tokenizer: Use 'podtype' info from library. Partial fix for #5623
2014-06-08 13:28:15 +02:00
Daniel Marjamäki
9e81fa04b2
Library: Added 'podtype' element. Partial fix for #5623
2014-06-08 12:09:00 +02:00
Alexander Mai
e1513090e2
#5909 crash: clang: test/Preprocessor/ifdef-recover.c. Avoid segfault in Preprocessor::getcfgs() on invalid code.
2014-06-08 10:02:16 +02:00
Daniel Marjamäki
56e3e150c2
Merge pull request #334 from Dmitry-Me/ReorderChecksAndCleanupDeclarations
...
Cleanup code - reorder checks and make variable declaration scope narrower
2014-06-07 18:35:03 +02:00
Daniel Marjamäki
4c7b0806aa
Library: handle validation expression '-1000-0'. Ticket #5847
2014-06-07 16:28:29 +02:00
Alexander Mai
4d5b463613
Fix clang compiler warning in mathlib.cpp and repair test case for #5895
2014-06-07 13:16:02 +02:00
Dmitry-Me
7692a306cd
Cleanup code - reorder checks and make variable declaration scope narrower.
2014-06-06 18:58:20 +04:00
orbitcowboy
16352ca674
Reverted fix 6d0f490138
, but keeping the testcase in the testsuite.
2014-06-06 14:44:22 +02:00
PKEuS
f1a57cbfcc
Refactorization in timer.cpp ( #5902 ), Removed misleading comment in symboldatabase
2014-06-05 17:39:14 +02:00
orbitcowboy
6d0f490138
#5895 - Fixed potential signed integer overflow in Checkother:getvalue. Added regression test.
2014-06-05 16:41:10 +02:00
PKEuS
f6c9320aee
Fixed incorrect usage of startOfExecutableScope() (Checking time reduced by ~60% (nonlinear) for #5876 )
2014-06-05 10:45:26 +02:00
PKEuS
0a0f1072c0
Attempt to fix travis and some more VS warnings
2014-06-04 19:18:27 +02:00
PKEuS
51f381edf3
Fixed VS warnings
2014-06-04 18:55:29 +02:00
PKEuS
2455b76abd
Fixed lots of bugs in the AST:
...
- Support new and delete
- Properly handle "..."
- References and rValue references as function parameters
- Destructor definitions
2014-06-04 18:47:56 +02:00
PKEuS
39b64ea5fb
Simplify rValue reference arguments without name (&& -> & &)
2014-06-04 18:45:56 +02:00
PKEuS
8db0790407
Tokenizer::tokenize() can now be called without AST being created
2014-06-04 18:45:28 +02:00
PKEuS
d93d7401c6
Moved getSourceFilePath(), isC() and isCPP() from Tokenizer to TokenList
...
Conflicts:
lib/tokenize.cpp
2014-06-04 18:36:25 +02:00
PKEuS
6aa88248ac
Fixed timer name
2014-06-04 18:34:45 +02:00
orbitcowboy
8fe163285f
MathLib: Added missing testcase for incdec.
2014-06-04 08:41:30 +02:00
orbitcowboy
60e80b6fb1
Fixed #5885 - fsanitize=undefined: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' in lib/tokenize.cpp.
2014-05-29 18:25:01 +02:00
orbitcowboy
e9144d1a78
Fixed #5890 - crash: wesnoth desktop_util.cpp / unicode.hpp.
2014-05-29 02:58:18 +02:00
Robert Reif
e5ae575ace
Fixed #5867 (invalid debug warnung: Scope::checkVariable : varid0)
2014-06-02 06:18:32 +02:00
Alexander Mai
ad1662a201
#5875 fix 'lib/checksizeof.cpp:142:26: runtime error: member call on null pointer of type 'Token'. Improve error handling in CheckSizeof::checkSizeofForPointerSize()
2014-06-01 22:18:17 +02:00
Daniel Marjamäki
42140b6488
Preprocessor: set error flag when unhandled characters are found so checking can bailout
2014-06-01 11:24:10 +02:00
Martin Ettl
af369b4925
astyle run [ci skip]
2014-05-16 23:01:21 +02:00
amai2012
6f31ce334d
#5875 Fix 'lib/mathlib.cpp:559:43: runtime error: division by zero'. Several fixes to MathLib::divide(): avoid division by zero, handle various representation of 0 value, use 'nan.' instead of '-nan.0'
2014-05-31 18:25:23 +02:00
Daniel Marjamäki
46bf23aa6d
TokenList: added assertion that makes sure the Preprocessor doesn't let through extended ascii wrongly.
2014-05-31 18:02:19 +02:00
amai
98ea1397b3
#5875 clang ubsan errors: lib/checkassignif.cpp:58:34: runtime error: member call on null pointer of type 'Token'
2014-05-31 15:12:04 +02:00
Daniel Marjamäki
66ad3c97b9
Fixed #5857 (strPlusChar: Crash on invalid code 'int+;')
2014-05-31 10:34:00 +02:00
PKEuS
86dede14c0
Merge pull request #327 from simartin/only_fill_if_needed
...
Only fill total_size in CheckBufferOverrun::checkFunctionParameter when useful
2014-05-30 20:56:33 +02:00
Daniel Marjamäki
70b4c945de
Fixed #5874 (False positive: 'opposite conditions in nested if' with arrays)
2014-05-30 19:19:24 +02:00
Simon Martin
f7356dd8c7
Only fill total_size in CheckBufferOverrun::checkFunctionParameter when it's useful.
2014-05-29 23:51:13 +02:00