Skip to content

Commit b8fab9a

Browse files
committed
C++: Respond to review comments.
1 parent 1f43a1a commit b8fab9a

File tree

3 files changed

+84
-84
lines changed

3 files changed

+84
-84
lines changed

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,86 @@ private import DataFlowImplConsistency
66
private import semmle.code.cpp.ir.internal.IRCppLanguage
77
private import SsaInternals as Ssa
88

9+
/**
10+
* INTERNAL: Do not use.
11+
*
12+
* A node that represents the indirect value of an operand in the IR
13+
* after `index` number of loads.
14+
*
15+
* Note: Unlike `RawIndirectOperand`, a value of type `IndirectOperand` may
16+
* be an `OperandNode`.
17+
*/
18+
class IndirectOperand extends Node {
19+
Operand operand;
20+
int indirectionIndex;
21+
22+
IndirectOperand() {
23+
this.(RawIndirectOperand).getOperand() = operand and
24+
this.(RawIndirectOperand).getIndirectionIndex() = indirectionIndex
25+
or
26+
this.(OperandNode).getOperand() =
27+
Ssa::getIRRepresentationOfIndirectOperand(operand, indirectionIndex)
28+
}
29+
30+
/** Gets the underlying operand. */
31+
Operand getOperand() { result = operand }
32+
33+
/** Gets the underlying indirection index. */
34+
int getIndirectionIndex() { result = indirectionIndex }
35+
36+
/**
37+
* Holds if this `IndirectOperand` is represented directly in the IR instead of
38+
* a `RawIndirectionOperand` with operand `op` and indirection index `index`.
39+
*/
40+
predicate isIRRepresentationOf(Operand op, int index) {
41+
this instanceof OperandNode and
42+
(
43+
op = operand and
44+
index = indirectionIndex
45+
)
46+
}
47+
}
48+
49+
/**
50+
* INTERNAL: Do not use.
51+
*
52+
* A node that represents the indirect value of an instruction in the IR
53+
* after `index` number of loads.
54+
*
55+
* Note: Unlike `RawIndirectInstruction`, a value of type `IndirectInstruction` may
56+
* be an `InstructionNode`.
57+
*/
58+
class IndirectInstruction extends Node {
59+
Instruction instr;
60+
int indirectionIndex;
61+
62+
IndirectInstruction() {
63+
this.(RawIndirectInstruction).getInstruction() = instr and
64+
this.(RawIndirectInstruction).getIndirectionIndex() = indirectionIndex
65+
or
66+
this.(InstructionNode).getInstruction() =
67+
Ssa::getIRRepresentationOfIndirectInstruction(instr, indirectionIndex)
68+
}
69+
70+
/** Gets the underlying instruction. */
71+
Instruction getInstruction() { result = instr }
72+
73+
/** Gets the underlying indirection index. */
74+
int getIndirectionIndex() { result = indirectionIndex }
75+
76+
/**
77+
* Holds if this `IndirectInstruction` is represented directly in the IR instead of
78+
* a `RawIndirectionInstruction` with instruction `i` and indirection index `index`.
79+
*/
80+
predicate isIRRepresentationOf(Instruction i, int index) {
81+
this instanceof InstructionNode and
82+
(
83+
i = instr and
84+
index = indirectionIndex
85+
)
86+
}
87+
}
88+
989
/** Gets the callable in which this node occurs. */
1090
DataFlowCallable nodeGetEnclosingCallable(Node n) { result = n.getEnclosingCallable() }
1191

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

