Commit Graph

224 Commits

Author SHA1 Message Date
PKEuS 1566b72c5b Fixed broken AST for simple expressions with delete operator.
Fixed cppcheck internal warning
2015-11-18 21:37:37 +01:00
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +01:00
Alexander Mai 5318970f1e #7109 segmentation fault (invalid code) in TokenList::createAst 2015-11-08 15:09:39 +01:00
PKEuS be36539ad7 Fixed AST generation for C++11-style initialization (#6528) 2015-11-06 17:34:26 +01:00
Daniel Marjamäki fc2bf2ef08 Fixed #7065 (AST: More explicit handling of lambda functions, generate ast for ';new Fred;') 2015-10-20 23:55:29 +02:00
Philipp Kloke a837cc48e0 Refactorization: Simplified code in tokenlist.cpp, token.cpp and testthreadexecutor.cpp 2015-10-19 09:01:20 +02:00
Daniel Marjamäki 9be284e80f AST: proper operator precedence for c++11 initializer {} and :: 2015-10-18 16:58:15 +02:00
Daniel Marjamäki 9bb2af1893 Fixed #7059 (AST: handle C++ initialization with {} better) 2015-10-18 13:43:39 +02:00
Daniel Marjamäki b81b21a57b Fixed #7051 (hang in ast code (failed to create a proper testcase)) 2015-10-18 11:42:18 +02:00
Daniel Marjamäki 30af2fcd73 iscast: handle '(ulong)~0' better 2015-10-17 18:25:27 +02:00
Daniel Marjamäki 507727e07f Fixed Travis 2015-10-17 17:15:19 +02:00
Daniel Marjamäki c88297c971 Fixed #7054 (AST: handle C++ initialization with {} better) 2015-10-17 17:03:24 +02:00
PKEuS 05b5275110 Improved AST:
- Fixed TODO for ternary operator. Add parantheses between ? and : where necessary as a preparation for createAst()
- Improved AST validation:
-- Better message for binary operator with only one operand
-- Ensure ? has : as second operand (#7035)
2015-10-12 19:21:48 +02:00
Daniel Marjamäki 40fffddb83 avoid some fixes for noisy signedness warnings 2015-10-11 12:36:23 +02:00
PKEuS ab8afec3eb Refactorizations:
- Avoid unnecessary loop iterations
- Avoid unnecessary condition checking
- Reduced code duplication in symboldatabase.cpp
2015-08-16 14:23:07 +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 35eb1a393d AST: handle concatening of strings better. this is not ideal but better. 2015-07-27 13:13:30 +02:00
Alexander Mai bbec54db8e Implement MathLib::isFloatHex to detect C99 hexadecimal floating pointer literals. Rename MathLib::isHex to MathLib::isIntHex 2015-07-26 08:06:56 +02:00
PKEuS 8ed0180279 Use C++11 string.back() instead of string[string.length()-1] 2015-07-25 17:19:53 +02:00
Daniel Marjamäki 8ffa917fa2 Fixed #6863 (AST: wrong handling of assignment between ? and :) 2015-07-24 13:02:00 +02:00
Daniel Marjamäki 8a72bb8aa8 AST: Fixed AST for struct initialisation 2015-07-21 11:40:42 +02:00
amai2012 ac1f0301c0 #6791 segmentation fault (invalid code) in TokenList::createAst. Fix null pointer access 2015-06-25 08:57:09 +02:00
Daniel Marjamäki a884362817 Fixed #6752 (wrong AST when there is lambda function) 2015-06-17 19:32:44 +02:00
XhmikosR 8fc4456fb4 Fix compilation error with MSVC 2013 after a7b82b5. 2015-06-15 16:06:18 +03:00
Alexander Mai a7b82b5c28 Refactoring to address some issues from #5895 (handling of unsigned numbers). Also adding a TODO testcase since the real issue (FP) is still not fixed 2015-06-13 18:08:13 +02:00
Alexander Mai 133d8f9a91 #6706 segmentation fault (invalid code) in tokenlist::compilePrecedence3. Local fix to prevent acess to NULL-token 2015-05-27 21:39:31 +02:00
Alexander Mai e28e9be82f Add TODO testcase for #5738. Refactoring: add some const 2015-05-25 08:20:14 +02:00
PKEuS 0d37c4df04 Fixed three unique crashs on garbage code (#6613).
Removed redundant copy of string in templatesimplifier.cpp
2015-04-01 12:43:24 +02:00
Daniel Marjamäki e251a99817 AST: fix handling of sizeof. ticket #6515 2015-02-18 19:56:13 +01:00
PKEuS f78744ac30 Fixed AST generation if expression starts with ternary operator 2015-02-01 14:02:19 +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
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
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +01:00
Alexander Mai 5300ba2074 Make single-argument constructors explicit 2014-11-13 21:39:14 +01:00
Daniel Marjamäki 7107286be6 Fixed #5891 (AST: wrong ast generated for 'x = (int)(double(123)*i);') 2014-10-16 15:57:05 +02:00
Daniel Marjamäki 94c677905b ast: don't hang when invalid code with new is found 'new (var1,var2,var3);' 2014-10-13 19:12:20 +02:00
Daniel Marjamäki aac9e66147 AST: fixed ast for 'new (char *)[10]' 2014-10-12 12:57:01 +02:00
Daniel Marjamäki f72a8d3f15 AST: fixed ast for 'a(new A(1)), b(new B(2))' 2014-10-12 12:13:01 +02:00
Daniel Marjamäki 649e2dfa97 AST: fixed ast for 'a = new (b) ::X;' 2014-10-12 11:12:25 +02:00
Daniel Marjamäki f96ea94048 AST: fixed ast for 'a(new (X), 5);' 2014-10-12 10:20:03 +02:00
Daniel Marjamäki c537c98751 AST: fixed ast for 'a(new (X));' 2014-10-12 09:24:43 +02:00
Daniel Marjamäki 489fc6cce7 AST: more fixes of new statements in clang test suite. some of it is not handled very well. 2014-10-11 13:20:48 +02:00
Daniel Marjamäki 4783a67042 AST: fixes for more new statements from clang test suite 2014-10-11 11:27:13 +02:00
Daniel Marjamäki e6708c1ae2 AST: fixed hang for 'new (int S::*[3][4][5])()' (clang test suite) 2014-10-11 08:32:49 +02:00
Daniel Marjamäki 5891bae59e AST: generilized handling of auto usage in new statement 2014-10-10 19:05:31 +02:00
Daniel Marjamäki 66d4614a87 AST: don't hang when using auto in new statement 2014-10-10 12:47:01 +02:00
Daniel Marjamäki b5faf3a0cc AST: improved handling of new 2014-10-10 10:37:54 +02:00
Daniel Marjamäki cca003490b Fixed #6203 (AST: fix problem with '; static_cast<...') 2014-10-10 08:18:24 +02:00
Martin Ettl 2ca47601cd Running astyle 2014-09-28 22:05:05 +02:00
Martin Ettl b677d3d17f Fix crash on garbage code in tokenlist. The corresponding backtrace along with a testcase is hosted at: https://github.com/orbitcowboy/cppcheck_crash_files/blob/master/crash220.cpp 2014-09-28 22:04:25 +02:00
PKEuS 58fe668fc4 Fixed AST for operator:: after template (#6195) 2014-09-29 11:01:37 +02:00
PKEuS 55b14853d0 Fixed AST: Compile expression inside [] brackets of operator new. (#6193) 2014-09-29 10:26:15 +02:00
Daniel Marjamäki 29a49d0641 removed some redundant null pointer checks before calling Token::Match 2014-09-14 11:35:04 +02:00
Simon Martin 53b58f0ed9 Refactoring. Use Token::Match instead of hardcoded patterns to increase readability. 2014-09-14 11:26:16 +02:00
Daniel Marjamäki 0ab7abded1 AST: fixed cast for 'return (long long)c << 40;' 2014-09-12 06:43:52 +02:00
PKEuS e4a81f9666 Improved checksum algorithm to fix configurations being purged by coincidence (#6126):
- Better distribution of values by rotating the bits of the checksum for each token
2014-09-03 23:10:38 +02:00
PKEuS bf2f76e70c Detect and purge duplicate configurations by calculating a checksum. 2014-09-02 22:35:52 +02:00
PKEuS 80df3dc642 Disabled several checks and simplifications for C code, if they are C++-only. Do not match arguments for C code, since there can't be overloads. 2014-09-01 18:43:24 +02:00
Daniel Marjamäki cd75b2d83d AST: fix hang for code 'MACRO({.x=1,.y=2})' 2014-08-25 19:10:16 +02:00
Daniel Marjamäki 1060b30e52 AST: better AST for placement new expression 'new (a) MyClass;' 2014-08-23 13:21:36 +02:00
PKEuS a1b7ab277b Changed handling of unhandled characters:
- Don't abort checking (reverts 42140b6488)
- Modified error message: New Id unhandledCharacter, removed redundant line information, improved message text
2014-08-08 09:49:09 +02:00
PKEuS 95afa51b24 Fixed crash #5991: Don't crash when lambda is incomplete
Fixed crash #6004: Support struct initializations in AST
2014-07-31 23:15:36 +02:00
Dmitry-Me ba3757dfd3 Bring variables decalaration to where they are really needed. 2014-07-10 11:23:14 +04:00
Alexander Mai df95cd09f0 Fix compiler warnings about type mismatch 2014-07-08 21:47:22 +02:00
amai2012 9b38ae73c1 Attempt to fix 2 Coverity messages.
Replace a few unsigned int by std::size_t
2014-07-07 21:25:30 +02:00
Daniel Marjamäki 72992c7973 AST: fixed ast for '++i;' 2014-06-26 17:31:57 +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 ec1bd420a7 Refactorizations optimizing std::string usage:
1) Added global static const std::string emptyString; object:
-> Replaces some static variables in functions which might be not threadsafe
-> Avoids constructor call (std::string::string(""))
-> Even functions that return an empty string in some branches can return by reference now.
Added to config.h to ensure that it is available everywhere

2) Added overloads for TestFixture::assertEquals for the most common use cases:
-> Moves conversion from const char[] to std::string into a function, reducing code duplication in binary.
2014-06-26 11:51:02 +02:00
PKEuS e80104327a AST: Fixed detection of operator new/delete - don't hang when C code is checked as C++ (#5910) 2014-06-26 09:19:57 +02:00
PKEuS 3a89e5d65f Fixed cppcheck warnings introduced by previous commit 2014-06-24 19:51:47 +02:00
PKEuS 1b5d127373 Cache results for TokenList::isC() and TokenList::isCPP() to avoid redundant calls to Path::isCPP()/isC(), which perform slow string operations (conversion to lowercase, substring, comparisons)
-> Speedup of 2% on self-checking cppcheck-core (MSVC12, x64, not matchcompiled)
2014-06-24 17:42:39 +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
PKEuS 2455b76abd Fixed lots of bugs in the AST:
- Support new and delete
- Properly handle "..."
- References and rValue references as function parameters
- Destructor definitions
2014-06-04 18:47:56 +02:00
PKEuS d93d7401c6 Moved getSourceFilePath(), isC() and isCPP() from Tokenizer to TokenList
Conflicts:
	lib/tokenize.cpp
2014-06-04 18:36:25 +02:00
Daniel Marjamäki 46bf23aa6d TokenList: added assertion that makes sure the Preprocessor doesn't let through extended ascii wrongly. 2014-05-31 18:02:19 +02:00
PKEuS 8f083af1e4 Attempt to fix travis build 2014-05-25 22:11:56 +02:00
PKEuS a407b55945 Added support for lambdas to AST
Fixed bug that return statement left an operand on the stack
2014-05-25 21:55:39 +02:00
PKEuS 55c87248ba Fixed crash on complex cast. 2014-05-24 20:21:08 +02:00
PKEuS 38aaa46804 Stabilized AST:
- Fixed broken simplification causing crashs when cast was followed by unary minus (real world examples from arch/parisc/math-emu/ (linux-kernel))
- Stabilized determination of unary and binary operators
2014-05-24 19:05:04 +02:00
PKEuS b78131cfcf Improved cast detection in AST:
-> Make use of it in checkother.cpp

Use tokenizer simplification instead of reimplementation for test suite
2014-05-24 11:29:32 +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
PKEuS d1c4777053 Fixed two bugs in AST compilation (#5830):
- Correctly parse operators .* and ->*
- Support empty branch in ternary expression (a?:c)
2014-05-19 21:54:59 +02:00
Philipp Kloke ed7d0b321b Bugfixes for AST and AST testing:
- Validate AST in test suite: Check for operand1 being set if operand2 is non-zero
- Fixed buggy unit tests in AST
- Fixed detection unary operator* after return statement (MPC-HC false positive)
2014-05-19 11:17:37 +02:00
PKEuS 683d0b7e82 Partially rewritten AST compilation:
- More straightforward approach for handling right-to-left associativity
 - More straightforward approach to handling unary operators
 - Improved handling of brackets

This fixes #5784, #5795, #5797, #5799, #5810 and a bunch of other problems
2014-05-18 12:10:39 +02:00
PKEuS a3bb8bf39c AST: Parse ternary and assignment operators as right-to-left and on the same precedence level 2014-05-11 17:50:58 +02:00
PKEuS 70dfb55f21 Simplified some Token::Match patterns 2014-05-11 17:50:58 +02:00
Daniel Marjamäki 9fc8bdcbac Fixed #5770 (AST: better handling of 'a.b[c.d]==0') 2014-05-08 06:48:53 +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
Daniel Marjamäki 7d583e639c AST: Fixed handling of '(((typeof(x))*)0)' 2014-05-04 18:36:04 +02:00
Daniel Marjamäki 5a23b739da ValueFlow: Improved bailout when variable is reassigned 2014-05-03 12:49:07 +02:00
Daniel Marjamäki 4b7aaba159 AST: assignment operators are executed from right to left 2014-05-03 12:08:42 +02:00
Daniel Marjamäki 648479d909 AST: Fixed tree for 'a.b[5]' 2014-04-29 06:09:26 +02:00
Daniel Marjamäki d279f3fb41 Fixed #5736 (AST: proper handling of 'a=(b).c;') 2014-04-27 18:03:50 +02:00
Daniel Marjamäki 9f2e37da37 AST: fixed 'a.b++' and '*c[5]--' 2014-04-27 16:02:24 +02:00
Daniel Marjamäki 11856b51aa AST: Fixed handling of 'a=b(c**)+1' 2014-04-26 13:32:08 +02:00
Daniel Marjamäki c34616a6ba AST: Fixed handling of 'a = b.c[++(d.e)];' 2014-04-26 13:16:34 +02:00
Frank Zingsheim ffa55bbaa0 Fixed #5725 (FP: multicondition Expression is always false because 'else if' in pngwrite.cxx (LibreOffice)) 2014-04-26 11:59:38 +02:00
Daniel Marjamäki 8602d13dc9 Fixed #5722 (AST: wrong handling of 'x = ((a[i])->getx)();' - the 'x' is an operand of the =) 2014-04-25 06:06:54 +02:00