aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-12-26 22:45:12 +0000
committerCohenArthur <arthur.cohen@embecosm.com>2025-01-16 14:00:31 +0000
commit68f142a0e92cc451d92e0bd9a4ca75dc50a7ff8f (patch)
tree23bc144b98ceef12fd72050c294dc6e3ea6911cb /gcc
parent0bde282a597356cc443d14aff17f9953d1bfda49 (diff)
downloadgcc-68f142a0e92cc451d92e0bd9a4ca75dc50a7ff8f.zip
gcc-68f142a0e92cc451d92e0bd9a4ca75dc50a7ff8f.tar.gz
gcc-68f142a0e92cc451d92e0bd9a4ca75dc50a7ff8f.tar.bz2
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')
-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 bd5a29d..674b189 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 35ee5c2..f2e9d70 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);