From 9c0b35cf620c4904a18e25733f50c9c0474fefa6 Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Thu, 22 Jun 2017 15:39:19 -0700 Subject: Enusre public header and generated code have no implicit converion. --- src/google/protobuf/compiler/cpp/cpp_string_field.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/google/protobuf/compiler/cpp/cpp_string_field.cc') diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index 7a849e2e..6a710888 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -477,7 +477,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, true, variables_, - "this->$name$().data(), this->$name$().length(),\n", printer); + "this->$name$().data(), static_cast(this->$name$().length()),\n", + printer); } } @@ -486,7 +487,8 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, false, variables_, - "this->$name$().data(), this->$name$().length(),\n", printer); + "this->$name$().data(), static_cast(this->$name$().length()),\n", + printer); } printer->Print(variables_, "::google::protobuf::internal::WireFormatLite::Write$declared_type$MaybeAliased(\n" @@ -498,7 +500,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, false, variables_, - "this->$name$().data(), this->$name$().length(),\n", printer); + "this->$name$().data(), static_cast(this->$name$().length()),\n", + printer); } printer->Print(variables_, "target =\n" @@ -797,7 +800,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, true, variables_, - "this->$name$().data(), this->$name$().length(),\n", printer); + "this->$name$().data(), static_cast(this->$name$().length()),\n", + printer); } } @@ -969,7 +973,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { GenerateUtf8CheckCodeForString( descriptor_, options_, true, variables_, "this->$name$(this->$name$_size() - 1).data(),\n" - "this->$name$(this->$name$_size() - 1).length(),\n", + "static_cast(this->$name$(this->$name$_size() - 1).length()),\n", printer); } } @@ -982,7 +986,8 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, false, variables_, - "this->$name$(i).data(), this->$name$(i).length(),\n", printer); + "this->$name$(i).data(), static_cast(this->$name$(i).length()),\n", + printer); } printer->Outdent(); printer->Print(variables_, @@ -999,7 +1004,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, false, variables_, - "this->$name$(i).data(), this->$name$(i).length(),\n", printer); + "this->$name$(i).data(), static_cast(this->$name$(i).length()),\n", + printer); } printer->Outdent(); printer->Print(variables_, -- cgit v1.2.3