Commit Graph

457 Commits

Author SHA1 Message Date
IOBYTE fcde1d80e9 Fix #8382 (Syntax error when scanning code with template and attribute) (#1089)
* Fix #8382 (Syntax error when scanning code with template and attribute)

This commit only addresses #8382. There are issues concerning which
versions of C++ should be supported and also generic C++ 14 attribute
support which can be revisited later.

* Remove all C++ style attributes.

Remove all C++ style attributes when C++ version is 11 or greater.
Rename simplify function to simplifyCPPAttributes.
Handle more cases of roreturn function attribute.
2018-02-16 22:25:51 +01:00
IOBYTE 3159d151d3 Fix symbol database crash on template type aliases by ignoring them. (#1045) 2018-01-21 21:22:26 +01:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
IOBYTE 03603c85cf Fixed #8331 (stack overflow: daca: firefox-58.0b14) (#1027) 2018-01-12 08:19:21 +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
Martin Ettl 53fbfc9fdb test: Various micro optimizations: Replaced std::string() with std::string(). Use std::string::clear() instead of s = and prefer std::string::empty() instead of (s == ) for checking a string is empty. 2018-01-05 22:03:49 +01:00
Robert Reif 69b75c43b4 SymbolDatabase: fix wrong type in union test. 2017-10-15 09:45:02 -04:00
IOBYTE 352fd7a381 SymbolDatabase: Add support for functions in unions. (#973) 2017-10-15 11:49:36 +02:00
Dmitry-Me cad30446e4 Resolve C4800 2017-10-14 22:50:56 +03:00
Ayaz Salikhov be2c65eb58 Simplify int vs bool 2017-10-08 07:54:39 +02:00
Daniel Marjamäki fe0a514a7c Fix testrunner 2017-09-16 02:13:48 +02:00
Dmitry-Me 6303437163 Resolve C4800 2017-08-15 17:42:56 +03:00
Robert Reif 354a773bfe Fix #8020 (ValueType: no value type for iterator + constant) 2017-07-16 11:27:32 -04:00
Daniel Marjamäki fabe07ffd6 Merge pull request #924 from IOBYTE/master
Fixed #6985 (SymbolDatabase: Function pointer not set when calling bas…
2017-07-16 14:04:25 +02:00
Robert Reif b0aec042a6 Fixed #6985(SymbolDatabase: Function pointer not set when calling base class function)
Use using namespace when looking up types.
2017-07-15 19:14:15 -04:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
PKEuS 68d77b73da SymbolDatabase: Fixed parsing of unnamed arguments, properly detect pointers (#8052) 2017-05-07 09:03:58 +02:00
Robert Reif e2bfe1c0ec Fixed #8044: Crash below SymbolDatabase::setValueType 2017-05-01 14:12:50 -04:00
IOBYTE 8a668aa860 Add missing else that could cause an extra try scope to be added to the scope list (#8025)
Add an optional extended description…
2017-04-30 08:58:41 +02:00
Robert Reif 78ad9825af Add support for auto variables in regular for loop. 2017-04-21 15:25:02 -04:00
Robert Reif 0ff8e49b69 Add support for auto variable initialized from function return type. 2017-04-20 15:22:57 -04:00
Robert Reif 69d18d9c29 Fix #7963: crash; Variable::setFlag ; gecko-dev , dom/canvas/WebGLTransformFeedback.cpp 2017-04-20 10:03:29 -04:00
Matthias Krüger 494f64cb88 tests: fix some self-check findings about functions that can be static.
Was:
[test/testtype.cpp:223]: (performance, inconclusive) Technically the member function 'TestType::removeFloat' can be static.
[test/testsymboldatabase.cpp:61]: (performance, inconclusive) Technically the member function 'TestSymbolDatabase::getSymbolDB_inner' can be static.
[test/teststl.cpp:1437]: (performance, inconclusive) Technically the member function 'TestStl::getArraylength' can be static.
2017-04-09 17:28:00 +02:00
Daniel Marjamäki fd2651909c Fixed #7978 (ValueType: container type not set properly) 2017-04-06 07:07:20 +02:00
Daniel Marjamäki fee86b9684 ValueType: Better handling of 'new Container' 2017-04-05 22:05:29 +02:00
Daniel Marjamäki 92fe210217 tweaked TestSymbolDatabase test case for unknown type. 2017-04-02 15:38:06 +02:00
Daniel Marjamäki b7dcdc00d0 Fixed #7970 (ValueType: no types set below 'new std::string') 2017-04-01 22:22:37 +02:00
PKEuS ea215c3b7b Fixed false positives in CheckClass::checkConst() due to unmatched function overloads
Fixed function matching if constness mismatches
2017-04-01 10:19:32 +02:00
Daniel Marjamäki 164df2aa7b Fixed #7966 (ValueType: wrong type for gcc initialization {[1]=..}) 2017-03-31 09:41:38 +02:00
Daniel Marjamäki 2da3123db2 Fix ValueType. The '[' in variable declaration is not a dereference. 2017-03-30 11:01:29 +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
Robert Reif c96e8daebc Don't change varid of member variables. 2017-03-25 10:59:35 -04: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 bc87e874e9 Add variable and type information for auto and auto variables in range based for loops of containers. 2017-03-23 20:14:49 -04:00
Robert Reif 7adfb6e0e4 Add variable and type information to tokens for C array range based for loops. 2017-03-23 19:48:20 -04:00
Robert Reif f8dd6ee014 Fix test code so it compiles. 2017-03-23 19:16:15 -04:00
Robert Reif 662bc6f846 Add variable or type information to auto and auto variable tokens. Changing the auto variable type requires rerunning the variable pointer pass to correct the symbol database for the new type. 2017-03-22 22:09:40 -04:00
PKEuS 8a3fb4dd6c SymbolDatabase: Fixed return type token detection for template member functions (#7945) 2017-03-16 20:47:24 +01:00
PKEuS bcba27fbb9 SymbolDatabase: Removed unnecessary bailout in function matching for pointers in function overload matching 2017-03-15 18:45:33 +01:00
PKEuS b27ba72fdd SymbolDatabase: Support function overload matching for member variables (#7932) 2017-03-15 18:37:22 +01:00
Daniel Marjamäki f3c0461001 ValueType: handling scoped types in 'new ...' 2017-03-05 10:24:51 +01:00
Daniel Marjamäki e0dd0a82ed ValueType: refactor and improve handling of 'new ...' 2017-03-05 10:02:47 +01:00
Robert Reif e02b2c4483 ValueType: handle new nothrow 2017-03-05 02:13:00 +01:00
Daniel Marjamäki 920398615d ValueType: handle scoped types in parsedecl 2017-03-05 01:21:02 +01:00
Daniel Marjamäki 12fe4a8b3e Fixed #7885 (ValueType: Wrong type for large hexvalue (platform=win32A)) 2017-03-04 14:19:14 +01:00
Daniel Marjamäki 45c5860ca4 Fixed #7926 (Memory Leak with auto not detected) 2017-03-02 22:24:26 +01:00
Daniel Marjamäki 51b5f1c286 Fixed #7931 (crash: SymbolDatabase: Variable::setFlag) 2017-03-01 17:13:22 +01:00
PKEuS 85768f1829 SymbolDatabase: Overload matching with boolean literals as argument and with arbitrary null-pointers 2017-02-28 22:43:47 +01:00
PKEuS 942644fde6 SymbolDatabase: Overload matching with character literals as argument 2017-02-28 22:08:41 +01:00
Daniel Marjamäki beaf29c158 SymbolDatabase: Update some properties for auto variables 2017-02-27 23:04:25 +01:00
Daniel Marjamäki 994f6b684d ValueType: initial handling of new 2017-02-27 20:57:28 +01:00
Daniel Marjamäki 7ecd5db8fb ValueType: Handle auto in range for loop 2017-02-27 02:09:33 +01:00
Daniel Marjamäki 2da360eec5 ValueType: Handle 'auto *p = ..' 2017-02-26 22:43:10 +01:00
Daniel Marjamäki dad455c0dd ValueType: Handle 'auto'. First fix for #4345 2017-02-26 20:02:57 +01:00
PKEuS c1d8fd7f13 SymbolDatabase: Better handling of pointers in findFunction(), supporting const pointers and std::string overloads 2017-02-26 11:36:04 +01:00
PKEuS 4a27376694 SymbolDatabase: Implement two-stage fallback mechanism for matching function overloads, increasing matching accuracy 2017-02-25 23:12:00 +01:00
PKEuS 3f1e2b4270 More conservative fallback for function overload matching 2017-02-24 20:56:47 +01:00
PKEuS 4e28d40bf0 Fixed matching long long overload to function call f(0) 2017-02-24 20:33:52 +01:00
Robert Reif 8e0f1ec788 Fixed #7909 (Crash in CheckMemoryLeakInClass) 2017-02-20 23:09:35 +01:00
Robert Reif 4123b457d7 Fixed #7441 (SymbolDatabase: No scope when function return type not specified) 2017-01-06 11:53:17 +01:00
Daniel Marjamäki 4558701c08 varid: don't generate varid and symboldatabase variable for function call parameter 2016-12-18 20:16:38 +01:00
Daniel Marjamäki c12cb69cc2 ValueType: Handle function pointers 2016-12-04 16:02:50 +01:00
PKEuS 36d12d7866 SymbolDatabase: Function::retDef should not point at "static" or "extern" 2016-11-28 17:23:39 +01:00
Daniel Marjamäki 21364b4401 Refactoring fix for #7816 2016-11-21 13:54:59 +01:00
Daniel Marjamäki 74fa69fe5e Fixed #7821 (syntax error, first token is &) 2016-11-20 17:59:50 +01:00
Daniel Marjamäki 5b377ea2e4 Fixed #7821 (segmentation fault, invalid last token) 2016-11-20 14:15:51 +01:00
Daniel Marjamäki 79fc332511 Fixed #7810 (SymbolDatabase: method with redundant scope info) 2016-11-17 22:45:50 +01: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 4587dfffd8 Fix -Wshadow warnings 2016-10-17 15:45:16 +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
Robert Reif bf7ef56ef5 Fixed #7713 (False positive: %hhu in format string (no. 1) requires 'unsigned char' but the argument type is 'signed int'.) 2016-08-26 19:47:36 +02:00
Robert Reif 62ac40fc5e Fixed #7706 ((debug) Executable scope 'foo' with unknown function.) 2016-08-20 22:43:27 +02:00
Robert Reif 1dd1f6dd6a Fixed #7673 ((debug) Executable scope 'foo' with unknown function.) 2016-08-20 17:56:48 +02:00
Daniel Marjamäki 8a66535399 Fixed #7694 (ValueType: 1.23L) 2016-08-20 08:44:53 +02:00
Robert Reif b56c765a45 Fixed #7703 ((debug) Executable scope 'foo' with unknown function.) 2016-08-20 07:43:15 +02: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 fc1a755100 Fixed #7666 (Executable scope with unknown function.) 2016-08-09 14:02:06 +02:00
Robert Reif cdfe92b753 Fixed #7657 (False positive: Function parameter 'c' should be passed by reference.) 2016-08-06 10:27:00 +02:00
Daniel Marjamäki fe3abd678f Revert "Fix potential null pointer dereference"
This reverts commit 6ca76ff965.
2016-08-04 10:40:07 +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
Dmitry-Me 6ca76ff965 Fix potential null pointer dereference
This was CID 1360399
2016-08-03 18:44:15 +03:00
Robert Reif b40edca62f Fixed #7387 (SymbolDatabase: Wrong overloaded function is picked) 2016-08-02 23:34:11 +02:00
Robert Reif b9030bcfcd Fixed #7650 (SymbolDatabase: Wrong Token::type(), enum and class with same name) 2016-08-02 23:30:46 +02:00
Robert Reif b44f448acc Fixed #7649 (SymbolDatabase: Wrong overloaded function is picked for char and wchar_t) 2016-08-02 18:54:01 +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
PKEuS fc1603eb9b MathLib, ValueType: Support integer suffix "i64" 2016-07-26 13:19:53 +02:00
Daniel Marjamäki 9082c097c8 Fixed testing of #7615. The code is not garbage so move it from TestGarbage to TestSymbolDatabase 2016-07-26 09:10:10 +02:00
PKEuS 2e2800f5bd Fixed several MSVC warnings 2016-07-24 12:36:36 +02:00
Daniel Marjamäki f50f024873 Revert "Resolve CID 1357639"
This reverts commit e3b0c3a974.

It's not a proper fix. I want that Cppcheck detects this bug also. I want to keep the CID open until Cppcheck can detect it.
2016-07-21 09:52:51 +02:00
Dmitry-Me e3b0c3a974 Resolve CID 1357639 2016-07-21 10:34:07 +03:00
Daniel Marjamäki a68da1a725 ValueType: Set valuetype for sizeof argument 2016-07-20 09:39:48 +02:00
PKEuS 801fd8f96a Support trailing return types (C++11) 2016-07-17 15:47:50 +02:00
Robert Reif eca805ba3b ValueFlow: Fixed constant folding of sizeof(enum) and sizeof(enumerator) (#7564) 2016-07-08 20:39:34 +02:00
Robert Reif 583b340034 enum: set the return type of derived class functions returning enums defined in a base class. 2016-06-05 14:08:33 +02:00
Robert Reif f4dd43a71a Fixed #7523 (Scope::findEnumerator(): does not find enum constant from other enum type) 2016-05-29 14:45:45 +02:00
Robert Reif 66cacde3db Fixed #7513 (value flow of array dimension with enum doesn't always work) 2016-05-26 11:25:50 +02:00
PKEuS c7b3836379 Small refactorizations:
- Optimized performance of several functions by adding pre-checks
- Simplified some code
- Fixed VS warning in testsymboldatabase.cpp
2016-05-25 15:30:49 +02:00
Daniel Marjamäki ae97f53244 Fixed #6184 (ValueType: overloaded < operator) 2016-05-25 13:56:36 +02:00
Daniel Marjamäki 397480f929 Fixed #7376 (ValueType: wrong type for container element) 2016-05-23 18:53:59 +02:00
Daniel Marjamäki df6a66deed SymbolDatabase: Add test that makes sure enum constant values are calculated properly. Related with ticket #7493. 2016-05-12 12:07:40 +02:00
Daniel Marjamäki a167a2d242 TestSymbolDatabase: Add some tests for the new enum handling 2016-05-09 18:34:24 +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 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 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
PKEuS b65cacf4b1 Tokenizer::simplifyStaticConst(): Support "struct" and operator:: (#7403) 2016-05-04 12:33:19 +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
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
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 8dccbfefcf ValueType: handle lowercase number suffix, for instance '0ll' 2016-01-03 13:34:47 +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
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
orbitcowboy ad17a0d721 testsymboldatabase: Improved constness of local variable. 2015-12-15 13:29:58 +01:00
orbitcowboy d93f2994d4 testsymboldatabase: Removed useless call of GetSymbolDatabase. 2015-12-15 13:11:20 +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
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
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 24882fb53a Fixed VarId accidentially assigned to case labels. 2015-10-26 21:24:53 +01:00