Skip to content

Conversation

@chrchr-github
Copy link
Collaborator

No description provided.

Copy link
Owner

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see why we want to have different results from ValueType::typeSize and ValueFlow::getSizeOf. Can you explain it? Did you consider refactoring so that ValueType::typeSize calls ValueFlow::getSizeOf or vice versa?

@chrchr-github
Copy link
Collaborator Author

I do not see why we want to have different results from ValueType::typeSize and ValueFlow::getSizeOf. Can you explain it? Did you consider refactoring so that ValueType::typeSize calls ValueFlow::getSizeOf or vice versa?

Yes, having those two functions is unfortunate, and they should be merged.
The main difference is that ValueType::typeSize returns the size of the pointed-to type by default (controlled by the p parameter). Also, ValueType::typeSize doesn't seem to work for user-defined types (it returns typeScope->definedType->sizeOf, which seems to only get set by clang import.

@chrchr-github chrchr-github marked this pull request as draft December 7, 2025 19:16
@chrchr-github
Copy link
Collaborator Author

BTW, is daca down? I haven't been able to connect to http://cppcheck1.osuosl.org:8000/ for a while.

@firewave
Copy link
Collaborator

firewave commented Dec 7, 2025

BTW, is daca down? I haven't been able to connect to http://cppcheck1.osuosl.org:8000/ for a while.

The server did not start up because the package index was corrupted. It is fixed now.

@firewave
Copy link
Collaborator

firewave commented Dec 7, 2025

The server did not start up because the package index was corrupted. It is fixed now.

Clients process data again.

lua-svn                                  2025-11-27 18:18      34      34         
0install-solver                          2025-12-07 23:38       8       8

Had been broken for over a week.

@chrchr-github chrchr-github marked this pull request as ready for review December 8, 2025 20:11
ValueType vt = *typeTok->valueType();
if (vt.pointer > 0)
--vt.pointer;
const size_t typeSize = vt.getSizeOf(settings, ValueType::Accuracy::ExactOrZero, ValueType::SizeOf::Pointer);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not check how this works.. but do we have to create a temporary?

I spontanously wonder; can't the 3rd argument be typeTok->valueType()->pointer > 1 ? ValueType::Sizeof::Pointer : ValueType::SizeOf::Pointee or something like that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that should no longer be necessary.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 9, 2025

"}";
values = tokenValues(code, "( D )");
ASSERT_EQUALS(1U, values.size());
TODO_ASSERT_EQUALS(2 * settings.platform.sizeof_pointer, 1, values.back().intvalue);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already incorrect before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants