bulk code format fix (#8707)

This commit is contained in:
Derek Bailey
2025-09-23 21:50:27 -07:00
committed by GitHub
parent 0e047869da
commit caf3b494db
559 changed files with 38871 additions and 31276 deletions

View File

@@ -23,7 +23,7 @@ static const uint64_t kOffsetBasis = 0xcbf29ce484222645ULL;
namespace flatbuffers {
template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
template <typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
uint64_t Hash(T value, uint64_t hash) {
return (hash * kFnvPrime) ^ value;
}
@@ -33,33 +33,51 @@ uint64_t Hash(double value, uint64_t hash) {
return (hash * kFnvPrime) ^ static_cast<uint64_t>(value);
}
uint64_t Hash(const flatbuffers::String *value, uint64_t hash) {
if (value == nullptr) { return hash * kFnvPrime; }
for (auto &c : value->str()) { hash = Hash(static_cast<uint8_t>(c), hash); }
uint64_t Hash(const flatbuffers::String* value, uint64_t hash) {
if (value == nullptr) {
return hash * kFnvPrime;
}
for (auto& c : value->str()) {
hash = Hash(static_cast<uint8_t>(c), hash);
}
return hash;
}
uint64_t Hash(const LeafStruct *value, uint64_t hash) {
if (value == nullptr) { return hash * kFnvPrime; }
uint64_t Hash(const LeafStruct* value, uint64_t hash) {
if (value == nullptr) {
return hash * kFnvPrime;
}
hash = Hash(value->a(), hash);
hash = Hash(value->b(), hash);
return hash;
}
template<typename T> uint64_t Hash(const Vector<T> *value, uint64_t hash) {
if (value == nullptr) { return hash * kFnvPrime; }
for (const T c : *value) { hash = Hash(c, hash); }
template <typename T>
uint64_t Hash(const Vector<T>* value, uint64_t hash) {
if (value == nullptr) {
return hash * kFnvPrime;
}
for (const T c : *value) {
hash = Hash(c, hash);
}
return hash;
}
template<typename T> uint64_t Hash(const Vector64<T> *value, uint64_t hash) {
if (value == nullptr) { return hash * kFnvPrime; }
for (const T c : *value) { hash = Hash(c, hash); }
template <typename T>
uint64_t Hash(const Vector64<T>* value, uint64_t hash) {
if (value == nullptr) {
return hash * kFnvPrime;
}
for (const T c : *value) {
hash = Hash(c, hash);
}
return hash;
}
uint64_t Hash(const RootTable *value, uint64_t hash) {
if (value == nullptr) { return hash * kFnvPrime; }
uint64_t Hash(const RootTable* value, uint64_t hash) {
if (value == nullptr) {
return hash * kFnvPrime;
}
// Hash all the fields so we can exercise all parts of the code.
hash = Hash(value->far_vector(), hash);
hash = Hash(value->a(), hash);
@@ -72,9 +90,9 @@ uint64_t Hash(const RootTable *value, uint64_t hash) {
return hash;
}
static int AccessBuffer(const uint8_t *data, size_t size,
static int AccessBuffer(const uint8_t* data, size_t size,
bool is_size_prefixed) {
const RootTable *root_table =
const RootTable* root_table =
is_size_prefixed ? GetSizePrefixedRootTable(data) : GetRootTable(data);
TEST_NOTNULL(root_table);
@@ -85,15 +103,17 @@ static int AccessBuffer(const uint8_t *data, size_t size,
return 0;
}
extern "C" int LLVMFuzzerInitialize(int *, char ***argv) {
extern "C" int LLVMFuzzerInitialize(int*, char*** argv) {
Verifier verifier(schema.begin(), schema.size());
TEST_EQ(true, reflection::VerifySchemaBuffer(verifier));
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size < FLATBUFFERS_MIN_BUFFER_SIZE) { return 0; }
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (size < FLATBUFFERS_MIN_BUFFER_SIZE) {
return 0;
}
// Take the first bit of data as a flag to control things.
const uint8_t flags = data[0];

View File

@@ -6,7 +6,7 @@
#include "test_init.h"
static std::filesystem::path exe_path_;
static const uint8_t *schema_bfbs_;
static const uint8_t* schema_bfbs_;
static size_t schema_bfbs_length_;
bool TestFileExists(std::filesystem::path file_path) {
@@ -14,7 +14,7 @@ bool TestFileExists(std::filesystem::path file_path) {
return true;
TEST_OUTPUT_LINE("@DEBUG: file '%s' not found", file_path.string().c_str());
for (const auto &entry :
for (const auto& entry :
std::filesystem::directory_iterator(file_path.parent_path())) {
TEST_OUTPUT_LINE("@DEBUG: parent path entry: '%s'",
entry.path().string().c_str());
@@ -22,7 +22,7 @@ bool TestFileExists(std::filesystem::path file_path) {
return false;
}
std::string LoadBinarySchema(const char *file_name) {
std::string LoadBinarySchema(const char* file_name) {
const auto file_path = exe_path_.parent_path() / file_name;
TEST_EQ(true, TestFileExists(file_path));
std::string schemafile;
@@ -30,21 +30,21 @@ std::string LoadBinarySchema(const char *file_name) {
flatbuffers::LoadFile(file_path.string().c_str(), true, &schemafile));
flatbuffers::Verifier verifier(
reinterpret_cast<const uint8_t *>(schemafile.c_str()), schemafile.size());
reinterpret_cast<const uint8_t*>(schemafile.c_str()), schemafile.size());
TEST_EQ(true, reflection::VerifySchemaBuffer(verifier));
return schemafile;
}
extern "C" int LLVMFuzzerInitialize(int *, char ***argv) {
extern "C" int LLVMFuzzerInitialize(int*, char*** argv) {
exe_path_ = (*argv)[0];
static const std::string schema_file =
LoadBinarySchema("annotated_binary.bfbs");
schema_bfbs_ = reinterpret_cast<const uint8_t *>(schema_file.c_str());
schema_bfbs_ = reinterpret_cast<const uint8_t*>(schema_file.c_str());
schema_bfbs_length_ = schema_file.size();
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
flatbuffers::BinaryAnnotator annotator(schema_bfbs_, schema_bfbs_length_,
data, size, false);

View File

@@ -48,14 +48,14 @@ bool TestFileExists(fs::path file_path) {
if (file_path.has_filename() && fs::exists(file_path)) return true;
TEST_OUTPUT_LINE("@DEBUG: file '%s' not found", file_path.string().c_str());
for (const auto &entry : fs::directory_iterator(file_path.parent_path())) {
for (const auto& entry : fs::directory_iterator(file_path.parent_path())) {
TEST_OUTPUT_LINE("@DEBUG: parent path entry: '%s'",
entry.path().string().c_str());
}
return false;
}
std::string LoadBinarySchema(const char *file_name) {
std::string LoadBinarySchema(const char* file_name) {
const auto file_path = exe_path_.parent_path() / file_name;
TEST_EQ(true, TestFileExists(file_path));
std::string schemafile;
@@ -63,12 +63,12 @@ std::string LoadBinarySchema(const char *file_name) {
flatbuffers::LoadFile(file_path.string().c_str(), true, &schemafile));
flatbuffers::Verifier verifier(
reinterpret_cast<const uint8_t *>(schemafile.c_str()), schemafile.size());
reinterpret_cast<const uint8_t*>(schemafile.c_str()), schemafile.size());
TEST_EQ(true, reflection::VerifySchemaBuffer(verifier));
return schemafile;
}
std::string do_test(const flatbuffers::IDLOptions &opts,
std::string do_test(const flatbuffers::IDLOptions& opts,
const std::string input_json, const bool check_parser) {
// (re)define parser options
parser_.opts = opts;
@@ -78,8 +78,7 @@ std::string do_test(const flatbuffers::IDLOptions &opts,
flatbuffers::Verifier verifier(parser_.builder_.GetBufferPointer(),
parser_.builder_.GetSize());
TEST_EQ(true, MyGame::Example::VerifyMonsterBuffer(verifier));
TEST_NULL(
GenText(parser_, parser_.builder_.GetBufferPointer(), &jsongen));
TEST_NULL(GenText(parser_, parser_.builder_.GetBufferPointer(), &jsongen));
} else if (check_parser) {
TEST_OUTPUT_LINE("parser failed with JSON:\n%s", input_json.c_str());
TEST_EQ_STR("", parser_.error_.c_str());
@@ -95,18 +94,18 @@ std::string do_test(const flatbuffers::IDLOptions &opts,
// your fuzz target. If you need to load data files, please use argv[0] to get
// the directory where your fuzz target executable is located.
// You must not modify argv[0].
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
(void)argc;
exe_path_ = (*argv)[0];
static const std::string schemafile = LoadBinarySchema("monster_test.bfbs");
// parse schema first, so we can use it to parse the data after
parser_.Deserialize(reinterpret_cast<const uint8_t *>(schemafile.c_str()),
parser_.Deserialize(reinterpret_cast<const uint8_t*>(schemafile.c_str()),
schemafile.size());
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Reserve one byte for Parser flags and one byte for repetition counter.
if (size < 3) return 0;
const uint8_t flags = data[0];
@@ -114,7 +113,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
data += 2;
size -= 2; // bypass
const std::string original(reinterpret_cast<const char *>(data), size);
const std::string original(reinterpret_cast<const char*>(data), size);
auto input = std::string(original.c_str()); // until '\0'
if (input.size() < kMinInputLength || input.size() > kMaxInputLength)
return 0;

View File

@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <stddef.h>
#include <stdint.h>
#include <clocale>
#include <string>
@@ -19,7 +20,7 @@ static constexpr uint8_t flags_allow_non_utf8 = 0x20;
// Utility for test run.
OneTimeTestInit OneTimeTestInit::one_time_init_;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Reserve one byte for Parser flags and one byte for repetition counter.
if (size < 3) return 0;
const uint8_t flags = data[0];
@@ -27,7 +28,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
data += 2;
size -= 2; // bypass
const std::string original(reinterpret_cast<const char *>(data), size);
const std::string original(reinterpret_cast<const char*>(data), size);
auto input = std::string(original.c_str()); // until '\0'
if (input.size() < kMinInputLength || input.size() > kMaxInputLength)
return 0;
@@ -46,7 +47,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// Check Parser.
parser.Parse(parse_input);
// TODO:
// Need to add additional checks for inputs passed Parse(parse_input) successfully:
// Need to add additional checks for inputs passed Parse(parse_input)
// successfully:
// 1. Serialization to bfbs.
// 2. Generation of a default object.
// 3. Verification of the object using reflection.

View File

@@ -38,7 +38,7 @@ static constexpr uint8_t flags_quotes_kind = 0x10; // quote " or '
// Find all 'subj' sub-strings and replace first character of sub-string.
// BreakSequence("testest","tes", 'X') -> "XesXest".
// BreakSequence("xxx","xx", 'Y') -> "YYx".
static void BreakSequence(std::string &s, const char *subj, char repl) {
static void BreakSequence(std::string& s, const char* subj, char repl) {
size_t pos = 0;
while (pos = s.find(subj, pos), pos != std::string::npos) {
s.at(pos) = repl;
@@ -48,8 +48,8 @@ static void BreakSequence(std::string &s, const char *subj, char repl) {
// Remove all leading and trailing symbols matched with pattern set.
// StripString("xy{xy}y", "xy") -> "{xy}"
static std::string StripString(const std::string &s, const char *pattern,
size_t *pos = nullptr) {
static std::string StripString(const std::string& s, const char* pattern,
size_t* pos = nullptr) {
if (pos) *pos = 0;
// leading
auto first = s.find_first_not_of(pattern);
@@ -64,19 +64,19 @@ static std::string StripString(const std::string &s, const char *pattern,
class RegexMatcher {
protected:
virtual bool MatchNumber(const std::string &input) const = 0;
virtual bool MatchNumber(const std::string& input) const = 0;
public:
virtual ~RegexMatcher() = default;
struct MatchResult {
size_t pos{ 0 };
size_t len{ 0 };
bool res{ false };
bool quoted{ false };
size_t pos{0};
size_t len{0};
bool res{false};
bool quoted{false};
};
MatchResult Match(const std::string &input) const {
MatchResult Match(const std::string& input) const {
MatchResult r;
// strip leading and trailing "spaces" accepted by flatbuffer
auto test = StripString(input, "\t\r\n ", &r.pos);
@@ -103,11 +103,11 @@ class RegexMatcher {
return r;
}
bool MatchRegexList(const std::string &input,
const std::vector<std::regex> &re_list) const {
bool MatchRegexList(const std::string& input,
const std::vector<std::regex>& re_list) const {
auto str = StripString(input, " ");
if (str.empty()) return false;
for (auto &re : re_list) {
for (auto& re : re_list) {
std::smatch match;
if (std::regex_match(str, match, re)) return true;
}
@@ -117,13 +117,12 @@ class RegexMatcher {
class IntegerRegex : public RegexMatcher {
protected:
bool MatchNumber(const std::string &input) const override {
bool MatchNumber(const std::string& input) const override {
static const std::vector<std::regex> re_list = {
std::regex{ R"(^[-+]?[0-9]+$)", std::regex_constants::optimize },
std::regex{R"(^[-+]?[0-9]+$)", std::regex_constants::optimize},
std::regex{ R"(^[-+]?0[xX][0-9a-fA-F]+$)",
std::regex_constants::optimize }
};
std::regex{R"(^[-+]?0[xX][0-9a-fA-F]+$)",
std::regex_constants::optimize}};
return MatchRegexList(input, re_list);
}
@@ -134,14 +133,13 @@ class IntegerRegex : public RegexMatcher {
class UIntegerRegex : public RegexMatcher {
protected:
bool MatchNumber(const std::string &input) const override {
bool MatchNumber(const std::string& input) const override {
static const std::vector<std::regex> re_list = {
std::regex{ R"(^[+]?[0-9]+$)", std::regex_constants::optimize },
std::regex{ R"(^[+]?0[xX][0-9a-fA-F]+$)",
std::regex_constants::optimize },
// accept -0 number
std::regex{ R"(^[-](?:0[xX])?0+$)", std::regex_constants::optimize }
};
std::regex{R"(^[+]?[0-9]+$)", std::regex_constants::optimize},
std::regex{R"(^[+]?0[xX][0-9a-fA-F]+$)",
std::regex_constants::optimize},
// accept -0 number
std::regex{R"(^[-](?:0[xX])?0+$)", std::regex_constants::optimize}};
return MatchRegexList(input, re_list);
}
@@ -152,7 +150,7 @@ class UIntegerRegex : public RegexMatcher {
class BooleanRegex : public IntegerRegex {
protected:
bool MatchNumber(const std::string &input) const override {
bool MatchNumber(const std::string& input) const override {
if (input == "true" || input == "false") return true;
return IntegerRegex::MatchNumber(input);
}
@@ -164,20 +162,20 @@ class BooleanRegex : public IntegerRegex {
class FloatRegex : public RegexMatcher {
protected:
bool MatchNumber(const std::string &input) const override {
bool MatchNumber(const std::string& input) const override {
static const std::vector<std::regex> re_list = {
// hex-float
std::regex{
R"(^[-+]?0[xX](?:(?:[.][0-9a-fA-F]+)|(?:[0-9a-fA-F]+[.][0-9a-fA-F]*)|(?:[0-9a-fA-F]+))[pP][-+]?[0-9]+$)",
std::regex_constants::optimize },
// dec-float
std::regex{
R"(^[-+]?(?:(?:[.][0-9]+)|(?:[0-9]+[.][0-9]*)|(?:[0-9]+))(?:[eE][-+]?[0-9]+)?$)",
std::regex_constants::optimize },
// hex-float
std::regex{
R"(^[-+]?0[xX](?:(?:[.][0-9a-fA-F]+)|(?:[0-9a-fA-F]+[.][0-9a-fA-F]*)|(?:[0-9a-fA-F]+))[pP][-+]?[0-9]+$)",
std::regex_constants::optimize},
// dec-float
std::regex{
R"(^[-+]?(?:(?:[.][0-9]+)|(?:[0-9]+[.][0-9]*)|(?:[0-9]+))(?:[eE][-+]?[0-9]+)?$)",
std::regex_constants::optimize},
std::regex{ R"(^[-+]?(?:nan|inf|infinity)$)",
std::regex_constants::optimize | std::regex_constants::icase }
};
std::regex{
R"(^[-+]?(?:nan|inf|infinity)$)",
std::regex_constants::optimize | std::regex_constants::icase}};
return MatchRegexList(input, re_list);
}
@@ -188,34 +186,46 @@ class FloatRegex : public RegexMatcher {
class ScalarReferenceResult {
private:
ScalarReferenceResult(const char *_type, RegexMatcher::MatchResult _matched)
ScalarReferenceResult(const char* _type, RegexMatcher::MatchResult _matched)
: type(_type), matched(_matched) {}
public:
// Decode scalar type and check if the input string satisfies the scalar type.
static ScalarReferenceResult Check(uint8_t code, const std::string &input) {
static ScalarReferenceResult Check(uint8_t code, const std::string& input) {
switch (code) {
case 0x0: return { "double", FloatRegex().Match(input) };
case 0x1: return { "float", FloatRegex().Match(input) };
case 0x2: return { "int8", IntegerRegex().Match(input) };
case 0x3: return { "int16", IntegerRegex().Match(input) };
case 0x4: return { "int32", IntegerRegex().Match(input) };
case 0x5: return { "int64", IntegerRegex().Match(input) };
case 0x6: return { "uint8", UIntegerRegex().Match(input) };
case 0x7: return { "uint16", UIntegerRegex().Match(input) };
case 0x8: return { "uint32", UIntegerRegex().Match(input) };
case 0x9: return { "uint64", UIntegerRegex().Match(input) };
case 0xA: return { "bool", BooleanRegex().Match(input) };
default: return { "float", FloatRegex().Match(input) };
case 0x0:
return {"double", FloatRegex().Match(input)};
case 0x1:
return {"float", FloatRegex().Match(input)};
case 0x2:
return {"int8", IntegerRegex().Match(input)};
case 0x3:
return {"int16", IntegerRegex().Match(input)};
case 0x4:
return {"int32", IntegerRegex().Match(input)};
case 0x5:
return {"int64", IntegerRegex().Match(input)};
case 0x6:
return {"uint8", UIntegerRegex().Match(input)};
case 0x7:
return {"uint16", UIntegerRegex().Match(input)};
case 0x8:
return {"uint32", UIntegerRegex().Match(input)};
case 0x9:
return {"uint64", UIntegerRegex().Match(input)};
case 0xA:
return {"bool", BooleanRegex().Match(input)};
default:
return {"float", FloatRegex().Match(input)};
};
}
const char *type;
const char* type;
const RegexMatcher::MatchResult matched;
};
bool Parse(flatbuffers::Parser &parser, const std::string &json,
std::string *_text) {
bool Parse(flatbuffers::Parser& parser, const std::string& json,
std::string* _text) {
auto done = parser.ParseJson(json.c_str());
if (done) {
TEST_NULL(GenText(parser, parser.builder_.GetBufferPointer(), _text));
@@ -230,7 +240,7 @@ OneTimeTestInit OneTimeTestInit::one_time_init_;
// llvm std::regex have problem with stack overflow, limit maximum length.
// ./scalar_fuzzer -max_len=3000
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Reserve one byte for Parser flags and one byte for repetition counter.
if (size < 3) return 0;
const uint8_t flags = data[0];
@@ -241,7 +251,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
size -= 2; // bypass
// Guarantee 0-termination.
const std::string original(reinterpret_cast<const char *>(data), size);
const std::string original(reinterpret_cast<const char*>(data), size);
auto input = std::string(original.c_str()); // until '\0'
if (input.size() < kMinInputLength || input.size() > kMaxInputLength)
return 0;
@@ -257,7 +267,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// This key:value ignored by the parser. Numbers can not have $.
BreakSequence(input, "$schema", '@'); // "$schema" -> "@schema"
// Break all known scalar functions (todo: add them to regex?):
for (auto f : { "deg", "rad", "sin", "cos", "tan", "asin", "acos", "atan" }) {
for (auto f : {"deg", "rad", "sin", "cos", "tan", "asin", "acos", "atan"}) {
BreakSequence(input, f, '_'); // ident -> ident
}
@@ -265,7 +275,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// the scalar type.
const auto ref_res =
ScalarReferenceResult::Check(flags & flags_scalar_type, input);
auto &recheck = ref_res.matched;
auto& recheck = ref_res.matched;
// Create parser
flatbuffers::IDLOptions opts;
@@ -338,7 +348,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
orig_done);
TEST_EQ_STR(fix_back.c_str(), orig_back.c_str());
}
if (orig_done) { TEST_EQ_STR(fix_back.c_str(), orig_back.c_str()); }
if (orig_done) {
TEST_EQ_STR(fix_back.c_str(), orig_back.c_str());
}
TEST_EQ_FUNC(fix_done, orig_done);
}
@@ -357,8 +369,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// Compare with print.
std::string ref_string, def_string;
FLATBUFFERS_ASSERT(!GenText(
parser, parser.builder_.GetBufferPointer(), &ref_string));
FLATBUFFERS_ASSERT(
!GenText(parser, parser.builder_.GetBufferPointer(), &ref_string));
FLATBUFFERS_ASSERT(!GenText(
def_parser, def_parser.builder_.GetBufferPointer(), &def_string));
if (ref_string != def_string) {
@@ -369,7 +381,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
// Restore locale.
if (use_locale) { FLATBUFFERS_ASSERT(setlocale(LC_ALL, "C")); }
if (use_locale) {
FLATBUFFERS_ASSERT(setlocale(LC_ALL, "C"));
}
}
return 0;
}

View File

@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <stddef.h>
#include <stdint.h>
#include <string>
#include "cpp17/generated_cpp17/monster_test_generated.h"

View File

@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <stddef.h>
#include <stdint.h>
#include <string>
#include "flatbuffers/flexbuffers.h"
@@ -14,6 +15,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// FIXME: we can't really verify this path, because the fuzzer will
// construct buffers that time out.
// Add a simple #define to bound the number of steps just for the fuzzer?
//flexbuffers::VerifyBuffer(data, size, nullptr);
// flexbuffers::VerifyBuffer(data, size, nullptr);
return 0;
}

View File

@@ -4,11 +4,11 @@
#if defined(_MSC_VER)
extern "C" void __debugbreak();
#define __builtin_trap __debugbreak
#else // Clang
#else // Clang
extern "C" void __builtin_trap(void);
#endif
// Declare Debug/Release independed assert macro.
#define fuzzer_assert_impl(x) (!!(x) ? static_cast<void>(0) : __builtin_trap())
#endif // !FUZZER_ASSERT_IMPL_H_
#endif // !FUZZER_ASSERT_IMPL_H_

View File

@@ -9,9 +9,9 @@
struct OneTimeTestInit {
// Declare trap for the Flatbuffers test engine.
// This hook terminate program both in Debug and Release.
static bool TestFailListener(const char *expval, const char *val,
const char *exp, const char *file, int line,
const char *func = nullptr) {
static bool TestFailListener(const char* expval, const char* val,
const char* exp, const char* file, int line,
const char* func = nullptr) {
(void)expval;
(void)val;
(void)exp;
@@ -39,7 +39,7 @@ struct OneTimeTestInit {
}
}
static const char *test_locale() {
static const char* test_locale() {
return one_time_init_.has_locale_ ? nullptr
: one_time_init_.test_locale_.c_str();
}