mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 14:46:08 +00:00
tools: Add @must_use support to intrinsics.def
Emits the new OverloadFlag::kMustUse flag on the annotated overloads. Nothing consumes this, yet. Bug: tint:1844 Change-Id: I4eb0943a23eaf5de98cd63444a686cffe62fb36e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120920 Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
ce10962d82
commit
d84903201d
@@ -106,6 +106,8 @@ type Overload struct {
|
||||
ReturnMatcherIndicesOffset *int
|
||||
// StageUses describes the stages an overload can be used in
|
||||
CanBeUsedInStage sem.StageUses
|
||||
// True if the overload is marked as @must_use
|
||||
MustUse bool
|
||||
// True if the overload is marked as deprecated
|
||||
IsDeprecated bool
|
||||
// The kind of overload
|
||||
@@ -211,6 +213,7 @@ func (b *IntrinsicTableBuilder) buildOverload(o *sem.Overload) (Overload, error)
|
||||
ParametersOffset: b.lut.parameters.Add(ob.parameters),
|
||||
ReturnMatcherIndicesOffset: ob.returnTypeMatcherIndicesOffset,
|
||||
CanBeUsedInStage: o.CanBeUsedInStage,
|
||||
MustUse: o.MustUse,
|
||||
IsDeprecated: o.IsDeprecated,
|
||||
Kind: string(o.Decl.Kind),
|
||||
ConstEvalFunction: o.ConstEvalFunction,
|
||||
|
||||
@@ -345,6 +345,15 @@ func (r *resolver) intrinsic(
|
||||
Compute: true,
|
||||
}
|
||||
}
|
||||
if mustUse := a.Attributes.Take("must_use"); mustUse != nil {
|
||||
if len(mustUse.Values) > 0 {
|
||||
return fmt.Errorf("%v @must_use does not accept any arguments", mustUse.Source)
|
||||
}
|
||||
if a.ReturnType == nil {
|
||||
return fmt.Errorf("%v @must_use can only be used on a function with a return type", mustUse.Source)
|
||||
}
|
||||
overload.MustUse = true
|
||||
}
|
||||
if constEvalFn := a.Attributes.Take("const"); constEvalFn != nil {
|
||||
switch len(constEvalFn.Values) {
|
||||
case 0:
|
||||
|
||||
@@ -177,6 +177,11 @@ type f32
|
||||
type T<x>
|
||||
conv f32(T<f32>)`,
|
||||
success,
|
||||
}, {
|
||||
`
|
||||
type f32
|
||||
@must_use fn f() -> f32`,
|
||||
success,
|
||||
}, {
|
||||
`enum E {A A}`,
|
||||
`
|
||||
@@ -518,6 +523,10 @@ type P<T>
|
||||
match m: f32
|
||||
fn f(P<m>)`,
|
||||
`file.txt:4:8 type matcher cannot be used directly here. Use a matcher constrained template argument`,
|
||||
}, {
|
||||
`
|
||||
@must_use fn f()`,
|
||||
`file.txt:1:2 @must_use can only be used on a function with a return type`,
|
||||
},
|
||||
} {
|
||||
|
||||
|
||||
@@ -182,6 +182,7 @@ type Overload struct {
|
||||
ReturnType *FullyQualifiedName
|
||||
Parameters []Parameter
|
||||
CanBeUsedInStage StageUses
|
||||
MustUse bool // True if function cannot be used as a statement
|
||||
IsDeprecated bool // True if this overload is deprecated
|
||||
ConstEvalFunction string // Name of the function used to evaluate the intrinsic at shader creation time
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user