diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-01-21 18:05:39 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-21 18:05:39 -0800 |
| commit | 41311209af4963f44acf34942d42828590d4b156 (patch) | |
| tree | 97318b544324b26f056fc824f22ba91e821c6330 /source/slang/legalize-types.cpp | |
| parent | 8196dc4a684a75344e507697273e2123af97b979 (diff) | |
Fix legalization of generic types (#377)
Previously, all legalizations of a generic type would use the name of the original decl for the "ordinary" part of things, and this would lead to collisions because the names didn't include the mangled generic arguments.
This is now fixed by storing the mangled name of the original inside of `struct` declarations created for legalization, and using those names instead.
Also adds support for `getElementPtr` instructions when doing IR type legalization.
Also tries to make a `DeclRefType` convert to a string using the underlying `DeclRef`. This doesn't help because `DeclRef::toString` doesn't actually include generic arguments either.
Diffstat (limited to 'source/slang/legalize-types.cpp')
| -rw-r--r-- | source/slang/legalize-types.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/slang/legalize-types.cpp b/source/slang/legalize-types.cpp index d1cef4dac..76fda18e3 100644 --- a/source/slang/legalize-types.cpp +++ b/source/slang/legalize-types.cpp @@ -1,6 +1,8 @@ // legalize-types.cpp #include "legalize-types.h" +#include "mangle.h" + namespace Slang { @@ -335,7 +337,9 @@ struct TupleTypeBuilder ordinaryStructDecl->loc = typeDeclRef.getDecl()->loc; ordinaryStructDecl->nameAndLoc = typeDeclRef.getDecl()->nameAndLoc; - addModifier(ordinaryStructDecl, new LegalizedModifier()); + auto typeLegalizedModifier = new LegalizedModifier(); + typeLegalizedModifier->originalMangledName = getMangledName(typeDeclRef); + addModifier(ordinaryStructDecl, typeLegalizedModifier); // We will do something a bit unsavory here, by setting the logical // parent of the new `struct` type to be the same as the orignal type @@ -408,7 +412,9 @@ struct TupleTypeBuilder pairElements[elementIndex].ordinaryFieldDeclRef = makeDeclRef(fieldDecl.Ptr()); - addModifier(fieldDecl, new LegalizedModifier()); + auto fieldLegalizedModifier = new LegalizedModifier(); + fieldLegalizedModifier->originalMangledName = getMangledName(ee.fieldDeclRef); + addModifier(fieldDecl, fieldLegalizedModifier); } RefPtr<Type> ordinaryStructType = DeclRefType::Create( |
