Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All #3

Open
wants to merge 10,000 commits into
base: release-3.20
Choose a base branch
from
Open

Conversation

Marklovesmichelle69
Copy link

See the CONTRIBUTING guide. Specifically:

Start ITK commit messages with a standard prefix (and a space):

  • BUG: fix for runtime crash or incorrect result
  • COMP: compiler error or warning fix
  • DOC: documentation change
  • ENH: new functionality
  • PERF: performance improvement
  • STYLE: no logic impact (indentation, comments)
  • WIP: Work In Progress not ready for merge

Provide a short, meaningful message that describes the change you made.

When the PR is based on a single commit, the commit message is usually left as the PR message.

A reference to a related issue or pull request in your repository. You can automatically close a related issues using keywords

@mentions of the person or team responsible for reviewing proposed changes.

Thanks for contributing to ITK!

kwrobot pushed a commit that referenced this pull request Sep 6, 2018
cmake_minimum_required(VERSION 3.9.5 FATAL_ERROR)
foreach(p
    ## Only policies introduced after the cmake_minimum_required
    ## version need to explicitly be set to NEW.
    CMP0070 #3.10.0 Define ``file(GENERATE)`` behavior for relative paths.
    CMP0071 #3.10.0 Let ``AUTOMOC`` and ``AUTOUIC`` process ``GENERATED`` files.
    )
  if(POLICY ${p})
    cmake_policy(SET ${p} NEW)
  endif()
endforeach()

Change-Id: I30c9a4f2401bf83bcdb56ba89d44b24ca8342853
kwrobot pushed a commit that referenced this pull request Mar 4, 2021
…n metric

Fix uninitialized variable use in `ANTS` neighborhood correlation metric:
ensure that `fixedImageGradient` and `movingImageGradient` have valid
values before assigning them to the `scanMem` struct that scans over
images.

Fixes:
```
Run-Time Check Failure #3 - The variable 'fixedImageGradient' is being
used without being initialized.
```

The bug was affecting a number of tests in the
`ITKRegistrationMethodsv4Test` module.

Signaled at
https://open.cdash.org/viewTest.php?onlyfailed&buildid=7067466
and
https://open.cdash.org/viewTest.php?onlyfailed&buildid=7069241
kwrobot pushed a commit that referenced this pull request Apr 29, 2024
Found with thread sanitizer (TSan) running the `itkANTSNeighborhoodCorrelationImageToImageRegistrationTest` unit test.

There was already a `m_ANTSAssociateOnceFlag` flag for use with `std::call_once`, so I just used that in this place too (it's already used elsewhere).

Partial backtrace from TSan:

```
WARNING: ThreadSanitizer: data race (pid=79176)
  Write of size 8 at 0x000108f02240 by thread T2:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    #1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    #2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    #3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    #4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)

  Previous write of size 8 at 0x000108f02240 by thread T14:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    #1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    #2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    #3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    #4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)
```
kwrobot pushed a commit that referenced this pull request May 30, 2024
Found with thread sanitizer (TSan) running the `itkANTSNeighborhoodCorrelationImageToImageRegistrationTest` unit test.

There was already a `m_ANTSAssociateOnceFlag` flag for use with `std::call_once`, so I just used that in this place too (it's already used elsewhere).

Partial backtrace from TSan:

```
WARNING: ThreadSanitizer: data race (pid=79176)
  Write of size 8 at 0x000108f02240 by thread T2:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    #1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    #2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    #3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    #4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)

  Previous write of size 8 at 0x000108f02240 by thread T14:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    #1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    #2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    #3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    #4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)
```
blowekamp and others added 26 commits November 20, 2024 15:30
The HDF5 library is adding a C-Preprocessor redefinitons pf function to
automatically add context based information.
Using Notepad++, Replace in Files, doing:

    Find what: ^( [ ]+)([^ ][^=\r\n]*::Pointer)([ ]+)(\w+);[\r\n]+\1\4\ =
    Replace with: $1$2$3$4 =
    Filters: itk*.* !+\test
    Directory: D:\src\ITK\Modules
    [v] Match case
    (*) Regular expression

- Follow-up to pull request #4952
commit b4b8e7b
Using Notepad++, Replace in Files, doing:

    Find what: ^( [ ]+)(typename )?([^ ].+)::Pointer[ ]+(\w+[ ]+= \3::New\(\);)
    Find what: ^( [ ]+)(typename )?([^ ].+)::Pointer[ ]+(\w+[ ]+=\r\n\1  \3::New\(\);)
    Replace with: $1auto $4
    Filters: itk*.* !+\test
    Directory: D:\src\ITK\Modules
    [v] Match case
    (*) Regular expression

Manually excluded the initialization of `m_ConvolutionImageFilter` (in
"itkFFTDiscreteGaussianImageFilter.h") as it is not a local variable.

Follow-up to pull request #2826
commit 5ab79bc
"STYLE: Use `auto` for declaration of variables initialized by `New()`"
This reverts commit 916a40c.

The strict tolerance is required for backward compatibility.
COMP: itktiff: Suppress C99 inline only on MSVC from VS 2013 and below - For Release Branch
…-spacing

Revert "BUG: Reduce tolerance for same slice checks"
- Follow-up to pull request #4964
commit 4926511
"STYLE: Replace `Pointer var; var = x` with `Pointer var = x`"

Triggered by a comment by Bradley Lowekamp at
#4964 (comment)
- Follow-up to pull request #4964
commit 677b761
"STYLE: Replace T::Pointer with auto when initializing variables by New()"

Triggered by a comment by Bradley Lowekamp at
#4964 (comment)
Using Notepad++, Replace in Files, doing:

    Find what: ^( [ ]+)([^ ][^=\r\n]*[Ii]terator[^=\r\n]*)([ ]+)(\w+[Ii]t);[\r\n]+\1\4\ =
    Replace with: $1$2$3$4 =
    Filters: itk*.* !+\test
    Directory: D:\src\ITK\Modules
    [v] Match case
    (*) Regular expression

- Follow-up to pull request #4964
commit 4926511
"STYLE: Replace `Pointer var; var = x` with `Pointer var = x`"
Small style improvement to the previous commit.

- Following pull request #3959
commit ef24b65
"STYLE: Construct local variables by passing arguments directly (part 2)",
11 March, 2023
This value is used for setting the publicly defined TIFFLIB_VERSION
macro. DCMTK uses this value.
For any ITK type `T`, `T::New()` does already initialize the object it returns.

Using Notepad++, Replace in Files, doing:

    Find what:  (\w+)([ ]+= .+::New\(\);)\r\n[\r\n]* [ ]+\1->Initialize\(\);
    Replace with:  $1$2
    Filters: itk*.* !+\test
    Directory: D:\src\ITK\Modules
    [v] Match case
    (*) Regular expression

Manually removed an obsolete comment saying `Clear elements`.
Code extracted from:

    https://github.com/libjpeg-turbo/libjpeg-turbo.git

at commit f29eda648547b36aa594c4116c7764a6c8a079b9 (3.0.4).
# By libjpeg-turbo Upstream
* upstream-jpeg-turbo:
  jpeg-turbo 2024-09-14 (f29eda64)
BUG: Set LIBTIFF_RELEASE_DATE in libtiff CMake configuration
DCMTK external project's configuration support forwarding ITK modules
properties, not cmake target properties. Update libtiff's ITK module
include properties to include the directory of the configuration
files. Remove unneeded includes.
ITK/Modules/Numerics/FEM/include/itkFEMImageMetricLoad.hxx:579:10: warning: variable 'chebycoefs0' set but not used [-Wunused-but-set-variable]
BUG: Update libtiff's ITK module include paths
Simplify the code by returning as soon as the condition is known to be
false.
Remove unnecessary "ok" temporary variable.
N-Dekker and others added 30 commits December 16, 2024 15:16
Added note about `CoordRepType` being replaced with `CoordinateType`.

Follow-up to:
- pull request #5006
commit a68b8f6
"ENH: FUTURE REMOVE `...CoordRepType` in favor of `...CoordinateType`"
- pull request #4997
commit e667fa3
"ENH: Deprecate (FUTURE REMOVE) CoordRepType in favor of CoordinateType"
Performance improvements to ComposeImageFilter
Use IDE static checker to identify and fix variables that
can be initialized rather than declared and assigned.
When the type of the initializer expression matches the declaration
use 'auto' to reduce the verbosity (redundnacy).

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
Implements detection of local variables which could be declared as const but
are not. Declaring variables as const is recommended by many coding
guidelines, such as: ES.25 from the C++ Core Guidelines.

cd ${BLDDIR}
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,misc-const-correctness -header-filter=.* -fix
This test requires that the variable be non-const
so that the related region types can be tested
as being non-const.

Suppress future corrections of this line.
Two if statements controlling the initialization of
derivativeImage are combined to minimize variable scope
and simplify logic.
The compiletime testing and logic could be simplified by
combining 2 compiletime computed blocks into 1.  This action
allowed for minimizing the scope of variables and simplifying
the overall logic of the function.
This is a rare false postive case to set the variable to const when it
needs to be non-const.
C++11 Range based for loops can be used instead of accessing
container via indexed random access operators.

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.
Finds C++11 for ranges where the loop variable is copied in each iteration but
it would suffice to obtain it by const reference.

The check is only applied to loop variables of types that are expensive to copy
which means they are not trivially copyable or have a non-trivial copy
constructor or destructor.

To ensure that it is safe to replace the copy with a const reference the following heuristic is employed:

The loop variable is const qualified.

The loop variable is not const, but only const methods or operators are invoked on it, or it is used as const reference or value argument in constructors or function calls.
Replace in Files, doing:

    Find what: ^( [ ]+)([^ ].*)[ ]+(\w+);[\r\n]+\1\3\.Fill\(
    Replace with: $1auto $3 = MakeFilled<$2>\(
    Filters: itk*.h;itk*.hxx;itk*.cxx
    Directory: D:\src\ITK\Modules
    [v] Match case
    (*) Regular expression
Changing variable to const caused windows builds
to fail.

error C2666: 'MetaImage::SequenceID': 2 overloads have similar conversions

Filtering\ImageFeature\include\itkZeroCrossingImageFilter.hxx(64): error C2668: 'itk::ImageRegion<3>::PadByRadius': ambiguous call to overloaded function
Core\Common\include\itkImageRegion.h(333): note: could be 'void itk::ImageRegion<3>::PadByRadius(const __int64 [])'
Core\Common\include\itkImageRegion.h(330): note: or       'void itk::ImageRegion<3>::PadByRadius(__int64)'
Filtering\ImageFeature\include\itkZeroCrossingImageFilter.hxx(64): note: while trying to match the argument list '(const itk::SizeValueType)'
Filtering\ImageFeature\include\itkZeroCrossingImageFilter.hxx(43): note: while compiling class template member function 'void itk::ZeroCrossingImageFilter<itk::Image<float,3>,itk::Image<float,3>>::GenerateInputRequestedRegion(void)'
Segmentation\LevelSets\include\itkSparseFieldLevelSetImageFilter.hxx(470): note: see reference to class template instantiation 'itk::ZeroCrossingImageFilter<itk::Image<float,3>,itk::Image<float,3>>' being compiled
Segmentation\LevelSets\include\itkSparseFieldLevelSetImageFilter.hxx(454): note: while compiling class template member function 'void itk::SparseFieldLevelSetImageFilter<TInputImage,TOutputImage>::CopyInputToOutput(void)'
Making variables const identified that the requestedRegion
was an unused variable.

Modules/Filtering/ImageGrid/test/itkCropImageFilterTest.cxx:82:31:
  warning: unused variable 'requestedRegion' [-Wunused-variable]

Expanded the testing to ensure that all 3 cropped regions
are updated to the same size & index values.
The ivar m_Factor was a constant that did not require
state to be saved.  The computation can be done at
compile time, thus saving runtime computations.

Move m_Factor from an ivar to a constexpr in the one place
it is used.
Use if constexpr to limit the compilation of code in
cases where array index access would fall outside
data structures in cases that should never be used.

Modules/Segmentation/LevelSets/include/itkLevelSetFunction.hxx:138:83:
warning: array index 2 is past the end of the array (that has type 'ScalarValueType[2]' (aka 'float[2]')) [-Warray-bounds]
  138 |       (gd->m_dx[i0] * gd->m_dx[i0] + gd->m_dx[i1] * gd->m_dx[i1] + gd->m_dx[i2] * gd->m_dx[i2]);
      |

Instrumenting with [[maybe_unused]] to suppress
Modules/Segmentation/LevelSets/include/itkLevelSetFunction.hxx:119:82:
warning: parameter 'gd' set but not used [-Wunused-but-set-parameter]
To demonstrate that this is an active project with a large community.
Implements detection of local variables which could be declared as const but
are not. Declaring variables as const is recommended by many coding
guidelines, such as: ES.25 from the C++ Core Guidelines.

cd ${BLDDIR}
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,misc-const-correctness -header-filter=.* -fix
IDE can identify these cases, but code changes are implemented manually

REPLACE: (^ *)const *([a-zA-Z0-9_:]* [0-9a-zA-Z_]* = *[\+\-e0-9\.]+;)
   WITH: $1constexpr $2

REPLACE: (^ *)const (\w* \w*\{\}\;)
   WITH: $1constexpr $2
If statement with compile-time constant can be
replaced with "if constexpr"
The test for epsilon > 0 is always true because
epsilon is a constexpr greater than 0.
[CTest: warning matched] /Users/builder/externalModules/Filtering/ImageCompare/test/itkSimilarityIndexImageFilterTest.cxx:63:18:
warning: result of comparison of 0 <= unsigned expression is always true [-Wtautological-unsigned-zero-compare]
   63 |       if (lower1 <= count && count <= upper1)
      |           ~~~~~~ ^  ~~~~~
[CTest: warning suppressed] 1 warning generated.
Windows build failed when making an unused variable constexpr.
Modules\Core\Common\test\itkVectorContainerTest.cxx(54): error C2127:
'p_null': illegal initialization of 'constexpr' entity with a
non-constant expression

Remove the unused variable to avoid the problem.
This is a follow-up to commit 4cbe24c,
PR #5030: #5030

The error message was:

FAILED: Wrapping/Generators/Python/itk/ITKCommon-6.0.dll lib/ITKCommon-6.0.lib
C:\Windows\system32\cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_dll --msvc-ver=1929 --intdir=Modules\Core\Common\src\CMakeFiles\ITKCommon.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~2\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\ITKCommon.rsp  /out:Wrapping\Generators\Python\itk\ITKCommon-6.0.dll /implib:lib\ITKCommon-6.0.lib /pdb:Wrapping\Generators\Python\itk\ITKCommon-6.0.pdb /dll /version:1.0 /machine:x64  /INCREMENTAL:NO && cd ."
LINK: command "C:\PROGRA~2\MICROS~2\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\ITKCommon.rsp /out:Wrapping\Generators\Python\itk\ITKCommon-6.0.dll /implib:lib\ITKCommon-6.0.lib /pdb:Wrapping\Generators\Python\itk\ITKCommon-6.0.pdb /dll /version:1.0 /machine:x64 /INCREMENTAL:NO /MANIFEST:EMBED,ID=2" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'python311.lib'

Closes #5075.
Using float space precision is not supported with wrapping python.
The python wrapping assumes a limited number of types, and those
types would need to be aliased for supporting float space
continuous indexes (and other types)
Need to match precision for types used to allow building.
In a few cases double precision was assumed for values
related to spacing precision.
Tested by means of `CheckConstexprBeginAndEndOfContainer()`. Note that these
default-constructors were already `constexpr` _implicitly_, as implied by
`= default`, when `ITK_FUTURE_LEGACY_REMOVE` would be enabled.

Used the expression `Superclass(Superclass())` as a workaround for a compiler
bug from GCC 9.4.0, causing warnings like:

  In file included from itkNumericTraitsTest.cxx:42:
  itkNumericTraitsRGBPixel.h: In function 'CheckVariableLengthArrayTraits(const T&) [with T = itk::RGBPixel<char>]':
  itkNumericTraitsRGBPixel.h:118:17: warning: '<anonymous>' may be used uninitialized in this function [-Wmaybe-uninitialized]
Core/Transform/test/itkTransformTest.cxx:224:46: error:
default initialization of an object of const type 'const
itk::itkTransformTestHelpers::TransformTester<double, 3,
3>::InputSymmetricSecondRankTensorType' (aka 'const
SymmetricSecondRankTensor<double, 3U>') without a user-provided default
constructor const InputSymmetricSecondRankTensorType ssrten;
                                                     ^
                                                     {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.