From 4cfa89b246a11af276db3ca03cf66390d0be6c85 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Mon, 5 Nov 2018 17:46:02 -0600 Subject: [PATCH 1/2] ENH: Add specification for -D__clang__ to clang-tidy Clang-tidy does not identify itself as the clang compiler, so there are many failed compilations errors displayed. --- Utilities/ITKv5Preparation/misc-unused-parameters.sh | 4 ++-- Utilities/ITKv5Preparation/modernize-loop-convert.sh | 4 ++-- Utilities/ITKv5Preparation/modernize-pass-by-value.sh | 4 ++-- .../ITKv5Preparation/modernize-return-braced-init-list.sh | 4 ++-- Utilities/ITKv5Preparation/modernize-use-auto.sh | 4 ++-- Utilities/ITKv5Preparation/modernize-use-bool-literals.sh | 4 ++-- Utilities/ITKv5Preparation/modernize-use-emplace.sh | 4 ++-- Utilities/ITKv5Preparation/modernize-use-equals-default.sh | 4 ++-- Utilities/ITKv5Preparation/modernize-use-equals-delete.sh | 4 ++-- Utilities/ITKv5Preparation/modernize-use-nullptr.sh | 4 ++-- Utilities/ITKv5Preparation/modernize-use-override.sh | 4 ++-- Utilities/ITKv5Preparation/performance-general.sh | 4 ++-- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Utilities/ITKv5Preparation/misc-unused-parameters.sh b/Utilities/ITKv5Preparation/misc-unused-parameters.sh index f8caecd3da1..dd9416569e5 100755 --- a/Utilities/ITKv5Preparation/misc-unused-parameters.sh +++ b/Utilities/ITKv5Preparation/misc-unused-parameters.sh @@ -41,7 +41,7 @@ SRCDIR=${SRCDIR} #My local SRC BLDDIR=${BLDDIR} #My local BLD cd ${BLDDIR} -run-clang-tidy.py -checks=-*,misc-unused-parameters -header-filter = .* -fix +run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,misc-unused-parameters -header-filter = .* -fix EOF @@ -49,7 +49,7 @@ export CC=/Users/johnsonhj/local/ccache/bin/clang_ccache export CXX=/Users/johnsonhj/local/ccache/bin/clang++11_ccache export PATH=~/local/llvm/llvm_trunk-build/bin:$PATH cd ${BLDDIR} -/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -checks=-*,misc-unused-parameters -header-filter = .* -fix +/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,misc-unused-parameters -header-filter = .* -fix cd ${SRCDIR} git add -A && git commit --file ${CMTMSG} diff --git a/Utilities/ITKv5Preparation/modernize-loop-convert.sh b/Utilities/ITKv5Preparation/modernize-loop-convert.sh index 1db187ee0e7..b33dca003c5 100755 --- a/Utilities/ITKv5Preparation/modernize-loop-convert.sh +++ b/Utilities/ITKv5Preparation/modernize-loop-convert.sh @@ -44,7 +44,7 @@ SRCDIR=${SRCDIR} #My local SRC BLDDIR=${BLDDIR} #My local BLD cd ${BLDDIR} -run-clang-tidy.py -checks=-*,modernize-loop-convert -header-filter=.* -fix +run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-loop-convert -header-filter=.* -fix EOF @@ -52,7 +52,7 @@ export CC=/Users/johnsonhj/local/ccache/bin/clang_ccache export CXX=/Users/johnsonhj/local/ccache/bin/clang++11_ccache export PATH=~/local/llvm/llvm_trunk-build/bin:$PATH cd ${BLDDIR} -/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -checks=-*,modernize-loop-convert -header-filter=.* -fix +/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-loop-convert -header-filter=.* -fix cd ${SRCDIR} git add -A && git commit --file ${CMTMSG} diff --git a/Utilities/ITKv5Preparation/modernize-pass-by-value.sh b/Utilities/ITKv5Preparation/modernize-pass-by-value.sh index c1f8e31f2c2..d9f27684d66 100755 --- a/Utilities/ITKv5Preparation/modernize-pass-by-value.sh +++ b/Utilities/ITKv5Preparation/modernize-pass-by-value.sh @@ -47,7 +47,7 @@ SRCDIR=${SRCDIR} #My local SRC BLDDIR=${BLDDIR} #My local BLD cd ${BLDDIR} -run-clang-tidy.py -checks=-*,modernize-pass-by-value -header-filter=.* -fix +run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-pass-by-value -header-filter=.* -fix EOF @@ -55,7 +55,7 @@ export CC=/Users/johnsonhj/local/ccache/bin/clang_ccache export CXX=/Users/johnsonhj/local/ccache/bin/clang++11_ccache export PATH=~/local/llvm/llvm_trunk-build/bin:$PATH cd ${BLDDIR} -/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -checks=-*,modernize-pass-by-value -header-filter=.* -fix +/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-pass-by-value -header-filter=.* -fix cd ${SRCDIR} git add -A && git commit --file ${CMTMSG} diff --git a/Utilities/ITKv5Preparation/modernize-return-braced-init-list.sh b/Utilities/ITKv5Preparation/modernize-return-braced-init-list.sh index 775922680be..3368c28631b 100755 --- a/Utilities/ITKv5Preparation/modernize-return-braced-init-list.sh +++ b/Utilities/ITKv5Preparation/modernize-return-braced-init-list.sh @@ -40,7 +40,7 @@ SRCDIR=${SRCDIR} #My local SRC BLDDIR=${BLDDIR} #My local BLD cd ${BLDDIR} -run-clang-tidy.py -checks=-*,modernize-return-braced-init-list -header-filter=.* -fix +run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-return-braced-init-list -header-filter=.* -fix EOF @@ -48,7 +48,7 @@ export CC=/Users/johnsonhj/local/ccache/bin/clang_ccache export CXX=/Users/johnsonhj/local/ccache/bin/clang++11_ccache export PATH=~/local/llvm/llvm_trunk-build/bin:$PATH cd ${BLDDIR} -/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -checks=-*,modernize-return-braced-init-list -header-filter=.* -fix +/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-return-braced-init-list -header-filter=.* -fix cd ${SRCDIR} git add -A && git commit --file ${CMTMSG} diff --git a/Utilities/ITKv5Preparation/modernize-use-auto.sh b/Utilities/ITKv5Preparation/modernize-use-auto.sh index 56fb0c9f3ea..94e6ea4209d 100755 --- a/Utilities/ITKv5Preparation/modernize-use-auto.sh +++ b/Utilities/ITKv5Preparation/modernize-use-auto.sh @@ -43,7 +43,7 @@ SRCDIR=${SRCDIR} #My local SRC BLDDIR=${BLDDIR} #My local BLD cd ${BLDDIR} -run-clang-tidy.py -checks=-*,modernize-use-auto -header-filter = .* -fix +run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-auto -header-filter = .* -fix EOF @@ -51,7 +51,7 @@ export CC=/Users/johnsonhj/local/ccache/bin/clang_ccache export CXX=/Users/johnsonhj/local/ccache/bin/clang++11_ccache export PATH=~/local/llvm/llvm_trunk-build/bin:$PATH cd ${BLDDIR} -/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -checks=-*,modernize-use-auto -header-filter = .* -fix +/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-auto -header-filter = .* -fix cd ${SRCDIR} git add -A && git commit --file ${CMTMSG} diff --git a/Utilities/ITKv5Preparation/modernize-use-bool-literals.sh b/Utilities/ITKv5Preparation/modernize-use-bool-literals.sh index 992657393f6..05195a99310 100755 --- a/Utilities/ITKv5Preparation/modernize-use-bool-literals.sh +++ b/Utilities/ITKv5Preparation/modernize-use-bool-literals.sh @@ -38,7 +38,7 @@ SRCDIR=${SRCDIR} #My local SRC BLDDIR=${BLDDIR} #My local BLD cd ${BLDDIR} -run-clang-tidy.py -checks=-*,modernize-use-bool-literals -header-filter=.* -fix +run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-bool-literals -header-filter=.* -fix EOF @@ -46,7 +46,7 @@ export CC=/Users/johnsonhj/local/ccache/bin/clang_ccache export CXX=/Users/johnsonhj/local/ccache/bin/clang++11_ccache export PATH=~/local/llvm/llvm_trunk-build/bin:$PATH cd ${BLDDIR} -/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -checks=-*,modernize-use-bool-literals -header-filter=.* -fix +/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-bool-literals -header-filter=.* -fix cd ${SRCDIR} git add -A && git commit --file ${CMTMSG} diff --git a/Utilities/ITKv5Preparation/modernize-use-emplace.sh b/Utilities/ITKv5Preparation/modernize-use-emplace.sh index f013fd0bed5..af9bbc4d851 100755 --- a/Utilities/ITKv5Preparation/modernize-use-emplace.sh +++ b/Utilities/ITKv5Preparation/modernize-use-emplace.sh @@ -41,7 +41,7 @@ SRCDIR=${SRCDIR} #My local SRC BLDDIR=${BLDDIR} #My local BLD cd ${BLDDIR} -run-clang-tidy.py -checks=-*,modernize-use-emplace -header-filter=.* -fix +run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-emplace -header-filter=.* -fix EOF @@ -49,7 +49,7 @@ export CC=/Users/johnsonhj/local/ccache/bin/clang_ccache export CXX=/Users/johnsonhj/local/ccache/bin/clang++11_ccache export PATH=~/local/llvm/llvm_trunk-build/bin:$PATH cd ${BLDDIR} -/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -checks=-*,modernize-use-emplace -header-filter=.* -fix +/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-emplace -header-filter=.* -fix cd ${SRCDIR} git add -A && git commit --file ${CMTMSG} diff --git a/Utilities/ITKv5Preparation/modernize-use-equals-default.sh b/Utilities/ITKv5Preparation/modernize-use-equals-default.sh index 3d05dcb6b07..d996b09ef15 100755 --- a/Utilities/ITKv5Preparation/modernize-use-equals-default.sh +++ b/Utilities/ITKv5Preparation/modernize-use-equals-default.sh @@ -47,7 +47,7 @@ SRCDIR=${SRCDIR} #My local SRC BLDDIR=${BLDDIR} #My local BLD cd ${BLDDIR} -run-clang-tidy.py -checks=-*,modernize-use-equals-default -header-filter=.* -fix +run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-equals-default -header-filter=.* -fix EOF @@ -55,7 +55,7 @@ export CC=/Users/johnsonhj/local/ccache/bin/clang_ccache export CXX=/Users/johnsonhj/local/ccache/bin/clang++11_ccache export PATH=~/local/llvm/llvm_trunk-build/bin:$PATH cd ${BLDDIR} -/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -checks=-*,modernize-use-equals-default -header-filter=.* -fix +/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-equals-default -header-filter=.* -fix cd ${SRCDIR} git add -A && git commit --file ${CMTMSG} diff --git a/Utilities/ITKv5Preparation/modernize-use-equals-delete.sh b/Utilities/ITKv5Preparation/modernize-use-equals-delete.sh index c5840e73d86..90a9523279d 100755 --- a/Utilities/ITKv5Preparation/modernize-use-equals-delete.sh +++ b/Utilities/ITKv5Preparation/modernize-use-equals-delete.sh @@ -39,7 +39,7 @@ SRCDIR=${SRCDIR} #My local SRC BLDDIR=${BLDDIR} #My local BLD cd ${BLDDIR} -run-clang-tidy.py -checks=-*,modernize-use-equals-delete -header-filter=.* -fix +run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-equals-delete -header-filter=.* -fix EOF @@ -47,7 +47,7 @@ export CC=/Users/johnsonhj/local/ccache/bin/clang_ccache export CXX=/Users/johnsonhj/local/ccache/bin/clang++11_ccache export PATH=~/local/llvm/llvm_trunk-build/bin:$PATH cd ${BLDDIR} -/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -checks=-*,modernize-use-equals-delete -header-filter=.* -fix +/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-equals-delete -header-filter=.* -fix cd ${SRCDIR} git add -A && git commit --file ${CMTMSG} diff --git a/Utilities/ITKv5Preparation/modernize-use-nullptr.sh b/Utilities/ITKv5Preparation/modernize-use-nullptr.sh index 9a204c7fee6..380dc82aa0e 100755 --- a/Utilities/ITKv5Preparation/modernize-use-nullptr.sh +++ b/Utilities/ITKv5Preparation/modernize-use-nullptr.sh @@ -39,7 +39,7 @@ SRCDIR=${SRCDIR} #My local SRC BLDDIR=${BLDDIR} #My local BLD cd ${BLDDIR} -run-clang-tidy.py -checks=-*,modernize-use-nullptr -header-filter=.* -fix +run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-nullptr -header-filter=.* -fix EOF @@ -47,7 +47,7 @@ export CC=/Users/johnsonhj/local/ccache/bin/clang_ccache export CXX=/Users/johnsonhj/local/ccache/bin/clang++11_ccache export PATH=~/local/llvm/llvm_trunk-build/bin:$PATH cd ${BLDDIR} -/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -checks=-*,modernize-use-nullptr -header-filter=.* -fix +/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-nullptr -header-filter=.* -fix cd ${SRCDIR} git add -A && git commit --file ${CMTMSG} diff --git a/Utilities/ITKv5Preparation/modernize-use-override.sh b/Utilities/ITKv5Preparation/modernize-use-override.sh index f69c4d96421..3cb0c79750c 100755 --- a/Utilities/ITKv5Preparation/modernize-use-override.sh +++ b/Utilities/ITKv5Preparation/modernize-use-override.sh @@ -39,7 +39,7 @@ SRCDIR=${SRCDIR} #My local SRC BLDDIR=${BLDDIR} #My local BLD cd ${BLDDIR} -run-clang-tidy.py -checks=-*,modernize-use-override -header-filter=.* -fix +run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-override -header-filter=.* -fix EOF @@ -47,7 +47,7 @@ export CC=/Users/johnsonhj/local/ccache/bin/clang_ccache export CXX=/Users/johnsonhj/local/ccache/bin/clang++11_ccache export PATH=~/local/llvm/llvm_trunk-build/bin:$PATH cd ${BLDDIR} -/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -checks=-*,modernize-use-override -header-filter=.* -fix +/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-override -header-filter=.* -fix cd ${SRCDIR} git add -A && git commit --file ${CMTMSG} diff --git a/Utilities/ITKv5Preparation/performance-general.sh b/Utilities/ITKv5Preparation/performance-general.sh index 4b1fd9aac65..bdcc55948a8 100755 --- a/Utilities/ITKv5Preparation/performance-general.sh +++ b/Utilities/ITKv5Preparation/performance-general.sh @@ -36,7 +36,7 @@ SRCDIR=${SRCDIR} #My local SRC BLDDIR=${BLDDIR} #My local BLD cd ${BLDDIR} -run-clang-tidy.py -checks=-*,performance* -header-filter=.* -fix +run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,performance* -header-filter=.* -fix EOF @@ -44,7 +44,7 @@ export CC=/Users/johnsonhj/local/ccache/bin/clang_ccache export CXX=/Users/johnsonhj/local/ccache/bin/clang++11_ccache export PATH=~/local/llvm/llvm_trunk-build/bin:$PATH cd ${BLDDIR} -/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -checks=-*,modernize-use-override -header-filter=.* -fix +/Users/johnsonhj/Dashboard/src/scripts/run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-override -header-filter=.* -fix cd ${SRCDIR} git add -A && git commit --file ${CMTMSG} From 0b60bc928daf4f2d86a3eca9400d68ffb16196a0 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Mon, 5 Nov 2018 17:53:02 -0600 Subject: [PATCH 2/2] PERF: emplace_back method results in potentially more efficient code 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. SRCDIR=/Users/johnsonhj/Dashboard/src/ITK #My local SRC BLDDIR=/Users/johnsonhj/Dashboard/src/ITK-clang/ #My local BLD cd /Users/johnsonhj/Dashboard/src/ITK-clang/ run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-emplace -header-filter=.* -fix --- .../TestKernel/src/itkTestDriverInclude.cxx | 4 +- .../itkJoinSeriesImageFilterStreamingTest.cxx | 2 +- .../ImageGrid/test/itkCyclicReferences.cxx | 2 +- .../CSV/test/itkCSVArray2DFileReaderTest.cxx | 16 ++--- .../itkCSVArray2DFileReaderWriterTest.cxx | 20 +++--- .../itkCSVNumericObjectFileWriterTest.cxx | 14 ++-- .../IO/ImageBase/src/itkImageIOFactory.cxx | 2 +- Modules/IO/MeshBase/src/itkMeshIOFactory.cxx | 2 +- ...mageToCooccurrenceListSampleFilterTest.cxx | 40 +++++------ .../test/itkTemporalProcessObjectTest.cxx | 70 +++++++------------ Modules/Video/IO/src/itkVideoIOFactory.cxx | 2 +- 11 files changed, 78 insertions(+), 96 deletions(-) diff --git a/Modules/Core/TestKernel/src/itkTestDriverInclude.cxx b/Modules/Core/TestKernel/src/itkTestDriverInclude.cxx index 3abc3613c82..3503d0241fd 100644 --- a/Modules/Core/TestKernel/src/itkTestDriverInclude.cxx +++ b/Modules/Core/TestKernel/src/itkTestDriverInclude.cxx @@ -159,7 +159,7 @@ int ProcessArguments(int *ac, ArgumentStringType *av, ProcessedOutputType * proc usage(); return 1; } - regressionTestParameters.compareList.push_back( ComparePairType((*av)[i + 1], (*av)[i + 2]) ); + regressionTestParameters.compareList.emplace_back((*av)[i + 1], (*av)[i + 2] ); (*av) += 3; *ac -= 3; } @@ -214,7 +214,7 @@ int ProcessArguments(int *ac, ArgumentStringType *av, ProcessedOutputType * proc } - hashTestList.push_back( HashPairType( filename, hashVector ) ); + hashTestList.emplace_back( filename, hashVector ); } else if ( !skip && strcmp((*av)[i], "--") == 0 ) diff --git a/Modules/Filtering/ImageCompose/test/itkJoinSeriesImageFilterStreamingTest.cxx b/Modules/Filtering/ImageCompose/test/itkJoinSeriesImageFilterStreamingTest.cxx index c106345cc04..8f488467d6a 100644 --- a/Modules/Filtering/ImageCompose/test/itkJoinSeriesImageFilterStreamingTest.cxx +++ b/Modules/Filtering/ImageCompose/test/itkJoinSeriesImageFilterStreamingTest.cxx @@ -77,7 +77,7 @@ int itkJoinSeriesImageFilterStreamingTest(int argc, char* argv[] ) extractor->InPlaceOn(); extractor->ReleaseDataFlagOn(); - savedPointers.push_back( extractor ); + savedPointers.emplace_back(extractor ); joinSeries->PushBackInput( extractor->GetOutput() ); diff --git a/Modules/Filtering/ImageGrid/test/itkCyclicReferences.cxx b/Modules/Filtering/ImageGrid/test/itkCyclicReferences.cxx index dddd8119df5..b6bb3c7b444 100644 --- a/Modules/Filtering/ImageGrid/test/itkCyclicReferences.cxx +++ b/Modules/Filtering/ImageGrid/test/itkCyclicReferences.cxx @@ -62,7 +62,7 @@ int itkCyclicReferences(int, char* [] ) //test unregister from vector of data objects { std::vector v; - v.push_back(if2); + v.emplace_back(if2); } }//image diff --git a/Modules/IO/CSV/test/itkCSVArray2DFileReaderTest.cxx b/Modules/IO/CSV/test/itkCSVArray2DFileReaderTest.cxx index 2c8e2318fdd..2a03b416921 100644 --- a/Modules/IO/CSV/test/itkCSVArray2DFileReaderTest.cxx +++ b/Modules/IO/CSV/test/itkCSVArray2DFileReaderTest.cxx @@ -205,10 +205,10 @@ int itkCSVArray2DFileReaderTest (int argc, char *argv[]) test_row_names = dfo->GetRowHeaders(); std::vector row_names; - row_names.push_back( "Jan" ); - row_names.push_back( "Feb" ); - row_names.push_back( "Mar,April" ); - row_names.push_back( "May" ); + row_names.emplace_back("Jan" ); + row_names.emplace_back("Feb" ); + row_names.emplace_back("Mar,April" ); + row_names.emplace_back("May" ); if ( !testStringVector(row_names, test_row_names) ) { @@ -223,10 +223,10 @@ int itkCSVArray2DFileReaderTest (int argc, char *argv[]) test_col_names = dfo->GetColumnHeaders(); std::vector col_names; - col_names.push_back( "Africa" ); - col_names.push_back( "Asia" ); - col_names.push_back( "Aus" ); - col_names.push_back( "US,Can" ); + col_names.emplace_back("Africa" ); + col_names.emplace_back("Asia" ); + col_names.emplace_back("Aus" ); + col_names.emplace_back("US,Can" ); if ( !testStringVector(col_names, test_col_names) ) { diff --git a/Modules/IO/CSV/test/itkCSVArray2DFileReaderWriterTest.cxx b/Modules/IO/CSV/test/itkCSVArray2DFileReaderWriterTest.cxx index e254f0b1250..f01925c4976 100644 --- a/Modules/IO/CSV/test/itkCSVArray2DFileReaderWriterTest.cxx +++ b/Modules/IO/CSV/test/itkCSVArray2DFileReaderWriterTest.cxx @@ -104,16 +104,16 @@ int itkCSVFileReaderWriterTest_Func(int argc, char *argv[], bool headers) { std::vector ColumnHeaders; std::vector RowHeaders; - ColumnHeaders.push_back( "itkArray2DObject" ); - ColumnHeaders.push_back( "Col1" ); - ColumnHeaders.push_back( "Col2" ); - ColumnHeaders.push_back( "Col3" ); - ColumnHeaders.push_back( "Col4" ); - ColumnHeaders.push_back( "Col5" ); - ColumnHeaders.push_back( "Col6" ); - RowHeaders.push_back( "Row1" ); - RowHeaders.push_back( "Row2" ); - RowHeaders.push_back( "Row3" ); + ColumnHeaders.emplace_back("itkArray2DObject" ); + ColumnHeaders.emplace_back("Col1" ); + ColumnHeaders.emplace_back("Col2" ); + ColumnHeaders.emplace_back("Col3" ); + ColumnHeaders.emplace_back("Col4" ); + ColumnHeaders.emplace_back("Col5" ); + ColumnHeaders.emplace_back("Col6" ); + RowHeaders.emplace_back("Row1" ); + RowHeaders.emplace_back("Row2" ); + RowHeaders.emplace_back("Row3" ); writer->SetRowHeaders( RowHeaders ); writer->SetColumnHeaders( ColumnHeaders ); } diff --git a/Modules/IO/CSV/test/itkCSVNumericObjectFileWriterTest.cxx b/Modules/IO/CSV/test/itkCSVNumericObjectFileWriterTest.cxx index 13e486fc180..bd7f70a7e74 100644 --- a/Modules/IO/CSV/test/itkCSVNumericObjectFileWriterTest.cxx +++ b/Modules/IO/CSV/test/itkCSVNumericObjectFileWriterTest.cxx @@ -180,13 +180,13 @@ int itkCSVNumericObjectFileWriterTest( int argc, char *argv[] ) std::vector ColumnHeaders; std::vector RowHeaders; - ColumnHeaders.push_back( "itkMatrixObject" ); - ColumnHeaders.push_back( "Col1" ); - ColumnHeaders.push_back( "Col2" ); - ColumnHeaders.push_back( "Col3" ); - RowHeaders.push_back( "Row1" ); - RowHeaders.push_back( "Row2" ); - RowHeaders.push_back( "Row3" ); + ColumnHeaders.emplace_back("itkMatrixObject" ); + ColumnHeaders.emplace_back("Col1" ); + ColumnHeaders.emplace_back("Col2" ); + ColumnHeaders.emplace_back("Col3" ); + RowHeaders.emplace_back("Row1" ); + RowHeaders.emplace_back("Row2" ); + RowHeaders.emplace_back("Row3" ); using fixedMatrixWriterType = itk::CSVNumericObjectFileWriter ; diff --git a/Modules/IO/ImageBase/src/itkImageIOFactory.cxx b/Modules/IO/ImageBase/src/itkImageIOFactory.cxx index 68630864057..3fdf76a08b1 100644 --- a/Modules/IO/ImageBase/src/itkImageIOFactory.cxx +++ b/Modules/IO/ImageBase/src/itkImageIOFactory.cxx @@ -41,7 +41,7 @@ ImageIOFactory::CreateImageIO(const char *path, FileModeType mode) auto * io = dynamic_cast< ImageIOBase * >( allobject.GetPointer() ); if ( io ) { - possibleImageIO.push_back(io); + possibleImageIO.emplace_back(io); } else { diff --git a/Modules/IO/MeshBase/src/itkMeshIOFactory.cxx b/Modules/IO/MeshBase/src/itkMeshIOFactory.cxx index 13f84aa7090..f6c41700180 100644 --- a/Modules/IO/MeshBase/src/itkMeshIOFactory.cxx +++ b/Modules/IO/MeshBase/src/itkMeshIOFactory.cxx @@ -40,7 +40,7 @@ ::CreateMeshIO(const char *path, FileModeType mode) if ( io ) { - possibleMeshIO.push_back(io); + possibleMeshIO.emplace_back(io); } else { diff --git a/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceListSampleFilterTest.cxx b/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceListSampleFilterTest.cxx index ab29acb39c1..358cfae9e49 100644 --- a/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceListSampleFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceListSampleFilterTest.cxx @@ -128,84 +128,84 @@ int itkScalarImageToCooccurrenceListSampleFilterTest( int , char *[] ) val[0] = 2; val[1] = 3; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 3; val[1] = 4; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 4; val[1] = 5; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 3; val[1] = 4; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 4; val[1] = 5; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 5; val[1] = 6; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 4; val[1] = 5; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 5; val[1] = 6; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 6; val[1] = 7; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 0; val[1] = 1; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 1; val[1] = 2; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 2; val[1] = 3; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 3; val[1] = 4; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 4; val[1] = 5; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 1; val[1] = 2; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 2; val[1] = 3; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 3; val[1] = 4; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 5; val[1] = 6; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 6; val[1] = 7; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); val[0] = 7; val[1] = 8; - baselineVectorList.push_back( val ); + baselineVectorList.emplace_back(val ); std::vector< MeasurementVectorType >::const_iterator it; diff --git a/Modules/Video/Core/test/itkTemporalProcessObjectTest.cxx b/Modules/Video/Core/test/itkTemporalProcessObjectTest.cxx index 625d8ead5b6..e6b8b1500cb 100644 --- a/Modules/Video/Core/test/itkTemporalProcessObjectTest.cxx +++ b/Modules/Video/Core/test/itkTemporalProcessObjectTest.cxx @@ -239,8 +239,8 @@ class DummyTemporalProcessObject : public TemporalProcessObject void TemporalStreamingGenerateData() override { // Create a START entry in the stack trace - m_CallStack.push_back(CallRecord(m_IdNumber, - CallRecord::START_CALL, CallRecord::STREAMING_GENERATE_DATA) ); + m_CallStack.emplace_back(m_IdNumber, + CallRecord::START_CALL, CallRecord::STREAMING_GENERATE_DATA ); // Report SizeValueType outputStart = this->GetOutput()->GetRequestedTemporalRegion().GetFrameStart(); @@ -286,8 +286,8 @@ class DummyTemporalProcessObject : public TemporalProcessObject //this->GetOutput()->SetBufferedTemporalRegion(this->GetOutput()->GetRequestedTemporalRegion()); // Create an END entry in the stack trace - m_CallStack.push_back(CallRecord(m_IdNumber, - CallRecord::END_CALL, CallRecord::STREAMING_GENERATE_DATA) ); + m_CallStack.emplace_back(m_IdNumber, + CallRecord::END_CALL, CallRecord::STREAMING_GENERATE_DATA ); } @@ -384,15 +384,15 @@ class DummyTemporalProcessObject : public TemporalProcessObject void GenerateData() override { // Create a START entry in the stack trace - m_CallStack.push_back(CallRecord(m_IdNumber, - CallRecord::START_CALL, CallRecord::GENERATE_DATA) ); + m_CallStack.emplace_back(m_IdNumber, + CallRecord::START_CALL, CallRecord::GENERATE_DATA ); std::cout << "*(ID = " << m_IdNumber << ") - GenerateData" << std::endl; Superclass::GenerateData(); // Create an END entry in the stack trace - m_CallStack.push_back(CallRecord(m_IdNumber, - CallRecord::END_CALL, CallRecord::GENERATE_DATA) ); + m_CallStack.emplace_back(m_IdNumber, + CallRecord::END_CALL, CallRecord::GENERATE_DATA ); } @@ -620,68 +620,52 @@ int itkTemporalProcessObjectTest( int , std::vector correctCallStack; // GenDat - START - obj 3 - correctCallStack.push_back( - RecordType(3, RecordType::START_CALL, RecordType::GENERATE_DATA) ); + correctCallStack.emplace_back(3, RecordType::START_CALL, RecordType::GENERATE_DATA ); // GenDat - START - obj 2 - correctCallStack.push_back( - RecordType(2, RecordType::START_CALL, RecordType::GENERATE_DATA) ); + correctCallStack.emplace_back(2, RecordType::START_CALL, RecordType::GENERATE_DATA ); // GenDat - START - obj 1 - correctCallStack.push_back( - RecordType(1, RecordType::START_CALL, RecordType::GENERATE_DATA) ); + correctCallStack.emplace_back(1, RecordType::START_CALL, RecordType::GENERATE_DATA ); // TempStreamGenDat - START - obj 1 - correctCallStack.push_back( - RecordType(1, RecordType::START_CALL, RecordType::STREAMING_GENERATE_DATA) ); + correctCallStack.emplace_back(1, RecordType::START_CALL, RecordType::STREAMING_GENERATE_DATA ); // TempStreamGenDat - END - obj 1 - correctCallStack.push_back( - RecordType(1, RecordType::END_CALL, RecordType::STREAMING_GENERATE_DATA) ); + correctCallStack.emplace_back(1, RecordType::END_CALL, RecordType::STREAMING_GENERATE_DATA ); // TempStreamGenDat - START - obj 1 - correctCallStack.push_back( - RecordType(1, RecordType::START_CALL, RecordType::STREAMING_GENERATE_DATA) ); + correctCallStack.emplace_back(1, RecordType::START_CALL, RecordType::STREAMING_GENERATE_DATA ); // TempStreamGenDat - END - obj 1 - correctCallStack.push_back( - RecordType(1, RecordType::END_CALL, RecordType::STREAMING_GENERATE_DATA) ); + correctCallStack.emplace_back(1, RecordType::END_CALL, RecordType::STREAMING_GENERATE_DATA ); // TempStreamGenDat - START - obj 1 - correctCallStack.push_back( - RecordType(1, RecordType::START_CALL, RecordType::STREAMING_GENERATE_DATA) ); + correctCallStack.emplace_back(1, RecordType::START_CALL, RecordType::STREAMING_GENERATE_DATA ); // TempStreamGenDat - END - obj 1 - correctCallStack.push_back( - RecordType(1, RecordType::END_CALL, RecordType::STREAMING_GENERATE_DATA) ); + correctCallStack.emplace_back(1, RecordType::END_CALL, RecordType::STREAMING_GENERATE_DATA ); // GenDat - END - obj 1 - correctCallStack.push_back( - RecordType(1, RecordType::END_CALL, RecordType::GENERATE_DATA) ); + correctCallStack.emplace_back(1, RecordType::END_CALL, RecordType::GENERATE_DATA ); // TempStreamGenDat - START - obj 2 - correctCallStack.push_back( - RecordType(2, RecordType::START_CALL, RecordType::STREAMING_GENERATE_DATA) ); + correctCallStack.emplace_back(2, RecordType::START_CALL, RecordType::STREAMING_GENERATE_DATA ); // TempStreamGenDat - END - obj 2 - correctCallStack.push_back( - RecordType(2, RecordType::END_CALL, RecordType::STREAMING_GENERATE_DATA) ); + correctCallStack.emplace_back(2, RecordType::END_CALL, RecordType::STREAMING_GENERATE_DATA ); // GenDat - END - obj 2 - correctCallStack.push_back( - RecordType(2, RecordType::END_CALL, RecordType::GENERATE_DATA) ); + correctCallStack.emplace_back(2, RecordType::END_CALL, RecordType::GENERATE_DATA ); // TempStreamGenDat - START - obj 3 - correctCallStack.push_back( - RecordType(3, RecordType::START_CALL, RecordType::STREAMING_GENERATE_DATA) ); + correctCallStack.emplace_back(3, RecordType::START_CALL, RecordType::STREAMING_GENERATE_DATA ); // TempStreamGenDat - END - obj 3 - correctCallStack.push_back( - RecordType(3, RecordType::END_CALL, RecordType::STREAMING_GENERATE_DATA) ); + correctCallStack.emplace_back(3, RecordType::END_CALL, RecordType::STREAMING_GENERATE_DATA ); // GenDat - END - obj 3 - correctCallStack.push_back( - RecordType(3, RecordType::END_CALL, RecordType::GENERATE_DATA) ); + correctCallStack.emplace_back(3, RecordType::END_CALL, RecordType::GENERATE_DATA ); // Check that correct number of calls made if (itk::TemporalProcessObjectTest::m_CallStack.size() != correctCallStack.size() ) @@ -759,12 +743,10 @@ int itkTemporalProcessObjectTest( int , correctCallStack.clear(); // GenDat - START - obj 3 - correctCallStack.push_back( - RecordType(3, RecordType::START_CALL, RecordType::GENERATE_DATA) ); + correctCallStack.emplace_back(3, RecordType::START_CALL, RecordType::GENERATE_DATA ); // GenDat - END - obj 3 - correctCallStack.push_back( - RecordType(3, RecordType::END_CALL, RecordType::GENERATE_DATA) ); + correctCallStack.emplace_back(3, RecordType::END_CALL, RecordType::GENERATE_DATA ); // Check that correct number of calls made if (itk::TemporalProcessObjectTest::m_CallStack.size() != correctCallStack.size() ) diff --git a/Modules/Video/IO/src/itkVideoIOFactory.cxx b/Modules/Video/IO/src/itkVideoIOFactory.cxx index 9d7c8bc8a3e..e3c4a0a5a2d 100644 --- a/Modules/Video/IO/src/itkVideoIOFactory.cxx +++ b/Modules/Video/IO/src/itkVideoIOFactory.cxx @@ -33,7 +33,7 @@ VideoIOBase::Pointer VideoIOFactory::CreateVideoIO( IOModeType mode, const char* auto * io = dynamic_cast< VideoIOBase* >( allobject.GetPointer() ); if (io) { - possibleVideoIO.push_back(io); + possibleVideoIO.emplace_back(io); } else {