Commit Graph

704 Commits

Author SHA1 Message Date
Paul Fultz II f1cc3ada86
Refactor valueFlowTerminatingCondition to handle inner conditions and complex conditions (#3060) 2021-01-21 20:18:53 +01:00
IOBYTE d39956414f
fix #10122, #10124 and #10125 (debug: Executable scope 'x' with unknown function.) (#3073) 2021-01-21 19:47:51 +01:00
IOBYTE 952857195b
fix out of line member functions using global namespace (#3063) 2021-01-19 18:52:47 +01:00
IOBYTE fde5994cc3
fix #10061 (debug: Executable scope 'x' with unknown function.) (#3062) 2021-01-18 19:01:04 +01:00
Rikard Falkeborn bedf3118ef
library: Refactor to use enum class (#3026) 2021-01-08 10:29:01 +01:00
IOBYTE c085151eb0
fix exprengine.cpp:2833:18: debug: Executable scope 'executeAllFunctions' with unknown function. (#3019) 2021-01-06 17:29:23 +01:00
IOBYTE 22b10f8987
fix token.cpp:745:19: debug: Executable scope 'getStrSize' with unknown function. (#3015) 2021-01-05 22:07:53 +01:00
IOBYTE 23da5c9815
fix #9885 (SymbolDatabase: function lookup fails calling variadic method) (#3002)
Co-authored-by: Robert Reif <reif@FX6840>
2021-01-03 11:17:32 +01:00
Ken-Patrick Lehrmann aad723bf3a
Fix false positive AssignmentIntegerToAddress (#2971) 2020-12-24 19:57:02 +01:00
IOBYTE 2ecab32fbe
fix debug printing of valuetype name with namespaces (#2968) 2020-12-21 19:47:54 +01:00
Wolfgang Stöggl 079255d913
Fix gcc11 build errors (#2963) 2020-12-19 21:54:19 +01:00
IOBYTE f2cf11682a
fix #10040 (symbolDatabaseWarning: debug: Executable scope 'x' with unknown function.) (#2955) 2020-12-18 07:46:01 +01:00
Daniel Marjamäki cb7eee2aa9 SymbolDatabase: Improved types for 'std::string + x' 2020-12-05 13:24:21 +01:00
Daniel Marjamäki 009ad11b3e SymbolDatabase: set proper valuetype for string addition result (#9161) 2020-12-01 20:16:39 +01:00
Daniel Marjamäki 2cd8ea83a7 Fixed #9860 (unused template not removed properly by default) 2020-11-22 16:43:36 +01:00
Daniel Marjamäki 22d6160624 Improve handling of decltype 2020-11-16 20:11:26 +01:00
Daniel Marjamäki 8b0699cd6a Revert "improved decltype() handling"
This reverts commit 6e8f77c519.
2020-11-15 21:32:05 +01:00
Daniel Marjamäki 6e8f77c519 improved decltype() handling 2020-11-15 20:58:17 +01:00
Daniel Marjamäki ae1b9cb14e SymbolDatabase: Improved function matching in C code 2020-11-04 07:17:17 +01:00
Rikard Falkeborn d7a8e25d92
Fix #9647: Set correct enum value (#2856)
* Tokenize: Set varId for variables in enum

Set varIds in enum values. It was previously disabled in 5119ae84b8
to avoid issues with enums named the same as global variables. Take care
to only set varids to variables used to set the value of an enumerator,
not the enumerator itself. This is somewhat complicated by the fact that
at the time this happens, astOperand1(), astOperand2(), astParent() etc
are not set. The current implementation is not perfect, for example in
the code below, y will not have a varid set, but x and z will. This is
deemed sufficient for now.

            int x, y, z;
            enum E { a = f(x, y, z); };

* Fix #9647: Value of enums with variables as init values

C++ allows enum values to be set using constexprs, which cppcheck did
not handle before. To solve this, add a new pass to valueflow to update
enum values after global consts have been processed. In order to do so,
I moved all settings of enum values to valueflow. After setting the enum
values, we need another call to valueFlowNumber() to actually set users
of the enums.

There is still room for improvements, since each pass of
valueFlowGlobalConstVar() and valueFlowEnumValue() only sets variables
that are possible to set directly, and not if setting the value of a
variable allows us to set the value of another. For example

	constexpr int a = 5;
	constexpr int b = a + 5;
	enum E { X = a };
	constexpr E e = X;

Here both b and e will not have their values set, even though cppcheck
should be possible to figure out their values. That's for another PR
though.

This was tested by running test-my-pr.py with 500 packages. The only
difference was one error message in fairy-stockfish_11.1, where cppcheck
now printed the correct size of an array instead of 2147483648 which I
assume is some kind of default value. In that package, using a constexpr
when setting enum values is common, but as mentioned, there was no
change in the number of warnings.
2020-10-22 07:45:04 +02:00
Rikard Falkeborn 2624d791e6
Symboldatabase: Don't set unknown enum values (#2852)
Previously, if an enum value was set to a value unknown to cppcheck, the
next enum value would erroneously be set to the last set value plus one
(or zero, if no enum value had been set before). This partially fixes
Trac ticket #9647, in the sense that it no longer sets wrong values for
these enum values. Further improvements to this would be to set the
correct values instead. It also fixes the false positive mentioned in the
comments in the ticket.
2020-10-18 20:41:36 +02:00
Rikard Falkeborn 33739d23aa
Fix #9941: Return value type of library functions returning unsigned (#2848)
Fix return value types of library functions returning unsigned.
Previously, the valueType of auto x = f() would be signed even if f()
was specified to return an unsigned type.

This fixes #9941, which is a regression in cppcheck 2.2 compared to 2.1.
The regression was introduced in 32df807b22.
2020-10-16 07:56:31 +02:00
Daniel Marjamäki c3517924d0 Clang import testing: Compare AST 2020-10-04 11:27:31 +02:00
Daniel Marjamäki 1251d35ba4 Fix SymbolDatabase for 'extern const char ( * x [ 256 ] ) ;' 2020-10-02 08:25:43 +02:00
Daniel Marjamäki e03a8e1dc1 Fixed #9892 (Crash: endless recursion in Token::typeDecl for expression 'auto combo = widget->combo = new Combo{};') 2020-09-11 21:29:48 +02:00
Paul b26c581556 Fix issue 9888: False positive: Using reference to dangling temporary with std::move 2020-09-10 22:38:31 -05:00
Daniel Marjamäki 136ac2c643 Fixed #9266 (handle operator() better) 2020-09-06 21:02:06 +02:00
shaneasd 9712c136bd
make result of <<|>> an xvalue (#2775) 2020-09-05 12:07:06 +02:00
Daniel Marjamäki 5acd6fcdc8 astyle formatting 2020-09-03 18:55:40 +02:00
shaneasd 08ea6435ac
fix false positives in constParameter (#2758) 2020-09-03 18:44:44 +02:00
Daniel Marjamäki 3fe46239cf SymbolDatabase; Refactoring, use Tokenizer::isFunctionHead to skip function attributes 2020-09-03 11:21:12 +02:00
Dan 974b6fb8e5
Add test cases for assign operators with default implementation (#2767) 2020-09-03 07:29:54 +02:00
Daniel Marjamäki f5ace9ffbe SymbolDatabase; Improved ValueType when container methods items 2020-06-26 22:47:28 +02:00
Daniel Marjamäki 3f1f62e078 Fixed #9746 (SymbolDatabase: Wrong valueType for return) 2020-06-10 21:13:53 +02:00
Oliver Stöneberg 4f68d85633
optimized non-matchcompiled Token::simpleMatch() a bit (#2640) 2020-05-26 20:13:56 +02:00
PKEuS d6390dbd14 Optimization: Improved performance of simplifyTypedef for code with lots of typedefs
20% performance gain when checking ExtremeTuxRacer sourcecode (with glext.h available)
2020-05-19 08:35:13 +02:00
Daniel Marjamäki 08ddd84780 Update copyright year 2020-05-10 11:16:32 +02:00
Daniel Marjamäki 3e0218299b Revert "Update copyright year"
This reverts commit 6eec6c4bd5.
2020-05-10 11:13:05 +02:00
Daniel Marjamäki 6eec6c4bd5 Update copyright year 2020-05-10 11:11:34 +02:00
Daniel Marjamäki 5eeeba97eb SymbolDatabase: Better handling of function pointer function argument 2020-05-02 17:04:54 +02:00
Oliver Stöneberg 1af959af2c
fixed -Wextra-semi-stmt Clang warnings (#2553)
* fixed -Wextra-semi-stmt Clang warnings

* adjusted REDIRECT macro to require a semicolon

* testmathlib.cpp: rolled back accidental change
2020-04-21 17:27:51 +02:00
Daniel Marjamäki 219180b00a Fixed #9038 (Auto type with explicit pointer symbol detected as integer) 2020-04-19 20:08:47 +02:00
Daniel Marjamäki e8bbfdbfee Fixed #9559 (Multiple checks to std::atomic are not redundant) 2020-04-19 17:29:40 +02:00
Oliver Stöneberg 2c1e36e63e
cleaned up includes based on include-what-you-use (#2600)
* cleaned up includes based on include-what-you-use

* check.h: trying to work around Visual Studio 2012 bug

* fixed Visual Studio compilation
2020-04-13 13:44:48 +02:00
Daniel Marjamäki 97b04ba9a7 Syntax check: Using keyword in global scope 2020-04-11 17:36:22 +02:00
Daniel Marjamäki f01783238e Fixed #9596 (False positive: Returning an integer in a function with a pointer return type auto handling) 2020-04-04 20:03:48 +02:00
Sebastian b8432b7e23
testsymboldatabase.cpp: Fix AppVeyor build error (#2568) 2020-03-10 12:26:00 +01:00
Daniel Marjamäki f093d23a36 SymbolDatabase: Fixed addArguments 2020-03-09 15:13:50 +01:00
Daniel Marjamäki cdee62c032 AST: Fixed AST for struct cast '(struct T){...}' 2020-03-08 16:21:22 +01:00
Daniel Marjamäki 5ea01c5d60 Fix Cppcheck warning 2020-03-08 10:02:46 +01:00
Daniel Marjamäki 5376ba1701 AST: Throw validation exception if ternary operator is missing operands 2020-03-07 21:46:38 +01:00
Daniel Marjamäki 6f6f9dd5bc Tokenizer: Throw unknownMacro in non-executable scope 2020-02-19 21:12:58 +01:00
Rikard Falkeborn f6e7fb4bd9
Bugfix valuetype for some integer constants (#2545) 2020-02-19 07:51:39 +01:00
Daniel Marjamäki 95ac456e13 Fixed #9582 (false positive "error: Out of bounds access" with std::array and constant) 2020-02-19 07:36:02 +01:00
Daniel Marjamäki e31b2f8b73 SymbolDatabase; Set smart pointer type in Variable valueType 2020-02-14 09:40:27 +01:00
Daniel Marjamäki 18124fe248 Fixed #9591 (SymbolDatabase: decltype) 2020-01-29 17:29:40 +01:00
Daniel Marjamäki 830f901206 Fixed #9586 (Valuetype: Wrong type for 'true << 1') 2020-01-27 11:46:59 +01:00
Dmitry-Me 895910b769 Fixed #7159 (wrong handling of function parameters) 2019-12-31 18:26:12 +03:00
Dmitry-Me 9133f9fe75 Improve test coverage for function arguments count 2019-12-20 18:28:32 +03:00
IOBYTE ec4c979cd8 fix daca error: Internal Error: Invalid syntax (#2452)
* fix daca error: Internal Error: Invalid syntax

* fix cppcheck warnings
2019-12-18 11:48:36 +01:00
Daniel Marjamäki 6d1c84e3a6 Fixed #9449 (SymbolDatabase: Function lookup fails when string literal is converted to bool) 2019-10-30 21:05:42 +01:00
IOBYTE 6b4a3bc830 fix #9431 (Invalid syntax error on valid C++ code) (#2298) 2019-10-26 17:39:46 +02:00
Georgy Komarov 72f07c8a33 Add MISRA checks for rules 21.1 and 21.12 (#2284)
* Add MISRA 21.1 check

This also required add static field for functions in symboldatabase.

* Add MISRA R21.12

* Use newer ASSERT macroses in tests
2019-10-26 08:32:46 +02:00
Daniel Marjamäki dedee2b173 SymbolDatabase: Better ValueType handling for containers 2019-10-23 19:54:59 +02:00
Daniel Marjamäki 87f65230ae SymbolDatabase: Better valuetype handling of container addition 2019-10-23 12:42:46 +02:00
Daniel Marjamäki f131a99ae3 SymbolDatabase: Improved ValueType in range for loop 2019-10-23 11:52:29 +02:00
Daniel Marjamäki c5c07b61a6 SymbolDatabase: Fix type for expression 'x = uint8_t(a[b])' 2019-10-22 20:40:36 +02:00
Daniel Marjamäki 223ceeb97f SymbolDatabase: Do not set constructor flag for function in namespace 2019-10-20 18:12:52 +02:00
Daniel Marjamäki 82d8f3e7f5 SymbolDatabase: Fix crash if std::shared_ptr type is only forwarded, not defined 2019-10-20 17:00:15 +02:00
Rikard Falkeborn 5c061c1c12 Set correct type and size of string and char literals (#2275)
* Set correct type and size of string and char literals

Use that string and char literal tokens store the prefix. This makes
it possible to distinghuish between different type of string literals
(i.e., utf8 encoded strings, utf16, wide strings, etc) which have
different type.

When the tokens holding the string and character values have the correct
type, it is possible to improve Token::getStrSize() to give the correct
result for all string types. Previously, it would return the number of
characters in the string, i.e., it would give the wrong size unless
the type of the string was char*.

Since strings now can have different size (in number of bytes) and
length (in number of elements), add a new helper function that returns
the number of characters. Checkers have been updated to use the correct
functions.

Having the size makes it possible to find more problems with prefixed
strings, and to reduce false positives, for example in the buffer
overflow checker.

Also, improve the stringLiteralWrite error message to also print the
prefix of the string (if there is one).

* Add comment and update string length
2019-10-20 07:11:57 +02:00
IOBYTE 5658dfcaf3 better fix for #9392 that also handles namespaces (#2282) 2019-10-18 18:05:48 +02:00
Daniel Marjamäki 7d6d561c84 SymbolDatabase: Better handling of function call using smart pointer 2019-10-15 19:33:25 +02:00
Daniel Marjamäki 4a4b4963cc SymbolDatabase: Fix function lookup for '::func()' 2019-10-15 12:39:02 +02:00
Daniel Marjamäki bf61bcf402 ValueType: Set ValueType for constructor calls 2019-10-14 09:19:16 +02:00
IOBYTE f99e83ece0 Fix #9411 (new daca crash related to using namespace) (#2264) 2019-10-12 11:39:14 +02:00
IOBYTE fe1f601b91 Fix #9389 ("debug: Executable scope 'x' with unknown function." with … (#2261)
* Fix #9389 ("debug: Executable scope 'x' with unknown function." with "using namespace")

* use static rather than anonymous namespace for new functions
2019-10-10 20:25:09 +02:00
Daniel Marjamäki 9f4db5018d SymbolDatabase: Added testcase for variable in if-scope 2019-10-09 16:41:07 +02:00
Daniel Marjamäki 3776604f06 SymbolDatabase: Add variable in if condition 'if (auto x = bar())' 2019-10-09 15:55:54 +02:00
Steve Mokris 506a952ad2 Parse `extern "C"`, and use it to avoid FP reference warnings (#2234)
Previously, cppcheck discarded the `extern "C"` specifier.  This patch modifies cppcheck to parse each as a Scope in the symbol database, then uses that scope to avoid false positives when making recommendations about changing a function argument to be a reference (since variable references is a C++ feature, unavailable in C, and thus unavailable in `extern "C"`).
2019-10-08 17:48:09 +02:00
Daniel Marjamäki 9f40341ba8 SymbolDatabase: Hardcoded handling for std::make_shared and std::make_unique , todo: library configuration would be better than hard coding 2019-10-08 17:19:24 +02:00
Daniel Marjamäki 79356b1883 SymbolDatabase: Better ValueType handling of 'LibraryType(..)' 2019-10-08 11:25:05 +02:00
Daniel Marjamäki 3c085fd88a Fixed #9359 (SymbolDatabase: function lookup fails when -funsigned-char is used) 2019-10-06 12:05:58 +02:00
IOBYTE 8f46bb3ef6 fix #9392 (SymbolDatabase: Weird default constructor outside class) (#2243) 2019-10-06 07:21:12 +02:00
Daniel Marjamäki 7294145797 SymbolDatabase: set value type for std::move() 2019-10-05 19:57:52 +02:00
IOBYTE c32a568c1f fix #8965 ("(debug) Executable scope 'x' with unknown function." with rvalue parameter in method) (#2237)
I fixed the AST enough to pass testrunner but I don't believe it is
correct.

This code:

void Foo4(int&&b);

has this AST:

( 'void'
|-Foo4
`-&& 'bool'
  |-int
  `-b 'signed int'

but I don't believe && should have `bool`.
2019-10-04 12:30:11 +02:00
Daniel Marjamäki 2a33c3cfec SymbolDatabase: Add test to ensure findFunction looks in current scope first 2019-10-03 21:29:01 +02:00
Daniel Marjamäki 87ece5856a Fix Cppcheck internal warning 2019-10-01 21:37:43 +02:00
Daniel Marjamäki cf965b72b5 SymbolDatabase: look for functions in anonymous namespaces in the findFunction 2019-10-01 19:09:34 +02:00
Daniel Marjamäki eb8908cd3e PodType: Add test 2019-09-29 17:02:14 +02:00
Oliver Stöneberg de9f489b08 use range loops / constness (#2181)
* use range loops / constness

* platform.cpp: avoid shadowed variable
2019-09-19 20:29:33 +02:00
Daniel Marjamäki 887e65d006 TestSymbolDatabase: Clean up code using ASSERT 2019-09-16 11:18:01 +02:00
Daniel Marjamäki 5a5cecd4d5 TestSymbolDatabase: Clean up code using ASSERT 2019-09-16 11:12:40 +02:00
Daniel Marjamäki 004b4e4dbe TestSuite: The ASSERT and ASSERT_EQUALS will now stop executing the test case upon failure. This can be used to avoid extra guard logic in tests. 2019-09-16 06:34:45 +02:00
Daniel Marjamäki 742c437953 Fixed #9354 (Unknown macro is not reported and then Cppcheck is silent about issues) 2019-09-13 13:05:48 +02:00
Daniel Marjamäki 7d63bdee6f astyle formatting
[ci skip]
2019-09-02 06:59:07 +02:00
Ken-Patrick 2c656d6586 Issue 9255: Prevent infinite recursion in parsedecl (#2134) 2019-09-01 11:36:02 +02:00
Ken-Patrick d1c6cb9aa5 Fix issue 9304: boolean type of ternary (#2131)
* Add test cases for 9304

* Fix 9304
2019-09-01 09:51:53 +02:00
Paul Fultz II ffdd2dc793 Fix issue 8924: Re-enable valueFlowTerminatingCondition 2019-08-05 07:18:06 +02:00
Daniel Marjamäki c03df8e6b4 SymbolDatabase: Improved matchParameter for containers 2019-08-03 10:10:40 +02:00
Daniel Marjamäki e66e6549ee SymbolDatabase: Improved ValueType::matchParameter handling of containers 2019-08-02 15:59:22 +02:00
Daniel Marjamäki 8deb855b41 Fix ValueType::matchParameter for 'const float *' => 'signed long long' 2019-07-31 18:55:55 +02:00
Daniel Marjamäki c51f44ce4c SymbolDatabase: extend usage of ValueType::matchParameter for variable parameters 2019-07-31 18:24:15 +02:00
Daniel Marjamäki 1eb5f2266c ValueType::matchParameter: Fix matching of char** and void* 2019-07-31 16:23:50 +02:00
Daniel Marjamäki a3dc2db77a SymbolDatabase: Use ValueType::matchParameter for variable address parameters 2019-07-31 12:38:36 +02:00
Daniel Marjamäki 039d49bcb1 Improve ValueType::matchParameter for pointers with different types 2019-07-31 12:12:17 +02:00
Daniel Marjamäki 728ac6ae2e SymbolDatabase: Use ValueType::matchParameter for char literal parameters 2019-07-31 09:35:32 +02:00
Daniel Marjamäki e58e51ee14 SymbolDatabase::findFunction: For string literal, a std::string parameter is a better match than a void* parameter 2019-07-30 21:20:01 +02:00
Daniel Marjamäki d5d50d9b17 ValueType::matchParameter: Improved constness matching 2019-07-30 09:19:51 +02:00
Daniel Marjamäki 3066c0653c Fixed #8668 (SymbolDatabase: Wrong findFunction match for const pointer argument) 2019-07-29 18:14:23 +02:00
Daniel Marjamäki 4fb6c27276 Modernize: Use enum class 2019-07-23 14:29:02 +02:00
Rikard Falkeborn 06337cedf5 Run more tests on full token list (#2020)
Since all checks are run on the full token list and not the simplified
one, run the tests on the full token list as well.
2019-07-22 10:26:55 +02:00
Daniel Marjamäki 58076bc672 SymbolDatabase: Better handling of smart pointers 2019-07-09 17:32:19 +02:00
Daniel Marjamäki a0b22410cf SymbolDatabase: Better handling of smart pointers 2019-07-07 21:52:49 +02:00
shaneasd 7e54f989f9 Update symbol database such that the override keyword implies that the function is also virtual (#1907)
* Update symbol database such that the override keyword implies that the function is also virtual

* Add test case for implicit override

* change isVirtual to hasVirtualSpecifier

* fix method documentation for getVirtualFunctionCalls and getFirstVirtualFunctionCallStack

* Fix isImplicitlyVirtual to consider the override keyword and document logic

* Fix getFirstVirtualFunctionCallStack and getVirtualFunctionCalls to use isImplicitlyVirtual instead of isVirtual so new test case passes
2019-07-04 12:32:32 +02:00
IOBYTE c4933acb5a Fixed #9147(SymbolDatabase bailout: unhandled code) (#1948)
* Fixed #9147(SymbolDatabase bailout: unhandled code)

* add test for #9183
2019-07-03 08:35:48 +02:00
Paul Fultz II 8f4cb36e1e Check for more garbage code (#1949)
* Check for garbage commas

* Find garbage dot operator
2019-07-03 08:28:24 +02:00
Scott Furry a195477470 Correct Zero/Null as pointer constant (#1938)
Building with enhanced clang warnings indicated a large number of
instances with the warning:

`warning: zero as null pointer constant`

Recommended practice in C++11 is to use `nullptr` as value for
a NULL or empty pointer value. All instances where this warning
was encountered were corrected in this commit.

Where warning was encountered in dependency code (i.e. external library)
no chnages were made. Patching will be offered upstream.
2019-06-30 21:39:22 +02:00
IOBYTE 8b347aed42 Fixed #8663 (Stack overflow with template disambiguator) (#1932) 2019-06-28 22:07:21 +02:00
Daniel Marjamäki 66a61fe5e8 SymbolDatabase: Improved findFunction 2019-05-30 20:26:45 +02:00
Daniel Marjamäki 36b6fb9f4d Fixed #8558 (False portability positive caused by incorrect method resolution) 2019-05-30 19:24:51 +02:00
Daniel Marjamäki 57c6628732 Revert 'Cleaning up unsimplified templates'. This fix caused problems. 2019-05-16 21:11:04 +02:00
Daniel Marjamäki d58d4273f9 Cleaning up unsimplified templates 2019-05-11 13:00:03 +02:00
Daniel Marjamäki 9947774ab7 Removed test case with unused templates 2019-05-05 19:15:42 +02:00
Rikard Falkeborn 1cc5f3abe7 Set wchar_t type (#1807)
This is necessary for valueflow to know the size, for example when
calculating sizeof(wchar_t).
2019-05-01 16:34:28 +02:00
IOBYTE 7799ed4243 Fixed #8889 (varid on function when using trailing return type.) (#1800)
* Fixed #8889 (varid on function when using trailing return type.)

Don't set varid for trailing return type.

* Add a test for #9066 (Tokenizer::setVarId: varid set for trailing return type)
2019-04-18 20:22:39 +02:00
Oliver Stöneberg 16ebb90b32 library.cpp: optimized Library::detectContainer() (#1778)
* library.cpp: optimized Library::detectContainer()

reduces Ir from 5882 to 1149 according to callgrind

* fixed hang in tests
2019-04-06 06:42:01 +02:00
IOBYTE 5cdde701ba template simplifier: add minimal template template support (#1779) 2019-04-04 06:07:49 +02:00
Daniel Marjamäki b0c58f2b10 Fixed #9000 (SymbolDatabase: lambda scope) 2019-03-30 10:32:36 +01:00
Daniel Marjamäki fe285f1df3 Fixed #9055 (SymbolDatabase: second argument is missing in the symbol database) 2019-03-30 07:44:36 +01:00
IOBYTE b6faa11fbf Fixed #9056 ("using namespace" inside namespace causes "SymbolDatabase bailout;) (#1753)
Fixed the bailout warning and one of the varid bugs.

The trailing return type still has a varid.
2019-03-24 17:31:34 +01:00
Daniel Marjamäki a2a216bbe3 SymbolDatabase: Improved handling of 'normal' non simplified token list 2019-03-15 19:00:42 +01:00
Daniel Marjamäki 1b4895a579 ValueType: Set ValueType for false/true 2019-03-09 17:27:27 +01:00
Daniel Marjamäki 226f0c7544 Fixed ValueType for auto variable 2019-02-27 10:28:18 +01:00
Daniel Marjamäki d84d8885f7 SymbolDatabase: Fix TODO assertions 2019-02-24 19:11:18 +01:00
Daniel Marjamäki ef731064bd Fixed #8964 (ValueType: auto constness) 2019-02-24 08:16:08 +01:00
Daniel Marjamäki c855cf8682 ValueType: Better constness for auto variable 2019-02-23 18:16:18 +01:00
Daniel Marjamäki b43572d75e Fixed #8969 (C++ functional cast not handled correctly) 2019-02-23 17:29:53 +01:00
orbitcowboy c3244cb359 Fixed regression introduced by my previous commit. 2019-02-20 11:11:20 +01:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
IOBYTE 1faae52d06 Fixed #8960 ("(debug) Unknown type 'x'." with alias in template class alias) (#1643)
* Fixed #8960 ("(debug) Unknown type 'x'." with alias in template class alias)

This commit adds non-template type alias support to the template
simplifier.  Only relatively simple type aliases are supported at this
time. More complex types will be added later.

--debug-warnings will show unsupported type aliases.

Type alias support will be removed from the symbol database in the
future.  Type alias tests have been removed from the symbol database
tests.

* Add the changes.

* Fix codacy warning.

* Fix travis warnings.
2019-02-05 08:52:23 +01:00
IOBYTE 05a3e6807b Fixed #8950 and #8952 (improve type alias support) (#1633)
* Fixed #8950 and #8952 (improve type alias support)

* fix travis build
2019-01-31 16:53:51 +01:00
Daniel Marjamäki 8dd641b8be Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
IOBYTE 2090866cd0 template simplifier: remove explicit instantiations after instantiation (#1523)
* template simplifier: remove explicit instantiations after instantiation

* Fix use after free crash in clang test suite.
2018-12-17 05:58:48 +01:00
IOBYTE 0f83aff3b8 Improve trailing return type support. (#1520)
* Improve trailing return type support.

* Partial fix for #8889 (varid on function when using trailing return type)

* Handle operators in templates.
2018-12-13 06:34:10 +01:00
Daniel Marjamäki 148f257c6b Fixed #8838 (False positive on overridden virtual function that is marked both const and final) 2018-11-10 21:57:50 +01:00
IOBYTE e302e6e7a1 Fix symbol database argsMatch to skip all redundant type information (class, struct, union, enum) (#1472) 2018-11-09 15:54:17 +01:00
IOBYTE 67fe99fcd9 Fix symbol database argsMatch function and its usage so qualified types are handled properly. (#1470)
* Fix symbol database argsMatch function and its usage so qualified types are handled properly.

* Remove assert.
2018-11-09 06:11:48 +01:00
IOBYTE adbbadec7f Fixed #8798 (template simplifier: wrong simpifications for namespaces) (#1452) 2018-10-26 14:20:13 +02:00
Daniel Marjamäki d265a0d6ab Fixed #8798 (SymbolDatabase: Inner unnamed union) 2018-10-20 09:43:08 +02:00
rikardfalkeborn 5e120b567c isVariableDeclaration: Handle pointer to const pointer (#1395)
isVariableDeclaration did not handle pointer to const pointer, or
pointer to volatile pointer. This resulted in FPs in examples like the
following:

    class Fred {
        public:
        const char *const *data;
        const char *const *getData() { return data; };
    }

where cppcheck would say getData could be static, since it didn't
recognize const char *const *data as a variable declaration.
2018-09-25 06:19:26 +02:00
orbitcowboy 2f032d8fa7
Improved const correctness of local variables. (#1396)
* Improved const correctness of local variables.

* Running astyle [ci-skip].

* Removed duplicate 'const'-keyword.
2018-09-24 15:08:16 +02:00
Daniel Marjamäki 5afb755a3c SymbolDatabase: Fix variable matching 2018-09-04 06:39:02 +02:00
Alexander Mai 320a957bbc Extend TestSymbolDatabase::findFunction19 to outline different results depending whether char is signed or unsigned on compile time 2018-06-28 22:16:18 +02:00
Daniel Marjamäki 10e693a8c3 Revert "SymbolDatabase: Improved lookup of function calls"
This reverts commit 3c87d60d5d.
2018-06-26 23:14:12 +02:00
Daniel Marjamäki 3c87d60d5d SymbolDatabase: Improved lookup of function calls 2018-06-26 22:12:12 +02:00
Daniel Marjamäki c583fb9186 Revert "SymbolDatabase: Improved lookup of function calls"
This reverts commit e4a70f87e6.
2018-06-26 13:05:33 +02:00
Daniel Marjamäki e4a70f87e6 SymbolDatabase: Improved lookup of function calls 2018-06-26 11:38:45 +02:00
Daniel Marjamäki 33493883b2 TestSymbolDatabase: Remove unused variable 2018-06-24 17:13:27 +02:00
Daniel Marjamäki ea6a9c965d TestSymbolDatabase: Code cleanup 2018-06-24 17:06:51 +02:00
Daniel Marjamäki 2a8296879c CheckOther: Use Variable::valueType() instead of Variable::typeStartToken 2018-06-23 16:42:36 +02:00
Daniel Marjamäki 10fc070f44 SymbolDatabase: Better handling of type aliases in ValueType 2018-06-20 14:49:55 +02:00
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 610b26bfbc Rename private member _platform_types 2018-06-17 16:58:28 +02:00
Daniel Marjamäki 074177fc6e Rename private member variables 2018-06-17 16:55:02 +02:00
Daniel Marjamäki 76280fe847 Fix testrunner 2018-06-16 21:36:30 +02:00
Daniel Marjamäki 7b106c067a Fixed #8603 (SymbolDatabase: 2 scopes with same function) 2018-06-03 23:14:24 +02:00
IOBYTE 36f7585798 Fixed #8600 (false-positive/regression: confusion between copy constructors of internal classes and lack of explicit keyword) (#1266) 2018-05-27 10:53:34 +02:00
IOBYTE 5c15cd3981 Fix DACA2 SymbolDatabase bailout; unhandled code for final class (#1253)
* Fix DACA2 SymbolDatabase bailout; unhandled code for final class

* Replace Match with simpleMatch
2018-05-21 21:23:21 +02:00
IOBYTE ce50df8047 Fix override warnings. (#1234) 2018-05-15 16:37:40 +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 5c06d08bfb Fix many DACA2 SymbolDatabase bailout; unhandled code false positives (#1225) 2018-05-13 19:00:42 +02:00
IOBYTE 9d30496ea1 Extend symbol database test for const volatile member function. (#1220) 2018-05-11 08:15:46 +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
IOBYTE 5452c4dc4a Fixed #8560 (Symboldatabase lacks entry for C++11 overloaded member function) (#1217) 2018-05-09 20:16:08 +02:00
Daniel Marjamäki 4408628107 Fixed #8538 (SymbolDatabase: wrong parsing of noexcept) 2018-05-05 08:31:56 +02:00
IOBYTE f94e9c5447 Fix #8540 (Syntax error involving forward-declared 'enum class') (#1203) 2018-05-04 07:56:20 +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 7015fb097e SymbolDatabase::isFunction: better handling of return types 2018-04-29 15:35:31 +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 d15b945c9e SymbolDatabase::isFunction: Fix wrong detection function 2018-04-27 10:24:02 +02:00
Daniel Marjamäki 5384802e16 SymbolDatabase: Look for types in anonymous scopes 2018-04-26 17:55:04 +02:00
IOBYTE fac851192a SymbolDatabase: fix problem where definition coudn't find forward declaration in class (#1190) 2018-04-24 22:43:47 +02:00
Daniel Marjamäki 8310198cd5 SymbolDatabase: Refactoring and testing isImplicitlyVirtual 2018-04-24 13:53:58 +02:00
Daniel Marjamäki bb227613bb SymbolDatabase: Better type lookup in methods 2018-04-23 22:27:15 +02:00
Daniel Marjamäki c5923fbdd3 astyle formatting 2018-04-09 22:21:17 +02:00
IOBYTE 8734e4dd38 Fix SymbolDatabase bailout to also support struct (#1160) 2018-04-09 18:53:55 +02:00
PKEuS e2002db78d Replaced make_container by C++11 initializer lists 2018-04-08 23:03:44 +02:00
IOBYTE 4f9073159a Fix another SymbolDatabase bailout (#1157) 2018-04-08 07:29:19 +02:00
IOBYTE 20f0784c06 Fix #8470 ((error) SymbolDatabase bailout; unhandled code) (#1155) 2018-04-07 16:41:39 +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 7e15e39f39 Fix some new SymbolDatabase bailout; unhandled code syntax errors. (#1152) 2018-04-06 21:32:32 +02:00
Daniel Marjamäki 05acf9b352 Fixed #8470 ((error) SymbolDatabase bailout; unhandled code) 2018-04-06 16:03:58 +02:00
IOBYTE 9f386d305a Fixed #8280 (False positive uninitMemberVar - initialized from nested overloaded function) (#1151) 2018-04-06 07:53:05 +02:00
IOBYTE a62c932a8f Improve findFunction for function calls with function calls as arguments. (#1147)
Duplicate the existing logic for variable to variable type comparisons
for function return type to variable type comparisons.
2018-04-04 20:44:01 +02:00
Daniel Marjamäki 4af2e517b9 Fixed #8465 (SymbolDatabase: bailout if there is 'struct A::B ab[5];') 2018-03-31 17:54:47 +02:00
Dmitry-Me c76b593467 Resolve C4800 warning 2018-03-27 00:58:53 +03:00
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