mirror of
https://github.com/github/codeql.git
synced 2025-12-21 03:06:31 +01:00
JS: Rewrite mayHaveStringValue to avoid misoptimization
This commit is contained in:
@@ -118,7 +118,11 @@ module DataFlow {
|
|||||||
predicate accessesGlobal(string g) { globalVarRef(g).flowsTo(this) }
|
predicate accessesGlobal(string g) { globalVarRef(g).flowsTo(this) }
|
||||||
|
|
||||||
/** Holds if this node may evaluate to the string `s`, possibly through local data flow. */
|
/** Holds if this node may evaluate to the string `s`, possibly through local data flow. */
|
||||||
predicate mayHaveStringValue(string s) { getAPredecessor().mayHaveStringValue(s) }
|
predicate mayHaveStringValue(string s) {
|
||||||
|
getAPredecessor().mayHaveStringValue(s)
|
||||||
|
or
|
||||||
|
s = getStringValue()
|
||||||
|
}
|
||||||
|
|
||||||
/** Gets the string value of this node, if it is a string literal or constant string concatenation. */
|
/** Gets the string value of this node, if it is a string literal or constant string concatenation. */
|
||||||
string getStringValue() { result = asExpr().getStringValue() }
|
string getStringValue() { result = asExpr().getStringValue() }
|
||||||
@@ -297,11 +301,6 @@ module DataFlow {
|
|||||||
/** Gets the expression or declaration this node corresponds to. */
|
/** Gets the expression or declaration this node corresponds to. */
|
||||||
override AST::ValueNode getAstNode() { result = astNode }
|
override AST::ValueNode getAstNode() { result = astNode }
|
||||||
|
|
||||||
override predicate mayHaveStringValue(string s) {
|
|
||||||
Node.super.mayHaveStringValue(s) or
|
|
||||||
astNode.(ConstantString).getStringValue() = s
|
|
||||||
}
|
|
||||||
|
|
||||||
override BasicBlock getBasicBlock() { astNode = result.getANode() }
|
override BasicBlock getBasicBlock() { astNode = result.getANode() }
|
||||||
|
|
||||||
override predicate hasLocationInfo(
|
override predicate hasLocationInfo(
|
||||||
|
|||||||
Reference in New Issue
Block a user