@ -51,8 +51,8 @@
# include "google/protobuf/map_entry_lite.h"
# include "absl/container/flat_hash_map.h"
# include "absl/container/flat_hash_set.h"
# include "google/protobuf/stubs/logging .h"
# include "google/protobuf/stubs/loggin g.h"
# include "absl/log/absl_check .h"
# include "absl/log/absl_lo g.h"
# include "absl/strings/ascii.h"
# include "absl/strings/escaping.h"
# include "absl/strings/str_cat.h"
@ -104,7 +104,7 @@ std::string ConditionalToCheckBitmasks(
parts . push_back (
absl : : StrCat ( " (( " , has_bits_var , " [ " , i , " ] & " , m , " ) ^ " , m , " ) " ) ) ;
}
GOOGLE_ ABSL_CHECK( ! parts . empty ( ) ) ;
ABSL_CHECK ( ! parts . empty ( ) ) ;
// If we have multiple parts, each expected to be 0, then bitwise-or them.
std : : string result =
parts . size ( ) = = 1
@ -208,7 +208,7 @@ RunMap FindRuns(const std::vector<const FieldDescriptor*>& fields,
// !HasHasbit(field).
bool EmitFieldNonDefaultCondition ( io : : Printer * p , const std : : string & prefix ,
const FieldDescriptor * field ) {
GOOGLE_ ABSL_CHECK( ! HasHasbit ( field ) ) ;
ABSL_CHECK ( ! HasHasbit ( field ) ) ;
Formatter format ( p ) ;
auto v = p - > WithVars ( { {
{ " prefix " , prefix } ,
@ -273,7 +273,7 @@ bool HasInternalHasMethod(const FieldDescriptor* field) {
void CollectMapInfo (
const Options & options , const Descriptor * descriptor ,
absl : : flat_hash_map < absl : : string_view , std : : string > * variables ) {
GOOGLE_ ABSL_CHECK( IsMapEntryMessage ( descriptor ) ) ;
ABSL_CHECK ( IsMapEntryMessage ( descriptor ) ) ;
absl : : flat_hash_map < absl : : string_view , std : : string > & vars = * variables ;
const FieldDescriptor * key = descriptor - > map_key ( ) ;
const FieldDescriptor * val = descriptor - > map_value ( ) ;
@ -359,16 +359,16 @@ std::vector<std::vector<const FieldDescriptor*>> CollectFields(
// masked to tell if any thing in "fields" is present.
uint32_t GenChunkMask ( const std : : vector < const FieldDescriptor * > & fields ,
const std : : vector < int > & has_bit_indices ) {
GOOGLE_ ABSL_CHECK( ! fields . empty ( ) ) ;
ABSL_CHECK ( ! fields . empty ( ) ) ;
int first_index_offset = has_bit_indices [ fields . front ( ) - > index ( ) ] / 32 ;
uint32_t chunk_mask = 0 ;
for ( auto field : fields ) {
// "index" defines where in the _has_bits_ the field appears.
int index = has_bit_indices [ field - > index ( ) ] ;
GOOGLE_ ABSL_CHECK_EQ( first_index_offset , index / 32 ) ;
ABSL_CHECK_EQ ( first_index_offset , index / 32 ) ;
chunk_mask | = static_cast < uint32_t > ( 1 ) < < ( index % 32 ) ;
}
GOOGLE_ ABSL_CHECK_NE( 0 , chunk_mask ) ;
ABSL_CHECK_NE ( 0 , chunk_mask ) ;
return chunk_mask ;
}
@ -465,7 +465,7 @@ void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index,
for ( auto field : chunks_ [ chunk ] ) {
int hasbit_index = has_bit_indices_ [ field - > index ( ) ] ;
// Fields on a chunk must be in the same word.
GOOGLE_ ABSL_CHECK_EQ( this_word , hasbit_index / 32 ) ;
ABSL_CHECK_EQ ( this_word , hasbit_index / 32 ) ;
mask | = 1 < < ( hasbit_index % 32 ) ;
}
}
@ -970,7 +970,7 @@ void MessageGenerator::GenerateSingularFieldHasBits(
}
if ( HasHasbit ( field ) ) {
int has_bit_index = HasBitIndex ( field ) ;
GOOGLE_ ABSL_CHECK_NE( has_bit_index , kNoHasbit ) ;
ABSL_CHECK_NE ( has_bit_index , kNoHasbit ) ;
auto v = p - > WithVars ( HasbitVars ( has_bit_index ) ) ;
format (
@ -1187,7 +1187,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
" } \n " ,
descriptor_ - > field ( 0 ) - > full_name ( ) ) ;
} else {
GOOGLE_ ABSL_CHECK( utf8_check = = Utf8CheckMode : : kVerify ) ;
ABSL_CHECK ( utf8_check = = Utf8CheckMode : : kVerify ) ;
format (
" static bool ValidateKey(std::string* s) { \n "
" #ifndef NDEBUG \n "
@ -1216,7 +1216,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
" } \n " ,
descriptor_ - > field ( 1 ) - > full_name ( ) ) ;
} else {
GOOGLE_ ABSL_CHECK( utf8_check = = Utf8CheckMode : : kVerify ) ;
ABSL_CHECK ( utf8_check = = Utf8CheckMode : : kVerify ) ;
format (
" static bool ValidateValue(std::string* s) { \n "
" #ifndef NDEBUG \n "
@ -1836,7 +1836,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
format . Outdent ( ) ;
format ( " }; " ) ;
GOOGLE_ ABSL_DCHECK( ! need_to_emit_cached_size ) ;
ABSL_DCHECK ( ! need_to_emit_cached_size ) ;
} // NOLINT(readability/fn_size)
void MessageGenerator : : GenerateInlineMethods ( io : : Printer * p ) {
@ -1875,8 +1875,8 @@ void MessageGenerator::GenerateSchema(io::Printer* p, int offset,
if ( inlined_string_indices_ . empty ( ) ) {
inlined_string_indices_offset = - 1 ;
} else {
GOOGLE_ ABSL_DCHECK_NE( has_offset , - 1 ) ;
GOOGLE_ ABSL_DCHECK( ! IsMapEntryMessage ( descriptor_ ) ) ;
ABSL_DCHECK_NE ( has_offset , - 1 ) ;
ABSL_DCHECK ( ! IsMapEntryMessage ( descriptor_ ) ) ;
inlined_string_indices_offset = has_offset + has_bit_indices_ . size ( ) ;
}
format ( " { $1$, $2$, $3$, sizeof($classtype$)}, \n " , offset , has_offset ,
@ -1959,7 +1959,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* p) {
field_generators_ . get ( field ) . GenerateInternalAccessorDeclarations ( p ) ;
if ( HasHasbit ( field ) ) {
int has_bit_index = HasBitIndex ( field ) ;
GOOGLE_ ABSL_CHECK_NE( has_bit_index , kNoHasbit ) < < field - > full_name ( ) ;
ABSL_CHECK_NE ( has_bit_index , kNoHasbit ) < < field - > full_name ( ) ;
format (
" static void set_has_$1$(HasBits* has_bits) { \n "
" (*has_bits)[$2$] |= $3$u; \n "
@ -2172,7 +2172,7 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(io::Printer* p) {
format ( " PROTOBUF_FIELD_OFFSET($classtype$, _impl_.$1$_), \n " , oneof - > name ( ) ) ;
count + + ;
}
GOOGLE_ ABSL_CHECK_EQ( count , descriptor_ - > real_oneof_decl_count ( ) ) ;
ABSL_CHECK_EQ ( count , descriptor_ - > real_oneof_decl_count ( ) ) ;
if ( IsMapEntryMessage ( descriptor_ ) ) {
entries + = 2 ;
@ -2415,7 +2415,7 @@ ArenaDtorNeeds MessageGenerator::NeedsArenaDestructor() const {
}
void MessageGenerator : : GenerateArenaDestructorCode ( io : : Printer * p ) {
GOOGLE_ ABSL_CHECK( NeedsArenaDestructor ( ) > ArenaDtorNeeds : : kNone ) ;
ABSL_CHECK ( NeedsArenaDestructor ( ) > ArenaDtorNeeds : : kNone ) ;
Formatter format ( p ) ;
@ -2922,7 +2922,7 @@ void MessageGenerator::GenerateClear(io::Printer* p) {
bool chunk_is_split =
! chunk . empty ( ) & & ShouldSplit ( chunk . front ( ) , options_ ) ;
// All chunks after the first split chunk should also be split.
GOOGLE_ ABSL_CHECK( ! first_split_chunk_processed | | chunk_is_split ) ;
ABSL_CHECK ( ! first_split_chunk_processed | | chunk_is_split ) ;
if ( chunk_is_split & & ! first_split_chunk_processed ) {
// Some fields are cleared without checking has_bit. So we add the
// condition here to avoid writing to the default split instance.
@ -2933,7 +2933,7 @@ void MessageGenerator::GenerateClear(io::Printer* p) {
for ( const auto & field : chunk ) {
if ( CanClearByZeroing ( field ) ) {
GOOGLE_ ABSL_CHECK( ! saw_non_zero_init ) ;
ABSL_CHECK ( ! saw_non_zero_init ) ;
if ( ! memset_start ) memset_start = field ;
memset_end = field ;
} else {
@ -2959,8 +2959,8 @@ void MessageGenerator::GenerateClear(io::Printer* p) {
// Check (up to) 8 has_bits at a time if we have more than one field in
// this chunk. Due to field layout ordering, we may check
// _has_bits_[last_chunk * 8 / 32] multiple times.
GOOGLE_ ABSL_DCHECK_LE( 2 , popcnt ( chunk_mask ) ) ;
GOOGLE_ ABSL_DCHECK_GE( 8 , popcnt ( chunk_mask ) ) ;
ABSL_DCHECK_LE ( 2 , popcnt ( chunk_mask ) ) ;
ABSL_DCHECK_GE ( 8 , popcnt ( chunk_mask ) ) ;
if ( cached_has_word_index ! = HasWordIndex ( chunk . front ( ) ) ) {
cached_has_word_index = HasWordIndex ( chunk . front ( ) ) ;
@ -2975,8 +2975,8 @@ void MessageGenerator::GenerateClear(io::Printer* p) {
// For clarity, do not memset a single field.
field_generators_ . get ( memset_start ) . GenerateMessageClearingCode ( p ) ;
} else {
GOOGLE_ ABSL_CHECK_EQ( chunk_is_split , ShouldSplit ( memset_start , options_ ) ) ;
GOOGLE_ ABSL_CHECK_EQ( chunk_is_split , ShouldSplit ( memset_end , options_ ) ) ;
ABSL_CHECK_EQ ( chunk_is_split , ShouldSplit ( memset_start , options_ ) ) ;
ABSL_CHECK_EQ ( chunk_is_split , ShouldSplit ( memset_end , options_ ) ) ;
format (
" ::memset(&$1$, 0, static_cast<::size_t>( \n "
" reinterpret_cast<char*>(&$2$) - \n "
@ -3249,7 +3249,7 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* p) {
void MessageGenerator : : GenerateClassSpecificMergeImpl ( io : : Printer * p ) {
if ( HasSimpleBaseClass ( descriptor_ , options_ ) ) return ;
// Generate the class-specific MergeFrom, which avoids the GOOGLE_ ABSL_CHECK and
// Generate the class-specific MergeFrom, which avoids the ABSL_CHECK and
// cast.
Formatter format ( p ) ;
if ( ! HasDescriptorMethods ( descriptor_ - > file ( ) , options_ ) ) {
@ -3313,8 +3313,8 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) {
// Check (up to) 8 has_bits at a time if we have more than one field in
// this chunk. Due to field layout ordering, we may check
// _has_bits_[last_chunk * 8 / 32] multiple times.
GOOGLE_ ABSL_DCHECK_LE( 2 , popcnt ( chunk_mask ) ) ;
GOOGLE_ ABSL_DCHECK_GE( 8 , popcnt ( chunk_mask ) ) ;
ABSL_DCHECK_LE ( 2 , popcnt ( chunk_mask ) ) ;
ABSL_DCHECK_GE ( 8 , popcnt ( chunk_mask ) ) ;
if ( cached_has_word_index ! = HasWordIndex ( chunk . front ( ) ) ) {
cached_has_word_index = HasWordIndex ( chunk . front ( ) ) ;
@ -3346,7 +3346,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) {
} else if ( field - > options ( ) . weak ( ) | |
cached_has_word_index ! = HasWordIndex ( field ) ) {
// Check hasbit, not using cached bits.
GOOGLE_ ABSL_CHECK( HasHasbit ( field ) ) ;
ABSL_CHECK ( HasHasbit ( field ) ) ;
auto v = p - > WithVars ( HasbitVars ( HasBitIndex ( field ) ) ) ;
format (
" if ((from.$has_bits$[$has_array_index$] & $has_mask$) != 0) { \n " ) ;
@ -3356,7 +3356,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) {
format ( " } \n " ) ;
} else {
// Check hasbit, using cached bits.
GOOGLE_ ABSL_CHECK( HasHasbit ( field ) ) ;
ABSL_CHECK ( HasHasbit ( field ) ) ;
int has_bit_index = has_bit_indices_ [ field - > index ( ) ] ;
const std : : string mask = absl : : StrCat (
absl : : Hex ( 1u < < ( has_bit_index % 32 ) , absl : : kZeroPad8 ) ) ;
@ -3380,7 +3380,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) {
if ( have_outer_if ) {
if ( deferred_has_bit_changes ) {
// Flush the has bits for the primitives we deferred.
GOOGLE_ ABSL_CHECK_LE( 0 , cached_has_word_index ) ;
ABSL_CHECK_LE ( 0 , cached_has_word_index ) ;
format ( " _this->$has_bits$[$1$] |= cached_has_bits; \n " ,
cached_has_word_index ) ;
}
@ -3506,7 +3506,7 @@ void MessageGenerator::GenerateVerify(io::Printer* p) {
void MessageGenerator : : GenerateSerializeOneofFields (
io : : Printer * p , const std : : vector < const FieldDescriptor * > & fields ) {
Formatter format ( p ) ;
GOOGLE_ ABSL_CHECK( ! fields . empty ( ) ) ;
ABSL_CHECK ( ! fields . empty ( ) ) ;
if ( fields . size ( ) = = 1 ) {
GenerateSerializeOneField ( p , fields [ 0 ] , - 1 ) ;
return ;
@ -3865,7 +3865,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled(
int num_fields = ordered_fields . size ( ) + sorted_extensions . size ( ) ;
constexpr int kLargePrime = 1000003 ;
GOOGLE_ ABSL_CHECK_LT( num_fields , kLargePrime )
ABSL_CHECK_LT ( num_fields , kLargePrime )
< < " Prime offset must be greater than the number of fields to ensure "
" those are coprime. " ;
@ -4082,8 +4082,8 @@ void MessageGenerator::GenerateByteSize(io::Printer* p) {
// Check (up to) 8 has_bits at a time if we have more than one field in
// this chunk. Due to field layout ordering, we may check
// _has_bits_[last_chunk * 8 / 32] multiple times.
GOOGLE_ ABSL_DCHECK_LE( 2 , popcnt ( chunk_mask ) ) ;
GOOGLE_ ABSL_DCHECK_GE( 8 , popcnt ( chunk_mask ) ) ;
ABSL_DCHECK_LE ( 2 , popcnt ( chunk_mask ) ) ;
ABSL_DCHECK_GE ( 8 , popcnt ( chunk_mask ) ) ;
if ( cached_has_word_index ! = HasWordIndex ( chunk . front ( ) ) ) {
cached_has_word_index = HasWordIndex ( chunk . front ( ) ) ;