[clang] [llvm] [SystemZ][z/OS] Support both EBCDIC & ASCII form of type_info::name() (PR #179687)

Tony Tao via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 4 08:59:35 PST 2026


================
@@ -3619,8 +3620,20 @@ llvm::GlobalVariable *ItaniumRTTIBuilder::GetAddrOfTypeName(
   // We know that the mangled name of the type starts at index 4 of the
   // mangled name of the typename, so we can just index into it in order to
   // get the mangled name of the type.
-  llvm::Constant *Init = llvm::ConstantDataArray::getString(VMContext,
-                                                            Name.substr(4));
+  llvm::Constant *Init;
+  if (CGM.getTriple().isOSzOS()) {
+    // On z/OS, typename is stored as 2 encodings: EBCDIC followed by ASCII.
+    SmallString<256> DualEncodedName;
+    llvm::ErrorOr<llvm::TextEncodingConverter> Converter =
+        llvm::TextEncodingConverter::create(
+            "UTF-8", CGM.getTriple().getDefaultNarrowTextEncoding());
----------------
tltao wrote:

Is the `getDefaultNarrowTextEncoding` function really needed? Seems like we check for `getTriple().isOSzOS()` in both places so couldn't this just be `"IBM-1047"`?

https://github.com/llvm/llvm-project/pull/179687


More information about the cfe-commits mailing list