| ... | @@ -1841,30 +1841,21 @@ pub const DeclGen = struct { | ... | @@ -1841,30 +1841,21 @@ pub const DeclGen = struct { |
| 1841 | dg.module.markDeclAlive(decl); | 1841 | dg.module.markDeclAlive(decl); |
| 1842 | | 1842 | |
| 1843 | if (dg.module.decl_exports.get(decl_index)) |exports| { | 1843 | if (dg.module.decl_exports.get(decl_index)) |exports| { |
| 1844 | return writer.writeAll(exports.items[export_index].options.name); | 1844 | try writer.writeAll(exports.items[export_index].options.name); |
| 1845 | } else if (decl.isExtern()) { | 1845 | } else if (decl.isExtern()) { |
| 1846 | return writer.writeAll(mem.sliceTo(decl.name, 0)); | 1846 | try writer.writeAll(mem.sliceTo(decl.name, 0)); |
| 1847 | } else if (dg.module.test_functions.get(decl_index)) |_| { | | |
| 1848 | const gpa = dg.gpa; | | |
| 1849 | const name = try decl.getFullyQualifiedName(dg.module); | | |
| 1850 | defer gpa.free(name); | | |
| 1851 | return writer.print("{}_{d}", .{ fmtIdent(name), @enumToInt(decl_index) }); | | |
| 1852 | } else { | 1847 | } else { |
| 1853 | const gpa = dg.gpa; | 1848 | // MSVC has a limit of 4095 character token length limit, and fmtIdent can (worst case), |
| 1854 | const name = try decl.getFullyQualifiedName(dg.module); | 1849 | // expand to 3x the length of its input, but let's cut it off at a much shorter limit. |
| 1855 | defer gpa.free(name); | 1850 | var name: [100]u8 = undefined; |
| 1856 | | 1851 | var name_stream = std.io.fixedBufferStream(&name); |
| 1857 | // MSVC has a limit of 4095 character token length limit, and fmtIdent can (worst case), expand | 1852 | decl.renderFullyQualifiedName(dg.module, name_stream.writer()) catch |err| switch (err) { |
| 1858 | // to 3x the length of its input | 1853 | error.NoSpaceLeft => {}, |
| 1859 | if (name.len > 1365) { | 1854 | }; |
| 1860 | var hash = ident_hasher_init; | 1855 | try writer.print("{}__{d}", .{ |
| 1861 | hash.update(name); | 1856 | fmtIdent(name_stream.getWritten()), |
| 1862 | const ident_hash = hash.finalInt(); | 1857 | @enumToInt(decl_index), |
| 1863 | try writer.writeAll("zig_D_"); | 1858 | }); |
| 1864 | return std.fmt.formatIntValue(ident_hash, "x", .{}, writer); | | |
| 1865 | } else { | | |
| 1866 | return writer.print("{}", .{fmtIdent(name)}); | | |
| 1867 | } | | |
| 1868 | } | 1859 | } |
| 1869 | } | 1860 | } |
| 1870 | | 1861 | |