Daniel Marjamäki
5e9b7a6749
Cleanup AST tests. The best would be if 'operators' in declarations was not included at all in the AST.
2019-05-04 07:31:59 +02:00
Rikard Falkeborn
c7d7f8738c
Optimize astStringVerbose() for large arrays ( #1815 )
...
Change the astStringVerbose() recursion to extend a string instead of
returning one. This has the benefit that for tokens where the recursion
runs deep (typically large arrays), the time savings can be substantial
(see comments on benchmarks further down).
The reason is that previously, for each token, the astString of its
operands was constructed, and then appended to this tokens astString.
This led to a lot of unnecessary string copying (and with that
allocations). Instead, by passing the string by reference, the number
of temporary strings is greatly reduced.
Another way of seeing it is that previously, the string was constructed
from end to beginning, but now it is constructed from the beginning to
end. There was no notable speedup by preallocating the entire string
using string::reserve() (at least not on Linux).
To benchmark, the changes and master were tested on Linux using the
commands:
make
time cppcheck --debug --verbose $file >/dev/null
i.e., the cppcheck binary was compiled with the settings in the
Makefile. Printing the output to screen or file will of course take
longer time.
In Trac ticket #8355 which triggered this change, an example file from the
Wine repository was attached. Running the above cppcheck on master took
24 minutes and with the changes in this commmit, took 22 seconds.
Another test made was on lib/tokenlist.cpp in the cppcheck repo, which is
more "normal" file. On that file there was no measurable time difference.
A synthetic benchmark was generated to illustrate the effects on dumping
the ast for arrays of different sizes. The generate code looked as
follows:
const int array[] = {...};
with different number of elements. The results are as follows (times are
in seconds):
N master optimized
10 0.1 0.1
100 0.1 0.1
1000 2.8 0.7
2000 19 1.8
3000 53 3.8
5000 350 10
10000 3215 38
As we can see, for small arrays, there is no time difference, but for
large arrays the time savings are substantial.
2019-04-30 13:35:48 +02:00
IOBYTE
505b7f7ebd
Fixed #9110 (Syntax error on valid C++ code) ( #1813 )
2019-04-29 15:17:37 +02:00
Paul Fultz II
ae8a3aae8d
Fix FP with unused variable ( #1814 )
2019-04-29 11:50:19 +02:00
amai2012
361fc44005
Adjust more test results for invalid code
2019-04-19 20:53:07 +02:00
Paul Fultz II
a90caa7e5a
Fix issue 9006: False positive: Return value of function std::move() is not used.
...
This is trying to fix the issue by fixing the ast and symbol database. First, the ast nodes will be created for the init list and the symbol database will not mark it as a scope. I am not sure if this is the correct approach as I dont really understand how the AST part works.
It did change the AST for `try {} catch (...) {}` but that is because it incorrectly treats `try {}` as an initializer list.
2019-04-15 06:37:27 +02:00
Daniel Marjamäki
1393c1c3a0
AST: Try to handle C++17 syntax 'if (init;expr)'
2019-04-12 17:35:06 +02:00
Daniel Marjamäki
292b679aba
Fixed build error. Renamed variable
2019-04-10 19:17:24 +02:00
Daniel Marjamäki
7610513c49
Fixed #9090 (Do not simplify standard functions)
2019-04-08 19:00:46 +02:00
Daniel Marjamäki
83106d5827
Unused templates: Remove unused template function with variadic arguments
2019-04-07 08:37:04 +02:00
Frank Zingsheim
574b77cf1f
Fixed: FP return reference to thread_local variable ( #1758 )
2019-03-27 12:22:53 +01:00
Paul Fultz II
91138578cc
Fix 9052: Crash: SIGSEGV in Token::previous (this=0x0) while checking mariadb-10.0
2019-03-22 01:56:09 +01:00
Rikard Falkeborn
6a3dd9a185
Handle concatenated string and char literals
...
This handles concatenated strings and characters from simplecpp.
Previously, L'c' would be preprocessed to the tokens "L" and "'c'".
cppcheck would then remove the "L" token and set "'c'" to be a wide
character literal. Now, it needs to remove the prefix instead.
When doing this, add handling of utf32 encoded literals (U) and UTF-8
encoded literals (u8).
2019-03-10 10:38:50 +01:00
Daniel Marjamäki
e17ddfd964
Changed AST for variable declarations with initializations
2019-03-09 19:09:15 +01:00
Daniel Marjamäki
75ce67f4b8
Fixed #9027 (cppcheck on Centos 7 - segmentation fault below CheckCondition::multiCondition2)
2019-03-08 19:27:20 +01:00
IOBYTE
5ee6c2138c
Fixed #9016 (tokenizer: wrong simplification for operator ^ (){}) ( #1724 )
2019-03-05 11:35:45 +01:00
Daniel Marjamäki
bd7790fd8c
Update copyright year
2019-02-09 07:24:06 +01:00
IOBYTE
05a3e6807b
Fixed #8950 and #8952 (improve type alias support) ( #1633 )
...
* Fixed #8950 and #8952 (improve type alias support)
* fix travis build
2019-01-31 16:53:51 +01:00
Daniel Marjamäki
8dd641b8be
Use OVERRIDE in test
2019-01-12 15:45:25 +01:00
practicalswift
0a1b3a9d6f
Fix typos ( #1568 )
2019-01-06 17:15:57 +01:00
Daniel Marjamäki
04d3672bde
Fixed #7203 (Better syntax error, handle array declaration with @)
2019-01-01 09:45:41 +01:00
IOBYTE
0f83aff3b8
Improve trailing return type support. ( #1520 )
...
* Improve trailing return type support.
* Partial fix for #8889 (varid on function when using trailing return type)
* Handle operators in templates.
2018-12-13 06:34:10 +01:00
Daniel Marjamäki
e0b64ec7a9
Fixed #8884 (AST: handle xs... template argument)
2018-12-12 19:00:14 +01:00
Daniel Marjamäki
01d0199ecf
Fix testrunner
2018-12-04 19:56:22 +01:00
Daniel Marjamäki
bd0a935d8a
Tokenizer: Improved handling of compiler extensions that use @ (see https://sourceforge.net/p/cppcheck/discussion/general/thread/8f618cb0a3 )
2018-12-04 19:33:39 +01:00
Daniel Marjamäki
49413b7d4c
Tokenizer: Add simplifyAt to handle some nonstandard code with @
2018-12-04 16:52:41 +01:00
Colomban Wendling
cad4e4ab20
Fix handling of `sizeof &var` ( #1498 )
...
Fixes https://trac.cppcheck.net/ticket/8870
2018-11-30 13:53:58 +01:00
IOBYTE
358f0c473d
Modify template simplifier to add forward declarations of some templa… ( #1489 )
...
* Modify template simplifier to add forward declarations of some template functions so symbol database can make sense of the expanded templates.
* Fix travis.
2018-11-23 11:36:09 +01:00
Daniel Marjamäki
9ef3c79bc6
Fixed #8851 (Crash in valueFlowContainerForward (daca@home: pbbam))
2018-11-18 20:18:55 +01:00
Daniel Marjamäki
5d086d60ad
Fixed #8844 (snd: Wrong varid and ast)
2018-11-14 21:05:09 +01:00
Daniel Marjamäki
e6a5e0f752
Warn when there is a unknown macro
2018-11-13 16:49:15 +01:00
Daniel Marjamäki
8327aab127
Fixed #8628 (Wrong AST in case)
2018-11-10 21:32:06 +01:00
IOBYTE
17a8a4898d
Fix another template simplifier namespace bug. ( #1467 )
...
* Fix another template simplifier namespace bug.
* Add missing forward declarations caused by token bug.
2018-11-07 21:25:42 +01:00
rikardfalkeborn
88008fedb1
findLambdaEndToken handle explicit type ( #1458 )
...
* findLambdaEndToken: Add tests
* Add handling of explicit return in findLambdaEndToken()
* Use AST in findLambdaEndToken()
* Fix ast when lambda is mutable
2018-10-31 12:36:08 +01:00
Daniel Marjamäki
8beb42cc90
astyle formatting
...
[ci skip]
2018-10-28 17:37:19 +01:00
Paul Fultz II
2b6cc33dc6
Fix issue 8757: Throw syntax error on invalid code ( #1378 )
...
* Fix issue 8757: Throw syntax error on invalid code
* Fix FP with lambda returns
* Remove double percent
* Check more keywords
* Skip preprocessor directives
* Check for valid PP directive
* Fix preprocessor check
* Dont check for preprocessor directives
2018-10-28 17:17:53 +01:00
Paul Fultz II
f5811c6818
Fix issue 8732: Syntax error when using enable_if ( #1453 )
...
* Fix issue 8732: Syntax error when using enable_if
* Fix FPs
* Use simpleMatch
2018-10-28 17:16:31 +01:00
Daniel Marjamäki
15160f1691
Fixed #8788 (AST Broken error from assigning lambda to variable)
2018-10-22 17:25:01 +02:00
Daniel Marjamäki
dc38681a56
Remove FIXME in AST validation. Ticket #8749
2018-10-22 11:37:24 +02:00
Daniel Marjamäki
29feaa5a51
Tokenizer: Avoid constant folding
2018-10-20 10:51:50 +02:00
Daniel Marjamäki
465db2dff7
Fixed #8786 (internalAstError on valid code with C style cast)
2018-10-18 20:17:23 +02:00
Daniel Marjamäki
7eb5ebe17e
Fixed #7887 (User function 'search' is wrongly mixed with std function)
2018-10-10 17:35:53 +02:00
Daniel Marjamäki
c048bd45f6
Refactor test code
2018-10-10 14:35:58 +02:00
Daniel Marjamäki
25cbfe27cf
Partial fix for #7887 , Improved tokenizer simplification of 'using namespace std;' - do not simplify user functions
2018-10-10 14:28:53 +02:00
Daniel Marjamäki
9dccc4037b
Fixed #8747 (Syntax error, AST broken (a = --*b))
2018-09-27 19:26:08 +02:00
Simon Martin
6bde2445a6
Ticket #8632 : Parenthesize ternary operator operands containing < to avoid wrongly thinking a template instantiation is met. ( #1389 )
2018-09-23 10:27:38 +02:00
IOBYTE
e9a44f70b2
Remove out of line member functions of instantiated template classes. ( #1377 )
...
* Remove out of line member functions of instantiated template classes.
2018-09-14 14:16:34 +02:00
Daniel Marjamäki
523a9c1c4a
Fixed #8746 (Syntax error, AST broken (using a::operator=))
2018-09-09 21:11:45 +02:00
Daniel Marjamäki
404eb6c746
Fixed #8745 (Syntax error: AST broken (or))
2018-09-09 16:41:06 +02:00
Simon Martin
1d85a78874
Ticket #8654 : Properly setup links for variadic template bases. ( #1357 )
2018-09-05 14:10:56 +02:00
Daniel Marjamäki
3a8bdad20a
Fixed #8232 (segmentation fault on valid C++ code in isOppositeCond())
2018-09-04 18:10:31 +02:00
IOBYTE
7224ee27d9
Fixed #8122 (simplifyTemplates: constructor outside template class not simplified properly) ( #1361 )
2018-09-02 17:49:13 +02:00
Simon Martin
acb0b9f07e
Ticket #8679 : Add support for C++11 thread_local and GCC's (among others) __thread extension. ( #1351 )
2018-08-26 19:46:36 +02:00
orbitcowboy
3ad8fa5288
windows.cfg: Improved support for more types.
2018-05-16 16:26:40 +02:00
orbitcowboy
4e38627a3d
windows.cfg: Improved support for Windows types (ref. https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx ).
2018-05-16 09:16:12 +02:00
IOBYTE
ce50df8047
Fix override warnings. ( #1234 )
2018-05-15 16:37:40 +02:00
orbitcowboy
d0089fe305
windows.cfg: Added missing PFLOAT definition.
2018-05-15 09:43:28 +02:00
PKEuS
4d549553b0
Small optimization in checkmemoryleak.cpp: Allow passing literals to addtoken()
...
Ran AStyle
2018-05-14 10:15:50 +02:00
Simon Martin
16e1e1d8f9
Ticket #8550 : Properly simplify "typedef class A B;". ( #1224 )
2018-05-12 10:20:33 +02:00
IOBYTE
184537884f
Don't remove the volatile keyword so we can properly overload functions. ( #1218 )
...
* Don't remove the volatile keyword so we can properly overload functions.
I fixed all the checks that had tests that use volatile. There will
probably be more changes needed due to lack of test coverage for
volatile in some checks.
* Fix unused private function warning.
2018-05-10 07:40:01 +02:00
Daniel Marjamäki
59cc479855
Save bitfield bit counts
2018-05-02 20:55:11 +02:00
Daniel Marjamäki
e6a37ec0b7
Fixed #8531 (false positive: (style) The function 'foo' overrides a function in a base class but is not marked with a 'override' specifier.)
2018-04-27 21:49:18 +02:00
Daniel Marjamäki
25599a76a7
Handle 'final' specifier better.
2018-04-27 14:57:43 +02:00
Simon Martin
9fade65dbb
Ticket #8281 , #8417 : Properly detect the end of "switch" statements to accept all legitimate uses of "case". ( #1112 )
2018-04-26 22:26:26 +02:00
Simon Martin
a451a5b598
Ticket #8436 : Handle C++11 initializations within ternary operator. ( #1174 )
2018-04-21 11:30:07 +02:00
Sebastian
c39a3e3f1c
windows string macros: Handle _T, _TEXT and TEXT internally, add tests ( #1163 )
...
Remove TEXT() macro from windows.cfg and handle it internally where it
can be correctly simplified (Ansi vs. Unicode).
Also add handling of _TEXT() macro which is just a synonym for _T().
Add tests to verify correct function and macro simplification.
2018-04-12 08:52:31 +02:00
PKEuS
17b4721bd2
C++17: Support "if constexpr" (by simplifying it to plain if() statement)
...
This might lead to complaints about constant expressions as if() statement, but should fix syntax errors.
2018-04-09 11:42:59 +02:00
IOBYTE
90983303f0
Fix #8477 (False positive caused by anonymous enum in method body) ( #1154 )
2018-04-08 08:00:12 +02:00
Daniel Marjamäki
c0272fc2ef
Fixed #8259 (Don't combine &= for anonymous reference parameters)
2018-04-01 10:27:16 +02:00
Daniel Marjamäki
210b921062
Fixed #8462 (AST: no ast created for 'e = { std::move(address),httpPort, (httpsPort) };')
2018-03-27 13:44:28 +02:00
Daniel Marjamäki
380ecc408f
Fixed #8418 (AST: wrong ast for throw expression)
2018-03-10 22:30:21 +01:00
IOBYTE
fcde1d80e9
Fix #8382 (Syntax error when scanning code with template and attribute) ( #1089 )
...
* Fix #8382 (Syntax error when scanning code with template and attribute)
This commit only addresses #8382 . There are issues concerning which
versions of C++ should be supported and also generic C++ 14 attribute
support which can be revisited later.
* Remove all C++ style attributes.
Remove all C++ style attributes when C++ version is 11 or greater.
Rename simplify function to simplifyCPPAttributes.
Handle more cases of roreturn function attribute.
2018-02-16 22:25:51 +01:00
Lauri Nurmi
e0e664f996
Fix permissions of certain non-executable files ( #1083 )
...
mode 0755 => 0644
2018-02-09 19:46:38 +01:00
Matthias Krüger
f009cfc845
fix some typos found by codespell.
2018-02-04 20:53:43 +01:00
Jørgen Kvalsvik
a61f21d1b6
Accept nested templates in tokenizer-simplify ( #1070 )
...
The following snippet triggerd the error:
template<typename DerivedT>
template<typename T>
auto ComposableParserImpl<DerivedT>::operator|( T const &other ) const -> Parser {
return Parser() | static_cast<DerivedT const &>( *this ) | other;
}
Whenever simplifyFunctionParameters was called on a templated class'
templated member function (and probably any nested template), the
tokenizer would recognise it as a syntax error, assuming that return
type *must* come after a template<> token.
2018-02-04 09:48:37 +01:00
David Hallas
4d18d3948f
Fixes issue with case inside switch that is not a compound statement ( #1031 )
...
* Fixes issue with case inside switch that is not a compound statement was treated as garbage
This fixes an issue with the check for case keywords outside of switch
detection that would treat a case statement inside a switch that is not
a compound statement as garbage, but this is perfectly valid C++. This
construct is used in several libraries, i.e. Google Test.
* Tweak check and handle missing semicolon
Tweaks the check with feedback from danmar.
Handle the case where there is no semicolon and document it with a unit
test.
2018-01-27 22:21:26 +01:00
Simon Martin
71ba513bdb
Ticket #8361 : Fix false positive in Tokenizer::findGarbageCode. ( #1061 )
2018-01-26 22:06:07 +01:00
Daniel Marjamäki
96e387a486
Fixed #8351 (segmentation fault on objective C code)
2018-01-24 18:06:11 +01:00
Alexey Eryomenko
913fdf44b6
member access operators are allowed inside the embedded SQL block when ( #1043 )
...
passing arguments for a query
2018-01-21 15:58:12 +01:00
Daniel Marjamäki
c4caee6b18
Updated copyright year
2018-01-14 15:37:52 +01:00
PKEuS
b684e1f202
Updated AStyle to version 3.0.1
2018-01-08 20:20:33 +01:00
Daniel Marjamäki
fc1ac180e6
Fixed #6218 (Template type aliasing misdetection)
2017-12-29 22:47:07 +01:00
Daniel Marjamäki
eaadfb3910
update debug token list output for templates.
2017-12-25 23:16:51 +01:00
Daniel Marjamäki
9c17bddbd4
Tweak fix for ticket #8297
2017-12-17 22:27:05 +01:00
Daniel Marjamäki
1428759479
Fixed #8297 (Tokenizer:createLinks: 'X<sizeof(int)==1 || sizeof(int)==4>()')
2017-12-17 15:53:05 +01:00
Daniel Marjamäki
511d14a051
astyle
...
[ci skip]
2017-11-05 17:56:24 +01:00
Daniel Marjamäki
4d8f069907
Renamed pro c sql to embedded sql
2017-11-03 21:04:12 +01:00
Daniel Marjamäki
4f6f1e20dd
Hide Pro*C SQL simplification. Use pro_c_sql.cfg library file if this is wanted.
2017-11-03 13:02:29 +01:00
Alexey Eryomenko
02461753f3
Fix for embedded PL/SQL blocks (Oracle Pro*C) ( #985 )
...
* fix for correct parsing of embedded PL/SQL blocks (Oracle Pro*C)
* enforce SQL block end at the end of nearest outer C block, when
appropriate terminator is not found
* added check for ; at the end of END-EXEC and made SQL block detection
more readable
2017-11-03 11:31:33 +01:00
Daniel Marjamäki
0425f1d46d
Fixed #8241 (FP: Same expression on both sides of operator)
2017-10-16 17:39:50 +02:00
hexcoder
051a18b120
pull request for ticket 8180 (better diagnostic output for bailouts) ( #964 )
...
* sync build instructions from readme.txt
* refactored the patch from ticket 8180. Moved logic from macros to the bailoutInternal function
* adapt to new bailout message format
* adapt to new bailout message format
* adapt to new bailout message format
* compile fix for Microsoft platform
* remove directory part from file locations in bailout message (normalize)
* remove directory part from valueflow message filter
* adapt tests to file format without directory part
* adapt tests to file format without directory part
* new line number agnostic assert_equals methods
* new line number agnostic assert_equals methods
* adapt to new method assertEqualsWithoutLineNumbers()
* adapt to new method assertEqualsWithoutLineNumbers()
* Bugfix: do not replace line number with spaces, remove it
* review changes: const char * -> std::string, size_t -> int, std::to_string() -> MathLib::toString()
* set #line at the beginning to guard against insertions from match compiler
* Bugfix: counting lines can be difficult :-) #line 1 -> #line 2
* added method stripDirectoryPart()
* added method stripDirectoryPart()
* used new method Path::stripDirectoryPart()
* new dependency path.h in lib/valueFlow.cpp
* code cleanup, removing redundant temporary objects and casts
2017-10-05 23:03:13 +02:00
Daniel Marjamäki
fe0a514a7c
Fix testrunner
2017-09-16 02:13:48 +02:00
Daniel Marjamäki
b9b47809f9
Fixed #8197 (iscast: '(b)&1' is not a cast)
2017-09-08 22:52:16 +02:00
Daniel Marjamäki
713f607168
Fixed #8156 (wrong ast for 'z = (x & (unsigned)1) | (y & (unsigned)2);')
2017-08-26 23:25:45 +02:00
Daniel Marjamäki
92e9744020
Fixed #8148 (Tokenizer: Braces are not added properly in do while)
2017-08-16 18:55:34 +02:00
Martin Güthle
1d491bd332
Treat noexcept correctly
...
Converts the noexcept to the already correctly handled noexcept(true)
2017-08-16 11:31:19 +02:00
Simon Martin
aa35462add
Ticket #8091 : Don't replace std types within enum definitions. ( #922 )
2017-07-29 11:56:09 +02:00
Daniel Marjamäki
dff9d13758
Fixed #8115 (Tokenizer: links not properly set in r-value template 'Foo<int> && foo')
2017-07-09 13:26:59 +02:00
Daniel Marjamäki
6417be4a71
Fixed #8054 (Tokenizer::simplifyKnownVariables(): Wrong simplification for global variables)
2017-07-08 22:12:01 +02:00
Daniel Marjamäki
453058c059
AST: Better handling of C++11 initializer lists
2017-06-09 22:35:46 +02:00
Daniel Marjamäki
fd74d455ce
AST: Better handling of case
2017-06-08 15:32:35 +02:00
Daniel Marjamäki
c1ea873e1c
TemplateSimplifier::simplifyCalculations: Add some more tests and make sure they pass
2017-06-08 08:15:05 +02:00
Daniel Marjamäki
26bd863d0a
Fixed #7724 (hang: long expression => wrong AST)
2017-06-04 12:16:49 +02:00
Daniel Marjamäki
b68c8d91ab
Fixed #8039 (Tokenizer: wrong simplification of string)
2017-06-01 22:21:02 +02:00
Ayaz Salikhov
28aa939d69
iwyu - include what you use
2017-05-27 04:33:47 +02:00
Daniel Marjamäki
dda5556ded
Fixed #8034 (AST: better handling for c++ type initialization)
2017-05-24 20:24:56 +02:00
Daniel Marjamäki
5444875f89
Fixed #8034 (AST: better handling for c++ type initialization)
2017-05-24 20:18:31 +02:00
Daniel Marjamäki
93e0516291
Fixed #8009 (Tokenizer: fix handling of template rvalue references)
2017-05-23 18:55:17 +02:00
Daniel Marjamäki
040d2f0012
Use simplecpp lexer in test cases
2017-05-18 21:52:31 +02:00
Alexander Mai
c1cdcc158f
Run astyle. Fix some Doxygen issues
2017-05-06 11:57:02 +02:00
amai2012
3e11eb9dca
#8050 cppcheckError: 0xFFFFFFul -> 16777215ULU. Don't add a suffix 'U' if there is already a suffix present.
2017-05-05 14:47:58 +02:00
Daniel Marjamäki
a8a54bbfa8
Fixed #6028 (Improvement: False positive caused by C keywords in assembly comments)
2017-05-05 08:57:24 +02:00
Alexander Mai
f54a6f085b
#7883 hang: CheckOther::checkFuncArgNamesDifferent() template code in .h. Activate language check for header files + Small refactoring
2017-05-03 20:36:26 +02:00
Daniel Marjamäki
8a08cc0796
Fixed #8029 (Tokenizer::simplifyCAlternativeTokens: dont simplify 'eb.and + 1')
2017-04-30 14:40:41 +02:00
Simon Martin
28960a8bba
Remove bailout and fix varid for template class member initialized in out-of-line constructor ( #8031 )
2017-04-30 08:59:47 +02:00
Daniel Marjamäki
d9f72d5f8c
AST: Handle 'x = { [ID] = 1, .. }' when ID is unexpanded macro
2017-04-26 22:35:04 +02:00
Daniel Marjamäki
1039c710e4
Fixed #8017 (AST: wrong ast for extra comma 's={1,}')
2017-04-22 11:23:11 +02:00
Daniel Marjamäki
e827119856
Fix testrunner InternalError
2017-04-21 21:02:46 +02:00
Daniel Marjamäki
902eb87a8a
Fixed #8016 (AST: wrong ast for 'x=(s){...};')
2017-04-21 17:44:11 +02:00
Daniel Marjamäki
7a26e046a8
Fixed #8001 (AST: Wrong AST for lambda function with 'std::string const&' result type)
2017-04-18 21:21:30 +02:00
Daniel Marjamäki
1a95dc9bd6
Fixed #7979 (Tokenizer: Detect and reject c++ code in .c file)
2017-04-17 22:15:29 +02:00
Daniel Marjamäki
bb015c6a2b
Fixed #8006 (AST: Wrong tree with complex for loops and casts)
2017-04-17 21:11:53 +02:00
Daniel Marjamäki
632a6b664c
AST: Harden handling of C++11
2017-04-10 23:29:15 +02:00
Daniel Marjamäki
2c43075ece
AST: weird clang syntax
2017-04-10 23:05:41 +02:00
Daniel Marjamäki
5e1b6aee8c
AST: Fix hang for weird VLA code
2017-04-10 22:17:34 +02:00
Daniel Marjamäki
ffeadbdde4
AST: improved handling for struct initialization 's = { [0] = 123 }'
2017-04-10 07:25:18 +02:00
Daniel Marjamäki
d92c529aa6
AST: Fix wrong handling of struct initialization, caused hang
2017-04-09 22:06:13 +02:00
Daniel Marjamäki
e6005dfa3c
AST: Fix AST for lambda '[&]{..}'
2017-04-09 17:49:55 +02:00
Daniel Marjamäki
8ffed6862d
Tokenizer: Add --check-config warning for macro with semicolon in argument
2017-04-07 19:19:10 +02:00
Daniel Marjamäki
392a06a44b
AST: better handling of '(struct X){...}'
2017-04-06 21:28:13 +02:00
Daniel Marjamäki
50da7d4919
Tokenizer: Write syntax error if there is C++ code in C file.
2017-04-06 08:50:35 +02:00
Daniel Marjamäki
e6ed08c4d8
Fixed #7976 (Internal error. Token::astOperand1() cyclic dependency. (ticket nr 2, new regression))
2017-04-05 11:00:02 +02:00
Daniel Marjamäki
9c5a136f04
Fixed #7975 (crash: Tokenizer::createLinks2 problem with enable_if<x&&y,C*>)
2017-04-03 21:48:22 +02:00
Daniel Marjamäki
abb43b6a81
Fixed #7934 (Wrong AST for 'for (i=0;cond;({min(x,10);}))')
2017-04-02 19:44:33 +02:00
Daniel Marjamäki
c18fe8262b
Fixed #7934 (Wrong AST for 'for (i=0;cond;({min(x,10);}))')
2017-03-19 07:26:11 +01:00
Daniel Marjamäki
ecc59859e1
Don't simplify _Bool in TokenList
2017-03-04 11:13:28 +01:00
Simon Martin
0943b2145b
Ticket #7891 : Do not remove spaces in the internal representation for template instantiations.
2017-02-05 17:35:29 +01:00
Matthias Krüger
f80e888b7e
run astyle
...
[ci-skip]
2017-01-31 16:22:31 +01:00
Simon Martin
5262ed018e
Ticket #7440 : Function calls should not abort pointer alias analysis for local variables.
2017-01-27 22:56:28 +01:00
Simon Martin
bd92ddd386
Ticket #7850 : Properly handle C functions called "class".
2017-01-06 21:16:28 +01:00
Robert Reif
4123b457d7
Fixed #7441 (SymbolDatabase: No scope when function return type not specified)
2017-01-06 11:53:17 +01:00
Robert Reif
4c25e798b1
Fixed #7865 (Tokenizer::createLinks2(): does does set links for <> in struct template)
2016-12-31 22:05:29 +01:00
Daniel Marjamäki
1b21767954
Fixed #5666 (False positive when modifiying std::string by pointer)
2016-12-26 17:13:35 +01:00
Daniel Marjamäki
426d1b4196
Merge pull request #846 from simartin/ticket_7805
...
Ticket #7805 : Ignore enumerators when simplifying known variables.
2016-12-21 17:58:48 +01:00
Simon Martin
5119ae84b8
Ticket #7805 : Ignore enumerators when simplifying known variables.
2016-12-17 14:05:26 +01:00
Daniel Marjamäki
d4f2512421
Tokenizer::simplifyKnownVariables: Added bailout when pointer alias is simplified and loop is encountered
2016-12-11 19:12:23 +01:00
orbitcowboy
8a45c3192b
There is not need to clear a string directly after its creation.
2016-11-30 10:39:14 +01:00
Stefan Weil
57b57428c2
Fix some typos in comments (found by codespell)
...
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-27 11:40:42 +01:00
Daniel Marjamäki
74fa69fe5e
Fixed #7821 (syntax error, first token is &)
2016-11-20 17:59:50 +01:00
Daniel Marjamäki
5b377ea2e4
Fixed #7821 (segmentation fault, invalid last token)
2016-11-20 14:15:51 +01:00
Daniel Marjamäki
efa3aba32a
Remove Tokenizer::simplifyNull()
2016-10-18 21:44:02 +02:00
Daniel Marjamäki
9cea2d6dfa
Tokenizer: Removed simplifications of standard functions that should be handled through configuration.
2016-10-18 19:25:58 +02:00
Daniel Marjamäki
d09a8dde57
Improved char literal handling. In the 'normal' tokenlist these should not be simplified to integer literals.
2016-10-12 10:20:24 +02:00
Daniel Marjamäki
bcbc8ef017
Fixed #7747 (Syntax error when setting the bitcount of an enum defined inside a struct)
2016-10-04 15:57:43 +02:00
Robert Reif
62ac40fc5e
Fixed #7706 ((debug) Executable scope 'foo' with unknown function.)
2016-08-20 22:43:27 +02:00
Daniel Marjamäki
7d6c587580
Fixed #6113 (Tokenizer::simplifyFunctionPointer: wrong simplification of usage 'return (*f)();')
2016-08-04 19:10:08 +02:00
Daniel Marjamäki
864cef2fd2
astyle formatting
...
[ci skip]
2016-08-02 09:03:03 +02:00
Daniel Marjamäki
31484133c0
Fixed #7158 (Tokenizer::createLinks2(): does not set links for < > in 'enum { value = boost::mpl::at_c<B,C> };')
2016-08-01 22:26:11 +02:00
Daniel Marjamäki
71f62950ed
Tokenizer::findGarbageCode: Make it less picky about 'UNKNOWN_MACRO if ..'
2016-07-26 14:35:11 +02:00
Daniel Marjamäki
7ff9545b10
Fixed #7637 (FP syntax error assignment in switch)
2016-07-26 12:15:55 +02:00
Daniel Marjamäki
fd19ab4ed1
fix garbage code handling
2016-07-26 08:50:00 +02:00
Daniel Marjamäki
adf16fae8b
Remove handling of ##, __FILE__, __LINE__ from tokenizer
2016-07-25 07:58:03 +02:00
Daniel Marjamäki
ed4a47de45
Tokenizer: Improve syntax checking of switch,if,while
2016-07-22 16:54:24 +02:00
Daniel Marjamäki
3eef225b36
Revert preprocessor fix for struct tag macros. There are performance problems.
2016-07-19 18:59:58 +02:00
Daniel Marjamäki
4cc4ebd5cd
Travis: run slow unit test on travis that is too slow to run on development machines
2016-07-19 17:10:49 +02:00
Daniel Marjamäki
72ead10d93
cleanup tests
2016-07-18 10:52:38 +02:00
Daniel Marjamäki
45ee29d5dc
Fixed #7604 (simplifyCalculation: expression '0 && x[2]' is not simplified properly)
2016-07-17 15:52:53 +02:00
Daniel Marjamäki
6e3d5dc0d1
Fixed #7580 (False positive when using logical operator keywords 'and', 'or')
2016-07-16 20:21:31 +02:00
Daniel Marjamäki
be755af762
Removed todo testcase for #5783
2016-05-26 18:47:36 +02:00
Daniel Marjamäki
06a594a9e0
Fixed #6207 ('not' misinterpreted as alternative C token)
2016-05-24 13:33:21 +02:00
Daniel Marjamäki
06d5e73e88
Fixed #7471 (Tokenizer::prepareTernaryOpForAST: typedef with comma inside ?:)
2016-05-22 11:33:21 +02:00
Alexander Mai
303a85a930
#4195 segmentation fault of cppcheck (invalid code). Fix segfault which turned up after refactoring the enum handling code.
2016-05-17 22:19:23 +02:00
Alexander Mai
9d1302d523
#7490 sizeof('a') should be sizeof(int) in C mode. Previous fix was hardcoding 4 for C.
2016-05-14 22:52:43 +02:00
Daniel Marjamäki
2cb03b3fd0
Fixed #7409 (Tokenizer: Links not set properly 'Data<T&&>')
2016-05-14 20:40:30 +02:00
Alexander Mai
251fc022fa
#7490 sizeof('a') should be 4 in C mode
2016-05-14 13:05:44 +02:00
Daniel Marjamäki
1caa79c45f
Tokenizer::simplifyPointerConst: Remove simplification. Its purpose was to avoid crash for garbage code ( #6900 ). This fixes #7485 .
2016-05-08 21:32:34 +02:00
PKEuS
f0fb7a8245
Simplify __attribute__ earlier ( #7462 )
2016-05-04 13:51:34 +02:00
PKEuS
b65cacf4b1
Tokenizer::simplifyStaticConst(): Support "struct" and operator:: ( #7403 )
2016-05-04 12:33:19 +02:00
Daniel Marjamäki
dc2a92263a
Fixed #7426 (RFC: time to replace simplifyEnum?)
2016-04-22 06:02:54 +02:00
amai2012
9f4d4bdde7
#6167 Refactoring: rename test functions. Rename TestTokenizer::removeCast*. TestTokenizer::varid* doesn't exist (anymore?).
2016-03-27 17:36:07 +02:00
Daniel Marjamäki
ac8341e3de
keep type suffixes after constant folding using bit operations
2016-03-21 21:20:02 +01:00
Daniel Marjamäki
253bfe432c
Fixed #7410 (Tokenizer: function pointer with throw())
2016-02-29 08:02:02 +01:00
Daniel Marjamäki
c0056d2455
Fixed #7347 (AST: wrong ast when template variable is declared and initiailized in if 'if (A::B<C> abc = 123)')
2016-01-26 10:40:44 +01:00
Daniel Marjamäki
7663b6ee75
Fixed #7348 (AST: wrong ast for cast that starts with :: '(::X*)x;')
2016-01-25 10:29:24 +01:00
Daniel Marjamäki
26612ab846
Fixed #5332 (Tokenizer: if braces not added properly 'if (x==123) label: {}')
2016-01-23 11:43:48 +01:00
Daniel Marjamäki
8568a80208
Fixed #6883 (Template parsing error)
2016-01-20 16:10:58 +01:00
Daniel Marjamäki
ab441f3fb1
Tokenizer:vardecl: split up reference variables declared in class better
2016-01-19 15:27:11 +01:00
Daniel Marjamäki
a0971355b7
Tweaked Tokenizer::simplifyAsm2()
2016-01-04 19:18:10 +01:00
Daniel Marjamäki
f1d3d5b47d
TestTokenizer::simplifyAsm2: replace invalid example code with valid code
2016-01-04 10:50:52 +01:00
Daniel Marjamäki
b748453b30
Tokenizer: Improve handling of block declarations (C extension)
2016-01-04 09:59:53 +01:00
Daniel Marjamäki
79e663dd6f
Settings: Remove '_' prefix for public member variables
2016-01-03 16:18:17 +01:00
Daniel Marjamäki
cd89e68f60
Fixed #6931 (noexcept and override qualifiers plus less than operator results in a syntax error)
2016-01-03 12:22:07 +01:00
Daniel Marjamäki
91d0f0fee0
astyle formatting
...
[ci skip]
2016-01-03 09:38:03 +01:00
Daniel Marjamäki
ed12b4dc44
Fixed #7253 (AST wrong on nested reinterpret_cast)
2016-01-03 09:37:38 +01:00
Daniel Marjamäki
95009a4630
Merge pull request #745 from lanurmi/2016_ad
...
Update copyright year to 2007-2016.
2016-01-01 22:57:19 +01:00
Daniel Marjamäki
f5715c1496
Rename Unspecified platform type to Native
2016-01-01 16:39:41 +01:00
Lauri Nurmi
996c9244d8
Update copyright year to 2007-2016.
2016-01-01 15:34:45 +02:00
Daniel Marjamäki
8171154e12
Fixed #7230 (Confusing code snippet in error message)
2015-12-31 01:15:49 +01:00
Daniel Marjamäki
15ecb26a6c
Tokenizer: Moved simplifyAssignmentInFunctionCall from simplifyTokenList1 to simplifyTokenList2
2015-12-28 13:58:41 +01:00
PKEuS
8f22e4924c
Updated AStyle to version 2.05.1
...
Tweaked runastyle.bat a little bit.
2015-12-17 15:53:13 +01:00
Daniel Marjamäki
8fd62e0cf9
Fixed #4931 (Wrong calculation of constants (simplifying: +,<<,% operations))
2015-11-20 19:43:11 +01:00
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
PKEuS
feae241fc0
Fixed simplification of pointers ( #6829 )
2015-11-10 14:45:24 +01:00
PKEuS
7a90b763f6
Tokenizer::simplifyLabelsCaseDefault(): Do not insert ; between two cases.
2015-11-06 19:59:23 +01:00
PKEuS
95a0c0f14c
Limit the number of cases created by Tokenizer::simplifyCaseRange().
2015-11-06 19:21:56 +01:00
PKEuS
1fe1d7ea4a
Extended Tokenizer::simplifyCaseRange() to support also ranges of chars.
2015-11-06 18:46:43 +01:00
PKEuS
41b1b9d850
Support case ranges (gcc extension, #6490 )
2015-11-06 18:39:03 +01:00
PKEuS
be36539ad7
Fixed AST generation for C++11-style initialization ( #6528 )
2015-11-06 17:34:26 +01:00
PKEuS
62bc827eb0
Fixed createLinks2() when inheriting from a template ( #6601 )
2015-11-06 10:44:37 +01:00
PKEuS
8374e8414b
Fixed use-after-free in clang test suite introduced recently ( #7087 )
2015-11-03 19:24:19 +01:00
PKEuS
b97f9e576d
Fixed crash in clang test suite introduced by previous commit.
2015-11-02 22:53:05 +01:00
PKEuS
b049050792
Fixed wrong parsing of ^{}
2015-11-02 22:14:41 +01:00
PKEuS
4ee56d2306
Fixed simplifyAssignmentInFunctionCall for complex expressions ( #6927 )
2015-10-27 20:01:40 +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
Alexander Mai
3b1d849476
Correct template syntax check which got introduced by an attempt fix #6865 . Disable test for #6865 , adjust some modified tests and add new regression tests
2015-10-19 20:03:33 +02:00
Daniel Marjamäki
b856ac51dd
Fixed #7064 (Tokenizer: Wrong simplification of 'a.public:')
2015-10-19 10:01:57 +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
ec87b09d89
Fixed #7056 (iscast does not handle '(ulong)~0' properly, Tokenizer::simplifyCalculations wrongly simplifies '(ulong)~0' to 'ulong~0')
2015-10-17 18:58:13 +02:00
Daniel Marjamäki
30af2fcd73
iscast: handle '(ulong)~0' better
2015-10-17 18:25:27 +02:00
Daniel Marjamäki
c88297c971
Fixed #7054 (AST: handle C++ initialization with {} better)
2015-10-17 17:03:24 +02:00
PKEuS
46bfa62aad
Execute prepareTernaryOpForAST earlier ( #7048 )
2015-10-15 10:31:54 +02:00
PKEuS
d0cc97a4cf
Fixed wrong syntax error ( #7045 )
2015-10-14 16:01:48 +02:00
Daniel Marjamäki
a04e072976
Fixed #7040 (False positive syntaxError False positive syntaxError)
2015-10-13 20:31:17 +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
a500f6f703
Improved handling of 'long double' and address-of in ValueType. Removed Tokenizer::simplifyFloatCasts() to handle float casts better.
2015-10-08 19:50:10 +02:00
PKEuS
3645e3c16b
Fixed two TODO unit tests by delaying arraySize simpification until createLink2 is executed
2015-10-08 12:52:28 +02:00
PKEuS
0a34b206e8
Refactorization: Reduced code duplication in test suite
2015-10-08 11:35:51 +02:00
Philipp Kloke
4ac6623875
Moved a few tests out of testtokenize.cpp; refactorized them
2015-10-07 22:45:38 +02:00
PKEuS
3a5cef8a7e
Refactorization: Improved usage of Settings instances in test suite
2015-10-07 18:40:03 +02:00
PKEuS
590f1f1d66
Fixed handling of __asm...__endasm ( #6970 )
2015-09-28 15:43:48 +02:00
Daniel Marjamäki
d88dc3ed3e
Reverted 00c54df07c
(don't remove enum declarations) because it caused unexpected false positives
2015-09-06 18:37:22 +02:00
Daniel Marjamäki
00c54df07c
Tokenizer: Don't remove enum declarations
2015-09-06 17:44:49 +02:00
amai2012
e683d31e71
Re-enable okenizer::removeMacroInClassDef for C code
2015-09-01 07:10:12 +02:00
PKEuS
d7853b9963
Fixed simplification of fma(a, b, c) ( #6958 )
2015-08-29 20:52:03 +02:00
PKEuS
d5bc3285b9
Move "extern" to the beginning of a declaration like "static" and "const"
2015-08-29 10:57:52 +02:00
PKEuS
2ace3d3144
Rewritten handling of declaration specifiers:
...
- Removed simplifyConst() because it did the opposite of the (superior) simplifyStaticConst()
- Execute simplifyStaticConst() in simplifyTokenList1() - there is no reason to defer it, and it is required to properly parse declarations like "unsigned static int i;"
- Fixed simplifyStaticConst() to handle more patterns. It did not work at the beginning of the token list and for function arguments
- Reimplemented Tokenizer::simplifyStdType()
-> properly support all possible ways to declare integers as requested by the standard, instead of only a few common permutations of "unsigned|signed", "short|char|long|int"
-> Fixed parsing of _Complex/complex types
2015-08-27 14:34:17 +02:00
PKEuS
37aec52399
Simplify complex/_Complex types ( #6939 )
2015-08-26 13:13:45 +02:00
Simon Martin
6fb19b02d0
Properly differentiate arrays of pointers and pointers to arrays.
2015-08-25 21:19:19 +02:00
PKEuS
8d926d7328
Moved some simple WinAPI/MFC-specific simplifications to windows.cfg
2015-08-20 15:59:59 +02:00
PKEuS
0babc4f38f
Moved some unit tests to testgarbage.cpp
2015-08-16 14:49:35 +02:00
Alexander Mai
b3cc4629a6
Remove obsolete tests. Add incomplete test for GNU __builtin_expect to gnu.c
2015-08-10 21:20:20 +02:00
Daniel Marjamäki
72706cd0b8
Fixed #6868 (Tokenizer: wrong simplification of the unlikely keyword)
2015-08-08 12:49:42 +02:00
Frank Zingsheim
7021cb2c6b
Fixed #6284 (Token::Match called with varid 0. Constants)
2015-08-02 09:11:51 +02:00
Alexander Mai
acf050793e
#6907 segmentation fault (invalid code) in Tokenizer::simplifyTokenList1
2015-08-01 07:39:56 +02:00
Matthias Krüger
83ee640977
Tokenizer::syntaxError: put the character that we have an invalid number of into singlequotes instead of parentheses.
2015-07-31 15:28:59 +02:00
Daniel Marjamäki
05a21d45eb
Fixed #6670 (Analysis failed when there are {} in LHS in compound assignment)
2015-07-27 13:44:35 +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
Simon Shanks
9910c1fa0c
Fixed #6617 (preprocessor performance improvement)
2015-07-24 13:30:41 +02:00