dotnet/roslyn

Remove extraneous branch for empty strings in interpolated string handler CFG

オープン

#57,611 opened on 2021/11/05

 (0 件のコメント) (0 件のリアクション) (1 人の担当者)C# (4,257 件のフォーク)batch import
Area-CompilersBugFeature - IOperationFeature - Interpolated String Improvementshelp wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

When an interpolated string handler is created for an empty string, and the constructor of the handler uses an out bool success parameter, we generate an unnecessary branch in the CFG for the code, demonstrated in the InterpolatedStringHandlerConversionFlow_16 test. We could take the approach Aleksey detailed in his review to remove that branch, but we will have to wire a CreateDiscardSymbol method through the semantic model to be able to create an IDiscardOperation for the parameter value. This is presently undone.

コントリビューターガイド