cache hasLocationInfo and Node::toString in the dataflow stage

This commit is contained in:
Erik Krogh Kristensen
2021-03-11 16:08:45 +01:00
parent 0edae89425
commit e5b13d9db4
2 changed files with 8 additions and 1 deletions

View File

@@ -149,6 +149,7 @@ module DataFlow {
* For more information, see
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
*/
cached
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
@@ -171,6 +172,7 @@ module DataFlow {
int getEndColumn() { hasLocationInfo(_, _, _, _, result) }
/** Gets a textual representation of this element. */
cached
string toString() { none() }
/**
@@ -294,12 +296,13 @@ module DataFlow {
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
Stages::DataFlowStage::ref() and
astNode.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override File getFile() { result = astNode.getFile() }
override string toString() { result = astNode.toString() }
override string toString() { Stages::DataFlowStage::ref() and result = astNode.toString() }
}
/**

View File

@@ -126,6 +126,10 @@ module Stages {
exists(any(Expr e).getExceptionTarget())
or
exists(DataFlow::ssaDefinitionNode(_))
or
any(DataFlow::Node node).hasLocationInfo(_, _, _, _, _)
or
exists(any(DataFlow::Node node).toString())
}
}