]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
lang-item: Add LangItem::PrettyString
authorArthur Cohen <arthur.cohen@embecosm.com>
Thu, 26 Dec 2024 22:45:12 +0000 (22:45 +0000)
committerCohenArthur <arthur.cohen@embecosm.com>
Thu, 16 Jan 2025 14:00:31 +0000 (14:00 +0000)
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.

gcc/rust/util/rust-lang-item.cc
gcc/rust/util/rust-lang-item.h

index bd5a29da9ffe7e0a9f698fd7b8f843e7331cbbe1..674b18919d27af089db5110d0db5f2edd5810a85 100644 (file)
@@ -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)
 {
index 35ee5c2a2c3a88e3b795d0d828b3ac8424cbaed5..f2e9d7036124775bbe8294d766082fbff3c95d7c 100644 (file)
@@ -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);