Commit Graph

332 Commits

Author SHA1 Message Date
Daniel Marjamäki b4cb2505c3 SymbolDatabase: Add Variable::valueType(). First step to reuse ValueType handling in Variable 2018-06-20 10:00:15 +02:00
Daniel Marjamäki eb978ee192 Refactoring: delete assignment operator 2018-06-19 14:00:50 +02:00
Daniel Marjamäki ad4ce84cf7 Rename private member variables 2018-06-17 17:20:16 +02:00
Daniel Marjamäki d9aeeb1d09 Renamed private member cpp to mIsCpp 2018-06-16 23:30:00 +02:00
Daniel Marjamäki 306b2a9810 Renamed private member defaultSignedness 2018-06-16 23:25:35 +02:00
Daniel Marjamäki 678e3271d4 Rename private flags member to mFlags 2018-06-16 23:11:45 +02:00
Daniel Marjamäki 15f7c26706 Renamed _blankTypes 2018-06-16 20:33:07 +02:00
Daniel Marjamäki 56126d6e2d Renamed _variableList to mVariableList 2018-06-16 20:31:47 +02:00
Daniel Marjamäki e8a00a38ac Rename _scope to mScope 2018-06-16 20:29:17 +02:00
Daniel Marjamäki 78974e9267 Rename _type to mType 2018-06-16 20:25:54 +02:00
Daniel Marjamäki fc6f17ed87 Rename _dimensions to mDimensions 2018-06-16 20:23:58 +02:00
Daniel Marjamäki 363f4ca939 rename _flags to mFlags 2018-06-16 16:14:34 +02:00
Daniel Marjamäki 67b111f11e SymbolDatabase: rename _constness to mConstness 2018-06-16 16:13:26 +02:00
Daniel Marjamäki 5154eb10c6 SymbolDatabase: rename _access 2018-06-16 16:12:27 +02:00
Daniel Marjamäki 7dfd4f61a1 SymbolDatabase: rename _index 2018-06-16 16:11:40 +02:00
Daniel Marjamäki 79ffe1d4fc Rename _tokenizer, _settings, _errorLogger 2018-06-16 16:10:28 +02:00
Daniel Marjamäki 8209c4aebd SymbolDatabase: rename _start and _end 2018-06-16 16:03:36 +02:00
Daniel Marjamäki 311454669f SymbolDatabase: rename _name 2018-06-16 15:57:16 +02:00
IOBYTE 3982c81394 Add support for C++ attribute nodiscard for functions. (#1269) 2018-05-29 21:43:56 +02:00
PKEuS 090a178ed6 Refactorization in SymbolDatabase: Do not redundantly store name in FriendInfo, and store FriendInfo in vector instead of list 2018-05-14 12:18:59 +02:00
IOBYTE 184537884f Don't remove the volatile keyword so we can properly overload functions. (#1218)
* Don't remove the volatile keyword so we can properly overload functions.

I fixed all the checks that had tests that use volatile.  There will
probably be more changes needed due to lack of test coverage for
volatile in some checks.

* Fix unused private function warning.
2018-05-10 07:40:01 +02:00
Daniel Marjamäki 59cc479855 Save bitfield bit counts 2018-05-02 20:55:11 +02:00
IOBYTE c3c1abd05e SymbolDatabase: improve checking of uninstantiated templates (#1196)
* SymbolDatabase: improve checking of uninstantiated templates

* Add bailout and debug warning for '>' token without a link in SymbolDatabase::findFunction()..

Don't crash on bad code simplification from tokenizer.
2018-05-01 07:32:19 +02:00
Daniel Marjamäki ff732e41ac SymbolDatabase: Remove unused Function constructor 2018-04-29 14:57:02 +02:00
Daniel Marjamäki ca8e19c96d SymbolDatabase: Refactor SymbolDatabase: variable list 2018-04-28 09:38:33 +02:00
Daniel Marjamäki f336c2efe7 Refactoring; Renamed Scope::classStart and Scope::classEnd 2018-04-27 22:36:30 +02:00
Daniel Marjamäki 25599a76a7 Handle 'final' specifier better. 2018-04-27 14:57:43 +02:00
Daniel Marjamäki b830f462e6 Added missingOverride checker; Function 'f' overrides function in base class but does not have the 'override' keyword. 2018-04-27 11:12:09 +02:00
Daniel Marjamäki d15b945c9e SymbolDatabase::isFunction: Fix wrong detection function 2018-04-27 10:24:02 +02:00
Daniel Marjamäki e97be9db2f SymbolDatabase: Refactoring, move logic from SymbolDatabase to Function class. Add a Function::isOverride() method. 2018-04-25 12:05:49 +02:00
Daniel Marjamäki 9aeb2aaa17 update doxygen comments 2018-04-25 10:14:57 +02:00
Daniel Marjamäki b94d8fd686 SymbolDatabase: Improve doxygen comments 2018-04-24 13:03:32 +02:00
Daniel Marjamäki e73fe49d3c 4e820b6c4a 2018-04-14 15:46:55 +02:00
Daniel Marjamäki be78e44c3f Revert "I see compilation problems with std::multimap::emplace on a old system so lets avoid that"
This reverts commit 4e820b6c4a.
2018-04-14 15:43:14 +02:00
Daniel Marjamäki 4e820b6c4a I see compilation problems with std::multimap::emplace on a old system so lets avoid that 2018-04-14 15:19:04 +02:00
Daniel Marjamäki f7d65cd735 SymbolDatabase: add constness attribute for Variable 2018-04-12 20:23:34 +02:00
PKEuS d2146844dd Refactorizations:
- Replace several push_back-calls by emplace_back
- Replace some x = x.substr(0, y) calls by x.erase(y)
2018-04-11 09:44:35 +02:00
Daniel Marjamäki 0daa3bba30 ValueType: Improved type handling of containers when [] operator is used 2018-04-06 22:26:35 +02:00
IOBYTE 06133fa3ba Refactor findFunction to unify two ValueFlow paths. (#1149) 2018-04-05 06:46:48 +02:00
Matthias Krüger f009cfc845 fix some typos found by codespell. 2018-02-04 20:53:43 +01:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
IOBYTE cefb2131c7 Add support for simple c++ 11 type ailases like: using INT = int; (#1024)
* Add support for simple c++ 11 type ailases like: using INT = int;

Only types supported by ValueType are supported. Complex types like
function pointers are not supported. Template type aliases are not
supported.

* Fix crash when type in using type alias is simplified away.

This fixes a crash when size_t is replaced with unsigned long in: using
size_t = unsigned long; by the tokenizer.

This does not fix the problem where Tokenizer::simplifyPlatformTypes()
simplifies away size_t in other cases.  This is only a problem when the
new type is different from the platform type.
2018-01-10 22:16:18 +01:00
Iván Matellanes cfeea3d35c Fixed #7331: Detect copy and move constructors with default parameters (#1018) 2018-01-07 14:20:19 +01:00
Sign Bit aaafa72bc8 Use a 'negative cache' for tokens / enumerator checks (#980)
Checking whether a token is an enumerator in all the available scopes
is expensive.  Once we determined that a token is not an enumerator,
skip all the expensive checks.
2017-10-18 18:01:36 +02:00
Florin Iucha 6e737082da Store the defined types in a map, for faster lookup 2017-10-17 09:00:14 +02:00
IOBYTE 352fd7a381 SymbolDatabase: Add support for functions in unions. (#973) 2017-10-15 11:49:36 +02:00
Dmitry-Me f28524fefa Unify variable names 2017-09-15 00:44:59 +03:00
Ayaz Salikhov b8cd7dbb5c Use nullptr instead of 0 or NULL (#936) 2017-08-09 20:00:26 +02:00
Ayaz Salikhov 3cd2f2d092 Don't cast bool to bool 2017-06-01 01:49:40 +03:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
Alexander Mai c1cdcc158f Run astyle. Fix some Doxygen issues 2017-05-06 11:57:02 +02:00
Daniel Marjamäki 1045ece946 dump: refactor valueType dump 2017-04-16 09:11:20 +02:00
Matthias Krüger 79010eecea lib: fix a bunch of warnings about differing function arguments in definition and declaration.
[lib/token.h:72] -> [lib/token.cpp:36]: (style, inconclusive) Function 'Token' argument 1 names different: declaration 'tokensBack' definition 't'.
    [lib/token.h:445] -> [lib/token.cpp:497]: (style, inconclusive) Function 'multiCompare' argument 1 names different: declaration 'needle' definition 'tok'.
    [lib/checkio.h:73] -> [lib/checkio.cpp:1385]: (style, inconclusive) Function 'ArgumentInfo' argument 3 names different: declaration 'isCPP' definition '_isCPP'.
    [lib/checkother.h:216] -> [lib/checkother.cpp:2136]: (style, inconclusive) Function 'checkComparisonFunctionIsAlwaysTrueOrFalseError' argument 2 names different: declaration 'strFunctionName' definition 'functionName'.
    [lib/errorlogger.h:214] -> [lib/errorlogger.cpp:51]: (style, inconclusive) Function 'ErrorMessage' argument 2 names different: declaration 'file0' definition 'file0_'.
    [lib/errorlogger.h:215] -> [lib/errorlogger.cpp:65]: (style, inconclusive) Function 'ErrorMessage' argument 2 names different: declaration 'file0' definition 'file0_'.
    [lib/library.h:327] -> [lib/library.cpp:1043]: (style, inconclusive) Function 'ignorefunction' argument 1 names different: declaration 'function' definition 'functionName'.
    [lib/mathlib.h:112] -> [lib/mathlib.cpp:1275]: (style, inconclusive) Function 'isNullValue' argument 1 names different: declaration 'tok' definition 'str'.
    [lib/preprocessor.h:91] -> [lib/preprocessor.cpp:122]: (style, inconclusive) Function 'setDirectives' argument 1 names different: declaration 'tokens' definition 'tokens1'.
    [lib/symboldatabase.h:860] -> [lib/symboldatabase.cpp:1801]: (style, inconclusive) Function 'argsMatch' argument 1 names different: declaration 'info' definition 'scope'.
    [lib/symboldatabase.h:1171] -> [lib/symboldatabase.cpp:2048]: (style, inconclusive) Function 'addClassFunction' argument 1 names different: declaration 'info' definition 'scope'.
    [lib/symboldatabase.h:1174] -> [lib/symboldatabase.cpp:2208]: (style, inconclusive) Function 'addNewFunction' argument 1 names different: declaration 'info' definition 'scope'.
    [lib/symboldatabase.h:1090] -> [lib/symboldatabase.cpp:3648]: (style, inconclusive) Function 'findVariableType' argument 2 names different: declaration 'type' definition 'typeTok'.
    [lib/symboldatabase.h:1101] -> [lib/symboldatabase.cpp:4308]: (style, inconclusive) Function 'findType' argument 1 names different: declaration 'tok' definition 'startTok'.
    [lib/symboldatabase.h:1176] -> [lib/symboldatabase.cpp:4349]: (style, inconclusive) Function 'findTypeInNested' argument 1 names different: declaration 'tok' definition 'startTok'.
    [lib/symboldatabase.h:1193] -> [lib/symboldatabase.cpp:4501]: (style, inconclusive) Function 'setValueType' argument 2 names different: declaration 'enumerators' definition 'enumerator'.
    [lib/path.h:159] -> [lib/path.cpp:247]: (style, inconclusive) Function 'isCPP' argument 1 names different: declaration 'extensionInLowerCase' definition 'path'.
    [lib/path.h:145] -> [lib/path.cpp:266]: (style, inconclusive) Function 'acceptFile' argument 1 names different: declaration 'filename' definition 'path'.
2017-04-03 00:06:46 +02:00
IOBYTE 7cae057615 Add missing varid or variable for member variables.
Add an optional extended description…
2017-03-30 10:07:58 +02:00
Daniel Marjamäki 5fb0f46a3a ValueType: Hide assignment operator 2017-03-24 13:38:45 +01:00
PKEuS f4c0ab5dd5 SymbolDatabase: Match function overloads by using ValueType information by running a second pass of the function pointer assignment routine. 2017-03-24 12:19:29 +01:00
Robert Reif fda1f02dab long double is a floating point type. 2017-03-22 19:11:40 -04:00
Robert Reif f099c6a110 Refactor symbol database value type support by making setValueTypeInTokenList and setValueType member functions of SymbolDatabase. Class variables are no longer passed around as parameters but accessed directly which simplifies the code. There should be no functional change. 2017-03-21 21:55:22 -04:00
Daniel Marjamäki ab7cf5d215 ValueType: set ValueType for method that returns iterator 2017-03-05 14:53:32 +01:00
Daniel Marjamäki 115ea08544 ValueType: Allow that type is library-container 2017-03-05 02:09:52 +01:00
Daniel Marjamäki 995d875cb2 SymbolDatabase: Refactoring 2017-03-01 18:09:50 +01:00
Daniel Marjamäki beaf29c158 SymbolDatabase: Update some properties for auto variables 2017-02-27 23:04:25 +01:00
Daniel Marjamäki a184d5d421 SymbolDatabase: Refactoring 2017-01-01 11:34:05 +01:00
Daniel Marjamäki 17aaecbd6b ValueFlow: Improved handling of sizeof 2016-12-18 14:03:48 +01:00
Daniel Marjamäki 0b3751520b Add a check for float conversion overflows 2016-11-22 22:37:13 +01:00
Frank Zingsheim c8ff96fe8f Fixed #6180 (Usage of variable after std::move or std::forward) 2016-11-20 15:14:49 +01:00
Robert Reif 1e999e0cfe Fixed #7697 ((debug) Executable scope 'B' with unknown function.) 2016-08-19 19:06:15 +02:00
Robert Reif 73e1378af8 Fixed #7661 (False positive: Function parameter 'e' should be passed by reference.) 2016-08-13 21:25:57 +02:00
Robert Reif 55b3f0bf38 Fixed #752 (SymbolDatabase: Does not match function if redundant keywords mismatch (C++)) 2016-08-04 09:06:32 +02:00
Robert Reif 891e21b478 Fixed #7458 (SymbolDatabase: Wrong overloaded function is picked) 2016-08-02 08:58:11 +02:00
Daniel Marjamäki 09b6568ea2 Fixed #7646 (podtypes do not get proper valuetype) 2016-07-31 19:47:34 +02:00
Daniel Marjamäki 0ddeac0429 refactor (use ast) and improve CheckOther::checkRedundantAssignment (warn about global variables unless they are volatile, handle arrays in lhs better) 2016-07-18 12:43:23 +02:00
PKEuS 801fd8f96a Support trailing return types (C++11) 2016-07-17 15:47:50 +02:00
PKEuS 44a19b527e Use ValueFlow and SymbolDatabase to detect buffer overflows with new and malloc, improving support for enums (#7576) 2016-07-08 20:53:08 +02:00
Daniel Marjamäki 54be403f64 Fixed #7026 (Cppcheck does not recognizes the use of a variabile inside lambda function) 2016-05-26 18:07:56 +02:00
Daniel Marjamäki 38741868b5 Fixed #3989 (false positive: memory leak (inline function)) 2016-05-26 17:42:27 +02:00
Daniel Marjamäki 7591a57587 Removed redundant valuetype debug output 2016-05-14 20:11:57 +02:00
PKEuS 0bf85f9aa5 ValueType: Support integers defined in libraries (#7394) 2016-05-04 15:39:56 +02:00
Daniel Marjamäki dc2a92263a Fixed #7426 (RFC: time to replace simplifyEnum?) 2016-04-22 06:02:54 +02:00
Daniel Marjamäki d964825c9f ValueType: Add debug output that is shown when --verbose is used 2016-02-15 16:18:24 +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 d19b5031fa Refactorization: Removed unused function. 2016-02-02 11:46:42 +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
PKEuS 8f493612e6 Refactorization: Removed unused function declaration from Tokenizer and fixed prototype of SymbolDatabase::cppcheckError 2016-01-09 09:34:31 +01:00
PKEuS 37fefe3479 Removed non-standard code annotations with __attribute__ 2016-01-09 09:33:56 +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
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 b457ceef0e Settings: Added defaultSign 2016-01-01 17:33:59 +01:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02:00
Daniel Marjamäki c5c386ceb8 ValueType: Handle void pointers 2015-12-29 19:58:51 +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
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
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +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
Daniel Marjamäki 5b082aa799 ValueType: struct member 2015-10-11 10:48:08 +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 604a9acb48 ValueType: Handling constness 2015-10-07 19:08:26 +02:00