• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2020 Vasyl Teliman
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_FUZZER_PASS_ADD_PARAMETERS_H_
16 #define SOURCE_FUZZ_FUZZER_PASS_ADD_PARAMETERS_H_
17 
18 #include <vector>
19 
20 #include "source/fuzz/fuzzer_pass.h"
21 
22 namespace spvtools {
23 namespace fuzz {
24 
25 // Randomly decides for each non-entry-point function in the module whether to
26 // add new parameters to it. If so, randomly determines the number of parameters
27 // to add, their type and creates constants used to initialize them.
28 class FuzzerPassAddParameters : public FuzzerPass {
29  public:
30   FuzzerPassAddParameters(opt::IRContext* ir_context,
31                           TransformationContext* transformation_context,
32                           FuzzerContext* fuzzer_context,
33                           protobufs::TransformationSequence* transformations,
34                           bool ignore_inapplicable_transformations);
35 
36   void Apply() override;
37 
38  private:
39   // Returns number of parameters of |function|.
40   uint32_t GetNumberOfParameters(const opt::Function& function) const;
41 };
42 
43 }  // namespace fuzz
44 }  // namespace spvtools
45 
46 #endif  // SOURCE_FUZZ_FUZZER_PASS_ADD_PARAMETERS_H_
47