• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Tint Authors.
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 #include "fuzzers/tint_ast_fuzzer/mutation.h"
16 
17 #include <cassert>
18 
19 #include "fuzzers/tint_ast_fuzzer/mutations/replace_identifier.h"
20 
21 namespace tint {
22 namespace fuzzers {
23 namespace ast_fuzzer {
24 
25 Mutation::~Mutation() = default;
26 
FromMessage(const protobufs::Mutation & message)27 std::unique_ptr<Mutation> Mutation::FromMessage(
28     const protobufs::Mutation& message) {
29   switch (message.mutation_case()) {
30     case protobufs::Mutation::kReplaceIdentifier:
31       return std::make_unique<MutationReplaceIdentifier>(
32           message.replace_identifier());
33     case protobufs::Mutation::MUTATION_NOT_SET:
34       assert(false && "Mutation is not set");
35       break;
36   }
37   return nullptr;
38 }
39 
40 }  // namespace ast_fuzzer
41 }  // namespace fuzzers
42 }  // namespace tint
43