Commit 4807b3c4 authored by David C. Lonie's avatar David C. Lonie

Silence warnings about unavoidable weak vtables.

- Exception classes cannot be exported due to MSVC's design decisions.
  See http://stackoverflow.com/questions/24511376. We must leave these
  classes as header only and silence the warnings.
- TransferResource in BufferState.h must remain a header-only class since
  there is no vtkm_interop library to compile the class into.
- The VTKDataSetReader hierarchy must similarly remain header-only since
  there is no vtkm_io library.
- The OptionParser Action classes are part of a header-only utility and
  cannot be easily compiled into a library.
-
parent 451930f0
......@@ -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
......
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment