Skip to content

Update Absl version and fix some gcc warnings #1605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cmake/BuildDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.19)
include(FetchContent)

set(absl_URL https://github.com/abseil/abseil-cpp.git)
set(absl_TAG 20240116.0)
set(absl_TAG 20250127.1)

set(re2_URL https://github.com/google/re2.git)
set(re2_TAG 2024-02-01)
Expand Down Expand Up @@ -74,7 +74,9 @@ set(RE2_BUILD_TESTING OFF)
FetchContent_MakeAvailable(re2)

set(GTEST_HAS_ABSL ON)
FetchContent_MakeAvailable(googletest)
if( NOT TARGET gtest)
FetchContent_MakeAvailable(googletest)
endif()

FetchContent_MakeAvailable(antlr_cpp)

Expand Down
8 changes: 4 additions & 4 deletions common/blob_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -471,17 +471,17 @@ void UnpackBytesFromAppendFile(
&kPackBegMagic[kMagicLen]);
if (pos == packed_data.end()) return;
pos += kMagicLen;
if (packed_data.end() - pos < kHashLen) return;
if (packed_data.end() - pos < (long int)kHashLen) return;
std::string hash(pos, pos + kHashLen);
pos += kHashLen;
size_t size = 0;
if (packed_data.end() - pos < sizeof(size)) return;
if (packed_data.end() - pos < (long int)sizeof(size)) return;
std::memcpy(&size, &*pos, sizeof(size));
pos += sizeof(size);
if (packed_data.end() - pos < size) return;
if (packed_data.end() - pos < (long int)size) return;
ByteArray ba(pos, pos + size);
pos += size;
if (packed_data.end() - pos < kMagicLen) return;
if (packed_data.end() - pos < (long int)kMagicLen) return;
if (std::memcmp(&*pos, kPackEndMagic, kMagicLen) != 0) continue;
pos += kMagicLen;
if (hash != Hash(ba)) continue;
Expand Down
2 changes: 1 addition & 1 deletion common/remote_file_oss.cc
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ absl::Status RemoteGlobMatch(std::string_view glob,
return absl::UnknownError(absl::StrCat(
"glob() failed, pattern: ", std::string(glob), ", returned: ", ret));
}
for (int i = 0; i < glob_ret.gl_pathc; ++i) {
for (size_t i = 0; i < glob_ret.gl_pathc; ++i) {
matches.emplace_back(glob_ret.gl_pathv[i]);
}
::globfree(&glob_ret);
Expand Down
7 changes: 4 additions & 3 deletions fuzztest/fuzztest_macros.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ absl::StatusOr<std::string> ParseDictionaryEntry(absl::string_view entry) {
// We unescape "\\", "\"", as well as each 2-digit hex codes (e.g. "\xab").
std::string parsed_entry;
int i = 0;
while (i < entry.size()) {
int entry_size = (int)entry.size();
while (i < entry_size) {
if (entry[i] != '\\') { // Handle unescaped character
parsed_entry.push_back(entry[i]);
++i;
} else if (i + 1 < entry.size() &&
} else if (i + 1 < entry_size &&
(entry[i + 1] == '\\' ||
entry[i + 1] == '"')) { // Handle \\ and \"
parsed_entry.push_back(entry[i + 1]);
i += 2;
} else if (i + 3 < entry.size() &&
} else if (i + 3 < entry_sizes &&
entry[i + 1] == 'x') { // Handle \xHH escape sequence
std::string unescaped_hex;
std::string error;
Expand Down
6 changes: 4 additions & 2 deletions fuzztest/internal/coverage.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ class ExecutionCoverage {
}

static char* GetCurrentStackFrame() {
#if defined(__has_builtin) && __has_builtin(__builtin_frame_address)
return reinterpret_cast<char*>(__builtin_frame_address(0));
#if defined __has_builtin
# if __has_builtin(__builtin_frame_address)
return reinterpret_cast<char*>(__builtin_frame_address(0));
# endif
#else
return nullptr;
#endif
Expand Down
4 changes: 2 additions & 2 deletions fuzztest/internal/domains/in_regexp_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ class InRegexpImpl
// state.
bool ShrinkByRemoveLoop(absl::BitGenRef prng, DFAPath& path) {
std::vector<std::vector<int>> state_appearances(dfa_.state_count());
for (int i = 0; i < path.size(); ++i) {
for (int i = 0; i < (int)path.size(); ++i) {
state_appearances[path[i].from_state_id].push_back(i);
}
std::vector<int> states_with_loop;
for (int i = 0; i < dfa_.state_count(); ++i) {
for (int i = 0; i < (int)dfa_.state_count(); ++i) {
if (state_appearances[i].size() > 1) states_with_loop.push_back(i);
}
if (!states_with_loop.empty()) {
Expand Down
18 changes: 9 additions & 9 deletions fuzztest/internal/domains/regexp_dfa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ absl::StatusOr<std::string> RegexpDFA::DFAPathToString(
std::string result;
for (size_t i = start_offset; i < *end_offset; ++i) {
auto& [from_state_id, edge_index] = path[i];
if (from_state_id >= states_.size() ||
edge_index >= states_[from_state_id].next.size()) {
if (from_state_id >= (int)states_.size() ||
edge_index >= (int)states_[from_state_id].next.size()) {
return absl::InvalidArgumentError("Invalid DFA path.");
}
const std::vector<std::int16_t>& chars_to_match =
Expand Down Expand Up @@ -185,7 +185,7 @@ void RegexpDFA::BuildEntireDFA(std::unique_ptr<re2::Prog> compiled_regexp) {
std::vector<int>& transition_vec = transition_table[i];
State& state = states_[i];

for (int j = 0; j < transition_vec.size() - 1; ++j) {
for (int j = 0; j < (int)transition_vec.size() - 1; ++j) {
// If `transition_vec[bytemap_idx] == state_id` at state `s`, it means
// that given a character `c` whose bytemap index is `bytemap_idx`,
// `s` will transition into state with id `state_id`. The bytemap index
Expand Down Expand Up @@ -222,7 +222,7 @@ void RegexpDFA::ComputeEdgeWeights() {
// A graph to record the predecessor states for every state.
std::vector<std::vector<bool>> is_predecessor(
states_.size(), std::vector<bool>(states_.size(), false));
for (int i = 0; i < states_.size(); ++i) {
for (int i = 0; i < (int)states_.size(); ++i) {
for (auto& transition : states_[i].next) {
is_predecessor[transition.next_state_id][i] = true;
}
Expand All @@ -233,18 +233,18 @@ void RegexpDFA::ComputeEdgeWeights() {
std::queue<int> q;
q.push(end_state_id_);
do {
size_t n = q.size();
int n = (int)q.size();
for (int i = 0; i < n; ++i) {
int state_id = q.front();
q.pop();
if (is_safe_node[state_id]) continue;
for (int j = 0; j < states_.size(); ++j) {
for (int j = 0; j < (int)states_.size(); ++j) {
if (is_predecessor[state_id][j]) q.push(j);
}
State& state = states_[state_id];
std::vector<int> edge_to_safe_nodes;
std::vector<int> edge_to_unsafe_nodes;
for (int j = 0; j < state.next.size(); ++j) {
for (int j = 0; j < (int)state.next.size(); ++j) {
if (is_safe_node[state.next[j].next_state_id])
edge_to_safe_nodes.push_back(j);
else
Expand Down Expand Up @@ -285,7 +285,7 @@ void RegexpDFA::CompressStates() {
std::vector<bool> is_dead_state(states_.size(), false);

// Skip the start state as it should never be compressed.
for (size_t i = 1; i < states_.size(); ++i) {
for (int i = 1; i < (int)states_.size(); ++i) {
State& state = states_[i];
if (state.next.size() != 1) continue;
const auto& [chars_to_match, next_state_id] = state.next[0];
Expand All @@ -309,7 +309,7 @@ void RegexpDFA::CompressStates() {
absl::flat_hash_map<int, int> state_id_map;
int live_state_num = 0;

for (int i = 0; i < states_.size(); ++i) {
for (int i = 0; i < (int)states_.size(); ++i) {
if (is_dead_state[i]) continue;
state_id_map[i] = live_state_num;
if (states_[i].is_end_state()) end_state_id_ = live_state_num;
Expand Down
2 changes: 1 addition & 1 deletion fuzztest/internal/domains/regexp_dfa.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class RegexpDFA {
std::vector<Edge> stack{Edge{from_state_id, 0}};
do {
auto [current_state_id, edge_index] = stack.back();
if (edge_index == states_[current_state_id].next.size()) {
if (edge_index == (int)states_[current_state_id].next.size()) {
stack.pop_back();
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion fuzztest/internal/domains/value_mutation_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ template <typename C, typename F>
auto ChooseOneOr(const C& values, absl::BitGenRef prng, F f) {
const int i =
absl::Uniform<int>(absl::IntervalClosedClosed, prng, 0, values.size());
return i < values.size() ? values[i] : f();
return i < (int)values.size() ? values[i] : f();
}

template <typename T>
Expand Down
3 changes: 3 additions & 0 deletions fuzztest/internal/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "absl/numeric/int128.h"

#define UNUSED(expr) do { (void)(expr); } while (0)
namespace google::protobuf {
template <typename T>
struct is_proto_enum;
Expand Down Expand Up @@ -708,6 +709,7 @@ constexpr std::optional<int> DetectBindableFieldCount() {
constexpr auto no_base = [](auto... I) {
return std::is_invocable_v<decltype(no_base_impl), decltype(I)...>;
};
UNUSED(no_base);

if constexpr (brace_init_count < 1) {
return brace_init_count_opt;
Expand All @@ -722,6 +724,7 @@ constexpr std::optional<int> DetectBindableFieldCount() {
constexpr auto no_two_bases = [](auto... I) {
return std::is_invocable_v<decltype(no_two_bases_impl), decltype(I)...>;
};
UNUSED(no_two_bases);

// Check for multiple inheritance. This condition also triggers if we have a
// struct whose first field is its base class. The latter case should be
Expand Down
2 changes: 1 addition & 1 deletion fuzztest/internal/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ bool FuzzTestFuzzerImpl::RunInUnitTestMode(const Configuration& configuration) {
const auto time_limit = stats_.start_time + duration;
Input mutation{params_domain_.Init(prng)};
const size_t max_iterations = duration == absl::ZeroDuration() ? 0 : 10000;
for (int i = 0; i < max_iterations; ++i) {
for (int i = 0; i < (int)max_iterations; ++i) {
runtime_.SetExternalFailureDetected(false);
RunOneInput(mutation);
if (runtime_.external_failure_detected()) {
Expand Down
4 changes: 2 additions & 2 deletions fuzztest/internal/table_of_recent_compares.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ class TableOfRecentCompares {
// Some simple optimization.
if (min == std::numeric_limits<ValueType>::min() &&
max == std::numeric_limits<ValueType>::max()) {
for (int i = 0; i < kTableSize; ++i) {
for (int i = 0; i < (int)kTableSize; ++i) {
auto dict_entry = GetMatchingIntegerDictionaryEntry(val, i);
if (dict_entry.has_value()) {
dictionary_set.insert(std::move(*dict_entry));
}
}
} else {
for (int i = 0; i < kTableSize; ++i) {
for (int i = 0; i < (int)kTableSize; ++i) {
auto dict_entry = GetMatchingIntegerDictionaryEntry(val, i, min, max);
if (dict_entry.has_value()) {
dictionary_set.insert(std::move(*dict_entry));
Expand Down
Loading