aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/util
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-12-26 22:45:12 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:57:49 +0100
commit5702b0a24e64082bcfd19372a67ef7699d033d22 (patch)
tree14e5c019b2bf4a148ef3164627a60063e33f3781 /gcc/rust/util
parent88aeeccaca422cd50331edb38d0a8a17e01a5fb9 (diff)
downloadgcc-5702b0a24e64082bcfd19372a67ef7699d033d22.zip
gcc-5702b0a24e64082bcfd19372a67ef7699d033d22.tar.gz
gcc-5702b0a24e64082bcfd19372a67ef7699d033d22.tar.bz2
gccrs: lang-item: Add LangItem::PrettyString
Which formats a lang item as it appears in source code. gcc/rust/ChangeLog: * util/rust-lang-item.cc (LangItem::PrettyString): New. * util/rust-lang-item.h: New.
Diffstat (limited to 'gcc/rust/util')
-rw-r--r--gcc/rust/util/rust-lang-item.cc6
-rw-r--r--gcc/rust/util/rust-lang-item.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/gcc/rust/util/rust-lang-item.cc b/gcc/rust/util/rust-lang-item.cc
index 4a60909..e038e90 100644
--- a/gcc/rust/util/rust-lang-item.cc
+++ b/gcc/rust/util/rust-lang-item.cc
@@ -118,6 +118,12 @@ LangItem::ToString (LangItem::Kind type)
return str.value ();
}
+std::string
+LangItem::PrettyString (LangItem::Kind type)
+{
+ return "#[lang = \"" + LangItem::ToString (type) + "\"]";
+}
+
LangItem::Kind
LangItem::OperatorToLangItem (ArithmeticOrLogicalOperator op)
{
diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h
index 62b15d7..f947f3f 100644
--- a/gcc/rust/util/rust-lang-item.h
+++ b/gcc/rust/util/rust-lang-item.h
@@ -134,6 +134,7 @@ public:
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);