cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

programmemory.cpp: avoid repeated iteration over values in `Executor::executeImpl()`

Open firewave opened this issue 1 year ago • 5 comments

firewave avatar Aug 15 '24 17:08 firewave

-D__GNUC__ --check-level=exhaustive ../lib/utils.cpp

Clang 17 722,148,610 -> 709,134,445 GCC 14 763,758,550 -> 748,797,242

The example from https://trac.cppcheck.net/ticket/10765#comment:4:

Clang 17 3,745,218,263 -> 3,683,364,401 GCC 14 4,007,836,001 -> 3,916,329,290

firewave avatar Aug 15 '24 17:08 firewave

@pfultz2 Is this a valid change?

The previous code had priority which value type have been taken which is no longer the case in the new code. Tests are still passing and I also added an else to break into and that was never hit so it seems like this change should be fine.

firewave avatar Aug 15 '24 17:08 firewave

Tokens can have more than one known value, but its not very common.

pfultz2 avatar Aug 16 '24 13:08 pfultz2

Tokens can have more than one known value, but its not very common.

So the priority of fetching the type is important?

What is such a case? We should add a unit test for that (if there isn't one already).

firewave avatar Aug 16 '24 13:08 firewave

Requires #7181 to be merged first.

There are multiple known values. TestAutoVariables::danglingLifetimeContainer fails when I assert on that. It has known ITERATOR_START and CONTAINER_SIZE.

firewave avatar Jan 26 '25 22:01 firewave