Commit Graph

6596 Commits

Author SHA1 Message Date
PKEuS ee046af20c Fixed false positives #6450 and #6451 2015-01-23 19:38:39 +01:00
PKEuS da35a74589 Fixed false negative: Passing uninitialized variable to stream (#4673) 2015-01-22 22:56:41 +01:00
PKEuS da5a04f071 Fixed recently introduced FP in checkuninitvar.cpp if address of variable is passed to a function 2015-01-22 21:22:02 +01:00
PKEuS 4c76f71499 Reactivated old uninitialized variable checker which I accidentially disabled in previous commit 2015-01-22 17:34:22 +01:00
PKEuS f4d11a4209 Fixed false negatives on try and non-executable scopes in checkUninitVar, removed unnecessary function parameters 2015-01-22 13:55:19 +01:00
PKEuS bdae9064ea Support throw in checkleakautovar.cpp 2015-01-22 11:12:26 +01:00
PKEuS 331a6b66be Fixed internal message 2015-01-22 10:53:53 +01:00
PKEuS 7c60fe4aef Fixed crash introduced by last commit. 2015-01-22 10:51:06 +01:00
PKEuS 7364cc8040 Fixed false positive in fityk: operator new calling constructor 2015-01-22 10:37:31 +01:00
PKEuS 60b2b655df Support new/delete in new uninitialized variable checking; realloc() requires an initialized first argument. 2015-01-21 23:46:52 +01:00
PKEuS c3e47f7eaa Fixed false positive in CheckUninitVar and internal message 2015-01-21 22:26:44 +01:00
PKEuS 94c3c45350 CheckUninitVar: Use function information from library, bailout for '?' 2015-01-21 22:02:25 +01:00
PKEuS ecb9d87e42 Fixed false positive: Bailout in checkuninitvar.cpp if setjmp is found 2015-01-21 16:49:34 +01:00
PKEuS 5334aaa25f Refactorization:
- Removed a few unit tests of old uninitialized variable checking expecting other results than same test for new checking
- A few tweaks to new uninitvar checking to improve results when run on tests for old check
- switched some (TODO) tests to new check if the TODO is fixed
2015-01-21 16:17:58 +01:00
PKEuS d8e282fe76 Refactorization: Made checkUninitVar::isVariableUsage() non-static 2015-01-21 13:52:03 +01:00
PKEuS 346532d312 Fixed false positives in CheckUninitVar::checkStruct() 2015-01-21 13:11:48 +01:00
PKEuS 54de731cac Refactorized CheckUninitVar::checkScope(), fixed false negative 2015-01-21 12:20:03 +01:00
PKEuS 5f36c7c914 Improved detection of Type::needInitialization:
- Implement shortcut for C code - all types need initialization there
- Break out of loop faster if we encounter a type that needs initialization (it is sufficient if one member needs initialization)
2015-01-21 10:34:58 +01:00
Samir Aguiar 141a071792 * Added Clang-related flag to gui.pro
* Updated external lib location with PWD variable
2015-01-20 19:20:00 +01:00
Thomas Jarosch ec21134817 Fix false negatives for local suppressions
Introduce a new bool setting jointSuppressionReport
that will be set by the analyseWholeProgram() code path.

When the flag is enabled, unmatched suppressions are
collected after running the final whole program analysis
to prevent false positives for the unusedFunction check.

The check functions in the unit test
for single / multi file suppressions were unified.
2015-01-20 18:47:30 +01:00
orbitcowboy 5a8574cc05 tokenlist::createAst(); should not be const. 2015-01-20 11:22:22 +01:00
orbitcowboy bf1565bd34 Fixed inconclusive warnings regarding const correctness. 2015-01-20 09:09:16 +01:00
Robert Reif 56dc0b02ef Fixed #6432 (cppcheck fails to detect ctor - partial template specialization) 2015-01-19 16:15:11 +01:00
Robert Reif 3b8540fdc0 Fixed #6424 (false negative: Use of 'class Ns::C' silence Cppcheck) 2015-01-19 06:38:54 +01:00
Thomas Jarosch a83fe0e268 Check "var" for null pointer before using it
Reported by covertey -> amai on IRC.
2015-01-18 13:02:58 +01:00
Thomas Jarosch c0aceb893e Replace custom code with Settings::isWindowsPlatform() 2015-01-18 12:43:43 +01:00
Thomas Jarosch 9a5260a43f Only simplify Windows's DEBUG_NEW macro on Windows platform 2015-01-18 12:20:23 +01:00
Thomas Jarosch cd4c297dce Fix segfault in template simplifier
When something parsing the template syntax
went wrong, "tok2" was NULL and resulted
in deleting all remaining tokens. Whoops.

Triggered by gcc test suite:
gcc/testsuite/g++.dg/cpp0x/variadic87.C

Tracked down the source of the bug with
valgrind's "--track-origins=yes" switch.
2015-01-18 01:43:43 +01:00
Thomas Jarosch 58cb6cc116 Add new "style" check to catch redundant pointer operations
Doing "&*some_ptr_var" is redundant and might be the remainder
of a refactoring. Warnings for expanded macros are excluded though:
They are often used with and without pointers and
do something like this: "func(&(*macroarg))".

The new check is fully AST based and was given
strong false positive testing on a large code base.
2015-01-18 00:34:07 +01:00
Thomas Jarosch 2bcd675653 Verbose AST dump: Show if token is expanded from macro
I also added the token variable id, but that decreased
readability of the AST tree too much.
2015-01-17 23:20:52 +01:00
Thomas Jarosch 10fffbfce0 Use unsigned int for all flags
Frank Zingsheim reported: With the parameter 'flag_'
and the member variable '_flags' having the type 'int'
produces a lot of warings in clang:

"warning: implicit conversion changes signedness: 'int' to 'unsigned int'".
2015-01-17 16:46:05 +01:00
Thomas Jarosch fd01cafb1b Clean up redundant pointer operations 2015-01-17 16:29:50 +01:00
Thomas Jarosch e6f042dadc Multi process check: Sanitize error messages for illegal characters
before sending them across the pipe.

The deserializer died while deserializing
a string containing a binary zero.
2015-01-17 16:12:00 +01:00
Thomas Jarosch 36bcefc39d Don't crash when the deserialization of an error message fails
Found while scanning the code of an
open source project related to onions.
2015-01-17 16:09:58 +01:00
Robert Reif 193645318b Tokenizer: Remove macro in class declaration like 'class DLLEXPORT Fred {}' to be able to handle the class better later 2015-01-17 07:42:49 +01:00
Thomas Jarosch 08985bf68a Throw exception in getVariableFromVarId() if called with out_of_range varId
That way we have a chance to catch code bugs at all.
2015-01-15 18:52:11 +01:00
Thomas Jarosch 1cc85bfce3 Add bounds check to getVariableFromVarId()
While poking around the memory leak check,
I managed to trigger an out-of-bounds access
in the symbol database.

Fix it by sanity checking the variable id
passed to getVariableFromVarId().
2015-01-14 23:00:38 +01:00
Thomas Jarosch ef7f104335 Make sure we have a valid Variable pointer before dereferencing it
All other call sites check the pointer already.
2015-01-14 23:00:28 +01:00
Thomas Jarosch c92d861b1e Fix typo in "internal error" message 2015-01-12 23:09:17 +01:00
Robert Reif 68bb197bcb Destructor detected as constructor resulting in false variable not initialized warnings 2015-01-12 06:11:22 +01:00
Thomas Jarosch 059f9d056c Move to global variables to file scope
Putting them in the anonymous namespace
is the same effect as making them "static".
2015-01-11 12:37:11 +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 fd2f93bb80 Two small refactorizations:
- Avoid leaving and entering again critical section without doing anything
- Use isPointer() in checkbufferoverrun.cpp instead of string comparison
2015-01-10 21:03:21 +01:00
PKEuS d019b7f9a6 Fixed wrong condition in library.cpp 2015-01-10 20:51:14 +01:00
Aneesh Azhakesan S fe5d2fc245 Fixed #5906 (false negative: 'else if' expression is always false (use library to determine if function is pure)) 2015-01-10 12:21:55 +01:00
Thomas Jarosch 332254e0af Make patterns compilable (mini refactoring) 2015-01-09 23:43:45 +01:00
PKEuS d110d715ba Refactorization: Use Token::link() when stringifying template argument list in symboldatabase.cpp 2015-01-09 22:03:43 +01:00
PKEuS 4da314b2e4 Declared recently added helper functions as static 2015-01-09 21:40:50 +01:00
PKEuS 25cd3794ac Refactorization: Simplified and unified SymbolDatabase printing 2015-01-09 21:35:16 +01:00
PKEuS 7452613479 Refactorization:
- Merged messages exceptThrowInNoexecptFunction, exceptThrowInNoThrowFunction, exceptThrowInAttributeNoThrowFunction and exceptThrowInDeclspecNoThrowFunction into a single message.
- Merged Token::fIsDeclspecNothrow into Token::fIsAttributeNothrow
2015-01-09 20:18:09 +01:00