Daniel Marjamäki
36a67c7022
Clang import; fixed ValueType::typeSize calls
2020-01-18 17:32:59 +01:00
Daniel Marjamäki
cefd7fb33f
Fix testrunner
2020-01-18 12:29:03 +01:00
Daniel Marjamäki
269d21e972
Clang import; Better array handling in sizeof()
2020-01-18 11:55:50 +01:00
Daniel Marjamäki
e78438e990
astyle formatting
...
[ci skip]
2020-01-12 10:32:47 +01:00
Daniel Marjamäki
668212ac2f
SymbolDatabase: Type lookup for clang type strings
2020-01-11 21:24:15 +01:00
Daniel Marjamäki
380cc78077
Clang; Run ValueFlow
2020-01-11 14:00:41 +01:00
Daniel Marjamäki
6b983a9587
Revert ValueFlow changes, there was unexpected problems in testrunner
2020-01-11 13:11:19 +01:00
Daniel Marjamäki
052eaba632
Clang; run ValueFlow analysis
2020-01-11 13:04:51 +01:00
Daniel Marjamäki
54a9b61329
Clang import; NamespaceDecl, varDecl4, varDecl5
2020-01-08 18:23:40 +01:00
Daniel Marjamäki
b829c4cebb
Clang import; Arrays
2020-01-07 12:19:06 +01:00
Daniel Marjamäki
8ea22edb4e
Clang Import; VarDecl
2020-01-06 13:47:19 +01:00
Ken-Patrick Lehrmann
b6d2c1b238
Fix github CI ( #2477 )
...
* Fix github CI
```
Checking lib/check.cpp: __CPPCHECK__=1...
lib/symboldatabase.h:719:5: warning: Class 'Function' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
Function(const Token *tokenDef);
^
Checking lib/templatesimplifier.cpp: __CPPCHECK__=1...
lib/symboldatabase.cpp:1754:33: warning: Condition 'settings' is always true [knownConditionTrueFalse]
const Library * const lib = settings ? &settings->library : nullptr;
^
lib/symboldatabase.cpp:1751:9: note: Assuming that condition '!settings' is not redundant
if (!settings)
^
lib/symboldatabase.cpp:1754:33: note: Condition 'settings' is always true
const Library * const lib = settings ? &settings->library : nullptr;
```
* Compile parseClangAstDump
2020-01-05 21:10:48 +01:00
Daniel Marjamäki
fa727185e5
Clang import; IfStmt
2020-01-05 19:18:32 +01:00
Daniel Marjamäki
b03bdfaf72
Import Clang ast dump (experimental)
2020-01-05 15:12:53 +01:00
Paul Fultz II
e07801a891
Fix issue 9563: new daca crash: findLambdaEndToken not finding end token ( #2472 )
2020-01-04 10:45:24 +01:00
Dmitry-Me
895910b769
Fixed #7159 (wrong handling of function parameters)
2019-12-31 18:26:12 +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
Paul Fultz II
9cb39b1d7e
Fix issue 9482: False positive: Reference to temporary returned using trailing return type ( #2413 )
2019-12-01 15:10:02 +01:00
Paul Fultz II
2bdb7dc236
Fix issue 9390: valueFlowTerminatingCondition bailout: Skipping function due to incomplete variable NULL ( #2412 )
...
* Fix issue 9390: valueFlowTerminatingCondition bailout: Skipping function due to incomplete variable NULL
* Uncomment keyword
* Add nullptr as well
2019-12-01 15:09:21 +01:00
Sebastian
c990d10ffa
Check for JSON error when parsing addon .json files + fixes ( #2374 )
...
* cppcheck.cpp: Check for JSON error when parsing addon .json files
This fixes that errors in JSON files given via `--addon=*.json` are
silently ignored and maybe only a part of the JSON file is used.
Now the error message which picojson can return is checked and a
corresponding error message is returned again by getAddonInfo().
* naming.json: Fix missing comma
* CLI: Fix naming violations detected by addon naming.py via naming.json
* Addon naming: Add argument for validating names of constants
* LIB: Rename functions/variables so they are valid, loosen naming rules
* GUI: Fix naming violations
2019-11-20 15:37:09 +01:00
Daniel Marjamäki
f5e3dc9a38
Improved fix for #8978 (False positive: Variable assigned value that is never used when assigning via iterator)
2019-11-17 12:08:21 +01:00
Paul Fultz II
c75bbbe253
Fix issue 9404: False positive: Either the condition 'if(x)' is redundant or there is possible null pointer dereference: a->x ( #2322 )
...
* Fix issue 9404: False positive: Either the condition 'if(x)' is redundant or there is possible null pointer dereference: a->x
* Use simpleMatch
* Add a test case for the FP
* Check if expression is changed
* Check for no return scope
* Use simpleMatch
2019-11-08 08:11:41 +01:00
Daniel Marjamäki
c7a23f126f
Fixed #9373 (False Positive - missingOverride)
2019-11-03 18:42:04 +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
Paul Fultz II
19cf636a4a
Move necessary code into valuetype ( #2265 )
...
* Fix parsing of smart pointers
* Improve deduction of return type
* Valuetype computation for decayed pointers
2019-10-12 11:40:02 +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
orbitcowboy
a9386fa093
Running astyle [ci skip]
2019-10-10 08:17:41 +02:00
Daniel Marjamäki
0c1e979af7
SymbolDatabase: Refactor handling of variable declarations in if condition
2019-10-09 22:27:48 +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
Daniel Marjamäki
1abf70a7cb
SymbolDatabase: Add null pointer check for ast operand for '(' token
2019-10-08 17:53:29 +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
Paul Fultz II
4eb4762d95
Extend lifetime checking to temporaries ( #2242 )
...
* Use lifetimes to check for returning reference to temporaries
* Check for dangling temporaries
* Check for unknown types for returining by reference
* Remove old returnTemporary check
* Format
* Check for deref op
* Ternary operator return an lvalue reference
* Warn when returning temporaries from member functions
* Improve handling of pointer to function
* Extend lifetimes of const references
2019-10-08 09:28:39 +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
Daniel Marjamäki
cf965b72b5
SymbolDatabase: look for functions in anonymous namespaces in the findFunction
2019-10-01 19:09:34 +02:00
Paul Fultz II
166bd2bafc
Fix issue 2153: valueFlowAfterCondition: struct member ( #2228 )
...
* Fix issue 2153: valueFlowAfterCondition: struct member
* Fix null pointer dereference
* Formatting
* Check for another null pointer
* Initialize variables
* Remove redundant condition
* Format
* Add missing initialization to copy constructor
* Format
2019-09-30 21:04:43 +02:00
Daniel Marjamäki
69a54b0ee9
Library: added 'stdtype' attribute in <podtype> element so we can configure standard types better
2019-09-29 16:48:25 +02:00
Daniel Marjamäki
4138bf7fb3
SymbolDatabase: Better handling when return type of function is PodType
2019-09-28 14:57:41 +02:00
Oliver Stöneberg
eac040a00b
Various clang-tidy fixes ( #2192 )
...
* use range loops
* removed redundant string initializations
* use nullptr
* use proper boolean false
* removed unnecessary continue from end of loop
* removed unnecessary c_str() usage
* use emplace_back()
* removed redundant void arguments
2019-09-25 15:25:19 +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
Paul Fultz II
ba037837c9
Track lifetime across multiple returns
...
This will now warn when doing something like this:
```cpp
template <class T, class K, class V>
const V& get_default(const T& t, const K& k, const V& v) {
auto it = t.find(k);
if (it == t.end()) return v;
return it->second;
}
const int& bar(const std::unordered_map<int, int>& m, int k) {
auto x = 0;
return get_default(m, k, x);
}
```
The lifetime warning is considered inconclusive in this case.
I also updated valueflow to no tinject inconclusive values unless `--inconclusive` flag is passed. This creates some false negatives because library functions are not configured to not modify their input parameters, and there are some checks that do not check if the value is inconclusive or not.
2019-09-11 19:25:09 +02:00
IOBYTE
e5220bdf0c
make ellipsis ... a single token ( #2143 )
...
* make ellipsis ... a single token
Using cppcheck -E to preprocess code with ellipsis produces output that
can't be compiled because ... is split into 3 tokens.
* try to fix addon
2019-09-04 08:07:30 +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
bd02ca5ccb
Fix issue 9207: Not detected 'always true' and unreachable code
2019-08-08 07:46:47 +02:00
Daniel Marjamäki
ebcca4edd1
Improve --debug-warnings output for 'auto' tokens without type. Do not report that prematurely before the type is set properly.
2019-08-05 13:42:06 +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
amai2012
f02636e995
Refactoring: Convert enums to enum classes
2019-08-02 21:14:29 +02:00
Daniel Marjamäki
e66e6549ee
SymbolDatabase: Improved ValueType::matchParameter handling of containers
2019-08-02 15:59:22 +02:00
Daniel Marjamäki
26b0ea52ed
SymbolDatabase: Simplify code
2019-08-02 15:41:18 +02:00
Daniel Marjamäki
7eaa49fd5b
Refactoring SymbolDatabase::findFunction. No functional change is intended.
2019-08-01 17:53:14 +02:00
Daniel Marjamäki
81db8fda18
SymbolDatabase: Code cleanup in findFunction
2019-08-01 17:29:25 +02:00
Daniel Marjamäki
25a13d061c
Refactoring SymbolDatabase::findFunction
2019-08-01 16:14:00 +02:00
Daniel Marjamäki
f95fdd80dd
SymbolDatabase: Refactoring findFunction
2019-08-01 14:30:29 +02:00
Daniel Marjamäki
2a17b897c5
SymbolDatabase: Use ValueType::matchParameter for *var parameters
2019-08-01 13:29:44 +02:00
Daniel Marjamäki
dbddc321e8
SymbolDatabase: Try to match function parameters with unknown types
2019-08-01 13:25:03 +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
91ca6165eb
SymbolDatabase: Use ValueType::matchParameter for expression parameters
2019-07-31 18:35:56 +02:00
Daniel Marjamäki
70ac607a5c
SymbolDatabase: extend usage of ValueType::matchParameter for variable parameters
2019-07-31 18:25:47 +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
35a3a34632
Revert "SymbolDatabase: Use ValueType::matchParameter"
...
This reverts commit cea00a8e09
.
2019-07-31 12:07:07 +02:00
Daniel Marjamäki
cea00a8e09
SymbolDatabase: Use ValueType::matchParameter
2019-07-31 11:20:43 +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
f5c269a191
SymbolDatabase: Use ValueType::matchParameter for string literal parameters
2019-07-30 21:02:35 +02:00
Daniel Marjamäki
d5d50d9b17
ValueType::matchParameter: Improved constness matching
2019-07-30 09:19:51 +02:00
Daniel Marjamäki
914430dede
Appveyor: A quick fix to make Appveyor happy, revert the changes
2019-07-30 07:59:28 +02:00
Daniel Marjamäki
88e3199372
SymbolDatabase: Use ValueType::matchParameter for numeric literal parameters
2019-07-30 07:48:14 +02:00
Daniel Marjamäki
bf219aecde
SymbolDatabase::findFunction: Use ValueType::matchParameter for expression parameters
2019-07-30 07:14:05 +02:00
Daniel Marjamäki
f13b1a0bce
SymbolDatabase: Use ValueType::matchParameter for boolean parameters
2019-07-29 22:58:12 +02:00
Daniel Marjamäki
ed5ae7c5fa
SymbolDatabase::findFunction: Use ValueType::matchParameter for float literal parameters
2019-07-29 21:53:39 +02:00
Daniel Marjamäki
cccbfaa0e4
SymbolDatabase::findFunction: Use getArguments utility function
2019-07-29 21:17:31 +02:00
Daniel Marjamäki
9e738db435
SymbolDatabase: expand usage of ValueType::matchParameter for non-pointer variables
2019-07-29 18:46:50 +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
9009eeb83d
Tweak Function::isSafe()
2019-07-25 20:52:24 +02:00
Daniel Marjamäki
4611cbb5bb
One more fix for Function::isSafe
2019-07-25 17:31:52 +02:00
Daniel Marjamäki
09be07f2b2
Fix Function::isSafe
2019-07-25 17:28:32 +02:00
Paul Fultz II
bb52a63c4e
Add check for const variables
...
When a local reference is declared, this will check if that local reference can be declared as `const`.
2019-07-24 09:59:01 +02:00
Daniel Marjamäki
753efb4c9b
Function::isSafe: handle global/namespace functions better
2019-07-24 08:23:05 +02:00
Daniel Marjamäki
4fb6c27276
Modernize: Use enum class
2019-07-23 14:29:02 +02:00
Daniel Marjamäki
681bd0a911
GUI: Better settings for extended safe checks
2019-07-23 11:54:38 +02:00
Daniel Marjamäki
74bd2aa680
Use range for loop
2019-07-22 12:24:16 +02:00
Daniel Marjamäki
a81c39af09
Replace 'unsigned' with 'nonneg'
2019-07-22 11:25:51 +02:00
Daniel Marjamäki
28e5133f50
Refactoring: Use range for loop
2019-07-18 14:55:01 +02:00
Daniel Marjamäki
e489d9a40f
Fix bug. Used wrong ValueType in smart pointer handling
2019-07-13 20:29:15 +02:00
IOBYTE
9700490e51
fix lib/checkclass.cpp:51:12: warning: enumeration value ‘eLambda’ not handled in switch [-Wswitch] ( #1978 )
2019-07-11 08:25:25 +02:00
Daniel Marjamäki
c9906125de
Safe functions: Check more possible function argument values
2019-07-10 16:59:05 +02:00
Daniel Marjamäki
58076bc672
SymbolDatabase: Better handling of smart pointers
2019-07-09 17:32:19 +02:00
Daniel Marjamäki
862c4ef87b
Symboldatabase: Fix possible null pointer dereference if smart pointer type does not have a scope
2019-07-08 17:43:45 +02:00
Daniel Marjamäki
a0b22410cf
SymbolDatabase: Better handling of smart pointers
2019-07-07 21:52:49 +02:00
Paul Fultz II
65af02f0cf
Fix crash with lambda capture ( #1960 )
2019-07-06 10:46:17 +02:00
Paul Fultz II
e0ced1c415
Parse lambdas as functions ( #1955 )
...
* Parse lambdas as functions
* Fix issue with missing paren
* Fix error when parsing non-existent args
* Remove unused function variable
2019-07-05 12:30:42 +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
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
Ken-Patrick
66ebc187f6
Cleanup some const_cast of Token* ( #1886 )
...
* Add non const version of some methods of Token
The aim is to reduce the (ab)use of const_cast.
* Cleanup some more const_cast in valueflow
* Remove useless const_cast
* Remove some const_cast from templatesimplifier
* Remove some const_cast from valueflow
2019-06-16 10:09:38 +02:00
Daniel Marjamäki
8359d85b12
Fix Cppcheck warning
2019-06-15 13:23:21 +02:00
Daniel Marjamäki
f66cbac0a4
Fix Cppcheck warning
2019-05-30 21:48:12 +02:00
Daniel Marjamäki
de07e2177c
Fix Travis hang
2019-05-30 21:25:14 +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
Paul Fultz II
195da2b3d2
Fix issue 8993: False positive duplicateCondition related to auto ( #1831 )
2019-05-14 08:57:36 +02:00
adamjrichter
47ce998e6e
lib: Separate statements of the form "assert(a && b)" into "assert(a)" and "assert(b)", for more precise diagnostics. ( #1825 )
2019-05-07 10:28:31 +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
Paul Fultz II
39f4374446
Improve diagnostics with null smart pointers ( #1805 )
...
* Warn when dereferencing null smart pointers
* Improve tracking of smart pointer values
* Use library isSmartPointer
2019-04-26 11:30:09 +02:00
Paul Fultz II
a90caa7e5a
Fix issue 9006: False positive: Return value of function std::move() is not used.
...
This is trying to fix the issue by fixing the ast and symbol database. First, the ast nodes will be created for the init list and the symbol database will not mark it as a scope. I am not sure if this is the correct approach as I dont really understand how the AST part works.
It did change the AST for `try {} catch (...) {}` but that is because it incorrectly treats `try {}` as an initializer list.
2019-04-15 06:37:27 +02:00
Daniel Marjamäki
0368648aff
debug warnings; report missing type for auto tokens
2019-03-31 17:38:00 +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
Paul Fultz II
91138578cc
Fix 9052: Crash: SIGSEGV in Token::previous (this=0x0) while checking mariadb-10.0
2019-03-22 01:56:09 +01:00
Paul Fultz II
774464eabb
Fix issue 8996: False positive duplicateCondition
...
This fixes issue 8996 by improving the alias checking by using lifetime analysis. It also extends the lifetime checker to handle constructors and initializer lists for containers and arrays.
2019-03-19 06:25:10 +01:00
Daniel Marjamäki
92f4113b59
Array index: Checking array index out of bounds for dynamic buffers
2019-03-17 13:09:15 +01:00
Daniel Marjamäki
d0c1632b51
Fix CheckBufferOverrun::array_index_12 when compiling with VS
2019-03-16 19:41:13 +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
a1ade2dd7d
Refactoring: Use range for
2019-03-14 19:57:58 +01:00
Daniel Marjamäki
56c47fc6ed
Refactoring: use continue
2019-03-14 19:53:45 +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
rikardfalkeborn
0e988cc755
Fix #8992 : Add originalTypeToken to auto ( #1701 )
2019-02-27 06:44:31 +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
rikardfalkeborn
dc4e7cef88
Run simplifyPlatformTypes on library return types ( #1672 )
...
Add a call to simplifyPlatformTypes() in
SymbolDatabase::setValueTypeInTokenList() to simplify return types of
library configured functions. This fixes the FN in #8141 . Regression
tests are added, both for the original issue and another FN in the comments.
In order to do that, move simplifyPlatformTypes() to TokenList from Tokenizer.
This is a pure refactoring and does not change any behaviour. The code was
literally copy-pasted from one file to another and in two places
'list.front()' was changed to 'front()'.
When adding the call to simplifyPlatformTypes(), the original type of
v.size() where v is a container is changed from 'size_t' to 'std::size_t'.
Tests are updated accordingly. It can be noted that if v is declared as
'class fred : public std::vector<int> {} v', the original type of 'v.size()'
is still 'size_t' and not 'std::size_t'.
2019-02-15 13:29:52 +01:00
Daniel Marjamäki
bd7790fd8c
Update copyright year
2019-02-09 07:24:06 +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
Paul Fultz II
3975913637
Extend lifetime checking for references
...
This will use the lifetime checker for dangling references. It will find these cases for indirectly assigned reference:
```cpp
int &foo()
{
int s = 0;
int& x = s;
return x;
}
```
This will also fix issue 510 as well:
```cpp
int &f( int k )
{
static int &r = k;
return r;
}
```
2019-01-23 07:29:16 +01:00
Lauri Nurmi
f267900257
Fix spelling of "overridden" in function names.
...
One 'd' was missing.
2019-01-15 06:22:14 +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
Paul Fultz II
54453c5802
Fix FP when copying pointer to string ( #1479 )
2018-11-14 06:59:25 +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
2275f05f65
Fixed #8833 (false negative: No 'return' statement in non-void function causes undefined behavior.) ( #1463 )
2018-11-05 06:55:30 +01:00
Daniel Marjamäki
efd92fd714
Refactoring: reuse utility function in SymbolDatabase
2018-11-04 13:29:29 +01: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
IOBYTE
01f9ce2c4a
Improve debug printing of type qualification when declaration and definition are in different scopes. ( #1394 )
2018-09-24 06:40:20 +02:00
orbitcowboy
d08b39c915
Improved const correctness of local variables. There are no functional changes intended. ( #1392 )
2018-09-23 20:24:51 +02:00
Daniel Marjamäki
5afb755a3c
SymbolDatabase: Fix variable matching
2018-09-04 06:39:02 +02:00
Daniel Marjamäki
e442bc47b1
astyle formatting
...
[ci skip]
2018-08-17 19:55:21 +02:00
Sylvain Joubert
13617375df
missingOverride: False positive with cv-ref mismatch ( #1340 )
2018-08-17 08:42:22 +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
10fc070f44
SymbolDatabase: Better handling of type aliases in ValueType
2018-06-20 14:49:55 +02:00
Daniel Marjamäki
b62c562a89
Try to make Travis happy
2018-06-20 14:13:04 +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
9edcae97fc
Fixed #8578 (Argument scope as global)
2018-06-19 08:50:32 +02:00
Daniel Marjamäki
ad4ce84cf7
Rename private member variables
2018-06-17 17:20:16 +02:00
orbitcowboy
0b74a90e75
symboldatabase: removed duplicate keywords in C++-keyword list.
2018-06-17 17:05:36 +02:00
Daniel Marjamäki
c102638970
astyle formatting
2018-06-17 08:45:26 +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
Daniel Marjamäki
7b106c067a
Fixed #8603 (SymbolDatabase: 2 scopes with same function)
2018-06-03 23:14:24 +02:00
Daniel Marjamäki
df9b243227
Modernize: use ranged for loops in CheckNullPointer
2018-06-03 09:27:18 +02:00
Matthias Krüger
558a2f0cc7
SymbolDatabase::createSymbolDatabaseFindAllScopes(): hoist _tokenizer->isC(PP) dereference out of loop.
2018-06-02 13:38:15 +02:00
IOBYTE
7681bbf227
Fixed #8146 (false positive: enum initialized using class member initializer syntax in struct in struct) ( #1270 )
2018-05-30 15:40:16 +02:00
IOBYTE
3982c81394
Add support for C++ attribute nodiscard for functions. ( #1269 )
2018-05-29 21:43:56 +02:00
orbitcowboy
33777c5b72
Improved const correcntess of local variables.
2018-05-29 13:24:48 +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
8320be203d
Fixed #8258 (Incorrect diagnostics when using delegating consturctor with default values) ( #1255 )
2018-05-22 06:42:37 +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
42ed5a6b98
Fixed #8581 (Delegating contructor warns for unintialized variables) ( #1250 )
...
* Fixed #8581 (Delegating contructor warns for unintialized variables)
* Replace Token::Match with isStandardType
2018-05-20 22:58:05 +02:00
PKEuS
c4b6beac4d
Fixed calculation precedence warning introduced in recent commit
2018-05-14 15:24:32 +02:00
Matthias Krüger
4c8bb9ac6f
fix a few typos
2018-05-14 13:11:59 +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
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
129bdb2752
SymbolDatabase::createSymbolDatabaseSetTypePointers: Optimize ~90%
2018-05-09 13:48:55 +02:00
IOBYTE
5d417bbfa1
SymbolDatabase: harden code for missing links ( #1207 )
...
* SymbolDatabase: harden code for missing links
Missing links for templates are common so check links before using them
to prevent crashes.
* SymbolDatabase: replace link check and single token match with match of two tokens
2018-05-06 08:23:07 +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
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
fce7a0a128
dump: add Function::type
2018-04-30 16:52:51 +02:00
Daniel Marjamäki
7015fb097e
SymbolDatabase::isFunction: better handling of return types
2018-04-29 15:35:31 +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
c7e5b941be
Symbol database: Minor tweaks
2018-04-27 10:35:11 +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
Daniel Marjamäki
d8634ca2a9
SymbolDatabase: Disable code for function pointers
...
This hopefully fixes all Travis crashes when running cppcheck:
[./test/Analysis/stack-addr-ps.c] (error) Internal error: Child process crashed with signal 11 [cppcheckError]
[./test/Index/complete-pointer-and-reference-to-functions.cpp] (error) Internal error: Child process crashed with signal 11 [cppcheckError]
[./test/SemaCXX/vararg-non-pod.cpp] (error) Internal error: Child process crashed with signal 11 [cppcheckError]
2018-04-25 18:48:26 +02:00
Daniel Marjamäki
e95c6e3038
Travis: Fix segmentation fault
2018-04-25 16:02:42 +02:00
Daniel Marjamäki
bd54986017
SymbolDatabase: Refactoring parsing of ) ... in functions
2018-04-25 14:35:09 +02:00
Daniel Marjamäki
6efe118aa3
Fix Cppcheck warning
2018-04-25 14:29:34 +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
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
f021094f75
minor refactorings in SymbolDatabase
2018-04-23 21:45:25 +02:00
Daniel Marjamäki
e3a4ef795e
Refactoring: After conditional return the 'else' is not needed
2018-04-23 16:27:56 +02:00
Daniel Marjamäki
97c86ff0e6
Dumps: Added isVirtual/isImplicitlyVirtual info
2018-04-13 21:15:43 +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
1767fe525b
Addons: Fixed handling of noname arguments
2018-04-10 11:10:10 +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
06133fa3ba
Refactor findFunction to unify two ValueFlow paths. ( #1149 )
2018-04-05 06:46:48 +02:00
jrp2014
b6504c70ca
Improve constness
2018-04-04 21:51:31 +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
3b07b749d6
Refactoring, use early return
2018-04-04 10:50:10 +02:00
IOBYTE
fa968d75bd
Partial fix for #8291 : (False positive uninitMemberVar when calling delegated constructor) ( #1142 )
2018-04-04 08:29:12 +02:00
IOBYTE
2a418fa0f5
Fixed #8466 (False Positive: Member variable is not initialized in the constructor. When using overloaded constructors) ( #1141 )
2018-04-02 18:32:45 +02:00
Daniel Marjamäki
9f92685b92
SymbolDatabase: Throw InternalError if parsing fails
2018-04-02 13:14:48 +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
Daniel Marjamäki
95ccd9483b
gcc 4.5 compatibility
2018-03-30 20:57:25 +02:00