1 // Copyright (c) 2019 Google LLC 2 // 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 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 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. 14 15 #ifndef SOURCE_FUZZ_DATA_DESCRIPTOR_H_ 16 #define SOURCE_FUZZ_DATA_DESCRIPTOR_H_ 17 18 #include <ostream> 19 #include <vector> 20 21 #include "source/fuzz/protobufs/spirvfuzz_protobufs.h" 22 23 namespace spvtools { 24 namespace fuzz { 25 26 // Factory method to create a data descriptor message from an object id and a 27 // list of indices. 28 protobufs::DataDescriptor MakeDataDescriptor( 29 uint32_t object, const std::vector<uint32_t>& indices); 30 31 // Hash function for data descriptors. 32 struct DataDescriptorHash { 33 size_t operator()(const protobufs::DataDescriptor* data_descriptor) const; 34 }; 35 36 // Equality function for data descriptors. 37 struct DataDescriptorEquals { 38 bool operator()(const protobufs::DataDescriptor* first, 39 const protobufs::DataDescriptor* second) const; 40 }; 41 42 std::ostream& operator<<(std::ostream& out, 43 const protobufs::DataDescriptor& data_descriptor); 44 45 } // namespace fuzz 46 } // namespace spvtools 47 48 #endif // SOURCE_FUZZ_DATA_DESCRIPTOR_H_ 49