Skip to content

Use clang-tidy -fix to replace 0 by nullptr#4041

Merged
sloriot merged 5 commits intoCGAL:masterfrom
lrineau:CGAL-clang_tidy__nullptr_on_Mesh_2-GF
Apr 17, 2021
Merged

Use clang-tidy -fix to replace 0 by nullptr#4041
sloriot merged 5 commits intoCGAL:masterfrom
lrineau:CGAL-clang_tidy__nullptr_on_Mesh_2-GF

Conversation

@lrineau
Copy link
Member

@lrineau lrineau commented Jun 27, 2019

Summary of Changes

As a followup to #3979, and because I hear a lot about clang-tidy, I wanted to try and use clang-tidy, to see if one can automatically replace 0 or NULL by nullptr. I have created a tiny .clang-tidy file.

The only check applied for now is modernize-use-nullptr.

To use it:

cmake -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-fix" build

and then I have used:

make && ctest -L Mesh_2

to compile (with clang-tidy enabled) the whole testsuite of Mesh_2. The option -fix of clang-tidy tells it to modify the source code directly. And then I have checked the results because committing: all was good. But I have modified the strange modifications made by #3979 in Hash_map/include/CGAL/Tools/chained_map.h (NULLKEY had been modified to nullptrKEY by error).

Release Management

  • Affected package(s): Mesh_2 and dependencies
  • License and copyright ownership: maintenance by GeometryFactory

I am not 100% sure that we want to apply that sort of pull-request to master for CGAL-5.0, because, like PRs #3979, #3978, and #3975, that increases the chance of conflicts with bug-fix pull-requests based on CGAL-4.13 or CGAL-4.14.

@lrineau lrineau added Modern C++ (C++11 and later) Cleaning rm: not for next release Indicate to the release team that a PR should not be merged before the next release branch is forked Work in progress labels Jun 27, 2019
@lrineau lrineau added this to the 5.1-beta milestone Jun 27, 2019
@lrineau lrineau self-assigned this Jun 27, 2019
@lrineau lrineau removed the rm: not for next release Indicate to the release team that a PR should not be merged before the next release branch is forked label Nov 8, 2019
@MaelRL
Copy link
Member

MaelRL commented Feb 3, 2020

What is missing to this PR?

@lrineau
Copy link
Member Author

lrineau commented Feb 4, 2020

There is a lot that is missing in this PR. I have applied clang-tidy only to Mesh_2 and its dependencies. I created that issue to start a discussion: do we want that tool clang-tidy applied to CGAL as a whole? And if yes, which rules of clang-tidy? So far I have experimented only with modernize-use-nullptr.

@MaelRL
Copy link
Member

MaelRL commented Feb 4, 2020

A possible path could be to extend this PR to all packages but just for nullptr and not include any .clang_tidy / NOLINTNEXTLINE so that it can be integrated. Afterwards, we could open an issue and look at all clang tidy options.

@lrineau
Copy link
Member Author

lrineau commented Feb 4, 2020

I agree. We should coordinate with other massive PR, like #3895.

@MaelRL MaelRL modified the milestones: 5.1-beta, 5.2-beta Apr 14, 2020
@maxGimeno
Copy link
Contributor

@lrineau is this PR still needed ? If yes, then it needs an update.

@lrineau
Copy link
Member Author

lrineau commented Oct 16, 2020

@lrineau is this PR still needed ? If yes, then it needs an update.

It is not "needed". That is just an improvement on CGAL code.

But it is useful.

@MaelRL #4041 (comment):

A possible path could be to extend this PR to all packages but just for nullptr and not include any .clang_tidy / NOLINTNEXTLINE so that it can be integrated. Afterwards, we could open an issue and look at all clang tidy options.

Why do you want to remove the /.clang-tidy file? clang-tidy could be a new useful tool in our testsuite.

@maxGimeno
Copy link
Contributor

ping @MaelRL

@MaelRL
Copy link
Member

MaelRL commented Oct 26, 2020

I just meant: it could be ignored temporarily so that there is no extra pollution in the results for warnings that we know we can first fix "off-testsuite". But sure, it would be useful to have.

@maxGimeno maxGimeno force-pushed the CGAL-clang_tidy__nullptr_on_Mesh_2-GF branch from fb8f274 to cc99fd9 Compare February 24, 2021 09:35
@maxGimeno maxGimeno changed the title (WIP) Use clang-tidy -fix to replace 0 by nullptr Use clang-tidy -fix to replace 0 by nullptr Mar 24, 2021
@maxGimeno
Copy link
Contributor

Conflicts with master

@maxGimeno maxGimeno force-pushed the CGAL-clang_tidy__nullptr_on_Mesh_2-GF branch from e1a15ff to 17602e5 Compare April 7, 2021 07:18
@maxGimeno
Copy link
Contributor

@lrineau lrineau added the rm only: ready for master For the release team only: that indicates that a PR is about to be merged in 'master' label Apr 16, 2021
@sloriot sloriot merged commit 5c343d2 into CGAL:master Apr 17, 2021
@sloriot sloriot deleted the CGAL-clang_tidy__nullptr_on_Mesh_2-GF branch April 17, 2021 08:45
@sloriot sloriot self-assigned this Apr 17, 2021
@lrineau lrineau removed Ready to be tested rm only: ready for master For the release team only: that indicates that a PR is about to be merged in 'master' labels Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants