@@ -287,7 +287,7 @@ class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
287
287
// possible values, and a list of enumerators to map them to.
288
288
class EnumArgument<string name, string type, bit is_string, list<string> values,
289
289
list<string> enums, bit opt = 0, bit fake = 0,
290
- bit isExternalType = 0>
290
+ bit isExternalType = 0, bit isCovered = 1 >
291
291
: Argument<name, opt, fake> {
292
292
string Type = type;
293
293
// When true, the argument will be parsed as an unevaluated string literal
@@ -296,13 +296,16 @@ class EnumArgument<string name, string type, bit is_string, list<string> values,
296
296
list<string> Values = values;
297
297
list<string> Enums = enums;
298
298
bit IsExternalType = isExternalType;
299
+ // We need to know whether an external enum is fully covered by the options
300
+ // in order to decide whether to emit unreachable default labels in a switch.
301
+ bit IsCovered = isCovered;
299
302
}
300
303
301
304
// FIXME: There should be a VariadicArgument type that takes any other type
302
305
// of argument and generates the appropriate type.
303
306
class VariadicEnumArgument<string name, string type, bit is_string,
304
307
list<string> values, list<string> enums,
305
- bit isExternalType = 0>
308
+ bit isExternalType = 0, bit isCovered = 1 >
306
309
: Argument<name, 1> {
307
310
string Type = type;
308
311
// When true, the argument will be parsed as an unevaluated string literal
@@ -311,6 +314,9 @@ class VariadicEnumArgument<string name, string type, bit is_string,
311
314
list<string> Values = values;
312
315
list<string> Enums = enums;
313
316
bit IsExternalType = isExternalType;
317
+ // We need to know whether an external enum is fully covered by the options
318
+ // in order to decide whether to emit unreachable default labels in a switch.
319
+ bit IsCovered = isCovered;
314
320
}
315
321
316
322
// Represents an attribute wrapped by another attribute.
@@ -2913,7 +2919,7 @@ def CodeModel : InheritableAttr, TargetSpecificAttr<TargetLoongArch> {
2913
2919
let Spellings = [GCC<"model">];
2914
2920
let Args = [EnumArgument<"Model", "llvm::CodeModel::Model", /*is_string=*/1,
2915
2921
["normal", "medium", "extreme"], ["Small", "Medium", "Large"],
2916
- /*opt=*/0, /*fake=*/0, /*isExternalType=*/1>];
2922
+ /*opt=*/0, /*fake=*/0, /*isExternalType=*/1, /*isCovered=*/0 >];
2917
2923
let Subjects = SubjectList<[NonTLSGlobalVar], ErrorDiag>;
2918
2924
let Documentation = [CodeModelDocs];
2919
2925
}
@@ -4472,7 +4478,7 @@ def HLSLShader : InheritableAttr {
4472
4478
["Pixel", "Vertex", "Geometry", "Hull", "Domain", "Compute",
4473
4479
"RayGeneration", "Intersection", "AnyHit", "ClosestHit",
4474
4480
"Miss", "Callable", "Mesh", "Amplification"],
4475
- /*opt=*/0, /*fake=*/0, /*isExternalType=*/1>
4481
+ /*opt=*/0, /*fake=*/0, /*isExternalType=*/1, /*isCovered=*/0 >
4476
4482
];
4477
4483
let Documentation = [HLSLSV_ShaderTypeAttrDocs];
4478
4484
let AdditionalMembers =
@@ -4487,30 +4493,31 @@ def HLSLResource : InheritableAttr {
4487
4493
let Spellings = [];
4488
4494
let Subjects = SubjectList<[Struct]>;
4489
4495
let LangOpts = [HLSL];
4490
- let Args = [EnumArgument<"ResourceClass", "llvm::hlsl::ResourceClass",
4491
- /*is_string=*/0,
4492
- ["SRV", "UAV", "CBuffer", "Sampler"],
4493
- ["SRV", "UAV", "CBuffer", "Sampler"],
4494
- /*opt=*/0, /*fake=*/0, /*isExternalType=*/1>,
4495
- EnumArgument<"ResourceKind", "llvm::hlsl::ResourceKind",
4496
- /*is_string=*/0,
4497
- ["Texture1D", "Texture2D", "Texture2DMS",
4498
- "Texture3D", "TextureCube", "Texture1DArray",
4499
- "Texture2DArray", "Texture2DMSArray",
4500
- "TextureCubeArray", "TypedBuffer", "RawBuffer",
4501
- "StructuredBuffer", "CBuffer", "Sampler",
4502
- "TBuffer", "RTAccelerationStructure",
4503
- "FeedbackTexture2D", "FeedbackTexture2DArray"],
4504
- ["Texture1D", "Texture2D", "Texture2DMS",
4505
- "Texture3D", "TextureCube", "Texture1DArray",
4506
- "Texture2DArray", "Texture2DMSArray",
4507
- "TextureCubeArray", "TypedBuffer", "RawBuffer",
4508
- "StructuredBuffer", "CBuffer", "Sampler",
4509
- "TBuffer", "RTAccelerationStructure",
4510
- "FeedbackTexture2D", "FeedbackTexture2DArray"],
4511
- /*opt=*/0, /*fake=*/0, /*isExternalType=*/1>,
4512
- DefaultBoolArgument<"isROV", /*default=*/0>
4513
- ];
4496
+ let Args = [
4497
+ EnumArgument<"ResourceClass", "llvm::hlsl::ResourceClass",
4498
+ /*is_string=*/0, ["SRV", "UAV", "CBuffer", "Sampler"],
4499
+ ["SRV", "UAV", "CBuffer", "Sampler"],
4500
+ /*opt=*/0, /*fake=*/0, /*isExternalType=*/1>,
4501
+ EnumArgument<
4502
+ "ResourceKind", "llvm::hlsl::ResourceKind",
4503
+ /*is_string=*/0,
4504
+ [
4505
+ "Texture1D", "Texture2D", "Texture2DMS", "Texture3D", "TextureCube",
4506
+ "Texture1DArray", "Texture2DArray", "Texture2DMSArray",
4507
+ "TextureCubeArray", "TypedBuffer", "RawBuffer", "StructuredBuffer",
4508
+ "CBuffer", "Sampler", "TBuffer", "RTAccelerationStructure",
4509
+ "FeedbackTexture2D", "FeedbackTexture2DArray"
4510
+ ],
4511
+ [
4512
+ "Texture1D", "Texture2D", "Texture2DMS", "Texture3D", "TextureCube",
4513
+ "Texture1DArray", "Texture2DArray", "Texture2DMSArray",
4514
+ "TextureCubeArray", "TypedBuffer", "RawBuffer", "StructuredBuffer",
4515
+ "CBuffer", "Sampler", "TBuffer", "RTAccelerationStructure",
4516
+ "FeedbackTexture2D", "FeedbackTexture2DArray"
4517
+ ],
4518
+ /*opt=*/0, /*fake=*/0, /*isExternalType=*/1, /*isCovered=*/0>,
4519
+ DefaultBoolArgument<"isROV", /*default=*/0>
4520
+ ];
4514
4521
let Documentation = [InternalOnly];
4515
4522
}
4516
4523
0 commit comments