Coding - Replace C-style casts with C++ cast operators#1206
Open
jijinbei wants to merge 3 commits intoOpen-Cascade-SAS:IRfrom
Open
Coding - Replace C-style casts with C++ cast operators#1206jijinbei wants to merge 3 commits intoOpen-Cascade-SAS:IRfrom
jijinbei wants to merge 3 commits intoOpen-Cascade-SAS:IRfrom
Conversation
Applies clang-tidy 20.1.8 google-readability-casting across all buildable modules (FoundationClasses, ModelingData, ModelingAlgorithms, Visualization, DataExchange, ApplicationFramework, Draw). 751 files changed; clang-tidy replaced C-style casts with static_cast / reinterpret_cast / const_cast or removed unnecessary ones. Four manual corrections were needed where the tool's default choice did not compile: - OSD_SharedLibrary.cxx: dlsym() returns void*, converting to function pointer requires reinterpret_cast, not static_cast. - TopLoc_Location.lxx: casts to `const void**` from const member address dropped a qualifier; rewrote as `const void* const*`. - TopOpeBRep_sort.cxx: qsort callback casts from `const void*` needed `const BOA_t*` to preserve const. - XCAFDoc_ShapeTool.cxx: casts to `void**` from const handle address dropped qualifiers; rewrote as `void* const*`. - IntCurveSurface_InterUtils.pxx: tool emitted an extra closing parenthesis in two `(double)iU`-style casts; removed. Excluded: src/Deprecated/, Khronos headers (OpenGl_glext.h, OpenGl_khrplatform.h). Verified by full Release build (Linux, GCC 15.2, Ninja, -O3 -DNDEBUG) across all seven modules. 0 errors. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Addresses PR Open-Cascade-SAS#1206 feedback: 1. macOS Clang build: static_cast<Standard_ThreadId>(pthread_t) does not compile because pthread_t is a pointer (_opaque_pthread_t*) on macOS, unlike Linux where it is unsigned long. Added #elif defined(__APPLE__) branches in OSD_Thread.cxx using reinterpret_cast for the two sites (line 190 and 365). 2. Check code formatting: applied the CI's format.patch artifact. The clang-tidy google-readability-casting replacements left some lines outside the configured column width; clang-format restores the layout across 213 files. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Applies the CI clang-format patch: nested preprocessor directives inside a block need 2-space indentation per OCCT's .clang-format.
Contributor
Author
|
Hand edits (clang-tidy google-readability-casting did the rest):
|
Contributor
Author
CLA ID1142 |
Member
|
My apologies, commit is very big to review. Many thanks for your commitment, after release the changes can be modified and merged ;) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mechanical replacement of C-style casts with named C++ cast operators
(
static_cast/reinterpret_cast/const_cast) acrosssrc/.Generated by
clang-tidy 20.1.8 google-readability-castingviarun-clang-tidy -j 20 -fix, scoped tosrc/and excluding theKhronos headers and
src/Deprecated/.Scope
static_castchoice did not compile (details in the commit body).Excluded
src/Deprecated/OpenGl_glext.h,OpenGl_khrplatform.hVerification
Full Release build on Linux (C++17, GCC 15.2, Ninja,
-O3 -DNDEBUG).0 errors across all seven modules.
Relation to #1205
Independent of PR #1205 (the C++17 modernization sweep). Branched
from upstream
master, no overlap in changed lines expected.CLA ID
1142
Notes
CR<issue_id>(no Mantis ticket yet).