Skip to content

Commit

Permalink
Always emit diagnostics directly on arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Nov 26, 2024
1 parent 7d7c292 commit 71037c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public override void Initialize(AnalysisContext context)

// Second cheap inital filter: we only care about invocations with a constant 'int' argument in first position.
// While we're validating this, let's also get the 'index' parameter, since we need to validate it anyway.
if (operation.Arguments is not [{ Value.ConstantValue: { HasValue: true, Value: int index } }, ..])
if (operation.Arguments is not [{ Value.ConstantValue: { HasValue: true, Value: int index } } firstArgument, ..])
{
return;
}
Expand Down Expand Up @@ -95,7 +95,7 @@ public override void Initialize(AnalysisContext context)
{
context.ReportDiagnostic(Diagnostic.Create(
IndexOutOfRangeForD2DIntrinsic,
operation.Syntax.GetLocation(),
firstArgument.Syntax.GetLocation(),
targetMethodSymbol.Name,
index,
typeSymbol,
Expand All @@ -106,7 +106,7 @@ public override void Initialize(AnalysisContext context)
// Second validation: the input type must match
context.ReportDiagnostic(Diagnostic.Create(
InvalidInputTypeForD2DIntrinsic,
operation.Syntax.GetLocation(),
firstArgument.Syntax.GetLocation(),
targetMethodSymbol.Name,
index));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ public async Task IndexOutOfRangeForD2DIntrinsic_InvalidArgument1_Warns(int inde
{
public float4 Execute()
{
return {|CMPSD2D0083:D2D.GetInput({{index}})|};
return D2D.GetInput({|CMPSD2D0083:{{index}}|});
}
}
""";
Expand All @@ -1331,7 +1331,7 @@ public async Task IndexOutOfRangeForD2DIntrinsic_InvalidArgument2_Warns(int inde
{
public float4 Execute()
{
return {|CMPSD2D0083:D2D.GetInput({{index}})|};
return D2D.GetInput({|CMPSD2D0083:{{index}}|});
}
}
""";
Expand Down Expand Up @@ -1382,10 +1382,10 @@ public async Task InvalidInputTypeForD2DIntrinsic_InvalidArguments_Warns()
{
public float4 Execute()
{
{|CMPSD2D0084:D2D.GetInputCoordinate(0)|};
{|CMPSD2D0084:D2D.SampleInput(0, 0)|};
{|CMPSD2D0084:D2D.SampleInputAtOffset(0, 0)|};
{|CMPSD2D0084:D2D.SampleInputAtPosition(0, 0)|};
D2D.GetInputCoordinate({|CMPSD2D0084:0|});
D2D.SampleInput({|CMPSD2D0084:0|}, 0);
D2D.SampleInputAtOffset({|CMPSD2D0084:0|}, 0);
D2D.SampleInputAtPosition({|CMPSD2D0084:0|}, 0);
return 0;
}
Expand Down

0 comments on commit 71037c2

Please sign in to comment.