Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3261612

Browse files
committed
C++: Exclude void-typed instructions from 'DataFlow::Node'. These nodes can never contain any data so we don't need dataflow nodes for them.
1 parent fafc0b5 commit 3261612

2 files changed

Lines changed: 8 additions & 1094 deletions

File tree

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ private module Cached {
3333
*/
3434
cached
3535
newtype TIRDataFlowNode =
36-
TInstructionNode(Instruction i) { not Ssa::ignoreInstruction(i) } or
36+
TInstructionNode(Instruction i) {
37+
not Ssa::ignoreInstruction(i) and
38+
// We exclude `void`-typed instructions because they cannot contain data.
39+
// However, if the instruction is a glvalue, and their type is `void`, then the result
40+
// type of the instruction is really `void*`, and thus we still want to have a dataflow
41+
// node for it.
42+
(not i.getResultType() instanceof VoidType or i.isGLValue())
43+
} or
3744
TOperandNode(Operand op) { not Ssa::ignoreOperand(op) } or
3845
TVariableNode(Variable var) or
3946
TPostFieldUpdateNode(FieldAddress operand, int indirectionIndex) {

0 commit comments

Comments
 (0)