Commit Graph

12213 Commits

Author SHA1 Message Date
chrchr-github ca0c13e27d
Fix crash in iscpp11init_impl() () 2023-01-26 22:25:49 +01:00
Oliver Stöneberg bea6aec2b2
extracted `ValueFlow::Value` to `vfvalue.{cpp|h}` () 2023-01-26 22:23:22 +01:00
chrchr-github b5a06d045e
Fix debug: CheckClass::isMemberVar found used member variable 'x' with varid 0 (inconclusive) () 2023-01-26 22:19:51 +01:00
chrchr-github a0f51d1e21
Improve <type-checks><unusedvar> error message () 2023-01-26 22:18:55 +01:00
Oliver Stöneberg a0b1285f4a
added CMake option `BUILD_CORE_DLL` to build lib as `cppcheck-core.dll` with Visual Studio () 2023-01-26 22:13:07 +01:00
Robert Reif c3aa0940be
fix truncation of token flags () 2023-01-26 22:11:37 +01:00
chrchr-github 3a8d9b8c87
Fix FP CastIntegerToAddressAtReturn with ternary operator () 2023-01-26 22:09:55 +01:00
Oliver Stöneberg e5572835c0
fixed `platforms` lookup / set proper platform type for `unix32-unsigned` and `unix64-unsigned` / copy `platforms` in CMake () 2023-01-26 22:05:40 +01:00
chrchr-github b12aebc817
Fix FN (style) Condition '...' is always true, add test for () 2023-01-26 22:03:12 +01:00
chrchr-github 84fdc08853
Fix internalAstError with chain of ternary operators () 2023-01-26 20:12:39 +01:00
chrchr-github c50339804b
Fix internalAstError with switch/case () 2023-01-26 20:11:45 +01:00
Oliver Stöneberg 41849b1a78
generate `*.vcxproj` file lists with `dmake` () 2023-01-21 11:55:36 +01:00
Oliver Stöneberg 38abeccd24
added command-line option `--disable=<id>` to disable individual checks () 2023-01-21 10:39:44 +01:00
chrchr-github 7945b835e1
Add support for std::string_view::substr() () 2023-01-20 15:46:06 +01:00
Oliver Stöneberg 99acd3145e
bumped simplecpp to 9dc2c3df53 () 2023-01-20 15:41:32 +01:00
Oliver Stöneberg a8fd5cbaf4
added `entrypoint` to library configuration and got rid of hard-coded ones () 2023-01-18 20:52:33 +01:00
chrchr-github 3076f9def1
Fix Function call not recognized with extra parentheses / FP nullPointer () 2023-01-18 20:38:37 +01:00
chrchr-github dfd3e8ac55
Partial fix for : No implicit int in C++ mode () 2023-01-18 20:37:00 +01:00
chrchr-github 7515305581
Add test for () 2023-01-18 17:30:22 +01:00
chrchr-github 0b62c73ff0
Fix spurious variable declaration with unknown macro and using () 2023-01-18 17:11:41 +01:00
chrchr-github c4784a1552
Partial fix for internalAstError regressions (iscpp11init) () 2023-01-18 17:09:55 +01:00
chrchr-github 9cf934c10d
Improve handling of 'final' in class declaration () 2023-01-18 17:08:43 +01:00
chrchr-github dee2ad8756
Fix FP selfAssignment () 2023-01-18 16:59:56 +01:00
chrchr-github a2fea3d9b4
Fix FP knownConditionTrueFalse with reassigned pointer () 2023-01-18 16:57:22 +01:00
chrchr-github f8f66aeea9
Improve std.cfg: std::addressof(), std::stringstream::str() ()
* Improve std.cfg: std::addressof(), std::stringstream::str()

* Format

* Add <leak-ignore/>
2023-01-16 22:08:31 +01:00
chrchr-github 6e2cc450b8
Fix FN functionConst with access of smart pointer ()
* Fix  FNfunctionConst with access of smart pointer

* Simplify
2023-01-16 22:07:04 +01:00
Oliver Stöneberg 124668979c
replaced some `std::ostringstream` usage with `std::to_string()` () 2023-01-16 22:05:33 +01:00
chrchr-github a102ff3c2f
Fix FN unusedFunction / Fix FP unusedFunction () 2023-01-14 20:16:55 +01:00
chrchr-github a79dff15ab
Fix FP uninitvar with try/catch () 2023-01-14 20:14:38 +01:00
chrchr-github 7bbdc95f25
Fix FP constVariable / FP constParameter / FP danglingTempReference ()
* Fix  FP constVariable with range-based for /  FP constParameter with unused non-const range loop variable

