1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

UB Sanitizer: Avoid warnings in third party code, with clang

This commit is contained in:
reuk 2021-09-21 16:33:57 +01:00
parent 485699020a
commit afa6465098
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11
5 changed files with 38 additions and 1 deletions

View file

@ -50,6 +50,7 @@ namespace OggVorbisNamespace
"-Wmisleading-indentation",
"-Wmissing-prototypes",
"-Wcast-align")
JUCE_BEGIN_NO_SANITIZE ("undefined")
#include "oggvorbis/vorbisenc.h"
#include "oggvorbis/codec.h"
@ -79,6 +80,7 @@ namespace OggVorbisNamespace
#include "oggvorbis/libvorbis-1.3.7/lib/vorbisfile.c"
#include "oggvorbis/libvorbis-1.3.7/lib/window.c"
JUCE_END_NO_SANITIZE
JUCE_END_IGNORE_WARNINGS_MSVC
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
#else

View file

@ -29,6 +29,8 @@
//==============================================================================
#if JucePlugin_Build_VST3 && (JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX || JUCE_BSD)
JUCE_BEGIN_NO_SANITIZE ("vptr")
#if JUCE_PLUGINHOST_VST3
#if JUCE_MAC
#include <CoreFoundation/CoreFoundation.h>
@ -3989,4 +3991,6 @@ extern "C" SMTG_EXPORT_SYMBOL IPluginFactory* PLUGIN_API GetPluginFactory()
extern "C" BOOL WINAPI DllMain (HINSTANCE instance, DWORD reason, LPVOID) { if (reason == DLL_PROCESS_ATTACH) Process::setCurrentModuleInstanceHandle (instance); return true; }
#endif
JUCE_END_NO_SANITIZE
#endif //JucePlugin_Build_VST3

View file

@ -28,6 +28,8 @@
namespace juce
{
JUCE_BEGIN_NO_SANITIZE ("vptr")
//==============================================================================
#define JUCE_DECLARE_VST3_COM_REF_METHODS \
Steinberg::uint32 PLUGIN_API addRef() override { return (Steinberg::uint32) ++refCount; } \
@ -1219,6 +1221,8 @@ private:
std::atomic<int32> flags { 0 };
};
JUCE_END_NO_SANITIZE
} // namespace juce
#endif // ! DOXYGEN

View file

@ -31,6 +31,10 @@
namespace juce
{
// UB Sanitizer doesn't necessarily have instrumentation for loaded plugins, so
// it won't recognize the dynamic types of pointers to the plugin's interfaces.
JUCE_BEGIN_NO_SANITIZE ("vptr")
using namespace Steinberg;
//==============================================================================
@ -3767,6 +3771,8 @@ FileSearchPath VST3PluginFormat::getDefaultLocationsToSearch()
#endif
}
JUCE_END_NO_SANITIZE
} // namespace juce
#endif // JUCE_PLUGINHOST_VST3

View file

@ -189,7 +189,7 @@
#define JUCE_IGNORE_MSVC(warnings) __pragma(warning(disable:warnings))
#define JUCE_BEGIN_IGNORE_WARNINGS_LEVEL_MSVC(level, warnings) \
__pragma(warning(push, level)) JUCE_IGNORE_MSVC(warnings)
#define JUCE_BEGIN_IGNORE_WARNINGS_MSVC(warnings) \
#define JUCE_BEGIN_IGNORE_WARNINGS_MSVC(warnings) \
__pragma(warning(push)) JUCE_IGNORE_MSVC(warnings)
#define JUCE_END_IGNORE_WARNINGS_MSVC __pragma(warning(pop))
#else
@ -198,3 +198,24 @@
#define JUCE_BEGIN_IGNORE_WARNINGS_MSVC(warnings)
#define JUCE_END_IGNORE_WARNINGS_MSVC
#endif
#if JUCE_MAC || JUCE_IOS
#define JUCE_SANITIZER_ATTRIBUTE_MINIMUM_CLANG_VERSION 10
#else
#define JUCE_SANITIZER_ATTRIBUTE_MINIMUM_CLANG_VERSION 5
#endif
/** Disable sanitizers for a range of functions.
This functionality doesn't seem to exist on GCC yet, so at the moment this only works for clang.
*/
#if JUCE_CLANG && __clang_major__ >= JUCE_SANITIZER_ATTRIBUTE_MINIMUM_CLANG_VERSION
#define JUCE_BEGIN_NO_SANITIZE(warnings) \
_Pragma(JUCE_TO_STRING(clang attribute push(__attribute__((no_sanitize(warnings))), apply_to=function)))
#define JUCE_END_NO_SANITIZE _Pragma(JUCE_TO_STRING(clang attribute pop))
#else
#define JUCE_BEGIN_NO_SANITIZE(warnings)
#define JUCE_END_NO_SANITIZE
#endif
#undef JUCE_SANITIZER_ATTRIBUTE_MINIMUM_CLANG_VERSION