8000 Remove all C-style casts and add clang-tidy rule to forbid them by Mytherin · Pull Request #7656 · duckdb/duckdb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove all C-style casts and add clang-tidy rule to forbid them #7656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
May 24, 2023

Conversation

Mytherin
Copy link
Collaborator

Follow-up from #6967

This PR removes all remaining C-style casts from the codebase and adds the cppcoreguidelines-pro-type-cstyle-cast clang-tidy rule that forbid all usage of C-style casts. Instead the dedicated Cast methods, [const]_data_ptr_cast, [const]_char_ptr_cast, or reinterpret_cast should be used instead.

Aside from just replacing casts and adding more Cast methods, this PR makes the following changes:

  • Adds the UnifiedVectorFormat::GetData method that should be used to get the array data of a UnifiedVectorFormat object
  • BaseExpression::Equals works with references instead of C-pointers
  • The CastPointerToValue should be used to cast a pointer to its uintptr_t value - instead of just casting the pointer
  • Pointers in several methods are made const
  • Many methods in the Transformer are moved to using references instead of pointers, and the PGCast and PGPointerCast methods are added that cast to a reference/optional_ptr respectively

Also includes #7650

@Mytherin Mytherin merged commit faf428b into duckdb:master May 24, 2023
@Mytherin Mytherin deleted the moreclangtidy branch July 5, 2023 03:40
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.

1 participant
0