* Fix ValueType /  FP danglingTempReference with auto

* Fix ValueType in range-based for

* Update symboldatabase.cpp
2023-01-11 22:04:06 +01:00
chrchr-github 491721a6ff
Fix spurious variable declaration with unknown macro () 2023-01-09 16:11:26 +01:00
Oliver Stöneberg 8cc3e0b2ff
errortypes.h: use `enum class` instead of wrapping types into classes () 2023-01-08 19:31:54 +01:00
chrchr-github 911d610f2d
Fix FN unusedFunction when enum value with same name exists () 2023-01-08 14:30:42 +01:00
Paul Fultz II cefc105c5f
Fix 11468: false positive danglingTempReference warning () 2023-01-07 23:44:22 +01:00
chrchr-github b29f111082
Improve qt.cfg: unreadVariable for macro parameter () 2023-01-07 23:29:47 +01:00
chrchr-github 4ebdf5fae1
Fix FP identicalConditionAfterEarlyExit when passing *this () 2023-01-07 22:10:07 +01:00
Paul Fultz II 6020feb271
Fix 11461: arrayIndexOutOfBounds false positive () 2023-01-07 22:09:17 +01:00
chrchr-github 4c1c506d21
FP returnTempReference with cast and scope operator () 2023-01-02 22:13:56 +01:00
chrchr-github 2007cd0a1d
Fix FP returnDanglingLifetime/returnTempreference with typeid () 2023-01-02 17:46:03 +01:00
chrchr-github f793b7dd35
Fix unintvar false positive ()
* Fix  unintvar false positive

* Format
2023-01-02 17:44:52 +01:00
chrchr-github 11f1a9d1f5
Fix crash on ternary with omitted operand ()
* Fix MSVC compiler warning

* Fix crash on incomplete ternary operator

* Revert "Fix crash on incomplete ternary operator"

This reverts commit 28df0f0ab6ff794e733617447f847a97c1a7a609.

* Handle ternary with omitted operand
2023-01-02 17:44:17 +01:00
Daniel Marjamäki bf11cdf299 TestCmdLineParser: Add tests for ignored paths 2023-01-01 15:32:37 +01:00
Oliver Stöneberg 0c95971c54
added .gitattributes and normalized files () 2022-12-30 21:33:45 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible () 2022-12-30 15:13:47 +01:00
orbitcowboy 3136a50b97 Formatting [ci skip] 2022-12-22 11:59:10 +01:00
orbitcowboy 347c10db3b posix.cfg: Improved configuration of mq_timedsend(). 2022-12-22 11:58:32 +01:00
orbitcowboy f5b9445767 posix.cfg: Added support for more posix_trace..() functions 2022-12-22 11:48:51 +01:00
orbitcowboy 3c57752c9b posix.cfg: Added support for more posix_trace..() functions 2022-12-22 11:39:00 +01:00
orbitcowboy 5991c33b0e posix.cfg: Added support for pthread_attr_getstack() and pthread_attr_setstack(). 2022-12-22 10:07:50 +01:00
orbitcowboy ccbc6a3b72 gnu.cfg: Added support for gethostbyname_r() and gethostbyname2_r() 2022-12-22 09:47:19 +01:00
orbitcowboy 3576f0a0c7 gnu.cfg: Added support for gethostbyaddr_r() 2022-12-22 09:36:53 +01:00
orbitcowboy ea56359a3f posix.cfg: Added nullPointer test for setkey() 2022-12-22 09:36:18 +01:00
orbitcowboy 24a71144f6 posix.cfg: Added support for encrypt() 2022-12-22 09:19:46 +01:00
orbitcowboy 7df6ba419e gnu.cfg: Added nullPointer tests for getop_long_only() 2022-12-22 09:13:18 +01:00
orbitcowboy 70ea3c2902 posix.cfg: Added nullPointer tests for getop() 2022-12-22 09:12:57 +01:00
orbitcowboy 521f0ce720 gnu.cfg: Added nullpointer tests for getopt_long(). 2022-12-21 17:06:08 +01:00
Oliver Stöneberg b380fd2589
added command-line option `--valueflow-max-iterations` to control amount of valueflow iterations / also log debug warning when iterations are being exceeded () 2022-12-20 20:51:08 +01:00
Oliver Stöneberg 3c68b9b29f
use `cbegin()` and `cend()` with `const_ierator` loops () 2022-12-20 20:32:16 +01:00
Paul Fultz II f8132ea022
Fix 11381: FP derefInvalidIteratorRedundantCheck when updating iterator using std::tie () 2022-12-20 20:29:19 +01:00
chrchr-github 7506b4ab52
Fix FP variableScope when lambda is used () 2022-12-20 14:50:31 +01:00
chrchr-github ad858e92dc
Partial fix for cppcheckError: Analysis failed (function not recognized) () 2022-12-19 22:29:43 +01:00
Paul Fultz II da32c5aecd
Fix 11442: new "Reference to temporary returned." FPs () 2022-12-19 22:28:59 +01:00
Oliver Stöneberg 2cd8bb94e4
some small `CmdLineParser` cleanups and improvements () 2022-12-19 22:28:36 +01:00
Paul Fultz II 9da574f4a0
Fix 11227: ValueFlow: Known value not set in condition for ternary operator ()
* Evaluate args before function call

* Fix tests

* Format

* Add test for 11227

* Format

* Fix known condition
2022-12-18 22:07:43 +01:00
Oliver Stöneberg 0ed98c8f29
removed unused test files () 2022-12-18 19:36:37 +01:00
chrchr-github 98b3d66684
Add test for () 2022-12-18 16:57:25 +01:00
chrchr-github 76c28073aa
Revert fix for () 2022-12-18 16:55:55 +01:00
chrchr-github 617cd29a41
Get type from auto () 2022-12-18 16:54:58 +01:00
chrchr-github b1abaf8809
Fix FP useStlAlgorithm (don't suggest std::accumulate when nothing is accumulated) () 2022-12-18 16:52:04 +01:00
gerboengels 63e30d1b8c
Fix syntaxError on lambda inside decltype ()
Use case where it gave an issue:

using customComparator = decltype([] (const X& lhs, const X& rhs) { return lhs.CompareTo(rhs); });
std::map<X, int, costomComparator> m;

Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-12-18 16:46:04 +01:00
chrchr-github 4c8aa56d8b
Partial fix for internalAstError regressions (iscpp11init) ()
* Partial fix for  internalAstError regressions (iscpp11init)

* Use %cop%

* Add test for 

* Format

* Format
2022-12-16 10:46:15 +01:00
Paul Fultz II 9c55b933c1
Partial fix for 11303: False negative: knownConditionTrueFalse using container .back() ()
* Partial fix for 11303: False negative: knownConditionTrueFalse using container .back()

* Format

* Fix error message
2022-12-15 18:35:19 +01:00
Paul Fultz II 90898945c1
Fix 10532: False negative: dangling string_view when using ternary operator ()
* Fix 10532: False negative: dangling string_view when using ternary operator

* Format

* Update
2022-12-15 18:34:43 +01:00
chrchr-github 553b579f8d
Fix FP knownConditionTrueFalse with loop over bool array ()
* Fix  FP knownConditionTrueFalse with loop over bool array

* Simplify
2022-12-15 14:31:02 +01:00
chrchr-github 0c1e2ceeb9
Fix FP wrongPrintfScanfArgNum - snprintf with parameter pack () 2022-12-15 08:52:13 +01:00
chrchr-github b7693ccc7a
Fix FP resourceLeak with goto () 2022-12-14 22:47:14 +01:00
Oliver Stöneberg 29e0133cb5
extracted `FwdAnalysis` from `astutils.{cpp|h}` ()
* added missing filtering offiles in Visual Studio project

* extracted `FwdAnalysis` from `astutils.{cpp|h}`
2022-12-13 22:29:23 +01:00
Paul Fultz II e2f398f81a
Fix 11250: FN: bufferAccessOutOfBounds (comma operator: int x = (3,4) ) ()
* Fix 11250: FN: bufferAccessOutOfBounds (comma operator: int x = (3,4) )

* Format
2022-12-13 07:52:58 +01:00
Oliver Stöneberg e01c463ff8
fixed - improved handling of suffixes in `MathLib::to{Double|ULong|Long}Number()` ()
* fixed  - improved handling of suffices in `MathLib::to{Double|ULong|Long}Number()`

* testmathlib.cpp: adjustments for `libc++`

* mathlib.cpp: added TODO
2022-12-13 07:52:45 +01:00
Paul Fultz II b4d455df48
Fix 11349: FP negativeIndex for clamped array index ()
* Fix 11349: FP negativeIndex for clamped array index

* Format

* Use emplace_back

* Use default constructor
2022-12-13 07:50:01 +01:00
chrchr-github 5b687cb038
Fix Crash in valueFlowForwardConst() () 2022-12-12 22:58:48 +01:00
chrchr-github 3f5054035d
Fix FP passedByValue for overriden function () 2022-12-12 21:52:58 +01:00
Paul Fultz II 3f88744851
Fix 11358: FP containerOutOfBounds for container passed by pointer () 2022-12-09 19:43:21 +01:00
Oliver Stöneberg 40a69e5afb
optimized deserializing of `ErrorMessage` and related main process code () 2022-12-09 19:34:51 +01:00
Paul Fultz II 7acbb656f3
Fix 11412: False positive: uninitvar ()
* Dont remove modified variables from dead code

* Add test for 11412

* Format
2022-12-09 07:15:47 +01:00
Paul Fultz II c150317f02
Fix 11384: FP knownConditionTrueFalse when variable is modified in return statement ()
* Fix 11384: FP knownConditionTrueFalse when variable is modified in return statement

* Format
2022-12-09 07:15:15 +01:00
chrchr-github c779cefa61
Fix debug: Missing variable class for variable with varid () 2022-12-08 20:17:06 +01:00
Paul Fultz II 0cb742701d
Fix 11415: FP containerOutOfBounds for container initialized in virtual method () 2022-12-08 20:10:58 +01:00
chrchr-github 04b7c0c200
Fix FP knownConditionTrueFalse with iterator ()
* Fix wrong value set in valueFlowSameExpressions()

* Fix   FP knownConditionTrueFalse with iterator
2022-12-08 10:40:55 +01:00
Paul Fultz II 663a8411dd
Fix 11416: FP nullPointerRedundantCheck for check after loop with break () 2022-12-08 07:27:06 +01:00
Oliver Stöneberg 4103d05c7f
improved `ErrorMessage::deserialize()` error messages () 2022-12-07 18:00:45 +01:00
chrchr-github 8713dabe58
Get type from iterator () 2022-12-07 09:38:36 +01:00
Oliver Stöneberg 8bb5ac0efd
improved `MathLib::to{ULong|Long|Double}Number()` and increased test coverage / added CMake option `USE_LIBCXX` / fixed () 2022-12-07 09:20:09 +01:00
chrchr-github 89dba226dd
Fix FP uninitvar with unseen typedef () 2022-12-07 09:14:22 +01:00
chrchr-github 0e57c27dd3
Fix debug: CheckClass::checkConst found unlinked template argument list () 2022-12-07 09:12:46 +01:00
chrchr-github d5d7446433
Add cfg for std::scoped_lock, handle template arguments in checkMisusedScopedObject() () 2022-12-07 09:10:48 +01:00
Oliver Stöneberg 7d3ce62ee9
improved errorhandling related to deserializing `ErrorMessage` () 2022-12-03 15:44:33 +01:00
Rikard Falkeborn 9427fa3c66
Refactor runtests to allow to specify files on command line () 2022-12-03 15:41:11 +01:00
chrchr-github 0854fda28a
Get type from smartpointer ()
* Fix  checkLibraryFunction treats "auto" as type

* Use utility function

* Get type from 'auto p = new ...'

* Fix merge

* Add test for recent fix

* Format

* Get type from smartpointer
2022-12-03 07:50:21 +01:00
chrchr-github 7d6683fb78
Fix FP knownConditionTrueFalse with container and brace init ()
* Fix  FP knownConditionTrueFalse with container and brace init

* Format

* Format

* Move to getInitListSize()
2022-12-02 22:07:08 +01:00
chrchr-github e4ee7cd59c
Get type from 'auto p = new ...' ()
* Fix  checkLibraryFunction treats "auto" as type

* Use utility function

* Get type from 'auto p = new ...'

* Fix merge
2022-12-02 20:28:14 +01:00
chrchr-github 9efedd6be9
Fix checkLibraryFunction treats "auto" as type ()
* Fix  checkLibraryFunction treats "auto" as type

* Use utility function
2022-12-02 07:21:33 +01:00
chrchr-github 428f5016d4
Partial fix for (iscpp11init) ()
* Partial fix for  (iscpp11init)

* Improve fix

* Add fix
2022-11-27 09:26:46 +01:00
chrchr-github 665e4230f2
Fix FP returnDanglingLifetime, std::unique_ptr and implicit conversion to bool () 2022-11-27 09:24:19 +01:00
chrchr-github 4cb49013a7
Fix FP danglingTemporaryLifetime with std::string_view () 2022-11-27 09:22:55 +01:00
Rikard Falkeborn 52264b9c26
Fix nullpointer dereference with alignof ()
* checknullpointer: Don't report dereference with alignof

* Refactor unevaluating operator check in checknullpointer

Unifying these ensures the different checks treat the operators the
same.

* Fix FP with _Alignof and null pointer

Just like alignof, _Alignof does not evaluate its operand.

* CheckNullPointer: Also support compiler specific alignof

This fixes  which is about __alignof__. For good measure, also add
the microsoft extensions __alignof and _alignof.
2022-11-27 09:20:19 +01:00
Rikard Falkeborn 8465d901c8
Fix 11396, doublefree on munmap in if-statement () 2022-11-26 15:45:27 +01:00
Daniel Marjamäki c26a8fb4ce Fixed (Cant exclude file) 2022-11-24 13:45:57 +01:00
Stefan van Kessel a5c16af16d
Fix lambda capture template syntax error () 2022-11-23 20:15:10 +01:00
chrchr-github 68acd77053
Fix FP ctuPointerArith with unknown buffer size () 2022-11-23 19:11:47 +01:00
Daniel Marjamäki ad8c1e26f0 dump: output language to dumpfile 2022-11-20 12:30:09 +01:00
chrchr-github 9f50611a44
Fix FP doubleFree with goto () 2022-11-19 16:49:34 +01:00
chrchr-github 80aa6dc1d9
Fix FP mismatchAllocDealloc with std::unique_ptr and custom deleter () 2022-11-18 19:45:25 +01:00
gerboengels 3fdba645a6
Improve fix for FP selfAssignment: lambda capture () 2022-11-18 19:44:32 +01:00
chrchr-github 4ce76d0b58
Fix debug: SymbolDatabase::findFunction found '>' without link. () 2022-11-14 21:08:15 +01:00
chrchr-github e3939d32d0
Fix crash on nullptr ()
* Update tokenlist.cpp

* Update testincompletestatement.cpp

* Fix  FP constStatement with lambda

* Format

* Fix crash on nullptr

* Emit syntax error

* Fix test

* Use strAt()

* Fix another crash on nullptr

* Update testconstructors.cpp

* Fix crash on nullptr

* Fix test
2022-11-13 23:04:51 +01:00
chrchr-github 701d381895
Fix FP selfAssignment: lambda capture / FP operatorEqRetRefThis ()
* Fix   FP selfAssignment: lambda capture /  
FP operatorEqRetRefThis

* Format
2022-11-13 21:20:44 +01:00
chrchr-github e8b37235d6
Fix internalAstError regressions (iscpp11init) () 2022-11-12 22:25:05 +01:00
Daniel Marjamäki 8fb8e06003 SymbolDatabase: Set valuetype for this 2022-11-12 22:23:42 +01:00
chrchr-github 4e75c08f58
Respect [[maybe_unused]] in unusedPrivateFunction () 2022-11-10 20:58:39 +01:00
Armin Müller 7f74aad8e2
Typos found by running "codespell" () 2022-11-09 22:52:03 +01:00
chrchr-github ffc0c57562
Fix crashes on nullptr () 2022-11-09 21:56:16 +01:00
gerboengels bd95efc987
Fix internal error "Unexpected tokens in initializer" with anonymous namespace ()
Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-11-05 22:41:13 +01:00
Daniel Marjamäki e45e5f9f15 SymbolDatabase: fix ValueType for '&array[x]' 2022-11-05 21:22:08 +01:00
Daniel Marjamäki ecb2938e7e SymbolDatabase: Set correct ValueType when there is array-to-pointer decay 2022-11-05 17:38:31 +01:00
gerboengels d7a8f7f297
Fix couple issues with missing operatorEqVarError () 2022-11-05 10:48:34 +01:00
omarandlorraine 6488650d24
use python3 on debians too ()
* use python3 on debians too

in Debian 11 which is Bullseye, /usr/bin/python is a Python2
interpreter, which means that cppcheck-htmlreport fails to run here.
So I've chenged the shebang to use python3

* change all shebangs from python to python3

Co-authored-by: Sam M W <smw@alertergroup.co.uk>
2022-11-03 22:14:30 +01:00
Rikard Falkeborn 3c21b9cc53
Fix , FP memory leak in if-statement in realloc with cast () 2022-11-03 10:37:43 +01:00
chrchr-github e4c5f36af0
Fix typedef: not simplified after inline keyword () 2022-11-02 15:15:33 +01:00
chrchr-github ccf2176664
Fix FP constStatement with lambda ()
* Update tokenlist.cpp

* Update testincompletestatement.cpp

* Fix  FP constStatement with lambda

* Format
2022-11-01 11:50:08 +01:00
chrchr-github d717e62ec3
Fix Detect assignment to temporary ()
* Fix  Detect assignment to temporary

* Use AST

* Warn if type definition is not seen
2022-11-01 11:46:42 +01:00
chrchr-github cf8051b7e2
Fix FP "Same value in both branches of ternary operator" on plus and minus zero ()
Fix  FP "Same value in both branches of ternary operator" on plus and minus zero
2022-10-31 15:18:25 +01:00
chrchr-github 6df8573e15
Fix Syntax error. Unexpected tokens in initializer. () 2022-10-29 21:24:50 +02:00
chrchr-github b4e78e8ac5
Fix new internalAstError ()
* Fix  new internalAstError

* Format

* Handle scope operator

* Format

* Format
2022-10-25 21:50:37 +02:00
chrchr-github 3b5601dbea
Add tests for , ()
* Add test for 

* Add test for 
2022-10-25 19:41:48 +02:00
chrchr-github 13d81cdd58
follow-up: Handle more variadic template arguments ()
* Update templatesimplifier.cpp

* Add tests
2022-10-22 00:28:33 +02:00
chrchr-github ae16aab997
Handle simple typedefs () 2022-10-22 00:28:05 +02:00
chrchr-github e046232535
Fix FP returnDanglingLifetime for pointer to struct member in static array ()
* Fix   FP returnDanglingLifetime for pointer to struct member in static array

* Undo
2022-10-22 00:27:30 +02:00
chrchr-github 515369739c
Fix FP constStatement for function-local struct definition+initialization statement () 2022-10-22 00:27:19 +02:00
Razvan Ioan Alexe 1da37461e3
Typo found in Summary of CWE: 758 () 2022-10-20 19:11:15 +02:00
chrchr-github 7b9c99003b
Improve unreachableCodeError: handle library functions ()
* Update templatesimplifier.cpp

* Add tests

* Improve unreachableCodeError message

* Update templatesimplifier.cpp

* Add tests

* Improve unreachableCodeError message

* Revert "Update templatesimplifier.cpp"

This reverts commit 3fd152ed4063772a5f162bd985c3d91bcc65eb55.

* Revert "Add tests"

This reverts commit e760ab51e66a0a2c3a0250caf4cf3b745db44d10.

* Improve unreachableCodeError: handle library functions

* Fix merge
2022-10-20 07:00:36 +02:00
chrchr-github 9c7b4c9540
Improve unreachableCodeError message ()
* Update templatesimplifier.cpp

* Add tests

* Improve unreachableCodeError message

* Update templatesimplifier.cpp

* Add tests

* Improve unreachableCodeError message

* Revert "Update templatesimplifier.cpp"

This reverts commit 3fd152ed4063772a5f162bd985c3d91bcc65eb55.

* Revert "Add tests"

This reverts commit e760ab51e66a0a2c3a0250caf4cf3b745db44d10.
2022-10-19 19:19:31 +02:00
chrchr-github 192c30ab1d
Fix crash in arraySize() ()
* Fix   FN: arrayIndexOutOfBounds

* Fix

* Fix crash in arraySize()
2022-10-19 19:19:01 +02:00
gerboengels 6a01fa9b70
Fix broken AST with (designated) initializers ()
* Make control flow a bit easier, and more similar to previous code

Made similar to around line 790

* In a cpp11init, always parse only the corresponding } ()

