Commit Graph

214 Commits

Author SHA1 Message Date
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
PKEuS d665641a76 Refactorizations:
- use std::string::pop_back() and std::string::back()
- pass argument as const std::string&
- Moved iterator into for loop head
2016-12-05 14:50:01 +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 f973a9a9d5 SymbolDatabase: Refactoring handling of library-function return type 2016-10-23 23:20:36 +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 095b2f73f7 Library: look for cfg files in more paths, include exepath even if CFGDIR is used. 2016-08-01 12:58:33 +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 b5d3ecb942 Updated TinyXML, make use of second argument of XMLElement::Attribute() 2016-07-09 11:56:07 +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
Alexander Mai 9d8dffbd79 #6269 false positives in case of overloaded standard library functions. Detect memset() with proper argument cound, using new function numberOfArguments() 2015-12-06 12:50:05 +01:00
PKEuS 70767a30c4 Small refactorizations:
- Avoid calling c_str() for functions that take std::string
- Avoid copying std::list
2015-12-03 14:19:30 +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 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 2a4cceae9e Library: Refactor handling of comma-separated names 2015-11-15 15:24:10 +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
Dmitry-Me ca75096141 Eliminate duplicate find() calls 2015-08-27 11:19:51 +03:00
Daniel Marjamäki 7bb9d2d2f3 minor tweak. use isNotLibraryFunction in Library to prevent false matches 2015-08-15 16:48:30 +02:00
PKEuS b77912a0b5 Support namespaces in CheckOther::checkIgnoredReturnValue() 2015-08-15 12:19:14 +02:00
PKEuS ebfdacb0d3 Introduced .cfg file format version to 2 (to prevent older cppcheck versions from failing silently when reading them), because 5b287fc849 introduced a backward-incompatible feature.
Increased format version of std.cfg, which is the only cfg file that makes use of the new backward incompatible feature.

Refactorization: Avoid a redundant std::string::find()-call
2015-08-11 14:05:01 +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 3a1a34751f Library: Initial handling of method calls 2015-08-10 09:41:06 +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
Daniel Marjamäki 06110689a6 Replace Token::Match with Token::simpleMatch 2015-08-09 20:07:38 +02:00
Daniel Marjamäki b70fe4c609 Fixed #6711 (Add namespace support to library files) 2015-08-09 19:55:33 +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
PKEuS 3d2e26daeb Small Refactorizations:
- Removed #include "symboldatabase.h" from library.h
- Moved variable to inner scope in tokenize.cpp
- Removed unnecessary variable in tokenize.cpp
2015-03-11 20:52:54 +01:00
Daniel Marjamäki 2d8a6c7b89 Fixed #6571 (Library::isNotLibraryFunction: Return true for methods) 2015-03-08 16:13:32 +01:00
Daniel Marjamäki 830f656a25 Library: variables are not library functions (variable declarations can look like function calls) 2015-03-01 11:46:43 +01:00
PKEuS 9dfb864522 Fixed two nullpointer messages in cppcheck 2015-02-01 15:21:09 +01:00
Daniel Marjamäki 73113c67e7 Fixed #6480 (False positive unreachableCode - member function exit called instead of ::exit()) 2015-01-31 16:55:55 +01:00
PKEuS b2835051df Refactorization: Renamed Token::Match pattern %var% to %name%, implement new pattern %var% which is true if varId > 0. 2015-01-31 12:32:04 +01:00
Daniel Marjamäki 57ec1aea91 Library: Don't rely on ast in isNotLibraryFunction since it's used in tokenizer 2015-01-31 10:24:10 +01:00
PKEuS 98e33a189f Enhanced CheckBufferOverrun:
- Fixed bug in library: manual and existing libraries use "size", but library.cpp reads "sizeof" as podtype attribute
- Fixed a couple of bugs in handling unknown size in checkbufferoverrun.cpp, get size from library if available.
2015-01-30 20:27:48 +01:00
Daniel Marjamäki 3285f85ebf Fixed #6460 (Library: better function/type matching) 2015-01-27 17:55:18 +01:00
PKEuS 787cbcb02e Accept unknown elements in Library files, but print a warning. This fixes backward compatibility of libraries with older cppcheck versions 2015-01-10 22:18:57 +01:00
PKEuS d019b7f9a6 Fixed wrong condition in library.cpp 2015-01-10 20:51:14 +01:00
Daniel Marjamäki 6a8293a8b7 Library: More strict matching of functions 2015-01-08 19:31:41 +01:00
PKEuS e06a4cdf00 Refactorized CheckStl::if_find():
- Added support for find()-like functions to Library::Container
- Use <container> information from library
- Fixed false positive #6402
2015-01-04 12:43:50 +01:00
PKEuS e39729ffcc Library: Add <container> tag to Libraries, provide configuration for std::vector, std::deque, std::array and STL strings
Token: Added function to jump to the next template argument
2015-01-03 22:18:33 +01:00
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +01:00
PKEuS 990d14f3e2 Fixed #6328: Use isAttributeNoreturn() whereever we also check Library::isnoreturn(). 2014-12-27 11:07:36 +01:00
Thomas Jarosch 2f1ba89567 Improve readability of Library::load()
by caching often used node names.

