Skip to content

Coding - Apply modernize-* and readability-* clang-tidy checks - #1207

Merged
dpasukhi merged 5 commits into
Open-Cascade-SAS:IRfrom
jijinbei:modernize-trio
Apr 28, 2026
Merged

dpasukhi merged 5 commits into
Open-Cascade-SAS:IRfrom
jijinbei:modernize-trio

Conversation

@jijinbei

@jijinbei jijinbei commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Eight additional clang-tidy checks that OCCT had not yet applied, all low-risk and semantics-preserving.

Checks applied

Commit 10bfbfe415:

  • modernize-concat-nested-namespaces (0 hits — OCCT does not use deeply nested namespaces)
  • modernize-redundant-void-arg (1 hit in FlexLexer.h)
  • modernize-use-equals-default (9 hits — empty ctor/dtor → = default)

Commit 40aea5b9fc:

  • modernize-use-emplace (main contributor — push_back(X(a,b))emplace_back(a, b))
  • readability-container-size-empty (size() == 0empty())
  • readability-redundant-string-init (std::string s = ""std::string s)
  • readability-redundant-member-init (X() : x_() {}X() {})
  • modernize-unary-static-assert

Hand edits

  • BOPTools_Set.cxx: clang-tidy collapsed a member-initializer-list copy ctor to = default but left trailing blank lines; merged to one line.

Verification

  • Full Release build on Linux (GCC 15.2, C++17, -O3 -DNDEBUG).
  • All GTests pass: 6718 passed, 4 skipped (same skips as master).

Scope

24 files changed total, ~200 lines diff. Excludes:

  • src/Deprecated/
  • Third-party Khronos headers (OpenGl_glext.h, OpenGl_khrplatform.h)

CLA ID

1142

…uals default)

Enables three modernize-* checks that OCCT had not yet applied:
- modernize-concat-nested-namespaces (C++17, 0 hits — OCCT does not use
  nested namespaces much)
- modernize-redundant-void-arg (1 hit in FlexLexer.h)
- modernize-use-equals-default (9 hits, empty ctor/dtor → `= default`)

Manual cleanup: BOPTools_Set copy constructor had an elaborate
member-init list that clang-tidy collapsed to `= default` but left
trailing blank lines; merged into a single line.

Verified by full Release build on Linux (GCC 15.2, C++17) and all
GTests (6718 passed, 4 skipped as before).
…sert checks

Five additional low-risk clang-tidy checks:
- modernize-use-emplace (main contributor; push_back(X(...)) → emplace_back(...))
- readability-container-size-empty (size() == 0 → empty())
- readability-redundant-string-init (std::string s = "" → std::string s)
- readability-redundant-member-init (X() : x_() {} → X() {})
- modernize-unary-static-assert (static_assert(x, "") → static_assert(x))

14 files modified; 11 warnings fixed. All changes are semantics-
preserving performance/clarity improvements.

Verified by full Release build and GTest (6718 passed, 4 skipped).
CI format check caught one emplace_back call that clang-tidy left
unwrapped past the column limit, plus minor continuation indent in
BRepExtrema_TriangleSet.cxx.
@jijinbei
jijinbei marked this pull request as ready for review April 19, 2026 04:16
@dpasukhi
dpasukhi requested a review from Copilot April 19, 2026 08:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Applies additional modernize-* and readability-* clang-tidy checks across OCCT to reduce boilerplate and align code with modern C++ conventions while keeping changes semantics-preserving.

Changes:

  • Replaces push_back(T(...)) with emplace_back(...) where applicable.
  • Replaces size() == 0 / size() != 0 checks with empty() / !empty().
  • Simplifies trivial constructors/destructors to = default and removes redundant (void) parameter lists.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Visualization/TKOpenGl/OpenGl/OpenGl_View_Raytrace.cxx Uses emplace_back for BVH vectors and switches .size()!=0 to !empty() for raytrace buffers.
src/Visualization/TKOpenGl/OpenGl/OpenGl_SceneGeometry.hxx Uses Elements.empty() in MaterialIndex() for clearer emptiness check.
src/ModelingData/TKBRep/BRepGraph/BRepGraph_VersionStamp.hxx Removes redundant member initializers in constructors.
src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_TriangleSet.cxx Uses emplace_back for triangle/vertex accumulation.
src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_SelfIntersection.cxx Uses emplace_back for shared-vertex pair collection.
src/ModelingAlgorithms/TKTopAlgo/BRepExtrema/BRepExtrema_ProximityValueTool.cxx Uses emplace_back for additional vertex collection.
src/ModelingAlgorithms/TKGeomAlgo/IntPolyh/IntPolyh_MaillageAffinage.cxx Uses emplace_back for BVH pair selection results.
src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_Polygon2dGen.gxx Removes redundant void argument in method signature.
src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_ExactIntersectionPoint.gxx Removes redundant void argument in method signature.
src/ModelingAlgorithms/TKGeomAlgo/IntCurve/IntCurve_DistBetweenPCurvesGen.gxx Removes redundant void argument in method signatures.
src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_GordonBuilder.cxx Defaults empty constructor with = default.
src/ModelingAlgorithms/TKGeomAlgo/GeomFill/GeomFill_Gordon.cxx Defaults empty constructor with = default.
src/ModelingAlgorithms/TKBO/GTests/BRepAlgoAPI_Cut_Test.cxx Uses emplace_back for test point vectors.
src/ModelingAlgorithms/TKBO/GTests/BOPTest_Utilities.pxx Uses empty() for parameter checks and emplace_back for point construction.
src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_Set.cxx Defaults copy constructor with = default.
src/ModelingAlgorithms/TKBO/BOPAlgo/BOPAlgo_Tools.cxx Uses emplace_back for vertex-pair collection.
src/FoundationClasses/TKernel/Standard/Standard_ReadLineBuffer.hxx Uses empty() for string emptiness check.
src/FoundationClasses/TKernel/Standard/Standard_ErrorHandler.cxx Defaults empty callback constructor with = default.
src/FoundationClasses/TKernel/GTests/NCollection_OrderedDataMap_Test.cxx Uses emplace_back when building expected string list in test.
src/FoundationClasses/TKernel/FlexLexer/FlexLexer.h Defaults virtual destructor and removes redundant (void) parameter list.
src/FoundationClasses/TKMath/BVH/BVH_BinaryTree.hxx Uses emplace_back for queueing node pairs during collapse.
src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWRepositionedTessellatedItem.pxx Defaults empty constructor with = default.
src/DataExchange/TKDESTEP/RWStepVisual/RWStepVisual_RWRepositionedTessellatedGeometricSet.pxx Defaults empty constructor with = default.
src/DataExchange/TKDESTEP/GTests/StepTidy_BaseTestFixture.pxx Removes redundant handle initializer in test fixture constructor.

const uint32_t theGeneration)
: myUID(theUID),
myRefUID(),

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

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

The constructor initializer list now contains a standalone blank line after : myUID(theUID), (and similarly leaves a visually empty slot where myRefUID() used to be). This compiles, but it is easy to miss in reviews and creates avoidable formatting churn; please remove the extra blank line so the initializer list is contiguous.

Suggested change

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Collapsed in 0f3eb32

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

// Initialize the work session and model.
StepTidy_BaseTestFixture()
: myWS()

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

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

After removing the redundant member initializer, the constructor now has an extra blank line between the signature and the opening brace. Please collapse this to match the surrounding style (constructor signature followed immediately by { or an initializer list) to avoid cosmetic diffs.

Suggested change

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Collapsed in 0f3eb32

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Collapse the orphan blank lines that remained after removing redundant
member initializers/declarations, so that constructor signatures and
initializer lists stay contiguous.
@dpasukhi
dpasukhi changed the base branch from master to IR April 19, 2026 16:02
@dpasukhi dpasukhi added the 3. CLA approved User has the signed CLA and ready to review or integration processes label Apr 28, 2026
@dpasukhi
dpasukhi self-requested a review April 28, 2026 17:49
@github-project-automation github-project-automation Bot moved this from Todo to Integration in Maintenance Apr 28, 2026
@dpasukhi

Copy link
Copy Markdown
Member

CLA ID 1142

@dpasukhi
dpasukhi merged commit 4d64ddc into Open-Cascade-SAS:IR Apr 28, 2026
35 of 36 checks passed
@github-project-automation github-project-automation Bot moved this from Integration to Done in Maintenance Apr 28, 2026
@dpasukhi

Copy link
Copy Markdown
Member

Merged, thank you for your patch.

@jijinbei

Copy link
Copy Markdown
Contributor Author

thanks!!

@jijinbei
jijinbei deleted the modernize-trio branch April 29, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. CLA approved User has the signed CLA and ready to review or integration processes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants