Commit a2faeda2 authored by Samuel Jackson's avatar Samuel Jackson
Browse files

Update all clang & gcc warnings to macros

parent 6aeec190
......@@ -7,7 +7,7 @@
#include <boost/python/list.hpp>
// clang-format off
GCC_DIAG_OFF(strict-aliasing)
DIAG_OFF(strict-aliasing)
// clang-format on
using Mantid::API::IMaskWorkspace;
......
......@@ -49,21 +49,21 @@ using return_readwrite_numpy =
return_value_policy<VectorRefToNumpy<WrapReadWrite>>;
//------------------------------- Overload macros ---------------------------
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
// Overloads for binIndexOf function which has 1 optional argument
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(MatrixWorkspace_binIndexOfOverloads,
MatrixWorkspace::binIndexOf, 1, 2)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
/**
* Set the values from an python array-style object into the given spectrum in
......
......@@ -15,7 +15,7 @@ using namespace Mantid::API;
using namespace Mantid::PythonInterface;
using namespace boost::python;
// clang-format off
GCC_DIAG_OFF(strict-aliasing)
DIAG_OFF(strict-aliasing)
// clang-format on
namespace {
......
......@@ -115,20 +115,20 @@ bpl::list keys(Run &self) {
return names;
}
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(integrateProtonCharge_Overload,
integrateProtonCharge, 0, 1)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
void export_Run() {
// Pointer
......
......@@ -19,20 +19,21 @@ GET_POINTER_SPECIALIZATION(Workspace)
namespace {
///@cond
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Workspace_isDirtyOverloads,
Workspace::isDirty, 0, 1)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
///@endcond
}
......
......@@ -46,22 +46,22 @@ Workspace_sptr createFromParentPtr(WorkspaceFactoryImpl &self,
}
/// Overload generator for create
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
BOOST_PYTHON_FUNCTION_OVERLOADS(createFromParent_Overload, createFromParentPtr,
2, 5)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(createTable_Overload, createTable, 0, 1)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(createPeaks_Overload, createPeaks, 0, 1)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
}
void export_WorkspaceFactory() {
......
#include "MantidPythonInterface/api/PythonAlgorithm/AlgorithmAdapter.h"
#include "MantidPythonInterface/kernel/Registry/PropertyWithValueFactory.h"
#include "MantidPythonInterface/kernel/Environment/WrapperHelpers.h"
#include "MantidPythonInterface/kernel/Environment/CallMethod.h"
#include "MantidPythonInterface/kernel/Environment/GlobalInterpreterLock.h"
#include "MantidPythonInterface/kernel/Converters/PySequenceToVector.h"
#include "MantidAPI/DataProcessorAlgorithm.h"
#include "MantidAPI/SerialAlgorithm.h"
#include "MantidAPI/ParallelAlgorithm.h"
#include "MantidAPI/DistributedAlgorithm.h"
#include "MantidAPI/ParallelAlgorithm.h"
#include "MantidAPI/SerialAlgorithm.h"
#include "MantidKernel/WarningSuppressions.h"
#include "MantidPythonInterface/kernel/Converters/PySequenceToVector.h"
#include "MantidPythonInterface/kernel/Environment/CallMethod.h"
#include "MantidPythonInterface/kernel/Environment/GlobalInterpreterLock.h"
#include "MantidPythonInterface/kernel/Environment/WrapperHelpers.h"
#include "MantidPythonInterface/kernel/Registry/PropertyWithValueFactory.h"
#include <boost/python/class.hpp>
#include <boost/python/dict.hpp>
......@@ -145,10 +146,10 @@ bool AlgorithmAdapter<BaseAlgorithm>::isRunning() const {
return SuperClass::isRunning();
} else {
Environment::GlobalInterpreterLock gil;
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wparentheses-equality"
#endif
// clang-format off
DIAG_OFF(parentheses-equality)
// clang-format on
PyObject *result = PyObject_CallObject(m_isRunningObj, nullptr);
if (PyErr_Occurred())
throw Environment::PythonException();
......@@ -164,9 +165,9 @@ bool AlgorithmAdapter<BaseAlgorithm>::isRunning() const {
throw std::runtime_error(
"Algorithm.isRunning - Expected bool return type.");
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(parentheses-equality)
// clang-format on
}
/**
......
......@@ -8,15 +8,14 @@ using Mantid::Geometry::IComponent;
using namespace boost::python;
namespace {
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
// Default parameter function overloads
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getParameterNames,
......@@ -47,11 +46,11 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getParamShortDescription,
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getParamDescription,
Component::getParamDescription, 1, 2)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
}
void export_Component() {
class_<Component, bases<IComponent>, boost::noncopyable>("Component", no_init)
......
......@@ -16,21 +16,21 @@ using namespace boost::python;
namespace //<unnamed>
{
///@cond
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
// define overloaded functions
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getEulerAngles_overloads,
Goniometer::getEulerAngles, 0, 1)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
///@endcond
/// Set the U vector via a numpy array
......
......@@ -16,7 +16,7 @@ using namespace boost::python;
GET_POINTER_SPECIALIZATION(IMDDimension)
// clang-format off
GCC_DIAG_OFF(strict-aliasing)
DIAG_OFF(strict-aliasing)
// clang-format on
namespace {
......
#include "MantidPythonInterface/kernel/Converters/DateAndTime.h"
#include "MantidKernel/WarningSuppressions.h"
#include "MantidPythonInterface/kernel/Converters/NumpyFunctions.h"
#include <boost/make_shared.hpp>
#include <boost/python.hpp>
......@@ -46,14 +47,13 @@ PyArray_Descr *descr_ns() { return func_PyArray_Descr("M8[ns]"); }
// internal function that handles raw pointer
boost::shared_ptr<Types::Core::DateAndTime>
to_dateandtime(const PyObject *datetime) {
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-qual"
#endif
// clang-format off
DIAG_OFF(cast-qual)
// clang-format on
if (!PyArray_IsScalar(datetime, Datetime)) {
#if __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(cast-qual)
// clang-format on
throw std::runtime_error("Expected datetime64");
}
......
......@@ -16,7 +16,7 @@ using boost::python::object;
using boost::python::len;
// clang-format off
GCC_DIAG_OFF(strict-aliasing)
DIAG_OFF(strict-aliasing)
// clang-format on
namespace Mantid {
......
......@@ -32,23 +32,23 @@ std::string getStringUsingCache(ConfigServiceImpl &self,
return self.getString(key, true);
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
/// Overload generator for getInstrument
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getInstrument_Overload, getInstrument, 0,
1)
/// Overload generator for getString
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getString_Overload, getString, 1, 2)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
}
void export_ConfigService() {
......
......@@ -24,19 +24,20 @@ using Mantid::PythonInterface::std_vector_exporter;
using namespace boost::python;
GET_POINTER_SPECIALIZATION(Property)
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(valueAsPrettyStrOverloader,
valueAsPrettyStr, 0, 2)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
void export_Property() {
register_ptr_to_python<Property *>();
......
......@@ -97,21 +97,21 @@ Statistics getStatisticsNumpy(const NumPy::NdArray &data,
}
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
// Define an overload to handle the default argument
BOOST_PYTHON_FUNCTION_OVERLOADS(getStatisticsOverloads, getStatisticsNumpy, 1,
2)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
//============================ Z score
//============================================
......@@ -160,21 +160,21 @@ std::vector<double> getModifiedZscoreNumpy(const NumPy::NdArray &data,
}
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
// Define an overload to handle the default argument
BOOST_PYTHON_FUNCTION_OVERLOADS(getModifiedZscoreOverloads,
getModifiedZscoreNumpy, 1, 2)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
//============================ getMoments
//============================================
......@@ -225,21 +225,21 @@ std::vector<double> getMomentsAboutOriginNumpy(const NumPy::NdArray &indep,
return getMomentsNumpyImpl(&getMomentsAboutOrigin, indep, depend, maxMoment);
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
// Define an overload to handle the default argument
BOOST_PYTHON_FUNCTION_OVERLOADS(getMomentsAboutOriginOverloads,
getMomentsAboutOriginNumpy, 2, 3)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
/**
* Proxy for @see Mantid::Kernel::getMomentsAboutMean so that it can accept
* numpy arrays
......@@ -251,21 +251,21 @@ std::vector<double> getMomentsAboutMeanNumpy(const NumPy::NdArray &indep,
return getMomentsNumpyImpl(&getMomentsAboutMean, indep, depend, maxMoment);
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
// Define an overload to handle the default argument
BOOST_PYTHON_FUNCTION_OVERLOADS(getMomentsAboutMeanOverloads,
getMomentsAboutMeanNumpy, 2, 3)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
///@endcond
}
......
......@@ -2,10 +2,11 @@
// Includes
//-----------------------------------------------------------------------------
#include "MantidPythonInterface/kernel/Registry/PropertyWithValueFactory.h"
#include "MantidKernel/PropertyWithValue.h"
#include "MantidKernel/WarningSuppressions.h"
#include "MantidPythonInterface/kernel/Registry/MappingTypeHandler.h"
#include "MantidPythonInterface/kernel/Registry/TypedPropertyValueHandler.h"
#include "MantidPythonInterface/kernel/Registry/SequenceTypeHandler.h"
#include "MantidKernel/PropertyWithValue.h"
#include "MantidPythonInterface/kernel/Registry/TypedPropertyValueHandler.h"
#include <boost/make_shared.hpp>
......@@ -186,10 +187,9 @@ const std::string PropertyWithValueFactory::isArray(PyObject *const object) {
PyObject *item = PySequence_Fast_GET_ITEM(object, 0);
// Boolean can be cast to int, so check first.
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wparentheses-equality"
#endif
// clang-format off
DIAG_OFF(parentheses-equality)
// clang-format on
if (PyBool_Check(item)) {
throw std::runtime_error(
"Unable to support extracting arrays of booleans.");
......@@ -197,9 +197,9 @@ const std::string PropertyWithValueFactory::isArray(PyObject *const object) {
if (PyLong_Check(item)) {
return std::string("LongIntArray");
}
#if __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(parentheses-equality)
// clang-format on
#if PY_MAJOR_VERSION < 3
// In python 2 ints & longs are separate
......
......@@ -22,14 +22,13 @@ using namespace Mantid::DataObjects::MDEventsTestHelper;
using namespace Mantid::PythonInterface::Policies;
using namespace WorkspaceCreationHelper;
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#endif
// clang-format off
DIAG_OFF(unknown-pragmas)
DIAG_OFF(unused-local-typdef)
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GCC_DIAG_OFF(conversion)
DIAG_OFF(conversion)
// clang-format on
BOOST_PYTHON_FUNCTION_OVERLOADS(create2DWorkspaceWithFullInstrument_overloads,
create2DWorkspaceWithFullInstrument, 2, 4)
......@@ -39,10 +38,11 @@ BOOST_PYTHON_FUNCTION_OVERLOADS(makeFakeMDHistoWorkspace_overloads,
BOOST_PYTHON_FUNCTION_OVERLOADS(
create2DWorkspaceWithRectangularInstrument_overloads,
create2DWorkspaceWithRectangularInstrument, 3, 3)
GCC_DIAG_ON(conversion)
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// clang-format off
DIAG_ON(conversion)
DIAG_ON(unknown-pragmas)
DIAG_ON(unused-local-typdef)
// clang-format on
BOOST_PYTHON_MODULE(WorkspaceCreationHelper) {
using namespace boost::python;
......
......@@ -53,14 +53,14 @@ public:
void loadConfiguration(Instrument_const_sptr poldiInstrument) override {
UNUSED_ARG(poldiInstrument);
}
GCC_DIAG_OFF_SUGGEST_OVERRIDE
DIAG_OFF_SUGGEST_OVERRIDE