Commit Graph

110 Commits

Author SHA1 Message Date
Sebastian 9a5fcddb5d
Library configuration: Enable configuring the direction of arguments. (#1717)
This enhances the library configuration so the direction of function
arguments can be specified (in, out, inout).
isVariableChangedByFunctionCall() uses this information now to avoid
guessing.
2019-03-01 15:47:08 +01:00
Daniel Marjamäki 7c4820e047 Rename Library::isargvalid() 2018-07-15 23:05:48 +02:00
rikardfalkeborn 491ee577c6 Support floats in valid config (#1297)
* Add tests for invalid ranges

* Refactor loadLibErrors

This reduces the amount of code slightly and will simplify adding
more tests.

* Handle empty valid field

Before this change, the sequence <valid></valid> in a config file would
result in a segmentation fault. Now an empty field results in the error
message:

cppcheck: Failed to load library configuration file 'mycfg.cfg'. Bad attribute value '""'

* Add support for valid for floating point arguments

Previously, it was not possible to add valid ranges to floating point
arguments since it only handled integers. This made ranges not work well
for floating point arguments since arguments were cast to integers
before the ranges were handled.

Fix this by using doubles instead of integers if the argument is a float.
Add some tests for this and make sure errors are printed with enough
precision (somewhat arbitrarily chosen).

Note that it is still only possible to add integer ranges (i.e. -1:1).

* Add support for floats in configuration valid range

Now that it is possible to handle decimal arguments, there is no reason
to not allow non-integer ranges. Take care to not allow broken
configurations.

* Move check to within if-clause

* Move asin{,f,l} and acos{,f,l} input checks to config file
2018-07-15 22:47:56 +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 dbf89856c0 Renamed Library private member variables 2018-06-17 16:39:10 +02:00
Daniel Marjamäki fb8e970419 Rename _alloc 2018-06-17 16:32:08 +02:00
Daniel Marjamäki fa8911a7d2 Renamed _suffixes 2018-06-17 13:47:18 +02:00
Daniel Marjamäki 153838c254 Renamed _prefixes 2018-06-17 13:46:24 +02:00
Daniel Marjamäki 9f191cd2dc Renamed _blocks 2018-06-17 13:45:31 +02:00
Daniel Marjamäki fea58e5e54 Renamed _offset 2018-06-17 13:44:56 +02:00
Daniel Marjamäki 743dcff036 Renamed _start and _end 2018-06-17 13:44:10 +02:00
Daniel Marjamäki 78974e9267 Rename _type to mType 2018-06-16 20:25:54 +02:00
Daniel Marjamäki d08b6e02b7 renamed _files to mFiles 2018-06-16 16:23:55 +02:00
orbitcowboy d013cb2f0d library.h: Improved const correctness of some function arguments. 2018-05-24 17:06:20 +02:00
jrp2014 b6504c70ca Improve constness 2018-04-04 21:51:31 +02:00
Daniel Marjamäki 7e4dba6a7e Updated copyright year 2018-03-31 20:59:09 +02:00
Paul 43be20a824 Check more opposite conditions 2018-03-24 07:58:37 +01:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
Daniel Marjamäki 13c0b4131b --check-library: improved function name output 2017-10-05 21:50:24 +02:00
Daniel Marjamäki b81b4fcb78 Fixed #8208 (CheckCondition: Use Library to determine if function is const) 2017-09-08 18:08:32 +02:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +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
PKEuS 2938278f00 Refactorization: Store minsizes in vector instead of list which has less overhead 2017-03-27 17:53:43 +02:00
PKEuS 92414b923a Library: Support variadic functions which are not a formatstr-function 2017-03-14 17:41:34 +01:00
PKEuS 40401534d7 Refactorized Library 2016-12-06 14:50:27 +01:00
PKEuS 2f6350a0d0 Refactorized Library 2016-12-06 14:09:28 +01:00
PKEuS 6e8ac13325 Refactorization:
- Optimized std::string usage
- Replaced list by vector
- Moved iterator into loop head
- Ran AStyle
2016-12-05 17:45:34 +01:00
Daniel Marjamäki 0e9810b7f6 CheckStl: validation of iterators returned from functions 2016-11-01 14:08:42 +01:00
Daniel Marjamäki 08a618c476 Library: Add <iterator> element in <function> <arg>. Not used by any checks yet. 2016-10-25 23:07:18 +02:00
Daniel Marjamäki c8f831b70d Library: Allow that type of function return is specified. Fixes #7668. 2016-10-23 23:04:15 +02:00
Daniel Marjamäki fae4a4dacf Fixed #7668 (ValueFlow: return value from abs) 2016-10-17 13:05:19 +02:00
Daniel Marjamäki 03a6282ab3 Fixed #7338 (Library: method in base class) 2016-09-04 14:14:21 +02:00
Daniel Marjamäki 789aef7fde Fixed #4920 (Microsoft ATL/MFC CString::Format argument checking) 2016-08-19 17:36:27 +02:00
Daniel Marjamäki 09b6568ea2 Fixed #7646 (podtypes do not get proper valuetype) 2016-07-31 19:47:34 +02:00
PKEuS ded8d80b23 Library: Support arguments with default value. Fixed default value handling for <container> tags broken in last commit. 2016-07-09 12:44:17 +02:00
PKEuS 64d2fd2f57 Added new attribute "arg" to <alloc> and <dealloc> to specify the argument that is allocated/deallocated.
This fixes several issues with allocation functions in windows.cfg, such as HeapAlloc() and VirtualAllocEx() (#7503)
2016-05-22 17:19:14 +02:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02: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 57d1196386 Replaced CheckNonReentrantFunctions and CheckObsoleteFunctions by generic CheckFunctions which is based on Library (#6529) 2015-11-22 09:18:07 +01:00
PKEuS 6590d46013 Added missing functionality to <container> elements in Librarie, completed STL container definitions in std.cfg 2015-11-20 18:22:55 +01:00
PKEuS 53b2eca983 Reimplemented CheckStl::stlBoundaries() based on Libraries; Added support for iterators to libraries 2015-11-20 15:53:14 +01:00
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +01:00
Daniel Marjamäki f5bd00f153 Library: return true from Library::isnullargbad() for format string arguments. Related with #7012. 2015-10-03 20:51:45 +02:00
Daniel Marjamäki 28e3c266b3 Fixed #7012 (False positive uninitvar - first argument to snprintf) 2015-10-03 18:35:16 +02:00
PKEuS b77912a0b5 Support namespaces in CheckOther::checkIgnoredReturnValue() 2015-08-15 12:19:14 +02:00
Daniel Marjamäki a70c57daa2 Library: move Library::alloc and Library::dealloc from header to cpp file and use the functionName utility function 2015-08-10 18:36:09 +02:00
Daniel Marjamäki 5b287fc849 Library: The <function> name attribute can now have a comma separated list of names 2015-08-09 21:27:57 +02:00
Simon Martin e5745d7d4a Restore build with libc++ and revert PR#228 and PR#562. 2015-04-12 20:29:49 +02:00
PKEuS 7f2b6881b3 Refactorization: Avoid including path.h in (almost) every source file (via library.h) 2015-03-11 22:54:45 +01:00