mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
C#: Implement extractor support for unsigned right shift.
This commit is contained in:
@@ -61,8 +61,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
containingType = Symbol.ContainingType;
|
||||
if (containingType is not null)
|
||||
{
|
||||
var containingNamedType = containingType as INamedTypeSymbol;
|
||||
return containingNamedType is null ||
|
||||
return containingType is not INamedTypeSymbol containingNamedType ||
|
||||
!containingNamedType.GetMembers(Symbol.Name).Contains(Symbol);
|
||||
}
|
||||
|
||||
@@ -83,7 +82,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// </summary>
|
||||
/// <param name="methodName">The method name.</param>
|
||||
/// <param name="operatorName">The converted operator name.</param>
|
||||
public static bool OperatorSymbol(string methodName, out string operatorName)
|
||||
public static bool TryGetOperatorSymbol(string methodName, out string operatorName)
|
||||
{
|
||||
var success = true;
|
||||
switch (methodName)
|
||||
@@ -147,6 +146,9 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
case "op_RightShift":
|
||||
operatorName = ">>";
|
||||
break;
|
||||
case "op_UnsignedRightShift":
|
||||
operatorName = ">>>";
|
||||
break;
|
||||
case "op_LeftShift":
|
||||
operatorName = "<<";
|
||||
break;
|
||||
@@ -166,7 +168,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
var match = Regex.Match(methodName, "^op_Checked(.*)$");
|
||||
if (match.Success)
|
||||
{
|
||||
OperatorSymbol("op_" + match.Groups[1], out var uncheckedName);
|
||||
TryGetOperatorSymbol("op_" + match.Groups[1], out var uncheckedName);
|
||||
operatorName = "checked " + uncheckedName;
|
||||
break;
|
||||
}
|
||||
@@ -190,7 +192,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
return OperatorSymbol(cx, method.ExplicitInterfaceImplementations.First());
|
||||
|
||||
var methodName = method.Name;
|
||||
if (!OperatorSymbol(methodName, out var result))
|
||||
if (!TryGetOperatorSymbol(methodName, out var result))
|
||||
cx.ModelError(method, $"Unhandled operator name in OperatorSymbol(): '{methodName}'");
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user