From 660b7894153a8205ac7e2ff209724c8a1a29d8bf Mon Sep 17 00:00:00 2001 From: attila Date: Thu, 25 Apr 2024 12:38:01 +0200 Subject: [PATCH] AU Client: Suppress EnumCastOutOfRange Clang Analyzer warning --- .../native/juce_CoreAudioLayouts_mac.h | 11 +++++++++++ .../juce_audio_plugin_client_AU_1.mm | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/modules/juce_audio_basics/native/juce_CoreAudioLayouts_mac.h b/modules/juce_audio_basics/native/juce_CoreAudioLayouts_mac.h index 4e095c06f4..bb165eba17 100644 --- a/modules/juce_audio_basics/native/juce_CoreAudioLayouts_mac.h +++ b/modules/juce_audio_basics/native/juce_CoreAudioLayouts_mac.h @@ -118,7 +118,12 @@ struct CoreAudioLayouts List { kAudioChannelLayoutTag_MPEG_5_1_D, { centre, left, right, leftSurround, rightSurround, LFE } }, List { kAudioChannelLayoutTag_MPEG_7_1_B, { centre, leftCentre, rightCentre, left, right, leftSurround, rightSurround, LFE } }, List { kAudioChannelLayoutTag_Emagic_Default_7_1, { left, right, leftSurround, rightSurround, centre, LFE, leftCentre, rightCentre } }, + + // Suppressing clang-analyzer-optin.core.EnumCastOutOfRange + #ifndef __clang_analyzer__ List { kAudioChannelLayoutTag_SMPTE_DTV, { left, right, centre, LFE, leftSurround, rightSurround, discreteChannel0 /* leftMatrixTotal */, (ChannelType) (discreteChannel0 + 1) /* rightMatrixTotal */} }, + #endif + List { kAudioChannelLayoutTag_ITU_2_2, { left, right, leftSurround, rightSurround } }, List { kAudioChannelLayoutTag_DVD_4, { left, right, LFE } }, List { kAudioChannelLayoutTag_DVD_5, { left, right, LFE, centreSurround } }, @@ -239,10 +244,13 @@ public: for (UInt32 i = 0; i < layout.mNumberChannelDescriptions; ++i) channels.addIfNotAlreadyThere (getChannelTypeFromAudioChannelLabel (layout.mChannelDescriptions[i].mChannelLabel)); + // Suppressing clang-analyzer-optin.core.EnumCastOutOfRange + #ifndef __clang_analyzer__ // different speaker mappings may point to the same JUCE speaker so fill up // this array with discrete channels for (int j = 0; channels.size() < static_cast (layout.mNumberChannelDescriptions); ++j) channels.addIfNotAlreadyThere (static_cast (AudioChannelSet::discreteChannel0 + j)); + #endif return channels; } @@ -285,8 +293,11 @@ public: return AudioChannelSet::ambisonic (ambisonicOrder).getChannelTypes(); } + // Suppressing clang-analyzer-optin.core.EnumCastOutOfRange + #ifndef __clang_analyzer__ for (UInt32 i = 0; i < numChannels; ++i) speakers.add (static_cast (AudioChannelSet::discreteChannel0 + i)); + #endif return speakers; } diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm b/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm index 3867633014..745b21a00f 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm @@ -878,9 +878,14 @@ public: if (const AudioProcessor::Bus* bus = juceFilter->getBus (isInput, busNr)) { AudioChannelSet discreteRangeSet; + + // Suppressing clang-analyzer-optin.core.EnumCastOutOfRange + #ifndef __clang_analyzer__ const int n = bus->getDefaultLayout().size(); + for (int i = 0; i < n; ++i) discreteRangeSet.addChannel ((AudioChannelSet::ChannelType) (256 + i)); + #endif // if the audioprocessor supports this it cannot // really be interested in the bus layouts