intrinsic_table.def: Support [[deprecated]] on fn

And produce a warning if these are used. Hard to test, as we don't want to introduce fake functions in our definition file.

Also add missing cast in EnumMatcher.

Bug: tint:806
Change-Id: I21f189e4befe419f6d5544acfc52387d9a5da782
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54001
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton
2021-06-10 17:31:54 +00:00
committed by Tint LUCI CQ
parent 06e2e5c2f7
commit 3e59eb0e5c
9 changed files with 289 additions and 9 deletions

View File

@@ -98,6 +98,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 deprecated
IsDeprecated bool
}
// Function is used to create the C++ IntrinsicInfo structure
@@ -196,6 +198,7 @@ func (b *intrinsicTableBuilder) buildOverload(o *sem.Overload) (Overload, error)
ParametersOffset: b.lut.parameters.Add(ob.parameters),
ReturnMatcherIndicesOffset: ob.returnTypeMatcherIndicesOffset,
CanBeUsedInStage: o.CanBeUsedInStage,
IsDeprecated: o.IsDeprecated,
}, nil
}

View File

@@ -275,6 +275,12 @@ func (r *resolver) function(a ast.FunctionDecl) error {
Compute: true,
}
}
if deprecated := a.Decorations.Take("deprecated"); deprecated != nil {
overload.IsDeprecated = true
if len(deprecated.Values) != 0 {
return fmt.Errorf("%v unexpected value for deprecated decoration", deprecated.Source)
}
}
if len(a.Decorations) != 0 {
return fmt.Errorf("%v unknown decoration", a.Decorations[0].Source)
}

View File

@@ -137,6 +137,7 @@ type Overload struct {
ReturnType *FullyQualifiedName
Parameters []Parameter
CanBeUsedInStage StageUses
IsDeprecated bool // True if this overload is deprecated
}
// StageUses describes the stages an overload can be used in