Skip to content

Commit 99c6a32

Browse files
author
AndreiDiaconu1
committed
Autoformat
1 parent 0e32639 commit 99c6a32

File tree

7 files changed

+27
-32
lines changed

7 files changed

+27
-32
lines changed

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ private predicate canCreateCompilerGeneratedElement(Element generatedBy, int nth
3333
generatedBy instanceof DelegateCreation and
3434
nth in [0 .. DelegateElements::noGeneratedElements(generatedBy)]
3535
or
36-
generatedBy instanceof DelegateCall and nth in [0 .. DelegateElements::noGeneratedElements(generatedBy)]
36+
generatedBy instanceof DelegateCall and
37+
nth in [0 .. DelegateElements::noGeneratedElements(generatedBy)]
3738
}
3839

3940
/**
@@ -90,7 +91,7 @@ private predicate ignoreExprOnly(Expr expr) {
9091
// Ignore the child expression of a goto case stmt
9192
expr.getParent() instanceof GotoCaseStmt
9293
or
93-
// Ignore the expression (that is not a declaration)
94+
// Ignore the expression (that is not a declaration)
9495
// that appears in a using block
9596
expr.getParent().(UsingBlockStmt).getExpr() = expr
9697
}
@@ -228,9 +229,7 @@ newtype TTranslatedElement =
228229
// Because of their implementation in C#,
229230
// we deal with all the types of initialization separately.
230231
// First only simple local variable initialization (ie. `int x = 0`)
231-
exists(LocalVariableDeclAndInitExpr lvInit |
232-
lvInit.getInitializer() = expr
233-
)
232+
exists(LocalVariableDeclAndInitExpr lvInit | lvInit.getInitializer() = expr)
234233
or
235234
// Then treat more complex ones
236235
expr instanceof ArrayInitializer

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/TranslatedStmt.qll

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -750,40 +750,37 @@ abstract class TranslatedSpecificJump extends TranslatedStmt {
750750
class TranslatedBreakStmt extends TranslatedSpecificJump {
751751
override BreakStmt stmt;
752752

753-
override Instruction getTargetInstruction() {
754-
result = getEnclosingLoopOrSwitchNextInstr(stmt)
755-
}
753+
override Instruction getTargetInstruction() { result = getEnclosingLoopOrSwitchNextInstr(stmt) }
756754
}
757755

758756
private Instruction getEnclosingLoopOrSwitchNextInstr(Stmt crtStmt) {
759757
if crtStmt instanceof LoopStmt or crtStmt instanceof SwitchStmt
760-
then
761-
result = getTranslatedStmt(crtStmt).getParent().getChildSuccessor(getTranslatedStmt(crtStmt))
758+
then result = getTranslatedStmt(crtStmt).getParent().getChildSuccessor(getTranslatedStmt(crtStmt))
762759
else result = getEnclosingLoopOrSwitchNextInstr(crtStmt.getParent())
763760
}
764761

765762
class TranslatedContinueStmt extends TranslatedSpecificJump {
766763
override ContinueStmt stmt;
767764

768-
override Instruction getTargetInstruction() {
769-
result = getEnclosingLoopTargetInstruction(stmt)
770-
}
765+
override Instruction getTargetInstruction() { result = getEnclosingLoopTargetInstruction(stmt) }
771766
}
772767

773768
private Instruction getEnclosingLoopTargetInstruction(Stmt crtStmt) {
774769
if crtStmt instanceof ForStmt
775770
then result = getNextForInstruction(crtStmt)
776-
else if crtStmt instanceof LoopStmt
777-
then result = getTranslatedStmt(crtStmt).getFirstInstruction()
778-
else result = getEnclosingLoopTargetInstruction(crtStmt.getParent())
771+
else
772+
if crtStmt instanceof LoopStmt
773+
then result = getTranslatedStmt(crtStmt).getFirstInstruction()
774+
else result = getEnclosingLoopTargetInstruction(crtStmt.getParent())
779775
}
780776

781777
private Instruction getNextForInstruction(ForStmt for) {
782778
if exists(for.getUpdate(0))
783779
then result = getTranslatedStmt(for).(TranslatedForStmt).getUpdate(0).getFirstInstruction()
784-
else if exists(for.getCondition())
785-
then result = getTranslatedStmt(for).(TranslatedForStmt).getCondition().getFirstInstruction()
786-
else result = getTranslatedStmt(for).(TranslatedForStmt).getBody().getFirstInstruction()
780+
else
781+
if exists(for.getCondition())
782+
then result = getTranslatedStmt(for).(TranslatedForStmt).getCondition().getFirstInstruction()
783+
else result = getTranslatedStmt(for).(TranslatedForStmt).getBody().getFirstInstruction()
787784
}
788785

789786
class TranslatedGotoLabelStmt extends TranslatedSpecificJump {
@@ -1021,7 +1018,8 @@ class TranslatedUsingBlockStmt extends TranslatedStmt {
10211018
result = this.getDecl(id + 1).getFirstInstruction()
10221019
)
10231020
or
1024-
child = this.getDecl(this.getNumberOfDecls() - 1) and result = this.getBody().getFirstInstruction()
1021+
child = this.getDecl(this.getNumberOfDecls() - 1) and
1022+
result = this.getBody().getFirstInstruction()
10251023
or
10261024
child = this.getBody() and result = this.getParent().getChildSuccessor(this)
10271025
}
@@ -1047,7 +1045,7 @@ class TranslatedUsingBlockStmt extends TranslatedStmt {
10471045
// more exact translation.
10481046
class TranslatedUsingDeclStmt extends TranslatedStmt {
10491047
override UsingDeclStmt stmt;
1050-
1048+
10511049
override TranslatedElement getChild(int id) { result = getDecl(id) }
10521050

10531051
override Instruction getFirstInstruction() { result = this.getDecl(0).getFirstInstruction() }

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/common/TranslatedCallBase.qll

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* Contains an abstract class that serves as a Base for classes that deal with the translation of calls
3-
* (both AST generated and compiler generated).
4-
*/
2+
* Contains an abstract class that serves as a Base for classes that deal with the translation of calls
3+
* (both AST generated and compiler generated).
4+
*/
55

