Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions csharp/ql/lib/printAst.ql
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ external string selectedSourceFile();

class PrintAstConfigurationOverride extends PrintAstConfiguration {
/**
* Holds if the location matches the selected file in the VS Code extension and
* the element is `fromSource`.
* Holds if the location `l` matches the selected file in the VS Code extension and
* the element is `e` is `fromSource`.
*/
override predicate shouldPrint(Element e, Location l) {
super.shouldPrint(e, l) and
Expand Down
2 changes: 1 addition & 1 deletion csharp/ql/lib/semmle/code/csharp/Assignable.qll
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ module AssignableDefinitions {
}

/**
* Holds if the `ref` assignment to `aa` via call `c` is uncertain.
* Holds if the `ref` assignment to `arg` via call `c` is uncertain.
*/
// Not in the cached module `Cached`, as that would introduce a dependency
// on the CFG construction, and effectively collapse too many stages into one
Expand Down
2 changes: 1 addition & 1 deletion csharp/ql/lib/semmle/code/csharp/Callable.qll
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ class TrueOperator extends UnaryOperator {
*
* Either an addition operator (`AddOperator`), a checked addition operator
* (`CheckedAddOperator`) a subtraction operator (`SubOperator`), a checked
* substraction operator (`CheckedSubOperator`), a multiplication operator
* subtraction operator (`CheckedSubOperator`), a multiplication operator
* (`MulOperator`), a checked multiplication operator (`CheckedMulOperator`),
* a division operator (`DivOperator`), a checked division operator
* (`CheckedDivOperator`), a remainder operator (`RemOperator`), an and
Expand Down
2 changes: 1 addition & 1 deletion csharp/ql/lib/semmle/code/csharp/Member.qll
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ class Parameterizable extends Declaration, @parameterizable {
final Parameter getARawParameter() { result = this.getRawParameter(_) }

/**
* Gets the type of the parameter, possibly prefixed
* Gets the type of the `i`th parameter, possibly prefixed
* with `out`, `ref`, or `params`, where appropriate.
*/
private string parameterTypeToString(int i) {
Expand Down
6 changes: 2 additions & 4 deletions csharp/ql/lib/semmle/code/csharp/PrintAst.qll
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,9 @@ final class AttributeNode extends ElementNode {
* A node representing a `TypeParameter`.
*/
final class TypeParameterNode extends ElementNode {
TypeParameter typeParameter;

TypeParameterNode() {
typeParameter = element and
not isNotNeeded(typeParameter.getDeclaringGeneric())
element =
any(TypeParameter typeParameter | not isNotNeeded(typeParameter.getDeclaringGeneric()))
}

override ElementNode getChild(int childIndex) { none() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,8 @@ private class Overflowable extends UnaryOperation {

/** A control flow element that is inside a `try` block. */
private class TriedControlFlowElement extends ControlFlowElement {
TryStmt try;

TriedControlFlowElement() {
this = try.getATriedElement() and
this = any(TryStmt try).getATriedElement() and
not this instanceof NonReturningCall
}

Expand Down
3 changes: 1 addition & 2 deletions csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,9 @@ module Ssa {
* An SSA definition that corresponds to an explicit assignable definition.
*/
class ExplicitDefinition extends Definition, SsaImpl::WriteDefinition {
SourceVariable sv;
AssignableDefinition ad;

ExplicitDefinition() { SsaImpl::explicitDefinition(this, sv, ad) }
ExplicitDefinition() { SsaImpl::explicitDefinition(this, _, ad) }

/**
* Gets an underlying assignable definition. The result is always unique,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private module SourceVariableImpl {
}

/**
* Gets an `out`/`ref` definition of the same source variable as the `out`/`ref`
* Gets an `out`/`ref` definition of the same source variable `v` as the `out`/`ref`
* definition `def`, belonging to the same call, at a position after `def`.
*/
OutRefDefinition getASameOutRefDefAfter(Ssa::SourceVariable v, OutRefDefinition def) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ private predicate isStrongTypeFsPicklerCall(MethodCall mc, Method m) {
(
m instanceof FsPicklerSerializerClassDeserializeMethod or
m instanceof FsPicklerSerializerClassDeserializeSequenceMethod or
m instanceof FsPicklerSerializerClasDeserializeSiftedMethod or
m instanceof FsPicklerSerializerClassDeserializeSiftedMethod or
m instanceof FsPicklerSerializerClassUnPickleMethod or
m instanceof FsPicklerSerializerClassUnPickleSiftedMethod or
m instanceof CsPicklerSerializerClassDeserializeMethod or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,15 @@ class FsPicklerSerializerClassDeserializeSequenceMethod extends Method, UnsafeDe
}
}

/**
* DEPRECATED: Use `FsPicklerSerializerClassDeserializeSiftedMethod` instead.
*/
deprecated class FsPicklerSerializerClasDeserializeSiftedMethod =
FsPicklerSerializerClassDeserializeSiftedMethod;

/** `MBrace.FsPickler.FsPicklerSerializer.DeserializeSifted` method */
class FsPicklerSerializerClasDeserializeSiftedMethod extends Method, UnsafeDeserializer {
FsPicklerSerializerClasDeserializeSiftedMethod() {
class FsPicklerSerializerClassDeserializeSiftedMethod extends Method, UnsafeDeserializer {
FsPicklerSerializerClassDeserializeSiftedMethod() {
this.getDeclaringType().getBaseClass*() instanceof FsPicklerSerializerClass and
this.hasUndecoratedName("DeserializeSifted")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private predicate valueOccurrenceCount(string value, int n) {
n > 20
}

private predicate occurenceCount(Literal lit, string value, int n) {
private predicate occurrenceCount(Literal lit, string value, int n) {
valueOccurrenceCount(value, n) and
value = lit.getValue() and
relevantLiteral(lit, value)
Expand All @@ -127,7 +127,7 @@ private predicate check(Literal lit, string value, int n, File f) {
// Check that the literal is nontrivial
not trivial(lit) and
// Check that it is repeated a number of times
occurenceCount(lit, value, n) and
occurrenceCount(lit, value, n) and
n > 20 and
f = lit.getFile()
}
Expand Down
13 changes: 7 additions & 6 deletions csharp/ql/src/Language Abuse/UselessUpcast.ql
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,16 @@ private class ConstructorCall extends Call {

/** An explicit upcast. */
class ExplicitUpcast extends ExplicitCast {
ValueOrRefType src;
ValueOrRefType dest;

ExplicitUpcast() {
src = this.getSourceType() and
dest = this.getTargetType() and
(src instanceof RefType or src instanceof Struct) and
src.isImplicitlyConvertibleTo(dest) and
src != dest // Handled by `cs/useless-cast-to-self`
exists(ValueOrRefType src |
src = this.getSourceType() and
dest = this.getTargetType() and
(src instanceof RefType or src instanceof Struct) and
src.isImplicitlyConvertibleTo(dest) and
src != dest // Handled by `cs/useless-cast-to-self`
)
}

pragma[nomagic]
Expand Down
4 changes: 2 additions & 2 deletions csharp/ql/src/Telemetry/DatabaseQuality.qll
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module CallTargetStats implements StatsSig {
private predicate isNoSetterPropertyCallInConstructor(PropertyCall c) {
exists(Property p, Constructor ctor |
p = c.getProperty() and
not exists(Setter a | a = p.getAnAccessor()) and
not p.getAnAccessor() instanceof Setter and
c.getEnclosingCallable() = ctor and
(
c.hasThisQualifier()
Expand All @@ -25,7 +25,7 @@ module CallTargetStats implements StatsSig {
private predicate isNoSetterPropertyInitialization(PropertyCall c) {
exists(Property p, AssignExpr assign |
p = c.getProperty() and
not exists(Setter a | a = p.getAnAccessor()) and
not p.getAnAccessor() instanceof Setter and
assign = c.getParent() and
assign.getLValue() = c and
assign.getParent() instanceof Property
Expand Down
Loading