fuzzer_pass_add_parameters.h 1.6 KB

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