aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-12-23 16:43:35 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-24 13:06:54 +0100
commitd9a02b1f6164428772a2eb8612cffb2eff9829d7 (patch)
tree48def157cff1502a66db4be9b3c7f5723b9b1d54 /gcc
parent14d04e93cf83d167c650709c9f09aa5267cf71c5 (diff)
downloadgcc-d9a02b1f6164428772a2eb8612cffb2eff9829d7.zip
gcc-d9a02b1f6164428772a2eb8612cffb2eff9829d7.tar.gz
gcc-d9a02b1f6164428772a2eb8612cffb2eff9829d7.tar.bz2
gccrs: lang-items: Add LangItem::IsEnumVariant
gcc/rust/ChangeLog: * util/rust-lang-item.cc (LangItem::IsEnumVariant): New function. * util/rust-lang-item.h: Declare it.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/util/rust-lang-item.cc9
-rw-r--r--gcc/rust/util/rust-lang-item.h5
2 files changed, 13 insertions, 1 deletions
diff --git a/gcc/rust/util/rust-lang-item.cc b/gcc/rust/util/rust-lang-item.cc
index ac90f97..b37a237 100644
--- a/gcc/rust/util/rust-lang-item.cc
+++ b/gcc/rust/util/rust-lang-item.cc
@@ -248,4 +248,13 @@ LangItem::NegationOperatorToLangItem (NegationOperator op)
rust_unreachable ();
}
+bool
+LangItem::IsEnumVariant (LangItem::Kind type)
+{
+ const static std::set<LangItem::Kind> enum_variants
+ = {Kind::OPTION_NONE, Kind::OPTION_SOME, Kind::RESULT_OK, Kind::RESULT_ERR};
+
+ return enum_variants.find (type) != enum_variants.end ();
+}
+
} // namespace Rust
diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h
index ad081a7..851909d 100644
--- a/gcc/rust/util/rust-lang-item.h
+++ b/gcc/rust/util/rust-lang-item.h
@@ -146,15 +146,18 @@ public:
static const BiMap<std::string, Kind> lang_items;
static tl::optional<Kind> Parse (const std::string &item);
+
static std::string ToString (Kind type);
static std::string PrettyString (Kind type);
+
static Kind OperatorToLangItem (ArithmeticOrLogicalOperator op);
static Kind
CompoundAssignmentOperatorToLangItem (ArithmeticOrLogicalOperator op);
static Kind NegationOperatorToLangItem (NegationOperator op);
static Kind ComparisonToLangItem (ComparisonOperator op);
-
static std::string ComparisonToSegment (ComparisonOperator op);
+
+ static bool IsEnumVariant (Kind type);
};
} // namespace Rust