Merge topic 'weak_vtable_warnings'

77baa8a2 Add test for exceptions thrown across library boundaries.
fd0e3e0e Remove vtable from WaveletFilter.
96bf0dac Give AxisAnnotation a virtual destructor.
4807b3c4 Silence warnings about unavoidable weak vtables.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Merge-request: !742
This commit is contained in:
David Lonie 2017-04-14 12:56:00 +00:00 committed by Kitware Robot
commit 2a4e55770f
22 changed files with 140 additions and 2 deletions

@ -32,6 +32,8 @@
namespace vtkm {
namespace cont {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
/// The superclass of all exceptions thrown by any VTKm function or method.
///
class VTKM_ALWAYS_EXPORT Error : public std::exception
@ -69,6 +71,8 @@ private:
std::string Message;
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
} // namespace vtkm::cont

@ -25,6 +25,8 @@
namespace vtkm {
namespace cont {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
/// This class is thrown when VTK-m attempts to manipulate memory that it should
/// not.
///
@ -35,6 +37,8 @@ public:
: Error(message) { }
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
} // namespace vtkm::cont

@ -25,6 +25,8 @@
namespace vtkm {
namespace cont {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
/// This class is thrown when VTK-m encounters data of a type that is
/// incompatible with the current operation.
///
@ -35,6 +37,8 @@ public:
: Error(message) { }
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
} // namespace vtkm::cont

@ -25,6 +25,8 @@
namespace vtkm {
namespace cont {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
/// This class is thrown when a VTKm function or method encounters an invalid
/// value that inhibits progress.
///
@ -35,6 +37,8 @@ public:
: Error(message) { }
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
} // namespace vtkm::cont

@ -25,6 +25,8 @@
namespace vtkm {
namespace cont {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
/// This class is thrown in the control environment whenever an error occurs in
/// the execution environment.
///
@ -35,6 +37,8 @@ public:
: Error(message) { }
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
} // namespace vtkm::cont

@ -25,6 +25,8 @@
namespace vtkm {
namespace cont {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
/// This class is thrown when VTKm detects an internal state that should never
/// be reached. This error usually indicates a bug in vtkm or, at best, VTKm
/// failed to detect an invalid input it should have.
@ -36,6 +38,8 @@ public:
: Error(message) { }
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
} // namespace vtkm::cont

@ -67,6 +67,8 @@ namespace vtkm {
namespace cont {
namespace cuda {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
/// This error is thrown whenever an unidentified CUDA runtime error is
/// encountered.
///
@ -92,6 +94,8 @@ public:
}
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
}
} // namespace vtkm::cont:cuda

@ -91,6 +91,21 @@
#define VTKM_OVERRIDE override
// Clang will warn about weak vtables (-Wweak-vtables) on exception classes,
// but there's no good way to eliminate them in this case because MSVC (See
// http://stackoverflow.com/questions/24511376). These macros will silence the
// warning for classes defined within them.
#ifdef VTKM_CLANG
#define VTKM_SILENCE_WEAK_VTABLE_WARNING_START \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wweak-vtables\"")
#define VTKM_SILENCE_WEAK_VTABLE_WARNING_END \
_Pragma("clang diagnostic pop")
#else // VTKM_CLANG
#define VTKM_SILENCE_WEAK_VTABLE_WARNING_START
#define VTKM_SILENCE_WEAK_VTABLE_WARNING_END
#endif // VTKM_CLANG
/// Simple macro to identify a parameter as unused. This allows you to name a
/// parameter that is not used. There are several instances where you might
/// want to do this. For example, when using a parameter to overload or

@ -24,6 +24,8 @@
#include <vtkm/interop/internal/OpenGLHeaders.h>
#include <vtkm/interop/internal/BufferTypePicker.h>
#include <vtkm/internal/ExportMacros.h>
#include <memory>
namespace vtkm{
@ -32,6 +34,9 @@ namespace interop{
namespace internal
{
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
/// \brief Device backend and opengl interop resources management
///
/// \c TransferResource manages a context for a given device backend and a
@ -43,6 +48,9 @@ namespace internal
public:
virtual ~TransferResource() {}
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
/// \brief Manages the state for transferring an ArrayHandle to opengl.

@ -25,6 +25,8 @@
namespace vtkm {
namespace io {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
class VTKM_ALWAYS_EXPORT ErrorIO : public vtkm::cont::Error
{
public:
@ -32,6 +34,8 @@ public:
ErrorIO(const std::string message) : Error(message) { }
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
} // namespace vtkm::io

@ -33,6 +33,8 @@ namespace vtkm {
namespace io {
namespace reader {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
class VTKDataSetReader : public VTKDataSetReaderBase
{
public:
@ -96,6 +98,8 @@ private:
std::unique_ptr<VTKDataSetReaderBase> Reader;
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
}
} // vtkm::io::reader

@ -31,6 +31,7 @@
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/internal/ExportMacros.h>
#include <vtkm/io/ErrorIO.h>
#include <algorithm>
@ -199,6 +200,7 @@ inline vtkm::cont::DynamicCellSet CreateCellSetStructured(const vtkm::Id3 &dim)
} // namespace internal
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
class VTKDataSetReaderBase
{
@ -820,6 +822,8 @@ private:
friend class VTKDataSetReader;
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
}
} // vtkm::io::reader

@ -66,6 +66,8 @@ inline vtkm::cont::ArrayHandle<T> ConcatinateArrayHandles(
} // namespace internal
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
class VTKPolyDataReader : public VTKDataSetReaderBase
{
public:
@ -175,6 +177,8 @@ private:
}
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
}
} // namespace vtkm::io:reader

@ -26,6 +26,8 @@ namespace vtkm {
namespace io {
namespace reader {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
class VTKRectilinearGridReader : public VTKDataSetReaderBase
{
public:
@ -100,6 +102,8 @@ private:
}
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
}
} // namespace vtkm::io:reader

@ -26,6 +26,8 @@ namespace vtkm {
namespace io {
namespace reader {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
class VTKStructuredGridReader : public VTKDataSetReaderBase
{
public:
@ -71,6 +73,8 @@ private:
}
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
}
} // namespace vtkm::io:reader

@ -26,6 +26,8 @@ namespace vtkm {
namespace io {
namespace reader {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
class VTKStructuredPointsReader : public VTKDataSetReaderBase
{
public:
@ -87,6 +89,8 @@ private:
}
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
}
} // namespace vtkm::io:reader

@ -26,6 +26,8 @@ namespace vtkm {
namespace io {
namespace reader {
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
class VTKUnstructuredGridReader : public VTKDataSetReaderBase
{
public:
@ -95,6 +97,8 @@ private:
}
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
}
}
} // namespace vtkm::io:reader

@ -42,7 +42,7 @@ protected:
public:
AxisAnnotation();
~AxisAnnotation();
virtual ~AxisAnnotation();
virtual void Render(const vtkm::rendering::Camera &camera,
const vtkm::rendering::WorldAnnotator &worldAnnotator,

@ -33,6 +33,7 @@ set(unit_tests
UnitTestBinaryOperators.cxx
UnitTestBounds.cxx
UnitTestCellShape.cxx
UnitTestExceptions.cxx
UnitTestImplicitFunctions.cxx
UnitTestListTag.cxx
UnitTestMath.cxx

@ -37,6 +37,9 @@
*
*/
// For warning suppression macros:
#include <vtkm/internal/ExportMacros.h>
/**
* @file
*
@ -1352,6 +1355,10 @@ private:
}
};
// The Action classes emit weak vtables. These classes are small, so we aren't
// concerned about the overhead here.
VTKM_SILENCE_WEAK_VTABLE_WARNING_START
/**
* @internal
* @brief Interface for actions Parser::workhorse() should perform for each Option it
@ -1479,6 +1486,8 @@ public:
}
};
VTKM_SILENCE_WEAK_VTABLE_WARNING_END
inline void Parser::parse(bool gnu, const Descriptor usage[], int argc, const char** argv, Option options[],
Option buffer[], int min_abbr_len, bool single_minus_longopt, int bufmax)
{

@ -0,0 +1,45 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2017 Sandia Corporation.
// Copyright 2017 UT-Battelle, LLC.
// Copyright 2017 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#include <vtkm/cont/Error.h>
#include <vtkm/cont/RuntimeDeviceTracker.h>
#include <vtkm/cont/internal/DeviceAdapterError.h>
//------------------------------------------------------------------------------
// This test ensures that exceptions thrown internally by the vtkm_cont library
// can be correctly caught across library boundaries.
int UnitTestExceptions(int, char *[])
{
vtkm::cont::RuntimeDeviceTracker tracker;
try {
// This throws a ErrorBadValue from RuntimeDeviceTracker::CheckDevice,
// which is compiled into the vtkm_cont library:
tracker.ResetDevice(vtkm::cont::DeviceAdapterTagError());
}
catch (vtkm::cont::ErrorBadValue&)
{
return EXIT_SUCCESS;
}
std::cerr << "Did not catch expected ErrorBadValue exception.\n";
return EXIT_FAILURE;
}

@ -96,7 +96,7 @@ public:
}
// destructor
virtual ~WaveletFilter()
~WaveletFilter()
{
if( LowDecomposeFilter )
{