Lines changed: 2 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ private Type getTypeImpl(Type t, int indirectionIndex) {
637637
* A node that represents the indirect value of an operand in the IR
638638
* after `index` number of loads.
639639
*/
640-
private class RawIndirectOperand extends Node, TRawIndirectOperand {
640+
class RawIndirectOperand extends Node, TRawIndirectOperand {
641641
Operand operand;
642642
int indirectionIndex;
643643

@@ -666,46 +666,6 @@ private class RawIndirectOperand extends Node, TRawIndirectOperand {
666666
}
667667
}
668668

669-
/**
670-
* INTERNAL: Do not use.
671-
*
672-
* A node that represents the indirect value of an operand in the IR
673-
* after `index` number of loads.
674-
*
675-
* Note: Unlike `RawIndirectOperand`, a value of type `IndirectOperand` may
676-
* be an `OperandNode`.
677-
*/
678-
class IndirectOperand extends Node {
679-
Operand operand;
680-
int indirectionIndex;
681-
682-
IndirectOperand() {
683-
this.(RawIndirectOperand).getOperand() = operand and
684-
this.(RawIndirectOperand).getIndirectionIndex() = indirectionIndex
685-
or
686-
this.(OperandNode).getOperand() =
687-
Ssa::getIRRepresentationOfIndirectOperand(operand, indirectionIndex)
688-
}
689-
690-
/** Gets the underlying operand. */
691-
Operand getOperand() { result = operand }
692-
693-
/** Gets the underlying indirection index. */
694-
int getIndirectionIndex() { result = indirectionIndex }
695-
696-
/**
697-
* Holds if this `IndirectOperand` is represented directly in the IR instead of
698-
* a `RawIndirectionOperand` with operand `op` and indirection index `index`.
699-
*/
700-
predicate isIRRepresentationOf(Operand op, int index) {
701-
this instanceof OperandNode and
702-
(
703-
op = operand and
704-
index = indirectionIndex
705-
)
706-
}
707-
}
708-
709669
/**
710670
* The value of an uninitialized local variable, viewed as a node in a data
711671
* flow graph.
@@ -731,7 +691,7 @@ class UninitializedNode extends Node {
731691
* A node that represents the indirect value of an instruction in the IR
732692
* after `index` number of loads.
733693
*/
734-
private class RawIndirectInstruction extends Node, TRawIndirectInstruction {
694+
class RawIndirectInstruction extends Node, TRawIndirectInstruction {
735695
Instruction instr;
736696
int indirectionIndex;
737697

@@ -760,46 +720,6 @@ private class RawIndirectInstruction extends Node, TRawIndirectInstruction {
760720
}
761721
}
762722

763-
/**
764-
* INTERNAL: Do not use.
765-
*
766-
* A node that represents the indirect value of an instruction in the IR
767-
* after `index` number of loads.
768-
*
769-
* Note: Unlike `RawIndirectInstruction`, a value of type `IndirectInstruction` may
770-
* be an `InstructionNode`.
771-
*/
772-
class IndirectInstruction extends Node {
773-
Instruction instr;
774-
int indirectionIndex;
775-
776-
IndirectInstruction() {
777-
this.(RawIndirectInstruction).getInstruction() = instr and
778-
this.(RawIndirectInstruction).getIndirectionIndex() = indirectionIndex
779-
or
780-
this.(InstructionNode).getInstruction() =
781-
Ssa::getIRRepresentationOfIndirectInstruction(instr, indirectionIndex)
782-
}
783-
784-
/** Gets the underlying instruction. */
785-
Instruction getInstruction() { result = instr }
786-
787-
/** Gets the underlying indirection index. */
788-
int getIndirectionIndex() { result = indirectionIndex }
789-
790-
/**
791-
* Holds if this `IndirectInstruction` is represented directly in the IR instead of
792-
* a `RawIndirectionInstruction` with instruction `i` and indirection index `index`.
793-
*/
794-
predicate isIRRepresentationOf(Instruction i, int index) {
795-
this instanceof InstructionNode and
796-
(
797-
i = instr and
798-
index = indirectionIndex
799-
)
800-
}
801-
}
802-
803723
private predicate isFullyConvertedArgument(Expr e) {
804724
exists(Call call |
805725
e = call.getAnArgument().getFullyConverted()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ import SourceVariables
8888

8989
/**
9090
* Holds if the `(operand, indirectionIndex)` columns should be
91-
* assigned an `RawIndirectOperand` value.
91+
* assigned a `RawIndirectOperand` value.
9292
*/
9393
predicate hasRawIndirectOperand(Operand op, int indirectionIndex) {
9494
exists(CppType type, int m |
@@ -102,7 +102,7 @@ predicate hasRawIndirectOperand(Operand op, int indirectionIndex) {
102102

103103
/**
104104
* Holds if the `(instr, indirectionIndex)` columns should be
105-
* assigned an `RawIndirectInstruction` value.
105+
* assigned a `RawIndirectInstruction` value.
106106
*/
107107
predicate hasRawIndirectInstruction(Instruction instr, int indirectionIndex) {
108108
exists(CppType type, int m |

0 commit comments

Comments
 (0)