Also constify existing name caches.
2014-12-12 22:18:22 +01:00
Robert Reif e2f72b4cb1 Fixed #6215 (Move Windows platform types into library) 2014-10-19 07:34:40 +02:00
PKEuS a02712cb66 Some small refactorizations:
- Removed redundant calls to std::string constructor
- Use default parameters in some places
2014-10-03 10:02:46 +02:00
PKEuS cbb8360b30 Added version attribute to .cfg files (#5928) 2014-09-29 16:26:17 +02:00
PKEuS 210294443e New check: Check for unused return values (#653) 2014-09-27 21:31:04 +02:00
PKEuS 3fade4d28c Improved performance of library loading (~5%):
- Use std::string for comparison, convert to string only once
- Avoid calling tinyxml functions multiple times
2014-09-10 20:29:44 +02:00
Dmitry-Me 0991d42cb9 Further resolve CID 1222223 2014-08-12 11:14:28 +04:00
Dmitry-Me 8cd6e490d9 Resolve CID 1222223. 2014-08-04 10:00:53 +04:00
amai2012 77095e2b05 Add some more functions to posix.cfg which allow to enable TestBufferOverrun::buffer_overrun_1_posix_functions
Fix some compiler warnings on MSVC
2014-07-05 22:47:10 +02:00
Daniel Marjamäki a3acc3241e Library: Added <minsize> element used for buffer overrun checking 2014-07-05 20:31:43 +02:00
Daniel Marjamäki 46479ced7e Library: Handle FIlE_NOT_FOUND better 2014-06-28 10:22:35 +02:00
Daniel Marjamäki ae81b09b58 Refactoring: Move isScopeNoReturn implementation to library and reuse it both in ValueFlow and Tokenizer 2014-06-22 19:13:15 +02:00
orbitcowboy 5c2ed8450e Revert my previous fix 28763fa020 and suppress gcc false positive warnings. 2014-06-13 15:46:43 +02:00
orbitcowboy 28763fa020 Libary: Fixed gcc warning -Wmissing-field-initializers 2014-06-13 13:17:08 +02:00
Alexander Mai 0f7071a000 Fix clang and coverity warnings 2014-06-12 20:03:11 +02:00
Daniel Marjamäki 42c3b3c89d Library: Change range operator in validation pattern to ':' 2014-06-08 18:12:11 +02:00
Daniel Marjamäki 9e81fa04b2 Library: Added 'podtype' element. Partial fix for #5623 2014-06-08 12:09:00 +02:00
Daniel Marjamäki 4c7b0806aa Library: handle validation expression '-1000-0'. Ticket #5847 2014-06-07 16:28:29 +02:00
PKEuS 0a0f1072c0 Attempt to fix travis and some more VS warnings 2014-06-04 19:18:27 +02:00
Daniel Marjamäki ed78d3e148 Library: Better error reporting when loading fails 2014-05-26 17:00:41 +02:00
Daniel Marjamäki 0c5707ebf1 Fixed #5512 (library (memory): extending standard free deallocator with allocators in custom cppcheck configuration file) 2014-04-19 13:15:06 +02:00
Daniel Marjamäki ce1aa1e011 Library: I had misunderstood const/pure a little so I corrected cfg and code 2014-03-14 20:08:34 +01:00
Daniel Marjamäki 8d8913a168 Partial fix for #5555. Add const,pure attributes to library. 2014-03-14 06:38:45 +01:00
Sam Truscott 385478d89e Reflection no longer part of markup. Some tokeniser not done on markup. 2014-03-11 15:57:28 +01:00
Daniel Marjamäki ca0509e20b Library: Fixed bug I caused when I cleaned up patch 2014-03-06 06:27:01 +01:00
Alexander Mai 1d4839b8a6 Fixed #1374 (false negative: using uninitialized variable in printf) 2014-03-06 06:16:14 +01:00
Daniel Marjamäki bef4739853 Library: the bug in tinyxml has been fixed so the workaround can be removed now 2014-03-01 14:09:03 +01:00
Daniel Marjamäki 720bd48a98 use nullptr in lib/library.cpp 2014-02-15 08:41:17 +01:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +01:00
Pavel Roschin 19a8cfd960 Library: add new "define" tag
This tag will allow to add some preprocessor defs into library.
It would be useful to provide more information about libraries
implementation details. As example GLib's library include tag
was added that helps to detect more memory leaks.
2014-02-07 10:13:36 +04:00
PKEuS b775714e3d Moved several hardcoded function names in format string checking into libraries (std.cfg and windows.cfg).
Added support for loading a library in test suite.
2014-01-12 03:44:24 -08:00
Daniel Marjamäki a26c5736da Library: Allow loading xml data from memory 2014-01-09 21:58:56 +01:00
Sam Truscott 4333dd3c75 Update Qt to support Markup structure 2014-01-02 18:18:24 +01:00
Daniel Marjamäki b08880f20f Library: Changed ignorefunction to a set 2014-01-02 17:28:24 +01:00
Daniel Marjamäki 8da0d84905 Library: fixed crash in Library::load if exename is NULL 2013-12-30 18:35:27 +01:00
Daniel Marjamäki ef3d3f2d40 Temporary fix for #5263 until tinyxml2 handle folders better. When https://github.com/leethomason/tinyxml2/issues/147 is fixed this should be reverted. 2013-12-28 21:57:13 +01:00
Daniel Marjamäki d3a848f2e6 Makefile: Added optional CFGDIR parameter that allows user to specify where Cppcheck will look for cfg files. 2013-12-26 18:41:51 +01:00
Daniel Marjamäki e2fa6a291c Uninitialized variables: Fixed false negatives for loop variables / pointer dereference 2013-12-23 12:27:00 +01:00
Daniel Marjamäki 76b907fe65 Fixed #5252 (Improve check: use Library to validate function arguments in invalidFunctionUsage) 2013-12-23 10:06:45 +01:00
Daniel Marjamäki be03d4718a Library: Added <valid> element that is used to define valid input values for functions 2013-12-22 19:10:14 +01:00
Daniel Marjamäki 85c62f98d7 Library: added <markup> element 2013-12-22 18:44:31 +01:00
Daniel Marjamäki 4769838b80 Library: Refactoring of markup code 2013-12-22 17:03:46 +01:00
Daniel Marjamäki 4fe6951b4c Library: Fixed loading of 'resource' 2013-11-23 18:16:40 +01:00
Daniel Marjamäki 2c1f579b3b Library: Fixed formatstr handling 2013-11-21 16:32:53 +01:00
Martin Ettl 5156481db4 Library: return false from load() when tinyxml::FirstChildElement() return a NULL pointer. 2013-10-31 19:49:36 +01:00
Daniel Marjamäki e446a28b3d Refactoring FileLister and Path so they don't depend on Library 2013-10-31 19:09:01 +01:00
Martin Ettl c529de6e07 Library: tinyxml2::FirstChildElement() is capable of returning 0. This fixes a waring of scan.coverity(): CID 1113430 (#1 of 1): Dereference null return value (NULL_RETURNS) 2013-10-29 00:36:27 +01:00
Daniel Marjamäki 514277e91b Library: Fixed bug. Continue if there is no errors. 2013-10-27 17:38:39 +01:00
PKEuS bd752cabcf Let TinyXML2 handle fopen/fclose. Added testlibrary.cpp to VS10 solution 2013-10-27 17:32:38 +01:00
Daniel Marjamäki e0244d343d Library: Fixed resource leak 2013-10-27 17:17:54 +01:00
Daniel Marjamäki 569a29bc4a Library: Added simple testing 2013-10-27 17:10:43 +01:00
PKEuS c95b153700 Refactorizations:
- Removed some redundant operator=, copy-ctor and dtor implementations
- use operator[] instead of at() in library loading code
2013-10-27 13:55:13 +01:00
Sam Truscott 6806fd8135 Extended Qt support through Library 2013-10-20 14:09:10 +02:00
Daniel Marjamäki bcbcee87d5 Library: Changed 'rt' to 'rb' when open files. TinyXml won't choke on CRLF in Windows then. Thanks sam-truscott for telling me this. 2013-09-13 07:26:52 +02:00
Daniel Marjamäki a1fafa7f06 Library: added <formatstr> and <strz> to argument checks 2013-07-22 20:21:45 +02:00
Daniel Marjamäki 0c5e39a813 Library: Added configuration file std.cfg that clients should load. 2013-07-20 17:12:56 +02:00
Daniel Marjamäki 0832734503 Library: Fixed compiler error 2013-07-20 15:40:57 +02:00
Daniel Marjamäki be5e4ccfd5 Library: Renamed <ignore> to <leak-ignore> 2013-07-20 13:12:24 +02:00
Daniel Marjamäki 1a2aaa6780 Library: If load from current path fails, try to load 'default' configuration from cppcheck-executable path. Allow that '.cfg' extension is not used. Allow that multiple configurations are provided (comma separated). 2013-07-20 10:21:05 +02:00
Daniel Marjamäki fa7f8ddc78 Library: Renamed Argument to ArgumentChecks to make it a bit more clear 2013-07-16 09:40:31 +02:00
Daniel Marjamäki 2a884446be Library: document not-null and not-uninit argument configuration 2013-07-15 21:58:29 +02:00
Daniel Marjamäki 66d8fa62d1 Library: added init attribute to <alloc> 2013-07-15 08:44:00 +02:00
Daniel Marjamäki b2f6e9e3eb library: improved handling of noreturn. The Tokenizer::isScopeNoReturn will now try to use the library to determine if scope is noreturn. 2013-07-14 10:10:11 +02:00
Daniel Marjamäki 7d47fd65a2 Renamed --environment to --library. Added --check-library. Renamed Environment to Library 2013-07-08 18:26:18 +02:00