mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Autoformat
This commit is contained in:
@@ -33,7 +33,8 @@ private predicate canCreateCompilerGeneratedElement(Element generatedBy, int nth
|
||||
generatedBy instanceof DelegateCreation and
|
||||
nth in [0 .. DelegateElements::noGeneratedElements(generatedBy)]
|
||||
or
|
||||
generatedBy instanceof DelegateCall and nth in [0 .. DelegateElements::noGeneratedElements(generatedBy)]
|
||||
generatedBy instanceof DelegateCall and
|
||||
nth in [0 .. DelegateElements::noGeneratedElements(generatedBy)]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +91,7 @@ private predicate ignoreExprOnly(Expr expr) {
|
||||
// Ignore the child expression of a goto case stmt
|
||||
expr.getParent() instanceof GotoCaseStmt
|
||||
or
|
||||
// Ignore the expression (that is not a declaration)
|
||||
// Ignore the expression (that is not a declaration)
|
||||
// that appears in a using block
|
||||
expr.getParent().(UsingBlockStmt).getExpr() = expr
|
||||
}
|
||||
@@ -228,9 +229,7 @@ newtype TTranslatedElement =
|
||||
// Because of their implementation in C#,
|
||||
// we deal with all the types of initialization separately.
|
||||
// First only simple local variable initialization (ie. `int x = 0`)
|
||||
exists(LocalVariableDeclAndInitExpr lvInit |
|
||||
lvInit.getInitializer() = expr
|
||||
)
|
||||
exists(LocalVariableDeclAndInitExpr lvInit | lvInit.getInitializer() = expr)
|
||||
or
|
||||
// Then treat more complex ones
|
||||
expr instanceof ArrayInitializer
|
||||
|
||||
@@ -750,40 +750,37 @@ abstract class TranslatedSpecificJump extends TranslatedStmt {
|
||||
class TranslatedBreakStmt extends TranslatedSpecificJump {
|
||||
override BreakStmt stmt;
|
||||
|
||||
override Instruction getTargetInstruction() {
|
||||
result = getEnclosingLoopOrSwitchNextInstr(stmt)
|
||||
}
|
||||
override Instruction getTargetInstruction() { result = getEnclosingLoopOrSwitchNextInstr(stmt) }
|
||||
}
|
||||
|
||||
private Instruction getEnclosingLoopOrSwitchNextInstr(Stmt crtStmt) {
|
||||
if crtStmt instanceof LoopStmt or crtStmt instanceof SwitchStmt
|
||||
then
|
||||
result = getTranslatedStmt(crtStmt).getParent().getChildSuccessor(getTranslatedStmt(crtStmt))
|
||||
then result = getTranslatedStmt(crtStmt).getParent().getChildSuccessor(getTranslatedStmt(crtStmt))
|
||||
else result = getEnclosingLoopOrSwitchNextInstr(crtStmt.getParent())
|
||||
}
|
||||
|
||||
class TranslatedContinueStmt extends TranslatedSpecificJump {
|
||||
override ContinueStmt stmt;
|
||||
|
||||
override Instruction getTargetInstruction() {
|
||||
result = getEnclosingLoopTargetInstruction(stmt)
|
||||
}
|
||||
override Instruction getTargetInstruction() { result = getEnclosingLoopTargetInstruction(stmt) }
|
||||
}
|
||||
|
||||
private Instruction getEnclosingLoopTargetInstruction(Stmt crtStmt) {
|
||||
if crtStmt instanceof ForStmt
|
||||
then result = getNextForInstruction(crtStmt)
|
||||
else if crtStmt instanceof LoopStmt
|
||||
then result = getTranslatedStmt(crtStmt).getFirstInstruction()
|
||||
else result = getEnclosingLoopTargetInstruction(crtStmt.getParent())
|
||||
else
|
||||
if crtStmt instanceof LoopStmt
|
||||
then result = getTranslatedStmt(crtStmt).getFirstInstruction()
|
||||
else result = getEnclosingLoopTargetInstruction(crtStmt.getParent())
|
||||
}
|
||||
|
||||
private Instruction getNextForInstruction(ForStmt for) {
|
||||
if exists(for.getUpdate(0))
|
||||
then result = getTranslatedStmt(for).(TranslatedForStmt).getUpdate(0).getFirstInstruction()
|
||||
else if exists(for.getCondition())
|
||||
then result = getTranslatedStmt(for).(TranslatedForStmt).getCondition().getFirstInstruction()
|
||||
else result = getTranslatedStmt(for).(TranslatedForStmt).getBody().getFirstInstruction()
|
||||
else
|
||||
if exists(for.getCondition())
|
||||
then result = getTranslatedStmt(for).(TranslatedForStmt).getCondition().getFirstInstruction()
|
||||
else result = getTranslatedStmt(for).(TranslatedForStmt).getBody().getFirstInstruction()
|
||||
}
|
||||
|
||||
class TranslatedGotoLabelStmt extends TranslatedSpecificJump {
|
||||
@@ -1021,7 +1018,8 @@ class TranslatedUsingBlockStmt extends TranslatedStmt {
|
||||
result = this.getDecl(id + 1).getFirstInstruction()
|
||||
)
|
||||
or
|
||||
child = this.getDecl(this.getNumberOfDecls() - 1) and result = this.getBody().getFirstInstruction()
|
||||
child = this.getDecl(this.getNumberOfDecls() - 1) and
|
||||
result = this.getBody().getFirstInstruction()
|
||||
or
|
||||
child = this.getBody() and result = this.getParent().getChildSuccessor(this)
|
||||
}
|
||||
@@ -1047,7 +1045,7 @@ class TranslatedUsingBlockStmt extends TranslatedStmt {
|
||||
// more exact translation.
|
||||
class TranslatedUsingDeclStmt extends TranslatedStmt {
|
||||
override UsingDeclStmt stmt;
|
||||
|
||||
|
||||
override TranslatedElement getChild(int id) { result = getDecl(id) }
|
||||
|
||||
override Instruction getFirstInstruction() { result = this.getDecl(0).getFirstInstruction() }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Contains an abstract class that serves as a Base for classes that deal with the translation of calls
|
||||
* (both AST generated and compiler generated).
|
||||
*/
|
||||
* Contains an abstract class that serves as a Base for classes that deal with the translation of calls
|
||||
* (both AST generated and compiler generated).
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.ir.implementation.Opcode
|
||||
@@ -14,7 +14,7 @@ private import semmle.code.csharp.ir.internal.IRCSharpLanguage as Language
|
||||
private import TranslatedExprBase
|
||||
|
||||
abstract class TranslatedCallBase extends TranslatedElement {
|
||||
override final TranslatedElement getChild(int id) {
|
||||
final override TranslatedElement getChild(int id) {
|
||||
// We choose the child's id in the order of evaluation.
|
||||
// Note: some calls do need qualifiers, though instructions for them have already
|
||||
// been generated; eg. a constructor does not need to generate a qualifier,
|
||||
@@ -174,9 +174,7 @@ abstract class TranslatedCallBase extends TranslatedElement {
|
||||
/**
|
||||
* Holds if the call has any arguments, not counting the `this` argument.
|
||||
*/
|
||||
final predicate hasArguments() {
|
||||
exists(getArgument(0))
|
||||
}
|
||||
final predicate hasArguments() { exists(getArgument(0)) }
|
||||
|
||||
predicate hasReadSideEffect() { any() }
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Contains an abstract class that serves as a Base for classes that deal with the translation of exprs
|
||||
* Contains an abstract class that serves as a Base for classes that deal with the translation of exprs
|
||||
* (both AST generated and compiler generated).
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ predicate hasPositionalArgIndex(int argIndex) {
|
||||
// correct number of parameters; it is an overestimation,
|
||||
// since we don't care about all the callables, so it
|
||||
// should be restricted more
|
||||
argIndex in [0..any(CSharp::Callable c).getNumberOfParameters() - 1]
|
||||
argIndex in [0 .. any(CSharp::Callable c).getNumberOfParameters() - 1]
|
||||
}
|
||||
|
||||
predicate hasAsmOperandIndex(int operandIndex) { none() }
|
||||
|
||||
@@ -9,8 +9,7 @@ Type getVariableType(Variable v) {
|
||||
exists(Type declaredType |
|
||||
declaredType = v.getType() and
|
||||
if v instanceof Parameter
|
||||
then
|
||||
result = declaredType
|
||||
then result = declaredType
|
||||
else
|
||||
if declaredType instanceof ArrayType
|
||||
then
|
||||
|
||||
Reference in New Issue
Block a user