Commit 9c0b35cf authored by Bo Yang's avatar Bo Yang

Enusre public header and generated code have no implicit converion.

parent f752d816
...@@ -924,7 +924,7 @@ no_warning_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \ ...@@ -924,7 +924,7 @@ no_warning_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \
../gmock/gtest/lib/libgtest_main.la ../gmock/gtest/lib/libgtest_main.la
no_warning_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include no_warning_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include
no_warning_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) \ no_warning_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) \
-Wall -Werror -Wall -Wconversion -Werror
nodist_no_warning_test_SOURCES = no_warning_test.cc $(protoc_outputs) nodist_no_warning_test_SOURCES = no_warning_test.cc $(protoc_outputs)
TESTS = protobuf-test protobuf-lazy-descriptor-test protobuf-lite-test \ TESTS = protobuf-test protobuf-lazy-descriptor-test protobuf-lite-test \
......
...@@ -240,7 +240,7 @@ bool Any::MergePartialFromCodedStream( ...@@ -240,7 +240,7 @@ bool Any::MergePartialFromCodedStream(
DO_(::google::protobuf::internal::WireFormatLite::ReadString( DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_type_url())); input, this->mutable_type_url()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->type_url().data(), this->type_url().length(), this->type_url().data(), static_cast<int>(this->type_url().length()),
::google::protobuf::internal::WireFormatLite::PARSE, ::google::protobuf::internal::WireFormatLite::PARSE,
"google.protobuf.Any.type_url")); "google.protobuf.Any.type_url"));
} else { } else {
...@@ -291,7 +291,7 @@ void Any::SerializeWithCachedSizes( ...@@ -291,7 +291,7 @@ void Any::SerializeWithCachedSizes(
// string type_url = 1; // string type_url = 1;
if (this->type_url().size() > 0) { if (this->type_url().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->type_url().data(), this->type_url().length(), this->type_url().data(), static_cast<int>(this->type_url().length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Any.type_url"); "google.protobuf.Any.type_url");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
...@@ -316,7 +316,7 @@ void Any::SerializeWithCachedSizes( ...@@ -316,7 +316,7 @@ void Any::SerializeWithCachedSizes(
// string type_url = 1; // string type_url = 1;
if (this->type_url().size() > 0) { if (this->type_url().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->type_url().data(), this->type_url().length(), this->type_url().data(), static_cast<int>(this->type_url().length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Any.type_url"); "google.protobuf.Any.type_url");
target = target =
......
This diff is collapsed.
...@@ -488,7 +488,8 @@ GenerateByteSize(io::Printer* printer) const { ...@@ -488,7 +488,8 @@ GenerateByteSize(io::Printer* printer) const {
printer->Print(variables_, printer->Print(variables_,
"if (data_size > 0) {\n" "if (data_size > 0) {\n"
" total_size += $tag_size$ +\n" " total_size += $tag_size$ +\n"
" ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n" " ::google::protobuf::internal::WireFormatLite::Int32Size(\n"
" static_cast<google::protobuf::int32>(data_size));\n"
"}\n" "}\n"
"int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n" "int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n"
"GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n"
......
...@@ -256,7 +256,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { ...@@ -256,7 +256,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
} else { } else {
printer->Print(variables_, printer->Print(variables_,
" unknown_fields_stream.WriteVarint32($tag$u);\n" " unknown_fields_stream.WriteVarint32($tag$u);\n"
" unknown_fields_stream.WriteVarint32(data.size());\n" " unknown_fields_stream.WriteVarint32(\n"
" static_cast<google::protobuf::uint32>(data.size()));\n"
" unknown_fields_stream.WriteString(data);\n"); " unknown_fields_stream.WriteString(data);\n");
} }
...@@ -267,12 +268,16 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { ...@@ -267,12 +268,16 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
if (key_field->type() == FieldDescriptor::TYPE_STRING) { if (key_field->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString( GenerateUtf8CheckCodeForString(
key_field, options_, true, variables_, key_field, options_, true, variables_,
StrCat(key, ".data(), ", key, ".length(),\n").data(), printer); StrCat(key, ".data(), static_cast<int>(", key, ".length()),\n").data(),
printer);
} }
if (value_field->type() == FieldDescriptor::TYPE_STRING) { if (value_field->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString(value_field, options_, true, variables_, GenerateUtf8CheckCodeForString(
StrCat(value, ".data(), ", value, ".length(),\n").data(), printer); value_field, options_, true, variables_,
StrCat(value, ".data(), static_cast<int>(", value, ".length()),\n")
.data(),
printer);
} }
// If entry is allocated by arena, its desctructor should be avoided. // If entry is allocated by arena, its desctructor should be avoided.
...@@ -376,14 +381,14 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizes( ...@@ -376,14 +381,14 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizes(
printer->Indent(); printer->Indent();
printer->Indent(); printer->Indent();
if (string_key) { if (string_key) {
GenerateUtf8CheckCodeForString(key_field, options_, false, variables, GenerateUtf8CheckCodeForString(
"p->first.data(), p->first.length(),\n", key_field, options_, false, variables,
printer); "p->first.data(), static_cast<int>(p->first.length()),\n", printer);
} }
if (string_value) { if (string_value) {
GenerateUtf8CheckCodeForString(value_field, options_, false, variables, GenerateUtf8CheckCodeForString(
"p->second.data(), p->second.length(),\n", value_field, options_, false, variables,
printer); "p->second.data(), static_cast<int>(p->second.length()),\n", printer);
} }
printer->Outdent(); printer->Outdent();
printer->Outdent(); printer->Outdent();
......
...@@ -452,7 +452,8 @@ GenerateByteSize(io::Printer* printer) const { ...@@ -452,7 +452,8 @@ GenerateByteSize(io::Printer* printer) const {
printer->Print(variables_, printer->Print(variables_,
"if (data_size > 0) {\n" "if (data_size > 0) {\n"
" total_size += $tag_size$ +\n" " total_size += $tag_size$ +\n"
" ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n" " ::google::protobuf::internal::WireFormatLite::Int32Size(\n"
" static_cast<google::protobuf::int32>(data_size));\n"
"}\n" "}\n"
"int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n" "int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);\n"
"GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n" "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n"
......
...@@ -477,7 +477,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { ...@@ -477,7 +477,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString( GenerateUtf8CheckCodeForString(
descriptor_, options_, true, variables_, descriptor_, options_, true, variables_,
"this->$name$().data(), this->$name$().length(),\n", printer); "this->$name$().data(), static_cast<int>(this->$name$().length()),\n",
printer);
} }
} }
...@@ -486,7 +487,8 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { ...@@ -486,7 +487,8 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString( GenerateUtf8CheckCodeForString(
descriptor_, options_, false, variables_, descriptor_, options_, false, variables_,
"this->$name$().data(), this->$name$().length(),\n", printer); "this->$name$().data(), static_cast<int>(this->$name$().length()),\n",
printer);
} }
printer->Print(variables_, printer->Print(variables_,
"::google::protobuf::internal::WireFormatLite::Write$declared_type$MaybeAliased(\n" "::google::protobuf::internal::WireFormatLite::Write$declared_type$MaybeAliased(\n"
...@@ -498,7 +500,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { ...@@ -498,7 +500,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString( GenerateUtf8CheckCodeForString(
descriptor_, options_, false, variables_, descriptor_, options_, false, variables_,
"this->$name$().data(), this->$name$().length(),\n", printer); "this->$name$().data(), static_cast<int>(this->$name$().length()),\n",
printer);
} }
printer->Print(variables_, printer->Print(variables_,
"target =\n" "target =\n"
...@@ -797,7 +800,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { ...@@ -797,7 +800,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString( GenerateUtf8CheckCodeForString(
descriptor_, options_, true, variables_, descriptor_, options_, true, variables_,
"this->$name$().data(), this->$name$().length(),\n", printer); "this->$name$().data(), static_cast<int>(this->$name$().length()),\n",
printer);
} }
} }
...@@ -969,7 +973,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { ...@@ -969,7 +973,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
GenerateUtf8CheckCodeForString( GenerateUtf8CheckCodeForString(
descriptor_, options_, true, variables_, descriptor_, options_, true, variables_,
"this->$name$(this->$name$_size() - 1).data(),\n" "this->$name$(this->$name$_size() - 1).data(),\n"
"this->$name$(this->$name$_size() - 1).length(),\n", "static_cast<int>(this->$name$(this->$name$_size() - 1).length()),\n",
printer); printer);
} }
} }
...@@ -982,7 +986,8 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { ...@@ -982,7 +986,8 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString( GenerateUtf8CheckCodeForString(
descriptor_, options_, false, variables_, descriptor_, options_, false, variables_,
"this->$name$(i).data(), this->$name$(i).length(),\n", printer); "this->$name$(i).data(), static_cast<int>(this->$name$(i).length()),\n",
printer);
} }
printer->Outdent(); printer->Outdent();
printer->Print(variables_, printer->Print(variables_,
...@@ -999,7 +1004,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { ...@@ -999,7 +1004,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString( GenerateUtf8CheckCodeForString(
descriptor_, options_, false, variables_, descriptor_, options_, false, variables_,
"this->$name$(i).data(), this->$name$(i).length(),\n", printer); "this->$name$(i).data(), static_cast<int>(this->$name$(i).length()),\n",
printer);
} }
printer->Outdent(); printer->Outdent();
printer->Print(variables_, printer->Print(variables_,
......
This diff is collapsed.
...@@ -280,7 +280,7 @@ bool FieldAccessInfo::MergePartialFromCodedStream( ...@@ -280,7 +280,7 @@ bool FieldAccessInfo::MergePartialFromCodedStream(
DO_(::google::protobuf::internal::WireFormatLite::ReadString( DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name())); input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(), this->name().data(), static_cast<int>(this->name().length()),
::google::protobuf::internal::WireFormat::PARSE, ::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.compiler.FieldAccessInfo.name"); "google.protobuf.compiler.FieldAccessInfo.name");
} else { } else {
...@@ -363,7 +363,7 @@ void FieldAccessInfo::SerializeWithCachedSizes( ...@@ -363,7 +363,7 @@ void FieldAccessInfo::SerializeWithCachedSizes(
// optional string name = 1; // optional string name = 1;
if (cached_has_bits & 0x00000001u) { if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(), this->name().data(), static_cast<int>(this->name().length()),
::google::protobuf::internal::WireFormat::SERIALIZE, ::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.compiler.FieldAccessInfo.name"); "google.protobuf.compiler.FieldAccessInfo.name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
...@@ -402,7 +402,7 @@ void FieldAccessInfo::SerializeWithCachedSizes( ...@@ -402,7 +402,7 @@ void FieldAccessInfo::SerializeWithCachedSizes(
// optional string name = 1; // optional string name = 1;
if (cached_has_bits & 0x00000001u) { if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(), this->name().data(), static_cast<int>(this->name().length()),
::google::protobuf::internal::WireFormat::SERIALIZE, ::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.compiler.FieldAccessInfo.name"); "google.protobuf.compiler.FieldAccessInfo.name");
target = target =
...@@ -795,7 +795,7 @@ bool MessageAccessInfo::MergePartialFromCodedStream( ...@@ -795,7 +795,7 @@ bool MessageAccessInfo::MergePartialFromCodedStream(
DO_(::google::protobuf::internal::WireFormatLite::ReadString( DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_name())); input, this->mutable_name()));
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(), this->name().data(), static_cast<int>(this->name().length()),
::google::protobuf::internal::WireFormat::PARSE, ::google::protobuf::internal::WireFormat::PARSE,
"google.protobuf.compiler.MessageAccessInfo.name"); "google.protobuf.compiler.MessageAccessInfo.name");
} else { } else {
...@@ -862,7 +862,7 @@ void MessageAccessInfo::SerializeWithCachedSizes( ...@@ -862,7 +862,7 @@ void MessageAccessInfo::SerializeWithCachedSizes(
// optional string name = 1; // optional string name = 1;
if (cached_has_bits & 0x00000001u) { if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(), this->name().data(), static_cast<int>(this->name().length()),
::google::protobuf::internal::WireFormat::SERIALIZE, ::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.compiler.MessageAccessInfo.name"); "google.protobuf.compiler.MessageAccessInfo.name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
...@@ -897,7 +897,7 @@ void MessageAccessInfo::SerializeWithCachedSizes( ...@@ -897,7 +897,7 @@ void MessageAccessInfo::SerializeWithCachedSizes(
// optional string name = 1; // optional string name = 1;
if (cached_has_bits & 0x00000001u) { if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(), this->name().data(), static_cast<int>(this->name().length()),
::google::protobuf::internal::WireFormat::SERIALIZE, ::google::protobuf::internal::WireFormat::SERIALIZE,
"google.protobuf.compiler.MessageAccessInfo.name"); "google.protobuf.compiler.MessageAccessInfo.name");
target = target =
......
This diff is collapsed.
...@@ -213,7 +213,7 @@ bool FieldMask::MergePartialFromCodedStream( ...@@ -213,7 +213,7 @@ bool FieldMask::MergePartialFromCodedStream(
input, this->add_paths())); input, this->add_paths()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->paths(this->paths_size() - 1).data(), this->paths(this->paths_size() - 1).data(),
this->paths(this->paths_size() - 1).length(), static_cast<int>(this->paths(this->paths_size() - 1).length()),
::google::protobuf::internal::WireFormatLite::PARSE, ::google::protobuf::internal::WireFormatLite::PARSE,
"google.protobuf.FieldMask.paths")); "google.protobuf.FieldMask.paths"));
} else { } else {
...@@ -252,7 +252,7 @@ void FieldMask::SerializeWithCachedSizes( ...@@ -252,7 +252,7 @@ void FieldMask::SerializeWithCachedSizes(
// repeated string paths = 1; // repeated string paths = 1;
for (int i = 0, n = this->paths_size(); i < n; i++) { for (int i = 0, n = this->paths_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->paths(i).data(), this->paths(i).length(), this->paths(i).data(), static_cast<int>(this->paths(i).length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.FieldMask.paths"); "google.protobuf.FieldMask.paths");
::google::protobuf::internal::WireFormatLite::WriteString( ::google::protobuf::internal::WireFormatLite::WriteString(
...@@ -271,7 +271,7 @@ void FieldMask::SerializeWithCachedSizes( ...@@ -271,7 +271,7 @@ void FieldMask::SerializeWithCachedSizes(
// repeated string paths = 1; // repeated string paths = 1;
for (int i = 0, n = this->paths_size(); i < n; i++) { for (int i = 0, n = this->paths_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->paths(i).data(), this->paths(i).length(), this->paths(i).data(), static_cast<int>(this->paths(i).length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.FieldMask.paths"); "google.protobuf.FieldMask.paths");
target = ::google::protobuf::internal::WireFormatLite:: target = ::google::protobuf::internal::WireFormatLite::
......
...@@ -150,7 +150,8 @@ struct ReflectionSchema { ...@@ -150,7 +150,8 @@ struct ReflectionSchema {
} }
uint32 GetOneofCaseOffset(const OneofDescriptor* oneof_descriptor) const { uint32 GetOneofCaseOffset(const OneofDescriptor* oneof_descriptor) const {
return oneof_case_offset_ + (oneof_descriptor->index() * sizeof(uint32)); return oneof_case_offset_ +
static_cast<uint32>(oneof_descriptor->index() * sizeof(uint32));
} }
bool HasHasbits() const { return has_bits_offset_ != -1; } bool HasHasbits() const { return has_bits_offset_ != -1; }
......
...@@ -250,11 +250,11 @@ class MapEntryImpl : public Base { ...@@ -250,11 +250,11 @@ class MapEntryImpl : public Base {
int GetCachedSize() const { int GetCachedSize() const {
int size = 0; int size = 0;
size += has_key() size += has_key()
? kTagSize + KeyTypeHandler::GetCachedSize(key()) ? static_cast<int>(kTagSize + KeyTypeHandler::GetCachedSize(key()))
: 0; : 0;
size += has_value() size += has_value()
? kTagSize + ValueTypeHandler::GetCachedSize( ? static_cast<int>(kTagSize + ValueTypeHandler::GetCachedSize(
value()) value()))
: 0; : 0;
return size; return size;
} }
......
...@@ -168,7 +168,7 @@ template <typename Derived, typename Key, typename T, ...@@ -168,7 +168,7 @@ template <typename Derived, typename Key, typename T,
int MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, int MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
default_enum_value>::size() const { default_enum_value>::size() const {
MapFieldBase::SyncMapWithRepeatedField(); MapFieldBase::SyncMapWithRepeatedField();
return impl_.GetMap().size(); return static_cast<int>(impl_.GetMap().size());
} }
template <typename Derived, typename Key, typename T, template <typename Derived, typename Key, typename T,
......
...@@ -60,7 +60,7 @@ class MapFieldLite { ...@@ -60,7 +60,7 @@ class MapFieldLite {
Map<Key, T>* MutableMap() { return &map_; } Map<Key, T>* MutableMap() { return &map_; }
// Convenient methods for generated message implementation. // Convenient methods for generated message implementation.
int size() const { return map_.size(); } int size() const { return static_cast<int>(map_.size()); }
void Clear() { return map_.clear(); } void Clear() { return map_.clear(); }
void MergeFrom(const MapFieldLite& other) { void MergeFrom(const MapFieldLite& other) {
for (typename Map<Key, T>::const_iterator it = other.map_.begin(); for (typename Map<Key, T>::const_iterator it = other.map_.begin();
......
...@@ -284,7 +284,7 @@ MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::ByteSize( ...@@ -284,7 +284,7 @@ MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::ByteSize(
template <typename Type> \ template <typename Type> \
inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::ByteSize( \ inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::ByteSize( \
const MapEntryAccessorType& value) { \ const MapEntryAccessorType& value) { \
return WireFormatLite::DeclaredType##Size(value); \ return static_cast<int>(WireFormatLite::DeclaredType##Size(value)); \
} }
GOOGLE_PROTOBUF_BYTE_SIZE(STRING, String) GOOGLE_PROTOBUF_BYTE_SIZE(STRING, String)
...@@ -320,7 +320,8 @@ template <typename Type> ...@@ -320,7 +320,8 @@ template <typename Type>
inline int inline int
MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::GetCachedSize( MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::GetCachedSize(
const MapEntryAccessorType& value) { const MapEntryAccessorType& value) {
return WireFormatLite::LengthDelimitedSize(value.GetCachedSize()); return static_cast<int>(
WireFormatLite::LengthDelimitedSize(value.GetCachedSize()));
} }
#define GET_CACHED_SIZE(FieldType, DeclaredType) \ #define GET_CACHED_SIZE(FieldType, DeclaredType) \
...@@ -328,7 +329,7 @@ MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::GetCachedSize( ...@@ -328,7 +329,7 @@ MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::GetCachedSize(
inline int \ inline int \
MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::GetCachedSize( \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::GetCachedSize( \
const MapEntryAccessorType& value) { \ const MapEntryAccessorType& value) { \
return WireFormatLite::DeclaredType##Size(value); \ return static_cast<int>(WireFormatLite::DeclaredType##Size(value)); \
} }
GET_CACHED_SIZE(STRING, String) GET_CACHED_SIZE(STRING, String)
......
...@@ -218,7 +218,7 @@ bool SourceContext::MergePartialFromCodedStream( ...@@ -218,7 +218,7 @@ bool SourceContext::MergePartialFromCodedStream(
DO_(::google::protobuf::internal::WireFormatLite::ReadString( DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_file_name())); input, this->mutable_file_name()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->file_name().data(), this->file_name().length(), this->file_name().data(), static_cast<int>(this->file_name().length()),
::google::protobuf::internal::WireFormatLite::PARSE, ::google::protobuf::internal::WireFormatLite::PARSE,
"google.protobuf.SourceContext.file_name")); "google.protobuf.SourceContext.file_name"));
} else { } else {
...@@ -257,7 +257,7 @@ void SourceContext::SerializeWithCachedSizes( ...@@ -257,7 +257,7 @@ void SourceContext::SerializeWithCachedSizes(
// string file_name = 1; // string file_name = 1;
if (this->file_name().size() > 0) { if (this->file_name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->file_name().data(), this->file_name().length(), this->file_name().data(), static_cast<int>(this->file_name().length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.SourceContext.file_name"); "google.protobuf.SourceContext.file_name");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
...@@ -276,7 +276,7 @@ void SourceContext::SerializeWithCachedSizes( ...@@ -276,7 +276,7 @@ void SourceContext::SerializeWithCachedSizes(
// string file_name = 1; // string file_name = 1;
if (this->file_name().size() > 0) { if (this->file_name().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->file_name().data(), this->file_name().length(), this->file_name().data(), static_cast<int>(this->file_name().length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.SourceContext.file_name"); "google.protobuf.SourceContext.file_name");
target = target =
......
...@@ -340,7 +340,7 @@ bool Struct::MergePartialFromCodedStream( ...@@ -340,7 +340,7 @@ bool Struct::MergePartialFromCodedStream(
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, &parser)); input, &parser));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
parser.key().data(), parser.key().length(), parser.key().data(), static_cast<int>(parser.key().length()),
::google::protobuf::internal::WireFormatLite::PARSE, ::google::protobuf::internal::WireFormatLite::PARSE,
"google.protobuf.Struct.FieldsEntry.key")); "google.protobuf.Struct.FieldsEntry.key"));
} else { } else {
...@@ -385,7 +385,7 @@ void Struct::SerializeWithCachedSizes( ...@@ -385,7 +385,7 @@ void Struct::SerializeWithCachedSizes(
struct Utf8Check { struct Utf8Check {
static void Check(ConstPtr p) { static void Check(ConstPtr p) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
p->first.data(), p->first.length(), p->first.data(), static_cast<int>(p->first.length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Struct.FieldsEntry.key"); "google.protobuf.Struct.FieldsEntry.key");
} }
...@@ -449,7 +449,7 @@ void Struct::SerializeWithCachedSizes( ...@@ -449,7 +449,7 @@ void Struct::SerializeWithCachedSizes(
struct Utf8Check { struct Utf8Check {
static void Check(ConstPtr p) { static void Check(ConstPtr p) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
p->first.data(), p->first.length(), p->first.data(), static_cast<int>(p->first.length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Struct.FieldsEntry.key"); "google.protobuf.Struct.FieldsEntry.key");
} }
...@@ -834,7 +834,7 @@ bool Value::MergePartialFromCodedStream( ...@@ -834,7 +834,7 @@ bool Value::MergePartialFromCodedStream(
DO_(::google::protobuf::internal::WireFormatLite::ReadString( DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_string_value())); input, this->mutable_string_value()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->string_value().data(), this->string_value().length(), this->string_value().data(), static_cast<int>(this->string_value().length()),
::google::protobuf::internal::WireFormatLite::PARSE, ::google::protobuf::internal::WireFormatLite::PARSE,
"google.protobuf.Value.string_value")); "google.protobuf.Value.string_value"));
} else { } else {
...@@ -923,7 +923,7 @@ void Value::SerializeWithCachedSizes( ...@@ -923,7 +923,7 @@ void Value::SerializeWithCachedSizes(
// string string_value = 3; // string string_value = 3;
if (has_string_value()) { if (has_string_value()) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->string_value().data(), this->string_value().length(), this->string_value().data(), static_cast<int>(this->string_value().length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Value.string_value"); "google.protobuf.Value.string_value");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
...@@ -970,7 +970,7 @@ void Value::SerializeWithCachedSizes( ...@@ -970,7 +970,7 @@ void Value::SerializeWithCachedSizes(
// string string_value = 3; // string string_value = 3;
if (has_string_value()) { if (has_string_value()) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->string_value().data(), this->string_value().length(), this->string_value().data(), static_cast<int>(this->string_value().length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Value.string_value"); "google.protobuf.Value.string_value");
target = target =
......
This diff is collapsed.
...@@ -268,7 +268,7 @@ inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive( ...@@ -268,7 +268,7 @@ inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive(
if (size > 0) { if (size > 0) {
const uint8* buffer = reinterpret_cast<const uint8*>(void_pointer); const uint8* buffer = reinterpret_cast<const uint8*>(void_pointer);
// The number of bytes each type occupies on the wire. // The number of bytes each type occupies on the wire.
const int per_value_size = tag_size + sizeof(value); const int per_value_size = tag_size + static_cast<int>(sizeof(value));
// parentheses around (std::min) prevents macro expansion of min(...) // parentheses around (std::min) prevents macro expansion of min(...)
int elements_available = int elements_available =
...@@ -344,8 +344,8 @@ inline bool WireFormatLite::ReadPackedFixedSizePrimitive( ...@@ -344,8 +344,8 @@ inline bool WireFormatLite::ReadPackedFixedSizePrimitive(
int length; int length;
if (!input->ReadVarintSizeAsInt(&length)) return false; if (!input->ReadVarintSizeAsInt(&length)) return false;
const int old_entries = values->size(); const int old_entries = values->size();
const int new_entries = length / sizeof(CType); const int new_entries = length / static_cast<int>(sizeof(CType));
const int new_bytes = new_entries * sizeof(CType); const int new_bytes = new_entries * static_cast<int>(sizeof(CType));
if (new_bytes != length) return false; if (new_bytes != length) return false;
// We would *like* to pre-allocate the buffer to write into (for // We would *like* to pre-allocate the buffer to write into (for
// speed), but *must* avoid performing a very large allocation due // speed), but *must* avoid performing a very large allocation due
...@@ -695,7 +695,7 @@ inline uint8* WireFormatLite::WriteFixedNoTagToArray( ...@@ -695,7 +695,7 @@ inline uint8* WireFormatLite::WriteFixedNoTagToArray(
GOOGLE_DCHECK_GT(n, 0); GOOGLE_DCHECK_GT(n, 0);
const T* ii = value.unsafe_data(); const T* ii = value.unsafe_data();
const int bytes = n * sizeof(ii[0]); const int bytes = n * static_cast<int>(sizeof(ii[0]));
memcpy(target, ii, bytes); memcpy(target, ii, bytes);
return target + bytes; return target + bytes;
#else #else
......
...@@ -2209,7 +2209,7 @@ bool StringValue::MergePartialFromCodedStream( ...@@ -2209,7 +2209,7 @@ bool StringValue::MergePartialFromCodedStream(
DO_(::google::protobuf::internal::WireFormatLite::ReadString( DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_value())); input, this->mutable_value()));
DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->value().data(), this->value().length(), this->value().data(), static_cast<int>(this->value().length()),
::google::protobuf::internal::WireFormatLite::PARSE, ::google::protobuf::internal::WireFormatLite::PARSE,
"google.protobuf.StringValue.value")); "google.protobuf.StringValue.value"));
} else { } else {
...@@ -2248,7 +2248,7 @@ void StringValue::SerializeWithCachedSizes( ...@@ -2248,7 +2248,7 @@ void StringValue::SerializeWithCachedSizes(
// string value = 1; // string value = 1;
if (this->value().size() > 0) { if (this->value().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->value().data(), this->value().length(), this->value().data(), static_cast<int>(this->value().length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.StringValue.value"); "google.protobuf.StringValue.value");
::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
...@@ -2267,7 +2267,7 @@ void StringValue::SerializeWithCachedSizes( ...@@ -2267,7 +2267,7 @@ void StringValue::SerializeWithCachedSizes(
// string value = 1; // string value = 1;
if (this->value().size() > 0) { if (this->value().size() > 0) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->value().data(), this->value().length(), this->value().data(), static_cast<int>(this->value().length()),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
"google.protobuf.StringValue.value"); "google.protobuf.StringValue.value");
target = target =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment