mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C++: Fix missing flow by also generating final global uses for functions that have a post-update node for the global variable.
This commit is contained in:
@@ -332,6 +332,13 @@ private module IndirectInstructions {
|
||||
|
||||
import IndirectInstructions
|
||||
|
||||
predicate isPostUpdateNodeImpl(Operand operand, int indirectionIndex) {
|
||||
operand = any(FieldAddress fa).getObjectAddressOperand() and
|
||||
indirectionIndex = [0 .. Ssa::countIndirectionsForCppType(Ssa::getLanguageType(operand))]
|
||||
or
|
||||
Ssa::isModifiableByCall(operand, indirectionIndex)
|
||||
}
|
||||
|
||||
/** Gets the callable in which this node occurs. */
|
||||
DataFlowCallable nodeGetEnclosingCallable(Node n) { result = n.getEnclosingCallable() }
|
||||
|
||||
|
||||
@@ -42,11 +42,7 @@ private newtype TIRDataFlowNode =
|
||||
[getMinIndirectionsForType(var.getUnspecifiedType()) .. SsaImpl::getMaxIndirectionsForType(var.getUnspecifiedType())]
|
||||
} or
|
||||
TPostUpdateNodeImpl(Operand operand, int indirectionIndex) {
|
||||
operand = any(FieldAddress fa).getObjectAddressOperand() and
|
||||
indirectionIndex =
|
||||
[0 .. SsaImpl::countIndirectionsForCppType(SsaImpl::getLanguageType(operand))]
|
||||
or
|
||||
SsaImpl::isModifiableByCall(operand, indirectionIndex)
|
||||
isPostUpdateNodeImpl(operand, indirectionIndex)
|
||||
} or
|
||||
TSsaSynthNode(SsaImpl::SynthNode n) or
|
||||
TSsaIteratorNode(IteratorFlow::IteratorFlowNode n) or
|
||||
|
||||
@@ -143,7 +143,14 @@ private predicate isGlobalUse(
|
||||
min(int cand, VariableAddressInstruction vai |
|
||||
vai.getEnclosingIRFunction() = f and
|
||||
vai.getAstVariable() = v and
|
||||
isDef(_, _, _, vai, cand, indirectionIndex)
|
||||
(
|
||||
isDef(_, _, _, vai, cand, indirectionIndex)
|
||||
or
|
||||
exists(Operand operand |
|
||||
isUse(_, operand, vai, cand, indirectionIndex) and
|
||||
isPostUpdateNodeImpl(operand, indirectionIndex)
|
||||
)
|
||||
)
|
||||
|
|
||||
cand
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user