@@ -3158,13 +3158,30 @@ suppressingFeatureIsolatedDeinit(PrintOptions &options,
3158
3158
action ();
3159
3159
}
3160
3160
3161
+ namespace {
3162
+ struct ExcludeAttrRAII {
3163
+ std::vector<AnyAttrKind> &ExcludeAttrList;
3164
+ unsigned OriginalExcludeAttrCount;
3165
+
3166
+ ExcludeAttrRAII (std::vector<AnyAttrKind> &ExcludeAttrList,
3167
+ DeclAttrKind excluded)
3168
+ : ExcludeAttrList(ExcludeAttrList),
3169
+ OriginalExcludeAttrCount (ExcludeAttrList.size())
3170
+ {
3171
+ ExcludeAttrList.push_back (excluded);
3172
+ }
3173
+
3174
+ ~ExcludeAttrRAII () {
3175
+ ExcludeAttrList.resize (OriginalExcludeAttrCount);
3176
+ }
3177
+ };
3178
+ }
3179
+
3161
3180
static void
3162
3181
suppressingFeatureAllowUnsafeAttribute (PrintOptions &options,
3163
3182
llvm::function_ref<void ()> action) {
3164
- unsigned originalExcludeAttrCount = options.ExcludeAttrList .size ();
3165
- options.ExcludeAttrList .push_back (DeclAttrKind::Unsafe);
3183
+ ExcludeAttrRAII scope (options.ExcludeAttrList , DeclAttrKind::Unsafe);
3166
3184
action ();
3167
- options.ExcludeAttrList .resize (originalExcludeAttrCount);
3168
3185
}
3169
3186
3170
3187
static void
@@ -3177,11 +3194,17 @@ suppressingFeatureCoroutineAccessors(PrintOptions &options,
3177
3194
static void
3178
3195
suppressingFeatureABIAttribute (PrintOptions &options,
3179
3196
llvm::function_ref<void ()> action) {
3180
- llvm::SaveAndRestore<bool > scope (options.PrintSyntheticSILGenName , true );
3181
- unsigned originalExcludeAttrCount = options.ExcludeAttrList .size ();
3182
- options.ExcludeAttrList .push_back (DeclAttrKind::ABI);
3197
+ llvm::SaveAndRestore<bool > scope1 (options.PrintSyntheticSILGenName , true );
3198
+ ExcludeAttrRAII scope2 (options.ExcludeAttrList , DeclAttrKind::ABI);
3199
+ action ();
3200
+ }
3201
+
3202
+ static void
3203
+ suppressingFeatureAddressableTypes (PrintOptions &options,
3204
+ llvm::function_ref<void ()> action) {
3205
+ ExcludeAttrRAII scope (options.ExcludeAttrList ,
3206
+ DeclAttrKind::AddressableForDependencies);
3183
3207
action ();
3184
- options.ExcludeAttrList .resize (originalExcludeAttrCount);
3185
3208
}
3186
3209
3187
3210
// / Suppress the printing of a particular feature.
0 commit comments