Replace google::protobuf::string with std::string.
google::protobuf::string has been removed in recent releases of
Protocol Buffers library.
Bug: 203713560
Test: OUT_DIR=out prebuilts/clang-tools/build-prebuilts.sh
Change-Id: I813648da19aa6e892a81a3f326cd42257f162657
diff --git a/kythe/cxx/common/kythe_metadata_file.cc b/kythe/cxx/common/kythe_metadata_file.cc
index 3d2536e..3f82c6e 100644
--- a/kythe/cxx/common/kythe_metadata_file.cc
+++ b/kythe/cxx/common/kythe_metadata_file.cc
@@ -46,7 +46,7 @@
absl::optional<std::string> LoadCommentMetadata(absl::string_view buf_string,
size_t comment_slash_pos,
size_t data_start_pos) {
- google::protobuf::string raw_data;
+ std::string raw_data;
// Over-reserves--though we expect the comment to be the only thing in the
// file or the last thing in the file, so this approximation is reasonable.
raw_data.reserve(buf_string.size() - comment_slash_pos);
@@ -74,9 +74,9 @@
}
break;
}
- google::protobuf::string decoded;
+ std::string decoded;
return absl::Base64Unescape(raw_data, &decoded)
- ? absl::optional<std::string>(std::string(decoded))
+ ? absl::optional<std::string>(decoded)
: absl::nullopt;
}
diff --git a/kythe/cxx/extractor/testdata/claim_pragma_test.cc b/kythe/cxx/extractor/testdata/claim_pragma_test.cc
index 077ec4f..97dc9f8 100644
--- a/kythe/cxx/extractor/testdata/claim_pragma_test.cc
+++ b/kythe/cxx/extractor/testdata/claim_pragma_test.cc
@@ -22,8 +22,6 @@
using ::google::protobuf::util::MessageDifferencer;
using ::testing::ElementsAre;
-using pbstring = ::google::protobuf::string;
-
constexpr char kExpectedContents[] = R"(
v_name {
language: "c++"
@@ -113,7 +111,7 @@
// {"message", "inner", "field"});
const FieldDescriptor* FindNestedFieldByLowercasePath(
const google::protobuf::Descriptor* descriptor,
- const std::vector<pbstring>& field_names) {
+ const std::vector<std::string>& field_names) {
const FieldDescriptor* field = nullptr;
for (const auto& name : field_names) {
if (descriptor == nullptr) return nullptr;
@@ -147,7 +145,7 @@
}
private:
- using HashMap = std::unordered_map<pbstring, size_t>;
+ using HashMap = std::unordered_map<std::string, size_t>;
ComparisonResult Compare(
const Message& message_1, const Message& message_2,
@@ -163,8 +161,8 @@
if (field->is_repeated()) {
// Allocate scratch strings to store the result if a conversion is
// needed.
- pbstring scratch1;
- pbstring scratch2;
+ std::string scratch1;
+ std::string scratch2;
return CompareCanonicalHash(reflection_1->GetRepeatedStringReference(
message_1, field, index_1, &scratch1),
reflection_2->GetRepeatedStringReference(
@@ -172,23 +170,23 @@
} else {
// Allocate scratch strings to store the result if a conversion is
// needed.
- pbstring scratch1;
- pbstring scratch2;
+ std::string scratch1;
+ std::string scratch2;
return CompareCanonicalHash(
reflection_1->GetStringReference(message_1, field, &scratch1),
reflection_2->GetStringReference(message_2, field, &scratch2));
}
}
- ComparisonResult CompareCanonicalHash(const pbstring& string_1,
- const pbstring& string_2) {
+ ComparisonResult CompareCanonicalHash(const std::string& string_1,
+ const std::string& string_2) {
return HashIndex(&left_message_hashes_, string_1) ==
HashIndex(&right_message_hashes_, string_2)
? SAME
: DIFFERENT;
}
- static size_t HashIndex(HashMap* canonical_map, const pbstring& hash) {
+ static size_t HashIndex(HashMap* canonical_map, const std::string& hash) {
size_t index = canonical_map->size();
// We use an index equivalent to the visitation order of the hashes.
// This is potentially fragile as we really only care if a protocol buffer
@@ -231,7 +229,7 @@
kythe::proto::CompilationUnit expected;
ASSERT_TRUE(TextFormat::ParseFromString(kExpectedContents, &expected));
- google::protobuf::string diffs;
+ std::string diffs;
diff.ReportDifferencesToString(&diffs);
EXPECT_TRUE(diff.Compare(expected, unit)) << diffs;
diff --git a/kythe/cxx/indexer/cxx/KytheIndexerUnitTest.cc b/kythe/cxx/indexer/cxx/KytheIndexerUnitTest.cc
index ca87642..d2807ea 100644
--- a/kythe/cxx/indexer/cxx/KytheIndexerUnitTest.cc
+++ b/kythe/cxx/indexer/cxx/KytheIndexerUnitTest.cc
@@ -277,9 +277,9 @@
EXPECT_EQ(vname_target.DebugString(), entry.target().DebugString());
}
-static void WriteStringToStackAndBuffer(const google::protobuf::string& value,
+static void WriteStringToStackAndBuffer(const std::string& value,
kythe::BufferStack* stack,
- google::protobuf::string* buffer) {
+ std::string* buffer) {
unsigned char* bytes = stack->WriteToTop(value.size());
memcpy(bytes, value.data(), value.size());
if (buffer) {
@@ -289,7 +289,7 @@
TEST(KytheIndexerUnitTest, BufferStackWrite) {
kythe::BufferStack stack;
- google::protobuf::string expected, actual;
+ std::string expected, actual;
{
google::protobuf::io::StringOutputStream stream(&actual);
stack.Push(0);
@@ -305,7 +305,7 @@
TEST(KytheIndexerUnitTest, BufferStackMergeDown) {
kythe::BufferStack stack;
- google::protobuf::string actual;
+ std::string actual;
{
google::protobuf::io::StringOutputStream stream(&actual);
stack.Push(0);
@@ -344,7 +344,7 @@
TEST(KytheIndexerUnitTest, BufferStackMergeFailures) {
kythe::BufferStack stack;
- google::protobuf::string actual;
+ std::string actual;
{
google::protobuf::io::StringOutputStream stream(&actual);
ASSERT_FALSE(stack.MergeDownIfTooSmall(0, 2048)); // too few on the stack
diff --git a/kythe/cxx/indexer/cxx/proto_conversions.h b/kythe/cxx/indexer/cxx/proto_conversions.h
index 59e0ab1..7167093 100644
--- a/kythe/cxx/indexer/cxx/proto_conversions.h
+++ b/kythe/cxx/indexer/cxx/proto_conversions.h
@@ -25,7 +25,7 @@
/// \brief Wrap a protobuf string in a StringRef.
/// \param string The string to wrap.
/// \return The wrapped string (which should not outlive `string`).
-inline llvm::StringRef ToStringRef(const google::protobuf::string& string) {
+inline llvm::StringRef ToStringRef(const std::string& string) {
return llvm::StringRef(string.c_str(), string.size());
}
} // namespace kythe
diff --git a/kythe/cxx/verifier/verifier.cc b/kythe/cxx/verifier/verifier.cc
index 1d05b7c..8f253ac 100644
--- a/kythe/cxx/verifier/verifier.cc
+++ b/kythe/cxx/verifier/verifier.cc
@@ -1288,7 +1288,7 @@
}
AstNode* Verifier::ConvertCodeFact(const yy::location& loc,
- const google::protobuf::string& code_data) {
+ const std::string& code_data) {
proto::common::MarkedSource marked_source;
if (!marked_source.ParseFromString(code_data)) {
std::cerr << loc << ": can't parse code protobuf" << std::endl;
diff --git a/kythe/cxx/verifier/verifier.h b/kythe/cxx/verifier/verifier.h
index 212dd1e..4db76b4 100644
--- a/kythe/cxx/verifier/verifier.h
+++ b/kythe/cxx/verifier/verifier.h
@@ -208,7 +208,7 @@
/// \return null if something went wrong; otherwise, an AstNode corresponding
/// to a VName of a synthetic node for `code_data`.
AstNode* ConvertCodeFact(const yy::location& loc,
- const google::protobuf::string& code_data);
+ const std::string& code_data);
/// \brief Converts a MarkedSource message to a form that's useful
/// to the verifier.
diff --git a/kythe/cxx/verifier/verifier_unit_test.cc b/kythe/cxx/verifier/verifier_unit_test.cc
index c530008..20c7f3f 100644
--- a/kythe/cxx/verifier/verifier_unit_test.cc
+++ b/kythe/cxx/verifier/verifier_unit_test.cc
@@ -2652,10 +2652,10 @@
TEST(VerifierUnitTest, DontConvertMarkedSource) {
Verifier v;
MarkedSource source;
- google::protobuf::string source_string;
+ std::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
- google::protobuf::string enc_source = printer.PrintBytes(source_string);
+ std::string enc_source = printer.PrintBytes(source_string);
ASSERT_TRUE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
@@ -2673,10 +2673,10 @@
Verifier v;
v.ConvertMarkedSource();
MarkedSource source;
- google::protobuf::string source_string;
+ std::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
- google::protobuf::string enc_source = printer.PrintBytes(source_string);
+ std::string enc_source = printer.PrintBytes(source_string);
ASSERT_TRUE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
@@ -2708,10 +2708,10 @@
v.ConvertMarkedSource();
MarkedSource source;
source.set_kind(kind_enum);
- google::protobuf::string source_string;
+ std::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
- google::protobuf::string enc_source = printer.PrintBytes(source_string);
+ std::string enc_source = printer.PrintBytes(source_string);
ASSERT_TRUE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
@@ -2732,10 +2732,10 @@
v.ConvertMarkedSource();
MarkedSource source;
source.add_link()->add_definition("kythe://corpus#sig");
- google::protobuf::string source_string;
+ std::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
- google::protobuf::string enc_source = printer.PrintBytes(source_string);
+ std::string enc_source = printer.PrintBytes(source_string);
ASSERT_TRUE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
@@ -2754,10 +2754,10 @@
v.ConvertMarkedSource();
MarkedSource source;
source.add_link()->add_definition("kythe:/&bad");
- google::protobuf::string source_string;
+ std::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
- google::protobuf::string enc_source = printer.PrintBytes(source_string);
+ std::string enc_source = printer.PrintBytes(source_string);
ASSERT_FALSE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
@@ -2772,10 +2772,10 @@
v.ConvertMarkedSource();
MarkedSource source;
source.add_link();
- google::protobuf::string source_string;
+ std::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
- google::protobuf::string enc_source = printer.PrintBytes(source_string);
+ std::string enc_source = printer.PrintBytes(source_string);
ASSERT_FALSE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
@@ -2792,10 +2792,10 @@
auto* link = source.add_link();
link->add_definition("kythe://corpus#sig");
link->add_definition("kythe://corpus#sig2");
- google::protobuf::string source_string;
+ std::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
- google::protobuf::string enc_source = printer.PrintBytes(source_string);
+ std::string enc_source = printer.PrintBytes(source_string);
ASSERT_FALSE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
@@ -2813,10 +2813,10 @@
child->set_kind(MarkedSource::IDENTIFIER);
child = source.add_child();
child->set_kind(MarkedSource::CONTEXT);
- google::protobuf::string source_string;
+ std::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
- google::protobuf::string enc_source = printer.PrintBytes(source_string);
+ std::string enc_source = printer.PrintBytes(source_string);
ASSERT_TRUE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
@@ -2841,10 +2841,10 @@
auto* link = child->add_link();
link->add_definition("kythe://corpus#sig");
link->add_definition("kythe://corpus#sig2");
- google::protobuf::string source_string;
+ std::string source_string;
ASSERT_TRUE(parent.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
- google::protobuf::string enc_source = printer.PrintBytes(source_string);
+ std::string enc_source = printer.PrintBytes(source_string);
ASSERT_FALSE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
@@ -2864,10 +2864,10 @@
source.set_lookup_index(42);
source.set_default_children_count(43);
source.set_add_final_list_token(true);
- google::protobuf::string source_string;
+ std::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
- google::protobuf::string enc_source = printer.PrintBytes(source_string);
+ std::string enc_source = printer.PrintBytes(source_string);
ASSERT_TRUE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
@@ -2890,10 +2890,10 @@
Verifier v;
MarkedSource source;
v.IgnoreDuplicateFacts();
- google::protobuf::string source_string;
+ std::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
- google::protobuf::string enc_source = printer.PrintBytes(source_string);
+ std::string enc_source = printer.PrintBytes(source_string);
ASSERT_TRUE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
@@ -2914,10 +2914,10 @@
Verifier v;
v.ConvertMarkedSource();
MarkedSource source;
- google::protobuf::string source_string;
+ std::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
- google::protobuf::string enc_source = printer.PrintBytes(source_string);
+ std::string enc_source = printer.PrintBytes(source_string);
ASSERT_TRUE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }