Coding - Apply modernize-* and readability-* clang-tidy checks - #1207
Conversation
…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.
There was a problem hiding this comment.
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(...))withemplace_back(...)where applicable. - Replaces
size() == 0/size() != 0checks withempty()/!empty(). - Simplifies trivial constructors/destructors to
= defaultand 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(), | ||
|
|
There was a problem hiding this comment.
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.
| // Initialize the work session and model. | ||
| StepTidy_BaseTestFixture() | ||
| : myWS() | ||
|
|
There was a problem hiding this comment.
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.
Collapse the orphan blank lines that remained after removing redundant member initializers/declarations, so that constructor signatures and initializer lists stay contiguous.
|
CLA ID 1142 |
|
Merged, thank you for your patch. |
|
thanks!! |
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 inFlexLexer.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() == 0→empty())readability-redundant-string-init(std::string s = ""→std::string s)readability-redundant-member-init(X() : x_() {}→X() {})modernize-unary-static-assertHand edits
BOPTools_Set.cxx: clang-tidy collapsed a member-initializer-list copy ctor to= defaultbut left trailing blank lines; merged to one line.Verification
-O3 -DNDEBUG).Scope
24 files changed total, ~200 lines diff. Excludes:
src/Deprecated/OpenGl_glext.h,OpenGl_khrplatform.h)CLA ID
1142