Address review comments

This commit is contained in:
Tamas Vajk
2021-04-09 13:39:37 +02:00
parent dbb3d3dc17
commit 46197e6e69
4 changed files with 10 additions and 13 deletions

View File

@@ -2,5 +2,4 @@ import csharp
import Common
from SourceBasicBlock bb
where not bb.getFirstNode().getElement().fromLibrary()
select bb.getFirstNode(), bb.getLastNode(), bb.length()

View File

@@ -11,9 +11,15 @@ class SourceControlFlowElement extends ControlFlowElement {
}
class SourceControlFlowNode extends ControlFlow::Node {
SourceControlFlowNode() { not this.getLocation().getFile() instanceof StubFile }
SourceControlFlowNode() {
not this.getLocation().getFile() instanceof StubFile and
not this.getLocation().getFile().fromLibrary()
}
}
class SourceBasicBlock extends ControlFlow::BasicBlock {
SourceBasicBlock() { not this.getLocation().getFile() instanceof StubFile }
SourceBasicBlock() {
not this.getLocation().getFile() instanceof StubFile and
not this.getLocation().getFile().fromLibrary()
}
}

View File

@@ -1,25 +1,18 @@
import csharp
import Common
/** Holds if `node` is not from a library. */
private predicate isSourceBased(SourceControlFlowNode node) { not node.getElement().fromLibrary() }
query predicate dominance(SourceControlFlowNode dom, SourceControlFlowNode node) {
isSourceBased(dom) and
dom.strictlyDominates(node) and
dom.getASuccessor() = node
}
query predicate postDominance(SourceControlFlowNode dom, SourceControlFlowNode node) {
isSourceBased(dom) and
dom.strictlyPostDominates(node) and
dom.getAPredecessor() = node
}
query predicate blockDominance(SourceBasicBlock dom, SourceBasicBlock bb) {
isSourceBased(dom.getFirstNode()) and dom.dominates(bb)
}
query predicate blockDominance(SourceBasicBlock dom, SourceBasicBlock bb) { dom.dominates(bb) }
query predicate postBlockDominance(SourceBasicBlock dom, SourceBasicBlock bb) {
isSourceBased(dom.getFirstNode()) and dom.postDominates(bb)
dom.postDominates(bb)
}

View File

@@ -4,7 +4,6 @@ import Common
query predicate edges(
SourceControlFlowNode node, SourceControlFlowNode successor, string attr, string val
) {
not node.getElement().fromLibrary() and
exists(ControlFlow::SuccessorType t | successor = node.getASuccessorByType(t) |
attr = "semmle.label" and
val = t.toString()