Commit Graph

228 Commits

Author SHA1 Message Date
PKEuS 3c8f5b85ae Refactorization: Allocate Token::_values (ValueFlow information) dynamically, reducing size of each token by around 10% 2017-03-27 18:48:34 +02:00
Frank Zingsheim cb5a5e6a25 Improve Fix #6180 (Access of moved variable still allowed until function is called) 2016-12-17 16:42:46 +01:00
Daniel Marjamäki b6cba4a55c Fixed #7784 (Token: can't be both type and variable) 2016-11-26 22:39:47 +01:00
Frank Zingsheim c8ff96fe8f Fixed #6180 (Usage of variable after std::move or std::forward) 2016-11-20 15:14:49 +01:00
Daniel Marjamäki 4732667488 ValueFlow: allow more value types 2016-11-13 22:33:39 +01:00
orbitcowboy 960a0c6b11 Token: Improved const correctness of findsimplematch() and findmatch(). There are no functional changes. 2016-10-29 21:37:45 +02:00
Daniel Marjamäki efa3aba32a Remove Tokenizer::simplifyNull() 2016-10-18 21:44:02 +02:00
Daniel Marjamäki ac1a869d60 unused struct members: don't warn about packed structs (#3088) 2016-09-05 17:27:12 +02:00
amai2012 eba1b0881d Minor refactoring: use nullptr (instead of 0/NULL), change signature of Tokenizer::createTokens 2016-05-07 16:30:54 +02:00
Daniel Marjamäki dc2a92263a Fixed #7426 (RFC: time to replace simplifyEnum?) 2016-04-22 06:02:54 +02:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02:00
Daniel Marjamäki 8ee3a8d168 Updated Token::Match documentation 2015-12-31 01:25:36 +01:00
PKEuS 18693a7fce Refactorized token.cpp:
- Removed redundant overload of Token::insertToken()
- Fixed leak in Token::deleteThis()
- Moved condition out of loop in Token::tokAt()
2015-12-14 22:04:51 +01:00
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +01:00
Daniel Marjamäki 8f6bd7fd0d Fixed #7014 (False positive for printf("%c", "hello"[0])) 2015-10-05 10:12:30 +02:00
Daniel Marjamäki 9b253612ca SymbolDatabase: Add type information in AST 2015-10-04 19:42:58 +02:00
PKEuS fbbdfa85ca Revert "Fixed false negative #5815"
This reverts commit dc6c278d83.
2015-09-09 14:46:47 +02:00
Dmitry-Me e082264677 Comment omitted one of the items listed 2015-09-04 11:19:03 +03:00
PKEuS dc6c278d83 Fixed false negative #5815 2015-08-31 14:12:19 +02:00
Dmitry-Me c760ccee13 Use const_cast to add const, better variable name 2015-08-27 17:14:33 +03:00
PKEuS 37aec52399 Simplify complex/_Complex types (#6939) 2015-08-26 13:13:45 +02:00
PKEuS 4d80df2f4a Added pointer to Type to Token (similar to Token::Variable() and Token::function()):
- Accessible via Token::type()
- Renamed former Token::type() to Token::tokType()
- Removed SymbolDatabase::isClassOrStruct()
2015-08-15 11:19:21 +02:00
Daniel Marjamäki e598b07a6d Moved functions to astutils 2015-08-03 09:20:50 +02:00
Daniel Marjamäki e5151a13ab Fixed #6867 (False positive memleak) 2015-07-25 11:37:03 +02:00
PKEuS 258e3b9dc3 Refactorization: Renamed Token::isOperator() to Token::isOperatorKeyword() to avoid confusion with Token::isOp(), use Token::isOperatorKeyword() in setVarId(). 2015-07-22 13:57:51 +02:00
Robert Reif 4e693f1620 Fixed #6827 2015-07-22 13:57:51 +02:00
Daniel Marjamäki b2b4bb49fa Refactoring handling of comparisons 2015-07-22 12:31:18 +02:00
Daniel Marjamäki eb0db322eb Fixed #6560 (ValueFlow: handling ternary operator better in valueFlowSubFunction) 2015-05-24 17:02:00 +02:00
PKEuS d5ad1def40 Removed two unused functions 2015-04-09 20:54:07 +02: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
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
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
Robert Reif 9e60f584d9 Fixed #6321: Implemented function Token::swapWithNext(). 2014-12-27 10:53:26 +01:00
Daniel Marjamäki fb3f5a159d Token: Added flag for attribute noreturn (#6328) 2014-12-24 12:50:51 +01:00
Daniel Marjamäki 90bd38a972 Renamed isCasted to isCast 2014-12-24 10:35:40 +01:00
Daniel Marjamäki 1b2a23b3fe Fixed #6350 (Tokenizer::simplifyCast: set Token::isCasted when cast is removed) 2014-12-23 16:16:14 +01:00
Daniel Marjamäki 051d42ae6b astyle formatting 2014-11-20 14:20:09 +01:00
orbitcowboy f5d804f71a running astyle 2014-11-20 10:13:03 +01:00
Alexander Mai 45ff012b2c Small doxygen fixes 2014-11-16 19:40:04 +01:00
PKEuS 1df1b9c2bd Fixed #5836: Make showing $ in stringified tokens optional 2014-09-29 14:50:00 +02:00
PKEuS c678937538 Fixed more false positives of #6056:
- Implemented nextArgument() for usages before < and > are linked
- slightly optimized nextArgument()
2014-08-20 15:02:52 +02:00
PKEuS adcc8b1634 Implement support for __attribute__((used)) (#3408) 2014-08-06 11:13:58 +02:00
Daniel Marjamäki a2f776b1b7 Dead pointer: Added checking for dead pointer usage when pointer alias local variable that has gone out of scope. 2014-08-05 06:24:23 +02:00
Daniel Marjamäki 47a2b35e98 BufferOverrun: Use ValueFlow string values more 2014-08-04 08:25:10 +02:00
Daniel Marjamäki ab958e7710 Fixed Cppcheck warning 2014-08-04 06:30:20 +02:00
Daniel Marjamäki 79fc549de0 ValueFlow: start adding valueflow handling of strings and pointer aliases 2014-08-03 20:11:22 +02:00
Daniel Marjamäki 544a5957e1 Token: Added utility function getStrSize as a complement to getStrLength 2014-08-01 13:12:18 +02:00
Daniel Marjamäki 8db5836e3f Fixed #5982 (Add xml dump) 2014-07-14 15:51:45 +02:00
Daniel Marjamäki 954400a382 Add simple xml debug output. When both --xml and --debug is used there will be xml debug output. 2014-07-13 17:21:45 +02:00
Dmitry-Me 9829e0b48a Clearer variable names, fix typo in comment. 2014-07-11 11:33:09 +04:00
PKEuS b4f0869a71 Reduced Token::Match complexity, better support for complex patterns 2014-07-02 15:25:41 +02:00
PKEuS 817d32f791 Fixed and cleaned up Token::Match engine 2014-07-02 15:25:19 +02:00
PKEuS 7ea7ee0005 Store Token::_originalName on heap, since it is only used for a small amount of Tokens (reduce memory usage of TokenList by ~12% (x64)) 2014-06-26 11:51:02 +02:00
PKEuS 8b9daadd25 Replaced static variable isCPP in Token (was not threadsafe):
- Encapsulate parameters passed through AST compiler functions in a struct
-> Reduces maintenance overhead when changing them
-> Contains parameter indicating if the file is C or C++
- Added eKeyword Token type (at the moment, only true for C++ keyword "delete", but should be set for other keywords as well)
2014-06-14 10:28:12 +02:00
Alexander Mai be9a566d48 Refactoring/small corrections to fix warnings from clang -fsanitize=undefined 'member call on null pointer' 2014-05-20 21:55:08 +02:00
Simon Martin 53d5df8cef Silence clang -Wsign-conversion warning with Token::setFlag. 2014-05-08 14:16:43 +02:00
Robert Reif 2d2847ddbd Fixed #5764 (Store Token flags in a single variable) 2014-05-06 06:35:48 +02:00
Robert Reif ae96491d6c Fixed #5756 (declspec(nothrow) not supported) 2014-05-04 20:47:20 +02:00
Alexander Mai 520aaf71b8 Fix some doxygen comments and add shortcut for tok==NULL to Token::simpleMatch() 2014-04-27 09:32:02 +02:00
Alexander Mai b5c580a59e Fix some clang warnings - most related to semantic doxygen errors 2014-04-26 16:17:26 +02:00
Robert Reif 6ff5de2118 Fixed #5697 (Check for throw in __attribute__((nothrow)) function) 2014-04-20 20:40:55 +02:00
PKEuS d9358de8b4 Refactorization: Use templates and rValue references
-> Performance gain of up to 15% on entire checking time (depends on setup; Result was checked with VS12 (x64), matchcompiled version, ran on tinyxml and cppcheck itself)
2014-04-03 15:03:37 +02:00
Daniel Marjamäki 3c64c70ce2 ValueFlow: Added utility functions getValueLE and getValueGE to simplify usage 2014-04-02 06:49:28 +02:00
Robert Reif 8c993c1363 Partial fix for #5555. Remember function attributes: pure, const, constructor, destructor 2014-03-14 05:40:17 +01:00
Daniel Marjamäki 4d06bc086d astyle formatting 2014-03-09 08:49:32 +01:00
Simon Martin a3d1cac79c Ticket #5373: Keep track whether tokens come from a C or C++ file to properly handle %type% in Token::Match with "delete" 2014-03-08 21:26:06 +01:00
Daniel Marjamäki acf5723bdd AST: improved AST printout when --verbose is used 2014-02-24 17:22:29 +01:00
Lauri Nurmi 70a67eaf85 Change some more 0 literals into nullptr. 2014-02-16 13:38:50 +02:00
Daniel Marjamäki fd3a8a2a18 Update copyright 2014-02-15 07:45:39 +01:00
Daniel Marjamäki 20b73747e0 value flow: refactor. added Token::getMaxValue() 2014-01-21 16:58:23 +01:00
Daniel Marjamäki 69109784e8 value flow: cleanup usage of valueflow. utility function Token::getValue was added. 2014-01-20 06:49:45 +01:00
Daniel Marjamäki 498cdb8610 added debug output for the value flow 2014-01-18 09:58:32 +01:00
Daniel Marjamäki b2b5590f2b Refactoring: Moved astStringify to the Token class and renamed it to expressionString. This can often be useful when reporting error messages that contains source code. 2014-01-17 18:37:49 +01:00
XhmikosR f9dd9676be Fix the C4099 warning. 2014-01-09 16:58:42 +02:00
Daniel Marjamäki d8270c710a Add new experimental value flow analysis 2014-01-04 20:57:02 +01:00
Alexander Mai 12df5300ba Fixed #5290 (Doxygen fixes (32be409)) 2014-01-01 20:46:00 +01:00
Daniel Marjamäki 4b72f01e99 clarify calculation: Fixed FP for 'a = (*p ? 1 : 2)' 2013-12-28 11:02:39 +01:00
Daniel Marjamäki 35189e80f2 Uninitialized variables: Fixed false positive for '*p=..' 2013-12-12 15:33:31 +01:00
Daniel Marjamäki b0ce42565e AST: Added experimental new implementations for CheckAssignIf::comparison, CheckOther::checkIncorrectLogicOperator and CheckOther::checkDuplicateExpression 2013-11-07 14:38:08 +01:00
Daniel Marjamäki a572c0b728 AST : cleanup unused functions 2013-11-06 12:38:58 +01:00
Daniel Marjamäki bbdfd8b5c7 Make it possible to create AST, by using the --ast flag 2013-11-02 18:37:35 +01:00
Robert Reif 2de3ebcb1e CheckIO: fixed some more false negatives. Ticket: #4964 2013-09-24 06:43:03 +02:00
Ettl Martin 9ab6655d85 Fixed #5007 (Same include guard naming) 2013-09-04 20:59:49 +02:00
Robert Reif 05f2f0e419 CheckIO: improved type info - keep track of original typename. 2013-08-31 06:26:39 +02:00
Daniel Marjamäki 4a1d1ce1a1 Fixed #3471 (Unused functions: take __attribute__((constructor)) in to consideration) 2013-08-30 06:27:46 +02:00
Daniel Marjamäki 2a78db4c06 Refactoring Token::findClosingBracket. 2013-07-31 10:30:20 +02:00
Zachary Blair de8ee5b042 Fixed #4554 (false negative: buffer access out of bounds) 2013-05-02 21:50:48 -07:00
PKEuS 3a35944c9e Changes in token.h/cpp:
- Properly set Token::_type to eVariable, eFunction or eName, depending on _function, _variable or _varId being set.
- Token can't be a variable and a function at a time - put Token::_function and Token::_variable into a union.
2013-03-05 08:50:01 -08:00
PKEuS 0a7fafa319 Fixed mistake in documentation 2013-03-01 02:47:50 -08:00
PKEuS f899e6ca30 Changed behaviour of %op% pattern accordingly to changes to Token::isOp(). Added %cop% as replacement for old %op% 2013-03-01 02:43:59 -08:00
PKEuS 670c4de8a9 Changed behaviour of Token::is*Op() functions:
- Rename Token::isOp() to Token::isConstOp() (indicating that the operator does _not_ modify the input variables)
- Create new Token::isOp(), returning true also for ++, -- and assignment operators
- Make Token::isExtendedOp() returning also true for all assignment and ++/-- operators
2013-02-28 12:50:29 -08:00
Robert Reif ec1c86c152 Symbol database: more function/variable cleanup. Ticket: #4494 2013-01-31 06:41:18 +01:00
Andrew C. Martin 4a73c93750 Fix compiler warnings and comment/string typos
- fix g++ warning:

> lib/checkother.cpp:3779: warning: comparison between signed and unsigned integer expressions

 - fix suncc warning (see [everything2](http://everything2.com/title/C%252B%252B%253A+static+extern+%2522C%2522)):

> "lib/checkmemoryleak.cpp", line 578: Warning (Anachronism): Formal argument __compar of type extern "C" int(*)(const void*,const void*) in call to bsearch(const void*, const void*, unsigned long, unsigned long, extern "C" int(*)(const void*,const void*)) is being passed int(*)(const void*,const void*).

- prefer empty() / isEmpty() over "size() > 0" (cases not caught by stlSize)

- fix word misspellings (mostly comments, a few output lines)

  - Parenthesis => Parentheses (both variations were used in the codebase)

  - fix typo and wording ("never alwayw") in gui/test/data/benchmark/simple.cpp's CheckOther::unsignedPositive():

```
-  "An unsigned variable will never alwayw be positive so it is either pointless or "
+  "An unsigned variable can't be negative so it is either pointless or "
```
2013-01-16 07:37:07 -07:00
Erik Lax 723d95597b Fixed #4481 (Simplify %str% [ %num% ]) 2013-01-13 20:52:38 +01:00
Thomas Jarosch 7dd07d8e77 Properly implement %op% for Token::multiCompare
Use tok->isOp() instead of doing it "manually".

This fixes false positives for the C++ template case since
the brackets in "template < something >" are not comparison operators.

Profiling showed using tok->isOp() is actually faster than before (-O2).
2013-01-09 17:05:53 +01:00
Edoardo Prezioso 1affb0c96b Use more Effective C++ code style in Token class:
1)The non-const version of Token::tokAt and Token::linkAt now will use a combination of const_cast and static_cast to remove duplicate code.
2)The non-const versions of Token::find(simple)match are added, in order to avoid the usage of const_cast outside the Token code.
3)As a consequence of 2), an useless const_cast applied to a call of Token::findsimplematch in Tokenizer code is removed.
2013-01-03 22:35:34 +01:00
Reijo Tomperi 5d5f7085bf Updating year 2012 -> 2013 to .cpp and .h files and man page. 2013-01-01 18:29:08 +02:00
acm4me 7da155c8ba Support for Sun Studio C++ compiler 2012-12-27 11:51:12 +01:00
Daniel Marjamäki aad3a041ad AST: Handle function calls 2012-12-16 10:06:55 +01:00