Skip to content

Commit 10a75b5

Browse files
iahsmeta-codesync[bot]
authored andcommitted
Remove cpp.enum_type support
Summary: Fully migrated to structured annotation Reviewed By: hchokshi Differential Revision: D69412826 fbshipit-source-id: d50b2b14e8dedced1e3695f24e02d6050bab636e
1 parent 043c229 commit 10a75b5

4 files changed

Lines changed: 1 addition & 55 deletions

File tree

third-party/thrift/src/thrift/compiler/codemod/structure_annotations.cc

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -232,37 +232,6 @@ class structure_annotations {
232232
to_add.insert("@cpp.MinimizePadding");
233233
fm_.add_include("thrift/annotation/cpp.thrift");
234234
}
235-
} else if (name == "cpp.enum_type") {
236-
to_remove.emplace_back(name, data);
237-
if (!node.has_structured_annotation(kCppEnumTypeUri)) {
238-
std::string_view value = data.value;
239-
if (value.substr(0, 2) == "::") {
240-
value = value.substr(2);
241-
}
242-
if (value.substr(0, 5) == "std::") {
243-
value = value.substr(5);
244-
}
245-
std::string type;
246-
if (value == "int8_t" || value == "char") {
247-
type = "I8";
248-
} else if (value == "uint8_t" || value == "unsigned char") {
249-
type = "U8";
250-
} else if (value == "int16_t" || value == "short") {
251-
type = "I16";
252-
} else if (value == "uint16_t" || value == "unsigned short") {
253-
type = "U16";
254-
} else if (
255-
value == "uint32_t" || value == "unsigned long" ||
256-
value == "unsigned" || value == "uint") {
257-
type = "U32";
258-
} else {
259-
return;
260-
}
261-
to_add.insert(
262-
fmt::format(
263-
"@cpp.EnumType{{type = cpp.EnumUnderlyingType.{}}}", type));
264-
fm_.add_include("thrift/annotation/cpp.thrift");
265-
}
266235
} else if (
267236
name == "cpp.declare_bitwise_ops" &&
268237
(node.has_structured_annotation(kBitmaskEnumUri) ||

third-party/thrift/src/thrift/compiler/codemod/structure_annotations_test.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,6 @@ def test_cpp(self):
154154
} (message="m", cpp.minimize_padding)
155155
exception EE {}
156156
157-
enum E8 {} (cpp.enum_type="char")
158-
enum E16 {} (cpp.enum_type="int16_t")
159-
enum E32 {} (cpp.enum_type="int")
160-
enum U8 {} (cpp.enum_type="std::uint8_t")
161-
enum U16 {} (cpp.enum_type="unsigned short")
162-
enum U32 {} (cpp.enum_type="::std::uint32_t", cpp.declare_bitwise_ops)
163-
164157
interaction J {} (serial)
165158
service S {
166159
void f() (thread = "eb", priority = "HIGH")
@@ -215,19 +208,6 @@ def test_cpp(self):
215208
}
216209
exception EE {}
217210
218-
@cpp.EnumType{type = cpp.EnumUnderlyingType.I8}
219-
enum E8 {}
220-
@cpp.EnumType{type = cpp.EnumUnderlyingType.I16}
221-
enum E16 {}
222-
enum E32 {}
223-
@cpp.EnumType{type = cpp.EnumUnderlyingType.U8}
224-
enum U8 {}
225-
@cpp.EnumType{type = cpp.EnumUnderlyingType.U16}
226-
enum U16 {}
227-
@cpp.EnumType{type = cpp.EnumUnderlyingType.U32}
228-
@thrift.DeprecatedUnvalidatedAnnotations{items = {"cpp.declare_bitwise_ops": "1"}}
229-
enum U32 {}
230-
231211
@thrift.Serial
232212
interaction J {}
233213
service S {

third-party/thrift/src/thrift/compiler/generate/t_mstch_cpp2_generator.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,6 @@ class t_mstch_cpp2_generator : public t_mstch_generator {
692692
throw std::runtime_error("unknown enum underlying type");
693693
}
694694
}
695-
if (const std::string* type =
696-
e.find_unstructured_annotation_or_null("cpp.enum_type")) {
697-
return *type;
698-
}
699695
return e.has_unstructured_annotation("cpp.deprecated_enum_unscoped")
700696
? "int"
701697
: "";

third-party/thrift/src/thrift/compiler/sema/standard_validator.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,7 @@ void deprecate_annotations(sema_context& ctx, const t_named& node) {
17531753
"code",
17541754
"cpp.indirection",
17551755
"cpp2.declare_bitwise_ops",
1756+
"cpp.enum_type",
17561757
"cpp2.enum_type",
17571758
"cpp2.deprecated_enum_unscoped",
17581759
"process_in_event_base",

0 commit comments

Comments
 (0)