66
import csharp
77
private import semmle.code.csharp.ir.implementation.Opcode
@@ -14,7 +14,7 @@ private import semmle.code.csharp.ir.internal.IRCSharpLanguage as Language
1414
private import TranslatedExprBase
1515

1616
abstract class TranslatedCallBase extends TranslatedElement {
17-
override final TranslatedElement getChild(int id) {
17+
final override TranslatedElement getChild(int id) {
1818
// We choose the child's id in the order of evaluation.
1919
// Note: some calls do need qualifiers, though instructions for them have already
2020
// been generated; eg. a constructor does not need to generate a qualifier,
@@ -174,9 +174,7 @@ abstract class TranslatedCallBase extends TranslatedElement {
174174
/**
175175
* Holds if the call has any arguments, not counting the `this` argument.
176176
*/
177-
final predicate hasArguments() {
178-
exists(getArgument(0))
179-
}
177+
final predicate hasArguments() { exists(getArgument(0)) }
180178

181179
predicate hasReadSideEffect() { any() }
182180

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/common/TranslatedExprBase.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Contains an abstract class that serves as a Base for classes that deal with the translation of exprs
2+
* Contains an abstract class that serves as a Base for classes that deal with the translation of exprs
33
* (both AST generated and compiler generated).
44
*/
55

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

csharp/ql/src/semmle/code/csharp/ir/internal/IRCSharpLanguage.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ predicate hasPositionalArgIndex(int argIndex) {
7676
// correct number of parameters; it is an overestimation,
7777
// since we don't care about all the callables, so it
7878
// should be restricted more
79-
argIndex in [0..any(CSharp::Callable c).getNumberOfParameters() - 1]
79+
argIndex in [0 .. any(CSharp::Callable c).getNumberOfParameters() - 1]
8080
}
8181

8282
predicate hasAsmOperandIndex(int operandIndex) { none() }

csharp/ql/src/semmle/code/csharp/ir/internal/IRUtilities.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ Type getVariableType(Variable v) {
99
exists(Type declaredType |
1010
declaredType = v.getType() and
1111
if v instanceof Parameter
12-
then
13-
result = declaredType
12+
then result = declaredType
1413
else
1514
if declaredType instanceof ArrayType
1615
then

0 commit comments

Comments
 (0)