Update path-to-regexp to address CVE-2024-45296 (#5895)
[KhronosGroup/SPIRV-Tools.git] / source / fuzz / transformation_context.h
blob3edcb636f9f8f9383bef233eca9126dc81d714a0
1 // Copyright (c) 2020 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.
15 #ifndef SOURCE_FUZZ_TRANSFORMATION_CONTEXT_H_
16 #define SOURCE_FUZZ_TRANSFORMATION_CONTEXT_H_
18 #include <memory>
20 #include "source/fuzz/fact_manager/fact_manager.h"
21 #include "source/fuzz/overflow_id_source.h"
22 #include "spirv-tools/libspirv.hpp"
24 namespace spvtools {
25 namespace fuzz {
27 // Encapsulates all information that is required to inform how to apply a
28 // transformation to a module.
29 class TransformationContext {
30 public:
31 // Constructs a transformation context with a given fact manager and validator
32 // options. Overflow ids are not available from a transformation context
33 // constructed in this way.
34 TransformationContext(std::unique_ptr<FactManager>,
35 spv_validator_options validator_options);
37 // Constructs a transformation context with a given fact manager, validator
38 // options and overflow id source.
39 TransformationContext(std::unique_ptr<FactManager>,
40 spv_validator_options validator_options,
41 std::unique_ptr<OverflowIdSource> overflow_id_source);
43 ~TransformationContext();
45 FactManager* GetFactManager() { return fact_manager_.get(); }
47 const FactManager* GetFactManager() const { return fact_manager_.get(); }
49 OverflowIdSource* GetOverflowIdSource() { return overflow_id_source_.get(); }
51 const OverflowIdSource* GetOverflowIdSource() const {
52 return overflow_id_source_.get();
55 spv_validator_options GetValidatorOptions() const {
56 return validator_options_;
59 private:
60 // Manages facts that inform whether transformations can be applied, and that
61 // are produced by applying transformations.
62 std::unique_ptr<FactManager> fact_manager_;
64 // Options to control validation when deciding whether transformations can be
65 // applied.
66 spv_validator_options validator_options_;
68 std::unique_ptr<OverflowIdSource> overflow_id_source_;
71 } // namespace fuzz
72 } // namespace spvtools
74 #endif // SOURCE_FUZZ_TRANSFORMATION_CONTEXT_H_