1 // Copyright (c) 2020 Google LLC
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #ifndef SOURCE_FUZZ_COUNTER_OVERFLOW_ID_SOURCE_H_
16 #define SOURCE_FUZZ_COUNTER_OVERFLOW_ID_SOURCE_H_
18 #include "source/fuzz/overflow_id_source.h"
23 // A source of overflow ids that uses a counter to provide successive ids from
24 // a given starting value.
25 class CounterOverflowIdSource
: public OverflowIdSource
{
27 // |first_available_id| is the starting value for the counter.
28 explicit CounterOverflowIdSource(uint32_t first_available_id
);
30 // Always returns true.
31 bool HasOverflowIds() const override
;
33 // Returns the current counter value and increments the counter.
34 // TODO(https://github.com/KhronosGroup/SPIRV-Tools/issues/2541) We should
35 // account for the case where the maximum allowed id is reached.
36 uint32_t GetNextOverflowId() override
;
38 const std::unordered_set
<uint32_t>& GetIssuedOverflowIds() const override
;
41 uint32_t next_available_id_
;
43 std::unordered_set
<uint32_t> issued_ids_
;
47 } // namespace spvtools
49 #endif // SOURCE_FUZZ_OVERFLOW_ID_SOURCE_COUNTER_H_