]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: lang-item: Add LangItem::PrettyString
authorArthur Cohen <arthur.cohen@embecosm.com>
Thu, 26 Dec 2024 22:45:12 +0000 (22:45 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 21 Mar 2025 11:57:49 +0000 (12:57 +0100)
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 4a609096144358ef435dd1bf639d245be68c7a15..e038e900f947b8afe67158888622e62f7d970a29 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 62b15d7b3fc54d513b1275c70184d8f471041ae3..f947f3f021c0023cb451a74b624604e361da5a30 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);