Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ef9bf6

Browse files
Andrei DiaconuAndreiDiaconu1
authored andcommitted
Fixed whitespace errors in PR
1 parent 025d68f commit 7ef9bf6

5 files changed

Lines changed: 171 additions & 280 deletions

File tree

csharp/ql/src/semmle/code/csharp/ir/Util.qll

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,46 @@
22
* Temporary file that has stubs for various functionalities in the IR conversion.
33
*/
44

5-
65
import csharp
76

8-
class Locatable extends Element {
9-
10-
}
7+
class Locatable extends Element { }
118

129
class ArrayInitWithMod extends ArrayInitializer {
13-
predicate isInitialized(int entry) {
14-
entry in [0..this.getNumberOfElements() - 1]
15-
}
16-
17-
pragma[inline]
18-
predicate isValueInitialized(int elementIndex) {
19-
isInitialized(elementIndex) and
20-
not exists(this.getElement(elementIndex))
21-
}
10+
predicate isInitialized(int entry) { entry in [0 .. this.getNumberOfElements() - 1] }
11+
12+
pragma[inline]
13+
predicate isValueInitialized(int elementIndex) {
14+
isInitialized(elementIndex) and
15+
not exists(this.getElement(elementIndex))
16+
}
2217
}
2318

2419
class ObjectInitializerMod extends ObjectInitializer {
25-
private predicate isInitialized(Field field) {
26-
not (field.isReadOnly()) and // TODO: Is this the only instance whena field can not be init?
27-
this.getAMemberInitializer().getTargetVariable() = field
28-
}
29-
30-
pragma[inline]
31-
predicate isValueInitialized(Field field) {
32-
this.isInitialized(field) and
33-
not field = this.getAMemberInitializer().getInitializedMember()
34-
}
20+
private predicate isInitialized(Field field) {
21+
not field.isReadOnly() and // TODO: Is this the only instance whena field can not be init?
22+
this.getAMemberInitializer().getTargetVariable() = field
23+
}
24+
25+
pragma[inline]
26+
predicate isValueInitialized(Field field) {
27+
this.isInitialized(field) and
28+
not field = this.getAMemberInitializer().getInitializedMember()
29+
}
3530
}
3631

3732
// TODO: See if we need to adapt this for C#
3833
abstract class SideEffectCallable extends Callable {
3934
/**
40-
* Holds if the function never reads from memory that was defined before entry to the function.
41-
* This memory could be from global variables, or from other memory that was reachable from a
42-
* pointer that was passed into the function.
43-
*/
35+
* Holds if the function never reads from memory that was defined before entry to the function.
36+
* This memory could be from global variables, or from other memory that was reachable from a
37+
* pointer that was passed into the function.
38+
*/
4439
abstract predicate neverReadsMemory();
4540

4641
/**
47-
* Holds if the function never writes to memory that remains allocated after the function
48-
* returns. This memory could be from global variables, or from other memory that was reachable
49-
* from a pointer that was passed into the function.
50-
*/
42+
* Holds if the function never writes to memory that remains allocated after the function
43+
* returns. This memory could be from global variables, or from other memory that was reachable
44+
* from a pointer that was passed into the function.
45+
*/
5146
abstract predicate neverWritesMemory();
5247
}

csharp/ql/src/semmle/code/csharp/ir/implementation/EdgeKind.qll

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
// TODO: Fix the switch
2-
32
import csharp
43

54
private newtype TEdgeKind =
6-
TGotoEdge() or // Single successor (including fall-through)
7-
TTrueEdge() or // 'true' edge of conditional branch
8-
TFalseEdge() or // 'false' edge of conditional branch
9-
TExceptionEdge() or // Thrown exception
10-
TDefaultEdge() or // 'default' label of switch
5+
TGotoEdge() or // Single successor (including fall-through)
6+
TTrueEdge() or // 'true' edge of conditional branch
7+
TFalseEdge() or // 'false' edge of conditional branch
8+
TExceptionEdge() or // Thrown exception
9+
TDefaultEdge() or // 'default' label of switch
1110
TCaseEdge()
11+
1212
// TCaseEdge(Expr expr, string condition) { // Case label of switch
1313
// exists(CaseStmt caseStmt |
1414
// hasCaseEdge(caseStmt, minValue, maxValue)
1515
// )
1616
// }
17-
1817
/**
1918
* Represents the kind of an edge in the IR control flow graph. Each
2019
* `Instruction` or `IRBlock` has at most one successor of any single
@@ -29,81 +28,58 @@ abstract class EdgeKind extends TEdgeKind {
2928
* or `IRBlock`.
3029
*/
3130
class GotoEdge extends EdgeKind, TGotoEdge {
32-
override final string toString() {
33-
result = "Goto"
34-
}
31+
final override string toString() { result = "Goto" }
3532
}
3633

37-
GotoEdge gotoEdge() {
38-
result = TGotoEdge()
39-
}
34+
GotoEdge gotoEdge() { result = TGotoEdge() }
4035

4136
/**
4237
* A "true" edge, representing the successor of a conditional branch when the
4338
* condition is non-zero.
4439
*/
4540
class TrueEdge extends EdgeKind, TTrueEdge {
46-
override final string toString() {
47-
result = "True"
48-
}
41+
final override string toString() { result = "True" }
4942
}
5043

51-
TrueEdge trueEdge() {
52-
result = TTrueEdge()
53-
}
44+
TrueEdge trueEdge() { result = TTrueEdge() }
5445

5546
/**
5647
* A "false" edge, representing the successor of a conditional branch when the
5748
* condition is zero.
5849
*/
5950
class FalseEdge extends EdgeKind, TFalseEdge {
60-
override final string toString() {
61-
result = "False"
62-
}
51+
final override string toString() { result = "False" }
6352
}
6453

65-
FalseEdge falseEdge() {
66-
result = TFalseEdge()
67-
}
54+
FalseEdge falseEdge() { result = TFalseEdge() }
6855

6956
/**
7057
* An "exception" edge, representing the successor of an instruction when that
7158
* instruction's evaluation throws an exception.
7259
*/
7360
class ExceptionEdge extends EdgeKind, TExceptionEdge {
74-
override final string toString() {
75-
result = "Exception"
76-
}
61+
final override string toString() { result = "Exception" }
7762
}
7863

79-
ExceptionEdge exceptionEdge() {
80-
result = TExceptionEdge()
81-
}
64+
ExceptionEdge exceptionEdge() { result = TExceptionEdge() }
8265

8366
/**
8467
* A "default" edge, representing the successor of a `Switch` instruction when
8568
* none of the case values matches the condition value.
8669
*/
8770
class DefaultEdge extends EdgeKind, TDefaultEdge {
88-
override final string toString() {
89-
result = "Default"
90-
}
71+
final override string toString() { result = "Default" }
9172
}
9273

93-
DefaultEdge defaultEdge() {
94-
result = TDefaultEdge()
95-
}
74+
DefaultEdge defaultEdge() { result = TDefaultEdge() }
9675

9776
///**
9877
// * A "case" edge, representing the successor of a `Switch` instruction when the
9978
// * the condition value matches a correponding `case` label.
10079
// */
10180
class CaseEdge extends EdgeKind, TCaseEdge {
102-
override final string toString() {
103-
result = "CASE"
104-
}
81+
final override string toString() { result = "CASE" }
10582
}
106-
10783
//class CaseEdge extends EdgeKind, TCaseEdge {
10884
// string minValue;
10985
// string maxValue;

0 commit comments

Comments
 (0)