Commit Graph

148 Commits

Author SHA1 Message Date
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
Daniel Marjamäki a6320a35e0 value flow: added experimental subfunction handling 2014-01-06 16:37:52 +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 a572c0b728 AST : cleanup unused functions 2013-11-06 12:38:58 +01:00
Daniel Marjamäki c505f5ea23 Fixed AST problem for 'if ((a.b&c)==d){}' 2013-11-02 19:18: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
Daniel Marjamäki bb0385321f Fixed #5074 (False positive: Duplicate expression (macro)) 2013-10-13 17:42:06 +02:00
Robert Reif 2de3ebcb1e CheckIO: fixed some more false negatives. Ticket: #4964 2013-09-24 06:43:03 +02:00
Robert Reif 489a3a6e53 Fixed #5015 (strings not being concatinated properly) 2013-09-06 05:36:33 +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
Robert Reif bf8a786265 reduce: add more settings from cppcheck cli 2013-08-19 06:06:53 +02:00
Daniel Marjamäki ed890a23a8 Token::printOut(): don't write title if it's empty 2013-08-18 09:01:03 +02:00
PKEuS a9a5dc0354 Updated to AStyle 2.03, require this version 2013-08-07 16:27:37 +02:00
Daniel Marjamäki 2a78db4c06 Refactoring Token::findClosingBracket. 2013-07-31 10:30:20 +02:00
Daniel Marjamäki b84547a312 Fixed #4798 (Token::Match(tok, '&|*|%var%') behaves differently when parsed or compiled) 2013-05-15 13:22:25 +02: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 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
Daniel Marjamäki d5af34331b ast: clarify the code somewhat 2013-02-23 07:43:12 +01:00
Andrew C. Martin bd0d9b9639 fix misspellings & gcc v3.4.6 warnings
1.  fix typos / misspellings
 - Fix misspelling within comments, variable/function names, stdout messages
 - changes the name of an error code: ```stlBoundries``` changed to ```stlBoundaries```.  Alias old name (```stlBoundries```) to the new one.

2.  fix gcc v3.4.6 32bit & 64bit warnings

 - fixes gcc v3.4.6 warnings, except for those in tinyxml and "-Wmissing-declarations" makefile warnings
 - in Preprocessor::handleIncludes(), replace a ```vector <bool>``` with ```stack<bool>``` (see ```vector<bool>``` warning below).
   - this is the only ```vector<bool>``` in the codebase
 - ```vector <bool>``` is actually a case of template specialization, and is not recommended, according to the following links:

http://stackoverflow.com/q/6461487
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2160.html
http://stackoverflow.com/q/670308

 - in the codebase before and after this change, testrunner SEGVs in a number of places on gcc v3.4.6, including ```Check::~Check()```, among others
   - fc42fc95 fixes this particular runtime issue for DJGPP & __sun
2013-02-09 23:43:09 -07: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
Edoardo Prezioso 6236e1dc38 Token::Match: removed harmless special code for initial '!!foo' patterns. 2013-01-09 20:13:33 +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 db2a129557 Tokenizer: Improved handling of '\0' in strings 2012-12-25 08:56:12 +01:00
Daniel Marjamäki bca7927913 AST: generate tree from bottom and upwards 2012-12-16 11:48:19 +01:00
Daniel Marjamäki aad3a041ad AST: Handle function calls 2012-12-16 10:06:55 +01:00
Daniel Marjamäki 1ad9c933ec AST: Improved handling of unary operators 2012-12-16 08:41:04 +01:00
Daniel Marjamäki fa8e5cd7d8 AST: Simple AST. Not used in the clients. Only part of the testing for now. 2012-12-15 20:21:09 +01:00
Edoardo Prezioso 45a16baaa0 Token: try to improve speed of multicompare macro. 2012-12-01 23:58:01 +01:00
Edoardo Prezioso f6c23fa1e7 runastyle and fix checkInternal messages. 2012-12-01 03:17:55 +01:00
Edoardo Prezioso aeb4531a58 Token::Match: add a new pattern: '%comp%'.
Token::Match returns true if the token is a comparison operator. It's equivalent to matching '<|<=|==|!=|>=|>' and the tests show that the new pattern speeds up the program execution. Added the new pattern in CheckInternal (and also reordered the %cmd% lists) and in TestToken.
2012-12-01 00:55:24 +01:00
Edoardo Prezioso 9dae536ce3 Little tweaks to Token::Match code. 2012-11-25 15:20:50 +01:00
Edoardo Prezioso e0c10efdce Add a 'prepend' bool option to Token::InsertToken.
If it's true, add a new token before this. Except when this is the first one in the list, because there's not a way to update the list.front (I noticed some Token functions can potentially delete the list.front(), I don't know which effects does it cause).
2012-11-20 02:58:19 +01:00
Edoardo Prezioso fdeacbaec6 Enhance style and code to Token::Match function. 2012-11-20 00:19:57 +01:00
Edoardo Prezioso 39bd31b44c Improve comment style in token.cpp. 2012-11-19 16:30:07 +01:00
Daniel Marjamäki 7ecfb189a2 astyle formatting 2012-11-18 15:04:45 +01:00
Edoardo Prezioso 9d0a295b85 Partially fixed #4288 (handle %var%|%num% patterns). 2012-11-17 20:51:18 +01:00
PKEuS 4ea2df8671 Changed handling of type wchar_t:
- Don't simplify wchar_t to unsigned short on Win32 platforms to ensure that checking of strings and nullpointer dereferences works.
- Added it as standard type
2012-11-11 14:47:16 +01:00
Edoardo Prezioso 87c931b74b Add '%char%' as pattern to match in Token::Match.
All and only those single characters enclosed in "'" are accepted.
2012-11-04 16:58:18 +01:00
PKEuS a748678636 Removed redundant nullpointer checks in token.cpp 2012-09-09 14:34:07 +02:00
Ankita-gupta ff7373f46f Fixed bug in Token::Match (#3720) 2012-08-30 13:33:19 +02:00
PKEuS 2ab33ef21b Added Pointer to enclosing scope to class Token (Only available when symboldatabase is created). 2012-08-11 11:47:11 -07:00
PKEuS 5e862351e9 Improvements in token.cpp:
- Shortened stringify output - 4 or more subsequent empty lines are abbreviated
- Fixed detection of comparision operators
- Make use of _type: Replaced three asserts by one
2012-08-02 11:36:54 -07:00