Fixed a crash when handling incorrect group shared fields

このコミットが含まれているのは:
Sergio Pedri committed 2021-02-18 00:11:58 +01:00
1 親 4fe3c857be
コミット e278ac8b36
3ファイル変更
+12 -15

検索条件に一致するファイルはありません

+10 -10
ファイルの表示
@@ -95,6 +95,8 @@ namespace ComputeSharp.SourceGenerators
{
foreach (var fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>())
{
if (fieldSymbol.IsStatic) continue;
// Captured fields must be named type symbols
if (fieldSymbol.Type is not INamedTypeSymbol typeSymbol)
{
@@ -106,15 +108,6 @@ namespace ComputeSharp.SourceGenerators
continue;
}
if (fieldSymbol.IsStatic) continue;
string typeName = HlslKnownTypes.GetMappedName(typeSymbol);
_ = HlslKnownKeywords.TryGetMappedName(fieldSymbol.Name, out string? mapping);
// Yield back the current mapping for the name (if the name used a reserved keyword)
yield return new[] { fieldSymbol.Name, mapping ?? fieldSymbol.Name, typeName };
// Track the type of items in the current buffer
if (HlslKnownTypes.IsTypedResourceType(typeSymbol.GetFullMetadataName()) &&
typeSymbol.TypeArguments.Length == 1)
@@ -129,6 +122,13 @@ namespace ComputeSharp.SourceGenerators
fieldSymbol.Locations.FirstOrDefault(),
structDeclarationSymbol, fieldSymbol.Name, typeSymbol));
}
string typeName = HlslKnownTypes.GetMappedName(typeSymbol);
_ = HlslKnownKeywords.TryGetMappedName(fieldSymbol.Name, out string? mapping);
// Yield back the current mapping for the name (if the name used a reserved keyword)
yield return new[] { fieldSymbol.Name, mapping ?? fieldSymbol.Name, typeName };
}
}
@@ -163,7 +163,7 @@ namespace ComputeSharp.SourceGenerators
continue;
}
if (typeSymbol.ElementType.IsUnmanagedType)
if (!typeSymbol.ElementType.IsUnmanagedType)
{
context.ReportDiagnostic(Diagnostic.Create(
DiagnosticDescriptors.InvalidGroupSharedFieldElementType,