Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update S3949 and CFG creation for C# 9 syntax #3439

Closed
andrei-epure-sonarsource opened this issue Jul 15, 2020 · 0 comments · Fixed by #3730
Closed

Update S3949 and CFG creation for C# 9 syntax #3439

andrei-epure-sonarsource opened this issue Jul 15, 2020 · 0 comments · Fixed by #3730
Assignees
Labels
Type: Bug Exceptions and blocking issues during analysis.
Milestone

Comments

@andrei-epure-sonarsource
Copy link
Contributor

andrei-epure-sonarsource commented Jul 15, 2020

S3949 is generating MLIR instructions for all C# syntaxes, based on the CFG. When encountering an unknown syntax, it will throw an exception together with an AD0001 warning. It fails for C# 9 syntax.

error AD0001: Analyzer 'SonarAnalyzer.Rules.CSharp.CbdeHandlerRule' threw an exception of type 'SonarAnalyzer.CBDE.CbdeException' with message 'Top level error in CBDE handling: WithExpression 
 Details:  
 Inner exception:  
 Stack trace:    at SonarAnalyzer.ControlFlowGraph.CSharp.CSharpControlFlowGraphBuilder.BuildExpression(ExpressionSyntax expression, Block currentBlock) 
    at SonarAnalyzer.ControlFlowGraph.CSharp.CSharpControlFlowGraphBuilder.BuildVariableDeclarator(VariableDeclaratorSyntax variableDeclarator, Block currentBlock) 
    at SonarAnalyzer.ControlFlowGraph.CSharp.CSharpControlFlowGraphBuilder.BuildVariableDeclaration(VariableDeclarationSyntax declaration, Block currentBlock) 
    at SonarAnalyzer.ControlFlowGraph.CSharp.CSharpControlFlowGraphBuilder.BuildStatement(StatementSyntax statement, Block currentBlock) 
    at SonarAnalyzer.ControlFlowGraph.CSharp.CSharpControlFlowGraphBuilder.BuildStatements(IEnumerable`1 statements, Block currentBlock) 
    at SonarAnalyzer.ControlFlowGraph.CSharp.CSharpControlFlowGraphBuilder.BuildBlock(BlockSyntax block, Block currentBlock) 
    at SonarAnalyzer.ControlFlowGraph.CSharp.CSharpControlFlowGraphBuilder.BuildStatement(StatementSyntax statement, Block currentBlock) 
    at SonarAnalyzer.ControlFlowGraph.CSharp.CSharpControlFlowGraphBuilder.Build(SyntaxNode node, Block currentBlock) 
    at SonarAnalyzer.ControlFlowGraph.AbstractControlFlowGraphBuilder.Build() 
    at SonarAnalyzer.ControlFlowGraph.CSharp.CSharpControlFlowGraph.Create(CSharpSyntaxNode node, SemanticModel semanticModel) 
    at SonarAnalyzer.CBDE.MlirExporter.ExportFunction(MethodDeclarationSyntax method) 
    at SonarAnalyzer.CBDE.CbdeHandler.ExportFunctionMlir(SyntaxTree tree, SemanticModel model, MlirExporterMetrics exporterMetrics, String mlirFileName) 
    at SonarAnalyzer.CBDE.CbdeHandler.<RegisterMlirAndCbdeInOneStep>b__31_0(CompilationAnalysisContext c)'. [C:\Workspace\sonar-dotnet\sonaranalyzer-dotnet\its\sources\Net5\Net5.csproj

Note: The regression ITs are considering AD0001 warnings as errors. Thus when running the Net5 integration test, we disable S3949. We should re-enable it after fixing this issue (see sonaranalyzer-dotnet/its/regression-test.ps1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Exceptions and blocking issues during analysis.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants