mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge master into next.
This commit is contained in:
@@ -190,30 +190,40 @@ private Type elementType(RefType t) {
|
||||
)
|
||||
}
|
||||
|
||||
private predicate upcastEnhancedForStmtAux(BaseSsaUpdate v, RefType t, RefType t1, RefType t2) {
|
||||
exists(EnhancedForStmt for |
|
||||
for.getVariable() = v.getDefiningExpr() and
|
||||
v.getSourceVariable().getType().getErasure() = t2 and
|
||||
t = boxIfNeeded(elementType(for.getExpr().getType())) and
|
||||
t.getErasure() = t1
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `v` is the iteration variable of an enhanced for statement, `t` is
|
||||
* the type of the elements being iterated over, and this type is more precise
|
||||
* than the type of `v`.
|
||||
*/
|
||||
private predicate upcastEnhancedForStmt(BaseSsaUpdate v, RefType t) {
|
||||
exists(EnhancedForStmt for, RefType t1, RefType t2 |
|
||||
for.getVariable() = v.getDefiningExpr() and
|
||||
v.getSourceVariable().getType().getErasure() = t2 and
|
||||
t = boxIfNeeded(elementType(for.getExpr().getType())) and
|
||||
t.getErasure() = t1 and
|
||||
exists(RefType t1, RefType t2 |
|
||||
upcastEnhancedForStmtAux(v, t, t1, t2) and
|
||||
t1.getASourceSupertype+() = t2
|
||||
)
|
||||
}
|
||||
|
||||
private predicate downcastSuccessorAux(CastExpr cast, BaseSsaVariable v, RefType t, RefType t1, RefType t2) {
|
||||
cast.getExpr() = v.getAUse() and
|
||||
t = cast.getType() and
|
||||
t1 = t.getErasure() and
|
||||
t2 = v.getSourceVariable().getType().getErasure()
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `va` is an access to a value that has previously been downcast to `t`.
|
||||
*/
|
||||
private predicate downcastSuccessor(VarAccess va, RefType t) {
|
||||
exists(CastExpr cast, BaseSsaVariable v, RefType t1, RefType t2 |
|
||||
cast.getExpr() = v.getAUse() and
|
||||
t = cast.getType() and
|
||||
t1 = t.getErasure() and
|
||||
t2 = v.getSourceVariable().getType().getErasure() and
|
||||
downcastSuccessorAux(cast, v, t, t1, t2) and
|
||||
t1.getASourceSupertype+() = t2 and
|
||||
va = v.getAUse() and
|
||||
dominates(cast, va) and
|
||||
|
||||
@@ -70,9 +70,12 @@ class XMLParent extends @xmlparent {
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED: Internal.
|
||||
*
|
||||
* Append the character sequences of this XML parent from left to right, separated by a space,
|
||||
* up to a specified (zero-based) index.
|
||||
*/
|
||||
deprecated
|
||||
string charsSetUpTo(int n) {
|
||||
n = 0 and xmlChars(_,result,this,0,_,_)
|
||||
or
|
||||
@@ -84,10 +87,7 @@ class XMLParent extends @xmlparent {
|
||||
|
||||
/** Append all the character sequences of this XML parent from left to right, separated by a space. */
|
||||
string allCharactersString() {
|
||||
exists(int n | n = this.getNumberOfCharacterSets() |
|
||||
(n = 0 and result = "") or
|
||||
(n > 0 and result = this.charsSetUpTo(n-1))
|
||||
)
|
||||
result = concat(string chars, int pos | xmlChars(_, chars, this, pos, _, _) | chars, " " order by pos)
|
||||
}
|
||||
|
||||
/** Gets the text value contained in this XML parent. */
|
||||
|
||||
Reference in New Issue
Block a user