STYLE: Clang tidy cleanups#1628
Merged
hjmjohnson merged 15 commits intoInsightSoftwareConsortium:masterfrom Feb 20, 2020
Merged
STYLE: Clang tidy cleanups#1628hjmjohnson merged 15 commits intoInsightSoftwareConsortium:masterfrom
hjmjohnson merged 15 commits intoInsightSoftwareConsortium:masterfrom
Conversation
dzenanz
reviewed
Feb 17, 2020
Member
dzenanz
left a comment
There was a problem hiding this comment.
The suggestions about parameter renaming are optional.
b7996b1 to
c056b11
Compare
thewtex
approved these changes
Feb 18, 2020
phcerdan
reviewed
Feb 18, 2020
c056b11 to
9db883c
Compare
2edeece to
bf61ec3
Compare
No conditional building needed now that VXL is updated to a supported version.
Find and remove redundant void argument lists.
Describe function overrides using the override keyword from C++11. SRCDIR= #My local SRC BLDDIR= #My local BLD cd run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-override -header-filter=.* -fix
Finds and replaces integer literals which are cast to bool. SRCDIR= #My local SRC BLDDIR= #My local BLD cd run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-bool-literals -header-filter=.* -fix
The check flags insertions to an STL-style container done by calling the push_back method with an explicitly-constructed temporary of the container element type. In this case, the corresponding emplace_back method results in less verbose and potentially more efficient code.
The check converts the usage of typedef with using keyword.
Converts a default constructor’s member initializers into the new default member initializers in C++11. Other member initializers that match the default member initializer are removed. This can reduce repeated code or allow use of ‘= default’.
This check replaces default bodies of special member functions with = default;. The explicitly defaulted function declarations enable more opportunities in optimization, because the compiler might treat explicitly defaulted functions as trivial. Additionally, the C++11 use of = default more clearly expreses the intent for the special member functions.
This check replaces undefined special member functions with = delete;. The explicitly deleted function declarations enable more opportunities in optimization, because the compiler might treat explicitly delted functions as noops. Additionally, the C++11 use of = delete more clearly expreses the intent for the special member functions.
With move semantics added to the language and the standard library updated with move constructors added for many types it is now interesting to take an argument directly by value, instead of by const-reference, and then copy. This check allows the compiler to take care of choosing the best way to construct the copy. The transformation is usually beneficial when the calling code passes an rvalue and assumes the move construction is a cheap operation. This short example illustrates how the construction of the value happens: SRCDIR= #My local SRC BLDDIR= #My local BLD cd run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-pass-by-value -header-filter=.* -fix
The emptiness of a container should be checked using the empty() method instead of the size() method. It is not guaranteed that size() is a constant-time function, and it is generally more efficient and also shows clearer intent to use empty(). Furthermore some containers may implement the empty() method but not implement the size() method. Using empty() whenever possible makes it easier to switch to another container in the future. SRCDIR= #My local SRC BLDDIR= #My local BLD cd run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,readability-container-size-empty -header-filter=.* -fix
C++11 Range based for loops can be used in Used as a more readable equivalent to the traditional for loop operating over a range of values, such as all elements in a container, in the forward direction.. Range based loopes are more explicit for only computing the end location once for containers.
… expression This check is responsible for using the auto type specifier for variable declarations to improve code readability and maintainability. The auto type specifier will only be introduced in situations where the variable type matches the type of the initializer expression. In other words auto should deduce the same type that was originally spelled in the source
Finds non-static member functions that can be made const because the functions don’t use this in a non-const way. This check tries to annotate methods according to logical constness (not physical constness). Therefore, it will suggest to add a const qualifier to a non-const method only if this method does something that is already possible though the public interface on a const pointer to the object: reading a public member variable calling a public const-qualified member function returning const-qualified this passing const-qualified this as a parameter. This check will also suggest to add a const qualifier to a non-const method if this method uses private data and functions in a limited number of ways where logical constness and physical constness coincide: - reading a member variable of builtin type Specifically, this check will not suggest to add a const to a non-const method if the method reads a private member variable of pointer type because that allows to modify the pointee which might not preserve logical constness. For the same reason, it does not allow to call private member functions or member functions on private member variables. In addition, this check ignores functions that - are declared virtual - contain a const_cast - are templated or part of a class template - have an empty body - do not (implicitly) use this at all (see readability-convert-member-functions-to-static).
bf61ec3 to
f64ee62
Compare
2 tasks
N-Dekker
added a commit
to N-Dekker/ITKSoftwareGuide
that referenced
this pull request
Dec 26, 2021
Following ITK commits: "STYLE: removing void if used in place of empty parameter list" by Dženan Zukić, 11 September 2018 InsightSoftwareConsortium/ITK@60807f4 "STYLE: Remove redundant void argument lists" by Hans Johnson, 20 February 2020 pull request InsightSoftwareConsortium/ITK#1628 InsightSoftwareConsortium/ITK@e6d859e In accordance with C++ Core Guidelines, August 19, 2021: "Don't use void as an argument type" https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#nl25-dont-use-void-as-an-argument-type Clang-Tidy "modernize-redundant-void-arg" check: https://clang.llvm.org/extra/clang-tidy/checks/modernize-redundant-void-arg.html
dzenanz
pushed a commit
to InsightSoftwareConsortium/ITKSoftwareGuide
that referenced
this pull request
Dec 27, 2021
Following ITK commits: "STYLE: removing void if used in place of empty parameter list" by Dženan Zukić, 11 September 2018 InsightSoftwareConsortium/ITK@60807f4 "STYLE: Remove redundant void argument lists" by Hans Johnson, 20 February 2020 pull request InsightSoftwareConsortium/ITK#1628 InsightSoftwareConsortium/ITK@e6d859e In accordance with C++ Core Guidelines, August 19, 2021: "Don't use void as an argument type" https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#nl25-dont-use-void-as-an-argument-type Clang-Tidy "modernize-redundant-void-arg" check: https://clang.llvm.org/extra/clang-tidy/checks/modernize-redundant-void-arg.html
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Dec 27, 2021
Following ITK commit "STYLE: removing void if used in place of empty parameter list", by Dženan Zukić, 11 September 2018 InsightSoftwareConsortium/ITK@60807f4 And ITK commit "STYLE: Remove redundant void argument lists", by Hans Johnson, 20 February 2020 pull request InsightSoftwareConsortium/ITK#1628 InsightSoftwareConsortium/ITK@e6d859e In accordance with C++ Core Guidelines, August 19, 2021: "Don't use void as an argument type" https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#nl25-dont-use-void-as-an-argument-type Clang-Tidy "modernize-redundant-void-arg" check: https://clang.llvm.org/extra/clang-tidy/checks/modernize-redundant-void-arg.html
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Dec 27, 2021
Following ITK commit "STYLE: removing void if used in place of empty parameter list", by Dženan Zukić, 11 September 2018 InsightSoftwareConsortium/ITK@60807f4 And ITK commit "STYLE: Remove redundant void argument lists", by Hans Johnson, 20 February 2020 pull request InsightSoftwareConsortium/ITK#1628 InsightSoftwareConsortium/ITK@e6d859e In accordance with C++ Core Guidelines, August 19, 2021: "Don't use void as an argument type" https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#nl25-dont-use-void-as-an-argument-type Clang-Tidy "modernize-redundant-void-arg" check: https://clang.llvm.org/extra/clang-tidy/checks/modernize-redundant-void-arg.html Using Notepad++ v8.1.9.2, Find in Files (Filters: *.hxx;*.h;*.cxx [v] Match case): Find what: (void); Replace with: (); (*) Normal Find what: ( void ) Replace with: () (*) Normal Find what: (void) Replace with: () (*) Normal Find what: void) Replace with: ) (*) Normal Find what: (void)\r\n Replace with: ()\r\n (*) Extended
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Dec 29, 2021
Follow-up to: "STYLE: removing void if used in place of empty parameter list" by Dženan Zukić, 11 September 2018 InsightSoftwareConsortium@60807f4 "STYLE: Remove redundant void argument lists" by Hans Johnson, 20 February 2020 pull request InsightSoftwareConsortium#1628 InsightSoftwareConsortium@e6d859e
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Dec 29, 2021
Did check all itk*.cxx, itk*.h, and itk*.hxx source files. Follow-up to: "STYLE: removing void if used in place of empty parameter list" by Dženan Zukić, 11 September 2018 InsightSoftwareConsortium@60807f4 "STYLE: Remove redundant void argument lists" by Hans Johnson, 20 February 2020 pull request InsightSoftwareConsortium#1628 InsightSoftwareConsortium@e6d859e
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Dec 30, 2021
Following ITK commit "STYLE: removing void if used in place of empty parameter list", by Dženan Zukić, 11 September 2018 InsightSoftwareConsortium/ITK@60807f4 And ITK commit "STYLE: Remove redundant void argument lists", by Hans Johnson, 20 February 2020 pull request InsightSoftwareConsortium/ITK#1628 InsightSoftwareConsortium/ITK@e6d859e In accordance with C++ Core Guidelines, August 19, 2021: "Don't use void as an argument type" https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#nl25-dont-use-void-as-an-argument-type Clang-Tidy "modernize-redundant-void-arg" check: https://clang.llvm.org/extra/clang-tidy/checks/modernize-redundant-void-arg.html Using Notepad++ v8.1.9.2, Find in Files (Filters: *.hxx;*.h;*.cxx [v] Match case): Find what: (void); Replace with: (); (*) Normal Find what: ( void ) Replace with: () (*) Normal Find what: (void) Replace with: () (*) Normal Find what: void) Replace with: ) (*) Normal Find what: (void)\r\n Replace with: ()\r\n (*) Extended
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Dec 31, 2021
Following ITK commit "STYLE: removing void if used in place of empty parameter list", by Dženan Zukić, 11 September 2018 InsightSoftwareConsortium/ITK@60807f4 And ITK commit "STYLE: Remove redundant void argument lists", by Hans Johnson, 20 February 2020 pull request InsightSoftwareConsortium/ITK#1628 InsightSoftwareConsortium/ITK@e6d859e In accordance with C++ Core Guidelines, August 19, 2021: "Don't use void as an argument type" https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#nl25-dont-use-void-as-an-argument-type Clang-Tidy "modernize-redundant-void-arg" check: https://clang.llvm.org/extra/clang-tidy/checks/modernize-redundant-void-arg.html Using Notepad++ v8.1.9.2, Find in Files (Filters: *.hxx;*.h;*.cxx [v] Match case): Find what: (void); Replace with: (); (*) Normal Find what: ( void ) Replace with: () (*) Normal Find what: (void) Replace with: () (*) Normal Find what: void) Replace with: ) (*) Normal Find what: (void)\r\n Replace with: ()\r\n (*) Extended
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Jan 3, 2022
Following ITK commit "STYLE: removing void if used in place of empty parameter list", by Dženan Zukić, 11 September 2018 InsightSoftwareConsortium/ITK@60807f4 And ITK commit "STYLE: Remove redundant void argument lists", by Hans Johnson, 20 February 2020 pull request InsightSoftwareConsortium/ITK#1628 InsightSoftwareConsortium/ITK@e6d859e In accordance with C++ Core Guidelines, August 19, 2021: "Don't use void as an argument type" https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#nl25-dont-use-void-as-an-argument-type Clang-Tidy "modernize-redundant-void-arg" check: https://clang.llvm.org/extra/clang-tidy/checks/modernize-redundant-void-arg.html Using Notepad++ v8.1.9.2, Find in Files (Filters: *.hxx;*.h;*.cxx [v] Match case): Find what: (void); Replace with: (); (*) Normal Find what: ( void ) Replace with: () (*) Normal Find what: (void) Replace with: () (*) Normal Find what: void) Replace with: ) (*) Normal Find what: (void)\r\n Replace with: ()\r\n (*) Extended
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
Jan 5, 2022
Ran LLVM 13.0.0 Clang-Tidy check `modernize-use-using`: https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-using.html Did Notepad++ v8.1.9.3 Find in Files Find what: typedef (\w+) [ ]*(\w+); Replace with: using $2 = $1; [v] Match case (*) Regular expression Following ITK "STYLE: Prefer c++11 'using' to 'typedef'": - pull request InsightSoftwareConsortium/ITK#1628 commit InsightSoftwareConsortium/ITK@32f6f1e by Hans Johnson, 20 February 2020. - pull request InsightSoftwareConsortium/ITK#1047 commit InsightSoftwareConsortium/ITK@f42f88b by Hans Johnson, Dženan Zukić, 1 July 2019 In accordance with C++ Core Guidelines, January 3, 2022: "Prefer `using` over `typedef` for defining aliases", https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rt-using
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.
More clang-tidy identified cleanups found when building with remote modules.