Commit Graph

629 Commits

Author SHA1 Message Date
Daniel Marjamäki 9c8922541e Avoid C++11 for-range to make AppVeyor happy 2016-05-09 13:05:08 +02:00
Robert Reif 381fa53ec6 SymbolDatabase: better handling of enum values 2016-05-09 12:40:56 +02:00
Daniel Marjamäki eac3660f46 ValueType: Changed type info for enums to 'signed int', that is what checks wants to see mostly. 2016-05-09 11:11:13 +02:00
Daniel Marjamäki e99a9b4742 SymbolDatabase: Fix cleanup (avoid dead pointers) 2016-05-08 18:34:23 +02:00
Daniel Marjamäki 7edb1bc2e2 Fixed #7484 (ValueType: crash with --debug --verbose) 2016-05-08 17:43:34 +02:00
Daniel Marjamäki e355e4ac78 ValueType: Refactoring 2016-05-08 17:42:53 +02:00
Daniel Marjamäki 803b4d4cf8 ValueType: Better handling of nested types 2016-05-08 14:55:10 +02:00
Daniel Marjamäki 636e97c272 ValueType: Improved debug output for nested types 2016-05-08 13:15:20 +02:00
Daniel Marjamäki f0953c6916 ValueType: better handling of nonstandard types 2016-05-08 11:55:25 +02:00
Daniel Marjamäki be90080976 Fixed #7481 (False positive AssignmentAddressToInteger - pointer to enum) 2016-05-07 19:51:37 +02:00
PKEuS 3366a74bb0 Refactorized CheckCondition::clarifyCondition():
- Reimplemented parts of the check based on ValueType
- Merged two loops

Fixed some type conversion messages
2016-05-06 15:22:45 +02:00
PKEuS 0bf85f9aa5 ValueType: Support integers defined in libraries (#7394) 2016-05-04 15:39:56 +02:00
PKEuS 6c3f0a7bb8 SymbolDatabase: Properly detect lambdas with return type (#7473) 2016-05-04 14:10:09 +02:00
amai2012 a54ec615f3 Run astyle 2016-04-25 11:12:35 +02:00
amai2012 479f00030e Restore compatibility with current C++ language set specification (VS2010) 2016-04-24 23:02:56 +02:00
Daniel Marjamäki 0635ceb42a Replaced C++11 auto keyword 2016-04-23 09:18:28 +02:00
Robert Reif ee2be81fae enums: Fix false negatives caused by new enum handling 2016-04-22 20:26:58 +02:00
Daniel Marjamäki dc2a92263a Fixed #7426 (RFC: time to replace simplifyEnum?) 2016-04-22 06:02:54 +02:00
Robert Reif 47634a0ada Fixed #7420 ((debug) Executable scope 'foo' with unknown function.) 2016-03-22 14:10:20 +01:00
Daniel Marjamäki 4e4873772d Fixed #7395 (ValueType: Result type of assignment operators) 2016-03-21 19:51:09 +01:00
Daniel Marjamäki d964825c9f ValueType: Add debug output that is shown when --verbose is used 2016-02-15 16:18:24 +01:00
PKEuS 0847d3d19a ValueType related bugfixes:
- ptrdiff_t is SIGNED
 - Detect pointers to unknown types as pointers
 - Do not identify bool* as boolean (#7381)
2016-02-05 20:29:17 +01:00
PKEuS 618ea498e9 ValueType: Support logical operators 2016-02-05 15:15:13 +01:00
PKEuS 35317695d4 ValueType: Fixed handling of constness 2016-02-05 13:31:31 +01:00
PKEuS 792835cd9a ValueType: Support ++/--. 2016-02-05 12:06:44 +01:00
PKEuS 2b179dc836 ValueType: Properly support ternary operator with pointers (#7378) 2016-02-05 09:59:48 +01:00
PKEuS 3b7948fb4e ValueType: Support ternary operator 2016-02-04 21:20:05 +01:00
PKEuS a9f52aec04 ValueType: Support unary arithmetical/bit operators 2016-02-04 21:03:54 +01:00
PKEuS cae19cadd3 ValueType: Added support for static member variables and simplified code 2016-02-04 20:49:13 +01:00
Alexander Mai d3546ea410 #7321 segmentation fault in valueFlowSwitchVariableScope::isVariableDeclaration 2016-02-03 22:49:57 +01:00
Alexander Mai cfe9c01bf8 #7257 segmentation fault in valueFlowSwitchVariable (invalid code). Correct SymbolDatabase::validateVariables() so it does not complain about function arguments for function without body 2016-02-03 21:52:02 +01:00
Alexander Mai d45f5c94cb Add (disabled) function in SymbolDatabase to check variable list (e.g. find variables w/o scope). Fix some doxygen warnings. 2016-02-03 17:08:46 +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 d19b5031fa Refactorization: Removed unused function. 2016-02-02 11:46:42 +01:00
Daniel Marjamäki 988918c9bc ValueType: Use signed as default sign for short/int/long/longlong 2016-01-31 14:34:26 +01:00
Daniel Marjamäki 0e89620212 Fixed #4698 (False positive: Uninitialized member variable warning with confusing namespaces) 2016-01-30 14:04:48 +01:00
Daniel Marjamäki 3d0338e9f9 Fixed #7212 (incorrectly adding function argument with no name) 2016-01-23 09:48:21 +01:00
Daniel Marjamäki f64930b7f5 Fixed #7343 (SymbolDatabase: handling of override) 2016-01-22 19:22:24 +01:00
Daniel Marjamäki a014920280 Fixed #7260 (ValueType: in C++ the result of 'sint >> unknowntype' has unknown type) 2016-01-07 10:46:19 +01:00
Daniel Marjamäki 58e28cb00e ValueType: Better handling of unsigned unknown types 2016-01-05 19:47:11 +01:00
Daniel Marjamäki 1db9cf4d09 SymbolDatabase: Add '#include <cctype>' for std::isalpha 2016-01-04 14:20:07 +01:00
Daniel Marjamäki 8dccbfefcf ValueType: handle lowercase number suffix, for instance '0ll' 2016-01-03 13:34:47 +01:00
Daniel Marjamäki 4ff7fa3f3b SymbolDatabase,Tokenizer: Refactor handling of noexcept 2016-01-03 08:36:00 +01:00
Daniel Marjamäki be8fc0f89f SymbolDatabase: Better handling of default and delete when reusing Tokenizer::isFunctionHead() 2016-01-03 00:01:29 +01:00
Daniel Marjamäki 66e047ee7d Refactoring SymbolDatabase. Reuse Tokenizer::isFunctionHead(). 2016-01-02 23:49:06 +01:00
Daniel Marjamäki 746d024e3d SymbolDatabase: Fix Token::Match pattern 2016-01-02 20:00:18 +01:00
Robert Reif db6dfa2d22 Fixed #7195 (crash: valueFlowSwitchVariable()) 2016-01-02 18:53:51 +01:00
Daniel Marjamäki 95009a4630 Merge pull request #745 from lanurmi/2016_ad
Update copyright year to 2007-2016.
2016-01-01 22:57:19 +01:00
Daniel Marjamäki 416861b530 ValueType: only use default signedness for char/short/int/long/longlong 2016-01-01 20:03:31 +01:00
Daniel Marjamäki b457ceef0e Settings: Added defaultSign 2016-01-01 17:33:59 +01:00
Daniel Marjamäki 2f26195b23 Fixed #7248 (crash in ValueType::str()) 2016-01-01 15:13:50 +01:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02:00
Daniel Marjamäki e69e952c46 Fixed #7245 (ValueType: Wrong result type for 'sint << uint') 2015-12-31 20:18:35 +01:00
Daniel Marjamäki fdcab8f1bb ValueType: better handling of struct member 2015-12-30 11:36:46 +01:00
Daniel Marjamäki c5c386ceb8 ValueType: Handle void pointers 2015-12-29 19:58:51 +01:00
Daniel Marjamäki 32455e8441 Fixed #7214 (ValueType: does not handle static_cast) 2015-12-26 15:20:17 +01:00
PKEuS a6b719eb10 Refactorization: Fixed true positive when self-checking cppcheck 2015-12-18 18:13:13 +01:00
Dmitry-Me 06ff877415 Typo in variable name 2015-12-18 15:46:12 +03:00
Dmitry-Me 166e2a2cb8 Extract duplicate code 2015-12-18 10:24:02 +03:00
Dmitry-Me ecc2e00a38 Don't proceed to outer scope once there's a match in this scope 2015-12-17 17:31:22 +03:00
Dmitry-Me 6f996142dc Loop variable wasn't really used 2015-12-17 12:54:05 +03:00
Daniel Marjamäki 0cc003830a Revert "Fix Compiler warnings."
This reverts commit cbb7c8b854.
2015-12-13 19:58:27 +01:00
Albert ARIBAUD (3ADEV) b8dd71c577 Factorize toxml() into a single member function
lib/symboldatabase.cpp and lib/tokenize.cpp both
define a static toxml() function. Make it a single
static ErrorLogger::toxml() member function.
2015-12-07 18:21:01 +01:00
PKEuS eb27d3b877 Refactorization: Moved condition out of loop and ran AStyle 2015-12-06 10:40:22 +01:00
Alexander Mai 98f2cd021e #7199 SymbolDatabase::validate() should be run in debug mode and print debug messages. In turn correct some test examples with invalid code. 2015-12-06 08:14:04 +01:00
Alexander Mai ba0859e838 #6981 crash in checkvaarg.cpp (with possible fix). Avoid segfault. Add SymbolDatabase::validate() to allow validating smyboldatabase 2015-12-05 20:55:26 +01:00
PKEuS 32e2fb2f78 Refactorization: Prefer Token::simpleMatch over Token::Match also for non-const patterns. 2015-12-03 13:04:55 +01:00
Alexander Mai 53dbcb956f Small refactoring: use a single complete set for reserved for each C/C++. Replace NULL by nullptr 2015-11-29 13:23:13 +01:00
PKEuS e8522c7883 Small refactorizations:
- #include cleanup
- Use std::array instead of std::vector
- Do not create a stringstream to concatenate 4 strings
- Use std::cout instead of printf
2015-11-29 10:56:44 +01:00
PKEuS 93c02ce826 Fixed compiler error introduced in previous commit and several MSVC warnings 2015-11-28 10:49:08 +01:00
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +01:00
Daniel Marjamäki ca8b15cd6b Fixed #7124 (int32_t etc are recognised as fundamental types, but std::int32_t etc are not) 2015-11-15 17:51:27 +01:00
Daniel Marjamäki ad0d23036c Fixed some cppcheck warnings about methods that can be static/const 2015-11-14 18:43:07 +01:00
PKEuS fdb596fa05 Do not set "pure" flag if function is declared as "= default" (#7101) 2015-11-07 22:21:50 +01:00
PKEuS eb2b0fa0d0 Fixed wrongly detected unconditional scope with C++11-style initialization in SymbolDatabase (#6581) 2015-11-06 10:16:44 +01:00
PKEuS dfdc0f6b99 Support range-based for-loop in SymbolDatabase 2015-10-26 19:20:42 +01:00
Daniel Marjamäki 0aad8af9ae avoid fix for noisy signedness warning 2015-10-11 12:22:37 +02:00
Daniel Marjamäki ac9cb87e04 ValueType: Handle bit operations, sizeof better. Use ValueType in astIsFloat(). 2015-10-11 12:20:40 +02:00
Daniel Marjamäki 5b082aa799 ValueType: struct member 2015-10-11 10:48:08 +02:00
Daniel Marjamäki 9738cc66eb ValueType: function return type 2015-10-11 08:42:31 +02:00
Daniel Marjamäki cf179f82b6 ValueType: Better handling of wide strings 2015-10-11 08:13:30 +02:00
Daniel Marjamäki 0849ad4707 ValueType: Better handling of const 2015-10-10 08:32:45 +02:00
Daniel Marjamäki a500f6f703 Improved handling of 'long double' and address-of in ValueType. Removed Tokenizer::simplifyFloatCasts() to handle float casts better. 2015-10-08 19:50:10 +02:00
Daniel Marjamäki be72b7413a ValueType: Handling of originalTypeName 2015-10-07 20:24:17 +02:00
Daniel Marjamäki c461b58421 astyle formatting
[ci skip]
2015-10-07 19:50:50 +02:00
Daniel Marjamäki 604a9acb48 ValueType: Handling constness 2015-10-07 19:08:26 +02:00
Daniel Marjamäki db31e22316 ValueType: Improved signedness 2015-10-07 18:10:48 +02:00
PKEuS b634a76fcb Added CPPCHECKLIB to two clases and reverted 30a942af0b 2015-10-07 13:38:34 +02:00
Daniel Marjamäki b9036c2ca8 AST types: Fix for 'long long' handling 2015-10-05 19:20:42 +02:00
Daniel Marjamäki f35c24d4af SymbolDatabase: Better handling of valuetypes in AST 2015-10-04 23:27:58 +02:00
Daniel Marjamäki 30a942af0b VS: Attempt to fix build problem with VS 2015-10-04 22:58:00 +02:00
Daniel Marjamäki 399cd0c07b SymbolDatabase: Refactoring AST type information 2015-10-04 20:32:16 +02:00
Daniel Marjamäki 9b253612ca SymbolDatabase: Add type information in AST 2015-10-04 19:42:58 +02:00
Dmitry-Me e9cb3d8c97 Consistent variable name 2015-09-04 17:00:44 +03:00
orbitcowboy c1120c1df4 Merge pull request #672 from Dmitry-Me/fixSpelling
Fix spelling
2015-09-04 15:39:03 +02:00
Dmitry-Me e377a2e9b2 Fix spelling 2015-09-04 16:12:40 +03:00
Dmitry-Me 31014fe334 Omit unneded action 2015-09-04 16:06:20 +03:00
Dmitry-Me a87990901a Better variable name 2015-09-04 11:38:46 +03:00
Martin Ettl 08413f0112 test/cfg: Improved testing of std.cfg. 2015-08-29 00:09:33 +02:00
Simon Martin 101cebbde1 Ticket #6957: Properly handle arrays of pointers in CheckClass::constructors. 2015-08-28 23:06:39 +02:00
PKEuS 39dd71e49b Merge pull request #653 from Dmitry-Me/reduceVariableScope
Reduce variable scope
2015-08-26 14:08:10 +02:00
Dmitry-Me 346f04098c Reduce variable scope 2015-08-26 14:48:19 +03:00
Simon Martin 6fb19b02d0 Properly differentiate arrays of pointers and pointers to arrays. 2015-08-25 21:19:19 +02:00
PKEuS a720153e1e Refactorization: Removed redundant code for syntax error handling in templatesimplifier.cpp and symboldatabase.cpp 2015-08-19 19:29:48 +02:00
Daniel Marjamäki 13cf6be40b dump: use toxml for function names to handle operator& etc 2015-08-18 15:39:15 +02:00
PKEuS ab8afec3eb Refactorizations:
- Avoid unnecessary loop iterations
- Avoid unnecessary condition checking
- Reduced code duplication in symboldatabase.cpp
2015-08-16 14:23:07 +02:00
PKEuS 1627b19dd6 Refactorizations:
- Call std::string::find() with char instead of char* where possible
- Avoid string copying
- Optimized several Token::tokAt/strAt calls
2015-08-16 10:33:51 +02:00
PKEuS 4d80df2f4a Added pointer to Type to Token (similar to Token::Variable() and Token::function()):
- Accessible via Token::type()
- Renamed former Token::type() to Token::tokType()
- Removed SymbolDatabase::isClassOrStruct()
2015-08-15 11:19:21 +02:00
Daniel Marjamäki 0e82730ee4 addons/naming.py: fixed error report for function name 2015-07-28 14:34:37 +02:00
Daniel Marjamäki 5a57e4030a dump: Add Function name attribute 2015-07-28 14:18:58 +02:00
PKEuS 258e3b9dc3 Refactorization: Renamed Token::isOperator() to Token::isOperatorKeyword() to avoid confusion with Token::isOp(), use Token::isOperatorKeyword() in setVarId(). 2015-07-22 13:57:51 +02:00
Robert Reif 4e693f1620 Fixed #6827 2015-07-22 13:57:51 +02:00
amai2012 4a1695c879 #6807 segmentation fault (invalid code) in Tokenizer::simplifyTypedef. #6808 segmentation fault (invalid code) in Tokenizer::simplifyTypedef. Throw InternalError on garbage code 2015-07-01 16:31:49 +02:00
Alexander Mai 6e03e7dca2 Remove some code checking for invalid class hierarchy which got obsolete since 480a5672b0. Run astyle 2015-07-01 07:50:13 +02:00
amai2012 480a5672b0 #6298 stack overflow in Scope::findFunctionInBase (endless recursion). Fix handling of circular class hierarchy 2015-07-01 00:04:01 +02:00
amai2012 0849deed01 #6801 C: FN variable scope, FP unused value?. Fix typo from d7aa65c1fc 2015-06-30 08:46:30 +02:00
Alexander Mai d7aa65c1fc #6800 segmentation fault (invalid code) in SymbolDatabase::SymbolDatabase. Fix null pointer access for invalid C code 2015-06-29 19:56:02 +02:00
amai2012 4a47b8b3ae Refactoring: Better distinguish between C and C++ in a few checks. 2015-06-28 16:49:16 +02:00
Alexander Mai 60f5bd97df Refactoring: missing include added, (potential) multi-threading issue fixed, expose static method to allow unit testing 2015-06-18 19:07:51 +02:00
Alexander Mai a5a835b1e0 #6771 segmentation fault (invalid code) in SymbolDatabase::SymbolDatabase 2015-06-14 22:18:28 +02:00
Alexander Mai 454d4573b4 #6742 segmentation fault (invalid code) in SymbolDatabase::SymbolDatabase. Fix in Type::initBaseInfo() 2015-06-02 20:15:21 +02:00
amai2012 7895f1c2bb #6737 Avoid segfault on garbage code inside Type::initBaseInfo. Disable test TestGarbage::garbageCode58() for #6732 since it triggers memory corruption still 2015-06-02 18:28:43 +02:00
Simon Martin 50e5595845 Ticket #6708: Check that a function name is not a reserved keyword in SymbolDatabase::isFunction instead of later. 2015-05-26 00:28:08 +02:00
Simon Martin 898ba783bf Ticket #6703: Rewrite pattern in SymbolDatabase to avoid crash upon garbage code. 2015-05-23 23:18:59 +02:00
Alexander Mai 7416d6add9 Another fix for handling of final/override specifiers in Tokenizer::simplifyKeyword() including a testcase. Ran astyle 2015-05-23 20:51:15 +02:00
amai2012 7c23f4e611 Merge pull request #596 from simartin/ticket_6620-6685
Ticket #6620, #6685: Reserved keywords cannot be function names.
2015-05-23 13:47:07 +02:00
Alexander Mai e8d84bc6b4 #6700 const vs non-const inside assert() statement. Function matching in symboldatabase did not honor const'ness of a class instance variable 2015-05-23 11:56:11 +02:00
Simon Martin 67eab0cd7c Ticket #6620, #6685: Reserved keywords cannot be function names. 2015-05-23 11:29:58 +02:00
Simon Martin 25aff001e0 Ticket #6675: Fixed pattern detecting C++ 11 delegated constructors. 2015-05-10 11:27:47 +02:00
Matthias Krüger 42f0955e3f Move more setting checks out of loops and use const bools instead. Reorder a few related checks.
Follow up to eedcb6abcb .
2015-04-10 14:31:19 +02:00
Robert Reif 4ceb24630d Fixed #6568: Scope for template class member function missing in symboldatabase 2015-04-09 21:01:47 +02:00
PKEuS d5ad1def40 Removed two unused functions 2015-04-09 20:54:07 +02:00
Frank Zingsheim 1f5265c1bd Fixed #6253 ([False Positive] Variable not initialized in the constructor) 2015-04-06 19:47:21 +02:00
Robert Reif c02acea5bf Fixed #6614 (false positive: (style) The class 'A' does not have a constructor.) 2015-04-04 11:33:25 +02:00
PKEuS e8161aeda6 Refactorized Scope::getVariableList(): Removed scope depth counter, simplified patterns 2015-03-15 12:37:50 +01:00
Robert Reif 27388c3696 Fixed #6546 (False positive uselessAssignmentPtrArg - triggered by throw?) 2015-02-28 16:07:43 +01:00
Robert Reif 130ffc5752 Fixed #6538 (Symboldatabase: improve isFunction) 2015-02-24 06:11:31 +01:00
Daniel Marjamäki 830d1eb3fd Revert "Fixed #6538 (Symboldatabase: improve isFunction)"
This reverts commit d7ef89bbe6.

There was crashes in a Travis job.
2015-02-23 08:07:19 +01:00
Robert Reif d7ef89bbe6 Fixed #6538 (Symboldatabase: improve isFunction) 2015-02-23 06:49:50 +01:00
Dmitry-Me 158a2acc41 Resolve CID 1037075 2015-02-19 17:16:38 +03:00
Robert Reif 323475393b Symboldatabase: improved debug output 2015-02-04 06:08:41 +01:00
PKEuS 27924d4ae2 Improved detection of array dimensions (#6430) 2015-01-31 13:12:06 +01:00
PKEuS b2835051df Refactorization: Renamed Token::Match pattern %var% to %name%, implement new pattern %var% which is true if varId > 0. 2015-01-31 12:32:04 +01:00
PKEuS 3a1bd4a5ad Fixed gcc shadowing warnings 2015-01-30 22:04:26 +01:00
PKEuS dcc1362890 SymbolDatabase: Support std::array (fixes #6401) 2015-01-30 21:56:27 +01:00
PKEuS 5f36c7c914 Improved detection of Type::needInitialization:
- Implement shortcut for C code - all types need initialization there
- Break out of loop faster if we encounter a type that needs initialization (it is sufficient if one member needs initialization)
2015-01-21 10:34:58 +01:00
Robert Reif 56dc0b02ef Fixed #6432 (cppcheck fails to detect ctor - partial template specialization) 2015-01-19 16:15:11 +01:00
Robert Reif 3b8540fdc0 Fixed #6424 (false negative: Use of 'class Ns::C' silence Cppcheck) 2015-01-19 06:38:54 +01:00
Thomas Jarosch fd01cafb1b Clean up redundant pointer operations 2015-01-17 16:29:50 +01:00
Robert Reif 68bb197bcb Destructor detected as constructor resulting in false variable not initialized warnings 2015-01-12 06:11:22 +01:00