From 6b44630afe4ff180ba608142e9515abcd369775e Mon Sep 17 00:00:00 2001 From: Ronan Date: Thu, 3 Apr 2025 06:17:15 +0200 Subject: Fixed generic interface specialization crashes (#6601): (#6688) * Fixed generic interface specialization crashes: - Add an export decoration to specialized generic interfaces. * Fixed generic interface specialization crashes: - Add an export decoration to specialized generic interfaces. - Use getTypeNameHint(...) instead of a manual mangler. * In cloneInstDecorationsAndChildren: specialize all linkage decorations, not just the exports. - If a linkage decoration is already present, it is not specialized and replaced by the specialized one. - If a specialization uses the TypeNameHint, sanitize it to be used as an identifier. - Use the identifier name sanitizer from slang-mangle. * Added tests/generics/generic-interface-linkage.slang - See #6601 and #6688 --- source/slang/slang-mangle.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'source/slang/slang-mangle.cpp') diff --git a/source/slang/slang-mangle.cpp b/source/slang/slang-mangle.cpp index 12e185c8b..63dfffb94 100644 --- a/source/slang/slang-mangle.cpp +++ b/source/slang/slang-mangle.cpp @@ -31,7 +31,7 @@ void emit(ManglingContext* context, String const& value) context->sb.append(value); } -void emitNameImpl(ManglingContext* context, UnownedStringSlice str) +void emitNameForLinkage(StringBuilder& sb, UnownedStringSlice str) { Index length = str.getLength(); // If the name consists of only traditional "identifer characters" @@ -61,8 +61,8 @@ void emitNameImpl(ManglingContext* context, UnownedStringSlice str) // code points and the number of extended grapheme clusters, // since the entire name is within the ASCII subset. // - emit(context, length); - context->sb.append(str); + sb.append(length); + sb.append(str); } else { @@ -98,9 +98,9 @@ void emitNameImpl(ManglingContext* context, UnownedStringSlice str) } } - context->sb.append("R"); - emit(context, encoded.getLength()); - context->sb.append(encoded); + sb.append("R"); + sb.append(encoded.getLength()); + sb.append(encoded); } // TODO: This logic does not rule out consecutive underscores, @@ -111,6 +111,11 @@ void emitNameImpl(ManglingContext* context, UnownedStringSlice str) // target, rather than adding complexity here. } +void emitNameImpl(ManglingContext* context, UnownedStringSlice str) +{ + emitNameForLinkage(context->sb, str); +} + void emitName(ManglingContext* context, Name* name) { String str = getText(name); -- cgit v1.2.3