// Copyright 2022 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "src/tint/transform/disable_uniformity_analysis.h"

#include <utility>

#include "src/tint/program_builder.h"
#include "src/tint/sem/module.h"

TINT_INSTANTIATE_TYPEINFO(tint::transform::DisableUniformityAnalysis);

namespace tint::transform {

DisableUniformityAnalysis::DisableUniformityAnalysis() = default;

DisableUniformityAnalysis::~DisableUniformityAnalysis() = default;

Transform::ApplyResult DisableUniformityAnalysis::Apply(const Program* src,
                                                        const DataMap&,
                                                        DataMap&) const {
    if (src->Sem().Module()->Extensions().Contains(
            builtin::Extension::kChromiumDisableUniformityAnalysis)) {
        return SkipTransform;
    }

    ProgramBuilder b;
    CloneContext ctx{&b, src, /* auto_clone_symbols */ true};
    b.Enable(builtin::Extension::kChromiumDisableUniformityAnalysis);

    ctx.Clone();
    return Program(std::move(b));
}

}  // namespace tint::transform
