chromium/third_party/libprotobuf-mutator/src/src/mutator.cc

// Copyright 2016 Google Inc. All rights reserved.
//
// 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/mutator.h"

#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <memory>
#include <random>
#include <string>
#include <utility>
#include <vector>

#include "src/field_instance.h"
#include "src/utf8_fix.h"
#include "src/weighted_reservoir_sampler.h"

namespace protobuf_mutator {

Any;
Descriptor;
FieldDescriptor;
FileDescriptor;
Message;
OneofDescriptor;
Reflection;
MessageDifferencer;
_1;

namespace {

const int kMaxInitializeDepth =;
const uint64_t kDefaultMutateWeight =;

enum class Mutation : uint8_t {};

MutationBitset;

Messages;
ConstMessages;

// Return random integer from [0, count)
size_t GetRandomIndex(RandomEngine* random, size_t count) {}

// Flips random bit in the buffer.
void FlipBit(size_t size, uint8_t* bytes, RandomEngine* random) {}

// Flips random bit in the value.
template <class T>
T FlipBit(T value, RandomEngine* random) {}

// Return true with probability about 1-of-n.
bool GetRandomBool(RandomEngine* random, size_t n = 2) {}

bool IsProto3SimpleField(const FieldDescriptor& field) {}

struct CreateDefaultField : public FieldFunction<CreateDefaultField> {};

struct DeleteField : public FieldFunction<DeleteField> {};

struct CopyField : public FieldFunction<CopyField> {};

struct AppendField : public FieldFunction<AppendField> {};

class CanCopyAndDifferentField
    : public FieldFunction<CanCopyAndDifferentField, bool> {};

// Selects random field and mutation from the given proto message.
class MutationSampler {};

// Selects random field of compatible type to use for clone mutations.
class DataSourceSampler {};

UnpackedAny;

const Descriptor* GetAnyTypeDescriptor(const Any& any) {}

std::unique_ptr<Message> UnpackAny(const Any& any) {}

const Any* CastToAny(const Message* message) {}

Any* CastToAny(Message* message) {}

std::unique_ptr<Message> UnpackIfAny(const Message& message) {}

void UnpackAny(const Message& message, UnpackedAny* result) {}

class PostProcessing {};

}  // namespace

class FieldMutator {};

namespace {

struct MutateField : public FieldFunction<MutateField> {};

struct CreateField : public FieldFunction<CreateField> {};

}  // namespace

void Mutator::Seed(uint32_t value) {}

void Mutator::Fix(Message* message) {}

void Mutator::Mutate(Message* message, size_t max_size_hint) {}

void Mutator::CrossOver(const Message& message1, Message* message2,
                        size_t max_size_hint) {}

void Mutator::RegisterPostProcessor(const Descriptor* desc,
                                    PostProcess callback) {}

bool Mutator::MutateImpl(const ConstMessages& sources, const Messages& messages,
                         bool copy_clone_only, int size_increase_hint) {}

int32_t Mutator::MutateInt32(int32_t value) {}

int64_t Mutator::MutateInt64(int64_t value) {}

uint32_t Mutator::MutateUInt32(uint32_t value) {}

uint64_t Mutator::MutateUInt64(uint64_t value) {}

float Mutator::MutateFloat(float value) {}

double Mutator::MutateDouble(double value) {}

bool Mutator::MutateBool(bool value) {}

size_t Mutator::MutateEnum(size_t index, size_t item_count) {}

std::string Mutator::MutateString(const std::string& value,
                                  int size_increase_hint) {}

std::string Mutator::MutateUtf8String(const std::string& value,
                                      int size_increase_hint) {}

bool Mutator::IsInitialized(const Message& message) const {}

}  // namespace protobuf_mutator