- _always_, because in some cases this was omitted (around line 790) or too strict (around line 860)
- _only_, and not following tokens which happen to be } as well (around line 1030)

* Fix unit tests: AST was incorrect, now is fixed

auto var{ {{},{}}, {} };

Old AST:
```
{
|-var
`-{
  `-,
    |-,
    | |-{
    | `-{
    `-{
```
New AST:
```
{
|-var
`-,
  |-{
  | `-,
  | | |-{
  | | `-{
  `-{
```
Compare the same example, but with `X{}` instead of just `{}`:
`auto var{ a{b{},c{}}, d{} };`
```
{
|-var
`-,
  |-{
  | |-a
  | `-,
  | | |-{
  | | | `-b
  | | `-{
  | | | `-c
  `-{
    `-d
```
This structure is similar to that of the new AST, not the old AST

* Fix unit tests: another AST was incorrect, now is fixed

Code: `auto var{{1,a::b{2,3}}, {4,a::b{5,6}}};`

Old AST:
```
{
|-var
`-{
  `-,
    |-,
    | |-1 'signed int'
    | `-{
    | | |-::
    | | | |-a
    | | | `-b
    | | `-,
    | | | |-2 'signed int'
    | | | `-3 'signed int'
    `-{
      `-,
        |-4 'signed int'
        `-{
          |-::
          | |-a
          | `-b
          `-,
            |-5 'signed int'
            `-6 'signed int'
```
New AST:
```
{
|-var
`-,
  |-{
  | `-,
  | | |-1 'signed int'
  | | `-{
  | | | |-::
  | | | | |-a
  | | | | `-b
  | | | `-,
  | | | | |-2 'signed int'
  | | | | `-3 'signed int'
  `-{
    `-,
      |-4 'signed int'
      `-{
        |-::
        | |-a
        | `-b
        `-,
          |-5 'signed int'
          `-6 'signed int'
```

* Fix unit tests: missing ; after class, resulting in incorrectly being marked as cpp11init

Because of the missing `;` after the class declaration, it was marked as a cpp11init block.
Which it isn't, and which now throws an exception

* Fix cpp11init to let unit tests pass again

The following unit tests failed on the newly introduced throws, because the code for these tests incorrectly marked some tokens as cpp11init:
TestVarID::varid_cpp11initialization
TestTokenizer::checkRefQualifiers

* Fix typo

* Improve check for void trailing return type

Observation: the only function body _not_ containing a semicolon, is a void function: something like
   auto make_zero(ini& i) -> void {
     while(--i > 0) {}
   }
Non-void function? Then it must return a value, and thus contain a semicolon, which is checked for a few lines later.

* Fix cpp11init with templated trailing return type

In the following example, vector was marked as cpp11init due to the mismatch of `%any% {`
auto f() -> std::vector<int> { return {}; }

I made the assumption that whenever "%any% {" matches, endtok must be set too.
If this assumtion doesn't hold (so "%any% {" matches, but endtok == nullptr), then the for-loop would search all the way to the end of stream. Which I guess was not the intention.

* Remove comments

Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-10-19 07:25:15 +02:00
chrchr-github 5a8e55c083
Fix FN: arrayIndexOutOfBounds ()
* Fix   FN: arrayIndexOutOfBounds

* Fix
2022-10-18 07:24:24 +02:00
chrchr-github c6c339a3e7
Fix Assert failure in templatesimplifier.cpp () 2022-10-16 19:34:25 +02:00
gerboengels 221873e69f
Fix ()
In this example:
```
//template<std::same_as<int> T> // <= works
template<same_as<int> T>        // <= didn't work
void f()
{}
```
the changed line used to match to `< same_as <`, therefore skip creating links.
The `%op% %name% <` already feels a bit like a workaround. So adding the condition that $op$ shouldn't be a comparison operator, but part of the template, seemed reasonable to me

Co-authored-by: Gerbo Engels <gerbo.engels@ortec-finance.com>
2022-10-16 19:33:44 +02:00
Oliver Stöneberg 2ac9fbc1bf
include all (internal non-generated) headers in clang-tidy checks () 2022-10-16 13:51:17 +02:00
chrchr-github 3273e51fd5
Fix FN useStlAlgorithm with iterators () 2022-10-16 13:46:26 +02:00
chrchr-github 6c24d2b865
Fix FP uninitvar for in-class member initialization () 2022-10-14 19:48:27 +02:00