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

Skip to content

Commit ba730b6

Browse files
committed
Fix failing tests
1 parent 5f18840 commit ba730b6

24 files changed

Lines changed: 88 additions & 44 deletions

File tree

csharp/ql/src/semmle/code/csharp/PrintAst.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ private newtype TPrintAstNode =
136136
TAttributesNode(Attributable attributable) {
137137
shouldPrint(attributable, _) and
138138
exists(attributable.getAnAttribute()) and
139+
exists(Attribute a | a = attributable.getAnAttribute() | shouldPrint(a, _)) and
139140
not isNotNeeded(attributable)
140141
} or
141142
TTypeParametersNode(UnboundGeneric unboundGeneric) {
@@ -298,7 +299,10 @@ class ControlFlowElementNode extends ElementNode {
298299
controlFlowElement.getParent*()
299300
)
300301
) and
301-
not isNotNeeded(element.getParent+())
302+
not isNotNeeded(element.getParent+()) and
303+
// LambdaExpr is both a Callable and a ControlFlowElement,
304+
// print it with the more specific CallableNode
305+
not element instanceof Callable
302306
}
303307

304308
override PrintAstNode getChild(int childIndex) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import csharp
22

33
from Expr argument
4+
where argument.fromSource()
45
select argument, argument.getExplicitArgumentName()

csharp/ql/test/library-tests/controlflow/graph/BasicBlock.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ import csharp
22
import Common
33

44
from SourceBasicBlock bb
5+
where bb.getLocation().getFile().fromSource()
56
select bb.getFirstNode(), bb.getLastNode(), bb.length()

csharp/ql/test/library-tests/controlflow/graph/Dominance.ql

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@ import csharp
22
import Common
33

44
query predicate dominance(SourceControlFlowNode dom, SourceControlFlowNode node) {
5-
dom.strictlyDominates(node) and dom.getASuccessor() = node
5+
dom.strictlyDominates(node) and
6+
dom.getASuccessor() = node and
7+
dom.getLocation().getFile().fromSource()
68
}
79

810
query predicate postDominance(SourceControlFlowNode dom, SourceControlFlowNode node) {
9-
dom.strictlyPostDominates(node) and dom.getAPredecessor() = node
11+
dom.strictlyPostDominates(node) and
12+
dom.getAPredecessor() = node and
13+
dom.getLocation().getFile().fromSource()
1014
}
1115

12-
query predicate blockDominance(SourceBasicBlock dom, SourceBasicBlock bb) { dom.dominates(bb) }
16+
query predicate blockDominance(SourceBasicBlock dom, SourceBasicBlock bb) {
17+
dom.dominates(bb) and
18+
dom.getLocation().getFile().fromSource()
19+
}
1320

1421
query predicate postBlockDominance(SourceBasicBlock dom, SourceBasicBlock bb) {
15-
dom.postDominates(bb)
22+
dom.postDominates(bb) and
23+
dom.getLocation().getFile().fromSource()
1624
}

csharp/ql/test/library-tests/controlflow/graph/EntryElement.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import Common
33
import ControlFlow::Internal
44

55
from SourceControlFlowElement cfe
6+
where cfe.fromSource()
67
select cfe, first(cfe)

csharp/ql/test/library-tests/controlflow/graph/ExitElement.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ private import semmle.code.csharp.controlflow.internal.Completion
44
import Common
55

66
from SourceControlFlowElement cfe, Completion c
7+
where cfe.fromSource()
78
select cfe, last(cfe, c), c

csharp/ql/test/library-tests/controlflow/graph/NodeGraph.ql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import Common
44
query predicate edges(
55
SourceControlFlowNode node, SourceControlFlowNode successor, string attr, string val
66
) {
7-
exists(ControlFlow::SuccessorType t | successor = node.getASuccessorByType(t) |
7+
exists(ControlFlow::SuccessorType t |
8+
successor = node.getASuccessorByType(t) and
9+
(node.getElement().fromSource() or successor.getElement().fromSource())
10+
|
811
attr = "semmle.label" and
912
val = t.toString()
1013
)
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import csharp
22
private import semmle.code.csharp.controlflow.Guards
33

4-
query predicate abstractValue(AbstractValue value, Expr e) { e = value.getAnExpr() }
4+
query predicate abstractValue(AbstractValue value, Expr e) {
5+
e = value.getAnExpr() and e.fromSource()
6+
}
57

68
query predicate dualValue(AbstractValue value, AbstractValue dual) { dual = value.getDualValue() }
79

8-
query predicate singletonValue(AbstractValue value) { value.isSingleton() }
10+
query predicate singletonValue(AbstractValue value) {
11+
value.isSingleton() and value.getAnExpr().fromSource()
12+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import csharp
22

33
query predicate countSplits(ControlFlowElement cfe, int i) {
4-
i = strictcount(ControlFlow::Nodes::ElementNode n | n.getElement() = cfe)
4+
i = strictcount(ControlFlow::Nodes::ElementNode n | n.getElement() = cfe and cfe.fromSource())
55
}
66

7-
query predicate ssaDef(Ssa::Definition def) { any() }
7+
query predicate ssaDef(Ssa::Definition def) { def.getLocation().getFile().fromSource() }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import csharp
22

33
from IntLiteral l
4+
where l.fromSource()
45
select l

0 commit comments

Comments
 (0)