Skip to content

Commit 543fbcd

Browse files
mkruskal-googlecopybara-github
authored andcommitted
Breaking change: Remove deprecated std::string error collector overrides
PiperOrigin-RevId: 590740727
1 parent 4b2a30c commit 543fbcd

5 files changed

Lines changed: 21 additions & 72 deletions

File tree

src/google/protobuf/compiler/importer.h

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -181,30 +181,12 @@ class PROTOBUF_EXPORT MultiFileErrorCollector {
181181
// Line and column numbers are zero-based. A line number of -1 indicates
182182
// an error with the entire file (e.g. "not found").
183183
virtual void RecordError(absl::string_view filename, int line, int column,
184-
absl::string_view message) {
185-
PROTOBUF_IGNORE_DEPRECATION_START
186-
AddError(std::string(filename), line, column, std::string(message));
187-
PROTOBUF_IGNORE_DEPRECATION_STOP
188-
}
184+
absl::string_view message)
185+
= 0;
189186
virtual void RecordWarning(absl::string_view filename, int line, int column,
190187
absl::string_view message) {
191-
PROTOBUF_IGNORE_DEPRECATION_START
192-
AddWarning(std::string(filename), line, column, std::string(message));
193-
PROTOBUF_IGNORE_DEPRECATION_STOP
194-
}
195-
196-
private:
197-
// These should never be called directly, but if a legacy class overrides
198-
// them they'll get routed to by the Record* methods.
199-
ABSL_DEPRECATED("Use RecordError")
200-
virtual void AddError(const std::string& filename, int line, int column,
201-
const std::string& message) {
202-
ABSL_LOG(FATAL) << "AddError or RecordError must be implemented.";
203188
}
204189

205-
ABSL_DEPRECATED("Use RecordWarning")
206-
virtual void AddWarning(const std::string& filename, int line, int column,
207-
const std::string& message) {}
208190
};
209191

210192
// Abstract interface which represents a directory tree containing proto files.

src/google/protobuf/descriptor.h

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,12 +2156,8 @@ class PROTOBUF_EXPORT DescriptorPool {
21562156
virtual void RecordError(absl::string_view filename,
21572157
absl::string_view element_name,
21582158
const Message* descriptor, ErrorLocation location,
2159-
absl::string_view message) {
2160-
PROTOBUF_IGNORE_DEPRECATION_START
2161-
AddError(std::string(filename), std::string(element_name), descriptor,
2162-
location, std::string(message));
2163-
PROTOBUF_IGNORE_DEPRECATION_STOP
2164-
}
2159+
absl::string_view message)
2160+
= 0;
21652161

21662162
// Reports a warning in the FileDescriptorProto. Use this function if the
21672163
// problem occurred should NOT interrupt building the FileDescriptorProto.
@@ -2176,27 +2172,8 @@ class PROTOBUF_EXPORT DescriptorPool {
21762172
const Message* descriptor,
21772173
ErrorLocation location,
21782174
absl::string_view message) {
2179-
PROTOBUF_IGNORE_DEPRECATION_START
2180-
AddWarning(std::string(filename), std::string(element_name), descriptor,
2181-
location, std::string(message));
2182-
PROTOBUF_IGNORE_DEPRECATION_STOP
21832175
}
21842176

2185-
private:
2186-
// These should never be called directly, but if a legacy class overrides
2187-
// them they'll get routed to by the Record* methods.
2188-
ABSL_DEPRECATED("Use RecordError")
2189-
virtual void AddError(const std::string& filename,
2190-
const std::string& element_name,
2191-
const Message* descriptor, ErrorLocation location,
2192-
const std::string& message) {
2193-
ABSL_LOG(FATAL) << "AddError or RecordError must be implemented.";
2194-
}
2195-
ABSL_DEPRECATED("Use RecordWarning")
2196-
virtual void AddWarning(const std::string& filename,
2197-
const std::string& element_name,
2198-
const Message* descriptor, ErrorLocation location,
2199-
const std::string& message) {}
22002177
};
22012178

22022179
// Convert the FileDescriptorProto to real descriptors and place them in

src/google/protobuf/io/tokenizer.h

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,16 @@ class PROTOBUF_EXPORT ErrorCollector {
5555
// column numbers. The numbers are zero-based, so you may want to add
5656
// 1 to each before printing them.
5757
virtual void RecordError(int line, ColumnNumber column,
58-
absl::string_view message) {
59-
PROTOBUF_IGNORE_DEPRECATION_START
60-
AddError(line, column, std::string(message));
61-
PROTOBUF_IGNORE_DEPRECATION_STOP
62-
}
58+
absl::string_view message)
59+
= 0;
6360

6461
// Indicates that there was a warning in the input at the given line and
6562
// column numbers. The numbers are zero-based, so you may want to add
6663
// 1 to each before printing them.
6764
virtual void RecordWarning(int line, ColumnNumber column,
6865
absl::string_view message) {
69-
PROTOBUF_IGNORE_DEPRECATION_START
70-
AddWarning(line, column, std::string(message));
71-
PROTOBUF_IGNORE_DEPRECATION_STOP
7266
}
7367

74-
private:
75-
// These should never be called directly, but if a legacy class overrides
76-
// them they'll get routed to by the Record* methods.
77-
ABSL_DEPRECATED("Use RecordError")
78-
virtual void AddError(int line, ColumnNumber column,
79-
const std::string& message) {
80-
ABSL_LOG(FATAL) << "AddError or RecordError must be implemented.";
81-
}
82-
ABSL_DEPRECATED("Use RecordWarning")
83-
virtual void AddWarning(int line, ColumnNumber column,
84-
const std::string& message) {}
8568
};
8669

8770
// This class converts a stream of raw text into a stream of tokens for

src/google/protobuf/retention_test.cc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "google/protobuf/descriptor.pb.h"
1515
#include <gtest/gtest.h>
16+
#include "absl/strings/string_view.h"
1617
#include "absl/strings/substitute.h"
1718
#include "google/protobuf/compiler/parser.h"
1819
#include "google/protobuf/dynamic_message.h"
@@ -160,6 +161,12 @@ TEST(RetentionTest, Method) {
160161
.GetExtension(protobuf_unittest::method_option));
161162
}
162163

164+
class SimpleErrorCollector : public io::ErrorCollector {
165+
public:
166+
SimpleErrorCollector() = default;
167+
void RecordError(int line, io::ColumnNumber column,
168+
absl::string_view message) override{};
169+
};
163170

164171
TEST(RetentionTest, StripSourceRetentionOptionsWithSourceCodeInfo) {
165172
// The tests above make assertions against the generated code, but this test
@@ -202,7 +209,7 @@ TEST(RetentionTest, StripSourceRetentionOptionsWithSourceCodeInfo) {
202209
FileDescriptorSet::descriptor()->file()->name());
203210
io::ArrayInputStream input_stream(proto_file.data(),
204211
static_cast<int>(proto_file.size()));
205-
io::ErrorCollector error_collector;
212+
SimpleErrorCollector error_collector;
206213
io::Tokenizer tokenizer(&input_stream, &error_collector);
207214
compiler::Parser parser;
208215
FileDescriptorProto file_descriptor;
@@ -242,7 +249,7 @@ TEST(RetentionTest, RemoveEmptyOptions) {
242249
FileDescriptorSet::descriptor()->file()->name());
243250
io::ArrayInputStream input_stream(proto_file.data(),
244251
static_cast<int>(proto_file.size()));
245-
io::ErrorCollector error_collector;
252+
SimpleErrorCollector error_collector;
246253
io::Tokenizer tokenizer(&input_stream, &error_collector);
247254
compiler::Parser parser;
248255
FileDescriptorProto file_descriptor;
@@ -282,7 +289,7 @@ TEST(RetentionTest, InvalidDescriptor) {
282289
FileDescriptorSet::descriptor()->file()->name());
283290
io::ArrayInputStream input_stream(proto_file.data(),
284291
static_cast<int>(proto_file.size()));
285-
io::ErrorCollector error_collector;
292+
SimpleErrorCollector error_collector;
286293
io::Tokenizer tokenizer(&input_stream, &error_collector);
287294
compiler::Parser parser;
288295
FileDescriptorProto file_descriptor_proto;
@@ -331,7 +338,7 @@ TEST(RetentionTest, MissingRequiredField) {
331338
FileDescriptorSet::descriptor()->file()->name());
332339
io::ArrayInputStream input_stream(proto_file.data(),
333340
static_cast<int>(proto_file.size()));
334-
io::ErrorCollector error_collector;
341+
SimpleErrorCollector error_collector;
335342
io::Tokenizer tokenizer(&input_stream, &error_collector);
336343
compiler::Parser parser;
337344
FileDescriptorProto file_descriptor_proto;
@@ -387,7 +394,7 @@ TEST(RetentionTest, InvalidRecursionDepth) {
387394
FileDescriptorSet::descriptor()->file()->name());
388395
io::ArrayInputStream input_stream(proto_file.data(),
389396
static_cast<int>(proto_file.size()));
390-
io::ErrorCollector error_collector;
397+
SimpleErrorCollector error_collector;
391398
io::Tokenizer tokenizer(&input_stream, &error_collector);
392399
compiler::Parser parser;
393400
FileDescriptorProto file_descriptor_proto;

upb/util/def_to_proto_test.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ MATCHER_P(EqualsProtoTreatNansAsEqual, proto,
4646
}
4747

4848
class NullErrorCollector : public google::protobuf::DescriptorPool::ErrorCollector {
49-
void AddError(const std::string& filename, const std::string& element_name,
50-
const google::protobuf::Message* descriptor, ErrorLocation location,
51-
const std::string& message) override {}
49+
void RecordError(absl::string_view filename, absl::string_view element_name,
50+
const google::protobuf::Message* descriptor, ErrorLocation location,
51+
absl::string_view message) override {}
5252
void RecordWarning(absl::string_view filename, absl::string_view element_name,
5353
const google::protobuf::Message* descriptor, ErrorLocation location,
5454
absl::string_view message) override {}

0 commit comments

Comments
 (0)