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

-Wextra-semi #4699

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ StatementMacros:
- INTEL_PRAGMA_WARN_PUSH
- INTEL_PRAGMA_WARN_POP
- INTEL_SUPPRESS_warning_1292
- itkBooleanMacro
- itkQEDefineFrontIteratorMethodsMacro
- itkQEAccessorsMacro
- itkCellVisitMacro
- itkNUMERIC_TRAITS_MIN_MAX_MACRO
- itkTemplateFloatingToIntegerMacro
- itkPadStruct
- itkLegacyMacro
- IPLSetMacroDeclaration
- IPLGetMacroDeclaration
TabWidth: 2
UseTab: Never
...
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class ITK_TEMPLATE_EXPORT VectorCentralDifferenceImageFunction
*/
itkSetMacro(UseImageDirection, bool);
itkGetConstMacro(UseImageDirection, bool);
itkBooleanMacro(UseImageDirection);
itkBooleanMacro(UseImageDirection)

protected:
VectorCentralDifferenceImageFunction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ITK_TEMPLATE_EXPORT ConicShellInteriorExteriorSpatialFunction
* set to false for the opposite direction. */
itkGetConstMacro(Polarity, bool);
itkSetMacro(Polarity, bool);
itkBooleanMacro(Polarity);
itkBooleanMacro(Polarity)

protected:
ConicShellInteriorExteriorSpatialFunction() = default;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkDataObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class ITK_FORCE_EXPORT_MACRO(ITKCommon) DataObject : public Object
}

itkGetConstReferenceMacro(ReleaseDataFlag, bool);
itkBooleanMacro(ReleaseDataFlag);
itkBooleanMacro(ReleaseDataFlag)

/** Turn on/off a flag to control whether every object releases its data
* after being used by a filter. Being a global flag, it controls the
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkFileOutputWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ class ITKCommon_EXPORT FileOutputWindow : public OutputWindow
/** Set/Get the buffer flushing mode */
itkSetMacro(Flush, bool);
itkGetConstMacro(Flush, bool);
itkBooleanMacro(Flush);
itkBooleanMacro(Flush)

/** Setting append will cause the log file to be
* opened in append mode. Otherwise, if the log file exists,
* it will be overwritten each time the FileOutputWindow
* is created. */
itkSetMacro(Append, bool);
itkGetConstMacro(Append, bool);
itkBooleanMacro(Append);
itkBooleanMacro(Append)

protected:
FileOutputWindow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class ITK_TEMPLATE_EXPORT GaussianDerivativeOperator : public NeighborhoodOperat
{
return m_NormalizeAcrossScale;
}
itkBooleanMacro(NormalizeAcrossScale);
itkBooleanMacro(NormalizeAcrossScale)

/** Set/Get the variance of the Gaussian kernel.
*
Expand Down
3 changes: 2 additions & 1 deletion Modules/Core/Common/include/itkGaussianKernelFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class ITK_TEMPLATE_EXPORT GaussianKernelFunction : public KernelFunctionBase<TRe

protected:
GaussianKernelFunction()
: m_Factor(TRealValueType{ 1.0 } / std::sqrt(TRealValueType{ 2.0 * itk::Math::pi })){};
: m_Factor(TRealValueType{ 1.0 } / std::sqrt(TRealValueType{ 2.0 * itk::Math::pi }))
{}
~GaussianKernelFunction() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkGaussianSpatialFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ITK_TEMPLATE_EXPORT GaussianSpatialFunction : public SpatialFunction<TOutp
/** Set/Get whether or not to normalize the Gaussian. Default is false. */
itkSetMacro(Normalized, bool);
itkGetConstMacro(Normalized, bool);
itkBooleanMacro(Normalized);
itkBooleanMacro(Normalized)

/** Set/Get the standard deviation in each direction. */
itkSetMacro(Sigma, ArrayType);
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkHexahedronCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class ITK_TEMPLATE_EXPORT HexahedronCell
InterpolationWeightType *) override;

/** Visitor interface */
itkCellVisitMacro(CellGeometryEnum::HEXAHEDRON_CELL);
itkCellVisitMacro(CellGeometryEnum::HEXAHEDRON_CELL)

protected:
/** Store the number of points needed for a hexahedron. */
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkImageSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class ITK_TEMPLATE_EXPORT ImageSource
* thus enabling custom region splitting methods. */
itkGetConstMacro(DynamicMultiThreading, bool);
itkSetMacro(DynamicMultiThreading, bool);
itkBooleanMacro(DynamicMultiThreading);
itkBooleanMacro(DynamicMultiThreading)

bool m_DynamicMultiThreading{};
};
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkImportImageContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class ITK_TEMPLATE_EXPORT ImportImageContainer : public Object
* \warning Improper use of these methods will result in memory leaks */
itkSetMacro(ContainerManageMemory, bool);
itkGetConstMacro(ContainerManageMemory, bool);
itkBooleanMacro(ContainerManageMemory);
itkBooleanMacro(ContainerManageMemory)

protected:
ImportImageContainer() = default;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkInPlaceImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ITK_TEMPLATE_EXPORT InPlaceImageFilter : public ImageToImageFilter<TInputI
* image type match. */
itkSetMacro(InPlace, bool);
itkGetConstMacro(InPlace, bool);
itkBooleanMacro(InPlace);
itkBooleanMacro(InPlace)

/** Can the filter run in place? To do so, the filter's first input
* and output must have the same dimension and pixel type. This
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkLightProcessObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ITKCommon_EXPORT LightProcessObject : public Object
itkGetConstReferenceMacro(AbortGenerateData, bool);

/** Turn on and off the AbortGenerateData flag. */
itkBooleanMacro(AbortGenerateData);
itkBooleanMacro(AbortGenerateData)

/** Set the execution progress of a process object. The progress is
* a floating number between (0,1), 0 meaning no progress; 1 meaning
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkLineCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class ITK_TEMPLATE_EXPORT LineCell : public TCellInterface
GetVertex(CellFeatureIdentifier, VertexAutoPointer &);

/** Visitor interface */
itkCellVisitMacro(CellGeometryEnum::LINE_CELL);
itkCellVisitMacro(CellGeometryEnum::LINE_CELL)

LineCell() = default;

Expand Down
3 changes: 2 additions & 1 deletion Modules/Core/Common/include/itkMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,8 @@ OutputWindowDisplayDebugText(const char *);
//
// See below for what to do for the method definition.
#if defined(ITK_LEGACY_REMOVE)
# define itkLegacyMacro(method) /* no ';' */
# define itkLegacyMacro(method) \
static_assert(true, "Compile time eliminated. Used to require a semi-colon at end of macro.")
#else
# if defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST)
// Provide legacy methods with no warnings.
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ itkTemplateFloatingToIntegerMacro(Floor);
* the default one (or at least that it is always restored to the
* default one).
*/
itkTemplateFloatingToIntegerMacro(Ceil);
itkTemplateFloatingToIntegerMacro(Ceil)

#undef itkTemplateFloatingToIntegerMacro

Expand Down
24 changes: 12 additions & 12 deletions Modules/Core/Common/include/itkNumericTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class NumericTraits<char> : public std::numeric_limits<char>
static constexpr char ITKCommon_EXPORT Zero = 0;
static constexpr char ITKCommon_EXPORT One = 1;

itkNUMERIC_TRAITS_MIN_MAX_MACRO();
itkNUMERIC_TRAITS_MIN_MAX_MACRO()

static constexpr char
NonpositiveMin()
Expand Down Expand Up @@ -621,7 +621,7 @@ class NumericTraits<unsigned char> : public std::numeric_limits<unsigned char>
static constexpr unsigned char ITKCommon_EXPORT Zero = 0;
static constexpr unsigned char ITKCommon_EXPORT One = 1;

itkNUMERIC_TRAITS_MIN_MAX_MACRO();
itkNUMERIC_TRAITS_MIN_MAX_MACRO()

static constexpr unsigned char
NonpositiveMin()
Expand Down Expand Up @@ -724,7 +724,7 @@ class NumericTraits<short> : public std::numeric_limits<short>
static constexpr short ITKCommon_EXPORT Zero = 0;
static constexpr short ITKCommon_EXPORT One = 1;

itkNUMERIC_TRAITS_MIN_MAX_MACRO();
itkNUMERIC_TRAITS_MIN_MAX_MACRO()
static constexpr short
NonpositiveMin()
{
Expand Down Expand Up @@ -827,7 +827,7 @@ class NumericTraits<unsigned short> : public std::numeric_limits<unsigned short>
static constexpr unsigned short ITKCommon_EXPORT Zero = 0;
static constexpr unsigned short ITKCommon_EXPORT One = 1;

itkNUMERIC_TRAITS_MIN_MAX_MACRO();
itkNUMERIC_TRAITS_MIN_MAX_MACRO()
static constexpr unsigned short
NonpositiveMin()
{
Expand Down Expand Up @@ -929,7 +929,7 @@ class NumericTraits<int> : public std::numeric_limits<int>
static constexpr int ITKCommon_EXPORT Zero = 0;
static constexpr int ITKCommon_EXPORT One = 1;

itkNUMERIC_TRAITS_MIN_MAX_MACRO();
itkNUMERIC_TRAITS_MIN_MAX_MACRO()
static constexpr int
NonpositiveMin()
{
Expand Down Expand Up @@ -1154,7 +1154,7 @@ class NumericTraits<long> : public std::numeric_limits<long>
static constexpr long ITKCommon_EXPORT Zero = 0L;
static constexpr long ITKCommon_EXPORT One = 1L;

itkNUMERIC_TRAITS_MIN_MAX_MACRO();
itkNUMERIC_TRAITS_MIN_MAX_MACRO()
static constexpr long
NonpositiveMin()
{
Expand Down Expand Up @@ -1257,7 +1257,7 @@ class NumericTraits<unsigned long> : public std::numeric_limits<unsigned long>
static constexpr unsigned long ITKCommon_EXPORT Zero = 0UL;
static constexpr unsigned long ITKCommon_EXPORT One = 1UL;

itkNUMERIC_TRAITS_MIN_MAX_MACRO();
itkNUMERIC_TRAITS_MIN_MAX_MACRO()
static constexpr unsigned long
NonpositiveMin()
{
Expand Down Expand Up @@ -1361,7 +1361,7 @@ class NumericTraits<float> : public std::numeric_limits<float>
static constexpr float ITKCommon_EXPORT Zero = 0.0f;
static constexpr float ITKCommon_EXPORT One = 1.0f;

itkNUMERIC_TRAITS_MIN_MAX_MACRO();
itkNUMERIC_TRAITS_MIN_MAX_MACRO()
static constexpr float
NonpositiveMin()
{
Expand Down Expand Up @@ -1464,7 +1464,7 @@ class NumericTraits<double> : public std::numeric_limits<double>
static constexpr double ITKCommon_EXPORT Zero = 0.0;
static constexpr double ITKCommon_EXPORT One = 1.0;

itkNUMERIC_TRAITS_MIN_MAX_MACRO();
itkNUMERIC_TRAITS_MIN_MAX_MACRO()
static constexpr double
NonpositiveMin()
{
Expand Down Expand Up @@ -1575,7 +1575,7 @@ class NumericTraits<long double> : public std::numeric_limits<long double>
static constexpr long double ITKCommon_EXPORT Zero = 0.0;
static constexpr long double ITKCommon_EXPORT One = 1.0;

itkNUMERIC_TRAITS_MIN_MAX_MACRO();
itkNUMERIC_TRAITS_MIN_MAX_MACRO()
static constexpr long double
NonpositiveMin()
{
Expand Down Expand Up @@ -1679,7 +1679,7 @@ class NumericTraits<long long> : public std::numeric_limits<long long>
static constexpr ValueType ITKCommon_EXPORT Zero = 0LL;
static constexpr ValueType ITKCommon_EXPORT One = 1LL;

itkNUMERIC_TRAITS_MIN_MAX_MACRO();
itkNUMERIC_TRAITS_MIN_MAX_MACRO()
static constexpr ValueType
NonpositiveMin()
{
Expand Down Expand Up @@ -1782,7 +1782,7 @@ class NumericTraits<unsigned long long> : public std::numeric_limits<unsigned lo
static constexpr ValueType ITKCommon_EXPORT Zero = 0ULL;
static constexpr ValueType ITKCommon_EXPORT One = 1ULL;

itkNUMERIC_TRAITS_MIN_MAX_MACRO();
itkNUMERIC_TRAITS_MIN_MAX_MACRO()
static constexpr ValueType
NonpositiveMin()
{
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkOutputWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class ITKCommon_EXPORT OutputWindow : public Object
* messages. */
itkSetMacro(PromptUser, bool);
itkGetConstMacro(PromptUser, bool);
itkBooleanMacro(PromptUser);
itkBooleanMacro(PromptUser)

protected:
OutputWindow();
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkPolyLineCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ITK_TEMPLATE_EXPORT PolyLineCell : public TCellInterface
GetVertex(CellFeatureIdentifier, VertexAutoPointer &);

/** Visitor interface */
itkCellVisitMacro(CellGeometryEnum::POLYLINE_CELL);
itkCellVisitMacro(CellGeometryEnum::POLYLINE_CELL)

void
InitializePoints(PointIdentifier numberOfPoints)
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkPolygonCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ITK_TEMPLATE_EXPORT PolygonCell : public TCellInterface
using EdgeInfoDQ = std::deque<EdgeInfo>;

/** Need to add POLYGON_CELL into CellInterface. */
itkCellVisitMacro(CellGeometryEnum::POLYGON_CELL);
itkCellVisitMacro(CellGeometryEnum::POLYGON_CELL)

/** Implement the standard CellInterface. */
CellGeometryEnum
Expand Down
20 changes: 13 additions & 7 deletions Modules/Core/Common/include/itkProcessObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class ITKCommon_EXPORT ProcessObject : public Object
itkGetConstReferenceMacro(AbortGenerateData, bool);

/** \brief Turn on and off the AbortGenerateData flag. */
itkBooleanMacro(AbortGenerateData);
itkBooleanMacro(AbortGenerateData)

/** \deprecated
* Set the execution progress of a process object. The progress is
Expand Down Expand Up @@ -488,16 +488,22 @@ class ITKCommon_EXPORT ProcessObject : public Object
* utilization. Default value is on. */
itkSetMacro(ReleaseDataBeforeUpdateFlag, bool);
itkGetConstReferenceMacro(ReleaseDataBeforeUpdateFlag, bool);
itkBooleanMacro(ReleaseDataBeforeUpdateFlag);
itkBooleanMacro(ReleaseDataBeforeUpdateFlag)

/** Get/Set the number of work units to create when executing. */
itkSetClampMacro(NumberOfWorkUnits, ThreadIdType, 1, ITK_MAX_THREADS);
itkGetConstReferenceMacro(NumberOfWorkUnits, ThreadIdType);

#if !defined(ITK_LEGACY_REMOVE) || defined(ITKV4_COMPATIBILITY)
itkLegacyMacro(void SetNumberOfThreads(ThreadIdType count)) { this->SetNumberOfWorkUnits(count); }
itkLegacyMacro(void SetNumberOfThreads(ThreadIdType count))
{
this->SetNumberOfWorkUnits(count);
}

itkLegacyMacro(ThreadIdType GetNumberOfThreads() const) { return this->GetNumberOfWorkUnits(); }
itkLegacyMacro(ThreadIdType GetNumberOfThreads() const)
{
return this->GetNumberOfWorkUnits();
}
#endif // !ITK_LEGACY_REMOVE

/** Return the multithreader used by this class. */
Expand Down Expand Up @@ -893,7 +899,7 @@ class ITKCommon_EXPORT ProcessObject : public Object
* updated in derived filters.
*/
itkGetConstMacro(ThreaderUpdateProgress, bool);
itkBooleanMacro(ThreaderUpdateProgress);
itkBooleanMacro(ThreaderUpdateProgress)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at the ITK_MACRO_NOOP mechanism.

We want the ; colon here to keep the code consistent. It may be that the we need to update the itkMacro.h to get rid of these.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: ALSO ENSURE THAT "ITK_LEGACY_REMOVE" and ITK_FUTURE_LEGACY_REMOVE is turned on when running this flag for testing.

Copy link
Contributor

@seanm seanm May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want the ; colon here to keep the code consistent.

You want the semi colon there? Even though you wouldn't if the macro's equivalent was written out by hand?

Example, itkBooleanMacro(ThreaderUpdateProgress) written manually would be:

  virtual void ThreaderUpdateProgressOn() { this->SetThreaderUpdateProgress(true); }
  virtual void ThreaderUpdateProgressOff() { this->SetThreaderUpdateProgress(false); }

which you wouldn't generally write as:

  virtual void ThreaderUpdateProgressOn() { this->SetThreaderUpdateProgress(true); }
  virtual void ThreaderUpdateProgressOff() { this->SetThreaderUpdateProgress(false); };

As this macro isn't a function-like (or statement-like) macro, it seems odd to end it with a semi.

virtual void
SetThreaderUpdateProgress(bool arg);

Expand All @@ -905,7 +911,7 @@ class ITKCommon_EXPORT ProcessObject : public Object
progressFixedToFloat(uint32_t fixed)
{
return static_cast<double>(fixed) / static_cast<double>(std::numeric_limits<uint32_t>::max());
};
}

/**
* Internal method convert floating point progress [0.0, 1.0] to internal integer representation. Values outside the
Expand All @@ -924,7 +930,7 @@ class ITKCommon_EXPORT ProcessObject : public Object
}
double temp = static_cast<double>(f) * std::numeric_limits<uint32_t>::max();
return static_cast<uint32_t>(temp);
};
}

/** These ivars are made protected so filters like itkStreamingImageFilter
* can access them directly. */
Expand Down
26 changes: 13 additions & 13 deletions Modules/Core/Common/include/itkPromoteType.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ struct Identity
using Type = Typed; \
};

ITK_ASSOCIATE(1, TA);
ITK_ASSOCIATE(2, TB);
ITK_ASSOCIATE(1, TA)
ITK_ASSOCIATE(2, TB)

ITK_ASSOCIATE(3, short);
ITK_ASSOCIATE(4, unsigned short);
ITK_ASSOCIATE(5, int);
ITK_ASSOCIATE(6, unsigned int);
ITK_ASSOCIATE(7, long);
ITK_ASSOCIATE(8, unsigned long);
ITK_ASSOCIATE(9, long long);
ITK_ASSOCIATE(10, unsigned long long);
ITK_ASSOCIATE(11, float);
ITK_ASSOCIATE(12, double);
ITK_ASSOCIATE(13, long double);
ITK_ASSOCIATE(3, short)
ITK_ASSOCIATE(4, unsigned short)
ITK_ASSOCIATE(5, int)
ITK_ASSOCIATE(6, unsigned int)
ITK_ASSOCIATE(7, long)
ITK_ASSOCIATE(8, unsigned long)
ITK_ASSOCIATE(9, long long)
ITK_ASSOCIATE(10, unsigned long long)
ITK_ASSOCIATE(11, float)
ITK_ASSOCIATE(12, double)
ITK_ASSOCIATE(13, long double)
#undef ITK_ASSOCIATE
} // namespace Details

Expand Down
Loading