Skip to content

Commit 4614372

Browse files
author
Dave Bartolomeo
committed
C++/C#: Add QLDoc
1 parent 6c12b59 commit 4614372

File tree

5 files changed

+140
-55
lines changed

5 files changed

+140
-55
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,49 @@ private newtype TOperand =
2323
defInstr = Construction::getPhiOperandDefinition(useInstr, predecessorBlock, overlap)
2424
}
2525

26-
private class OperandBase extends TOperand {
26+
/**
27+
* Base class for all register operands. This is a placeholder for the IPA union type that we will
28+
* eventually use for this purpose.
29+
*/
30+
private class RegisterOperandBase extends TRegisterOperand {
2731
abstract string toString();
2832
}
2933

30-
private class RegisterOperandBase extends OperandBase, TRegisterOperand {
31-
abstract override string toString();
32-
}
33-
34+
/**
35+
* Returns the register operand with the specified parameters.
36+
*/
3437
private RegisterOperandBase registerOperand(
3538
Instruction useInstr, RegisterOperandTag tag, Instruction defInstr
3639
) {
3740
result = TRegisterOperand(useInstr, tag, defInstr)
3841
}
3942

40-
private class NonPhiMemoryOperandBase extends OperandBase, TNonPhiMemoryOperand {
41-
abstract override string toString();
43+
/**
44+
* Base class for all non-Phi memory operands. This is a placeholder for the IPA union type that we
45+
* will eventually use for this purpose.
46+
*/
47+
private class NonPhiMemoryOperandBase extends TNonPhiMemoryOperand {
48+
abstract string toString();
4249
}
4350

51+
/**
52+
* Returns the non-Phi memory operand with the specified parameters.
53+
*/
4454
private NonPhiMemoryOperandBase nonPhiMemoryOperand(Instruction useInstr, MemoryOperandTag tag) {
4555
result = TNonPhiMemoryOperand(useInstr, tag)
4656
}
4757

48-
private class PhiOperandBase extends OperandBase, TPhiOperand {
49-
abstract override string toString();
58+
/**
59+
* Base class for all Phi operands. This is a placeholder for the IPA union type that we will
60+
* eventually use for this purpose.
61+
*/
62+
private class PhiOperandBase extends TPhiOperand {
63+
abstract string toString();
5064
}
5165

66+
/**
67+
* Returns the Phi operand with the specified parameters.
68+
*/
5269
private PhiOperandBase phiOperand(
5370
Instruction useInstr, Instruction defInstr, IRBlock predecessorBlock, Overlap overlap
5471
) {
@@ -58,8 +75,8 @@ private PhiOperandBase phiOperand(
5875
/**
5976
* A source operand of an `Instruction`. The operand represents a value consumed by the instruction.
6077
*/
61-
class Operand extends OperandBase {
62-
override string toString() { result = "Operand" }
78+
class Operand extends TOperand {
79+
string toString() { result = "Operand" }
6380

6481
final Language::Location getLocation() { result = getUse().getLocation() }
6582

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Operand.qll

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,49 @@ private newtype TOperand =
2323
defInstr = Construction::getPhiOperandDefinition(useInstr, predecessorBlock, overlap)
2424
}
2525

26-
private class OperandBase extends TOperand {
26+
/**
27+
* Base class for all register operands. This is a placeholder for the IPA union type that we will
28+
* eventually use for this purpose.
29+
*/
30+
private class RegisterOperandBase extends TRegisterOperand {
2731
abstract string toString();
2832
}
2933

30-
private class RegisterOperandBase extends OperandBase, TRegisterOperand {
31-
abstract override string toString();
32-
}
33-
34+
/**
35+
* Returns the register operand with the specified parameters.
36+
*/
3437
private RegisterOperandBase registerOperand(
3538
Instruction useInstr, RegisterOperandTag tag, Instruction defInstr
3639
) {
3740
result = TRegisterOperand(useInstr, tag, defInstr)
3841
}
3942

40-
private class NonPhiMemoryOperandBase extends OperandBase, TNonPhiMemoryOperand {
41-
abstract override string toString();
43+
/**
44+
* Base class for all non-Phi memory operands. This is a placeholder for the IPA union type that we
45+
* will eventually use for this purpose.
46+
*/
47+
private class NonPhiMemoryOperandBase extends TNonPhiMemoryOperand {
48+
abstract string toString();
4249
}
4350

51+
/**
52+
* Returns the non-Phi memory operand with the specified parameters.
53+
*/
4454
private NonPhiMemoryOperandBase nonPhiMemoryOperand(Instruction useInstr, MemoryOperandTag tag) {
4555
result = TNonPhiMemoryOperand(useInstr, tag)
4656
}
4757

48-
private class PhiOperandBase extends OperandBase, TPhiOperand {
49-
abstract override string toString();
58+
/**
59+
* Base class for all Phi operands. This is a placeholder for the IPA union type that we will
60+
* eventually use for this purpose.
61+
*/
62+
private class PhiOperandBase extends TPhiOperand {
63+
abstract string toString();
5064
}
5165

66+
/**
67+
* Returns the Phi operand with the specified parameters.
68+
*/
5269
private PhiOperandBase phiOperand(
5370
Instruction useInstr, Instruction defInstr, IRBlock predecessorBlock, Overlap overlap
5471
) {
@@ -58,8 +75,8 @@ private PhiOperandBase phiOperand(
5875
/**
5976
* A source operand of an `Instruction`. The operand represents a value consumed by the instruction.
6077
*/
61-
class Operand extends OperandBase {
62-
override string toString() { result = "Operand" }
78+
class Operand extends TOperand {
79+
string toString() { result = "Operand" }
6380

6481
final Language::Location getLocation() { result = getUse().getLocation() }
6582

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Operand.qll

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,49 @@ private newtype TOperand =
2323
defInstr = Construction::getPhiOperandDefinition(useInstr, predecessorBlock, overlap)
2424
}
2525

26-
private class OperandBase extends TOperand {
26+
/**
27+
* Base class for all register operands. This is a placeholder for the IPA union type that we will
28+
* eventually use for this purpose.
29+
*/
30+
private class RegisterOperandBase extends TRegisterOperand {
2731
abstract string toString();
2832
}
2933

30-
private class RegisterOperandBase extends OperandBase, TRegisterOperand {
31-
abstract override string toString();
32-
}
33-
34+
/**
35+
* Returns the register operand with the specified parameters.
36+
*/
3437
private RegisterOperandBase registerOperand(
3538
Instruction useInstr, RegisterOperandTag tag, Instruction defInstr
3639
) {
3740
result = TRegisterOperand(useInstr, tag, defInstr)
3841
}
3942

40-
private class NonPhiMemoryOperandBase extends OperandBase, TNonPhiMemoryOperand {
41-
abstract override string toString();
43+
/**
44+
* Base class for all non-Phi memory operands. This is a placeholder for the IPA union type that we
45+
* will eventually use for this purpose.
46+
*/
47+
private class NonPhiMemoryOperandBase extends TNonPhiMemoryOperand {
48+
abstract string toString();
4249
}
4350

51+
/**
52+
* Returns the non-Phi memory operand with the specified parameters.
53+
*/
4454
private NonPhiMemoryOperandBase nonPhiMemoryOperand(Instruction useInstr, MemoryOperandTag tag) {
4555
result = TNonPhiMemoryOperand(useInstr, tag)
4656
}
4757

48-
private class PhiOperandBase extends OperandBase, TPhiOperand {
49-
abstract override string toString();
58+
/**
59+
* Base class for all Phi operands. This is a placeholder for the IPA union type that we will
60+
* eventually use for this purpose.
61+
*/
62+
private class PhiOperandBase extends TPhiOperand {
63+
abstract string toString();
5064
}
5165

66+
/**
67+
* Returns the Phi operand with the specified parameters.
68+
*/
5269
private PhiOperandBase phiOperand(
5370
Instruction useInstr, Instruction defInstr, IRBlock predecessorBlock, Overlap overlap
5471
) {
@@ -58,8 +75,8 @@ private PhiOperandBase phiOperand(
5875
/**
5976
* A source operand of an `Instruction`. The operand represents a value consumed by the instruction.
6077
*/
61-
class Operand extends OperandBase {
62-
override string toString() { result = "Operand" }
78+
class Operand extends TOperand {
79+
string toString() { result = "Operand" }
6380

6481
final Language::Location getLocation() { result = getUse().getLocation() }
6582

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Operand.qll

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,49 @@ private newtype TOperand =
2323
defInstr = Construction::getPhiOperandDefinition(useInstr, predecessorBlock, overlap)
2424
}
2525

26-
private class OperandBase extends TOperand {
26+
/**
27+
* Base class for all register operands. This is a placeholder for the IPA union type that we will
28+
* eventually use for this purpose.
29+
*/
30+
private class RegisterOperandBase extends TRegisterOperand {
2731
abstract string toString();
2832
}
2933

30-
private class RegisterOperandBase extends OperandBase, TRegisterOperand {
31-
abstract override string toString();
32-
}
33-
34+
/**
35+
* Returns the register operand with the specified parameters.
36+
*/
3437
private RegisterOperandBase registerOperand(
3538
Instruction useInstr, RegisterOperandTag tag, Instruction defInstr
3639
) {
3740
result = TRegisterOperand(useInstr, tag, defInstr)
3841
}
3942

40-
private class NonPhiMemoryOperandBase extends OperandBase, TNonPhiMemoryOperand {
41-
abstract override string toString();
43+
/**
44+
* Base class for all non-Phi memory operands. This is a placeholder for the IPA union type that we
45+
* will eventually use for this purpose.
46+
*/
47+
private class NonPhiMemoryOperandBase extends TNonPhiMemoryOperand {
48+
abstract string toString();
4249
}
4350

51+
/**
52+
* Returns the non-Phi memory operand with the specified parameters.
53+
*/
4454
private NonPhiMemoryOperandBase nonPhiMemoryOperand(Instruction useInstr, MemoryOperandTag tag) {
4555
result = TNonPhiMemoryOperand(useInstr, tag)
4656
}
4757

48-
private class PhiOperandBase extends OperandBase, TPhiOperand {
49-
abstract override string toString();
58+
/**
59+
* Base class for all Phi operands. This is a placeholder for the IPA union type that we will
60+
* eventually use for this purpose.
61+
*/
62+
private class PhiOperandBase extends TPhiOperand {
63+
abstract string toString();
5064
}
5165

66+
/**
67+
* Returns the Phi operand with the specified parameters.
68+
*/
5269
private PhiOperandBase phiOperand(
5370
Instruction useInstr, Instruction defInstr, IRBlock predecessorBlock, Overlap overlap
5471
) {
@@ -58,8 +75,8 @@ private PhiOperandBase phiOperand(
5875
/**
5976
* A source operand of an `Instruction`. The operand represents a value consumed by the instruction.
6077
*/
61-
class Operand extends OperandBase {
62-
override string toString() { result = "Operand" }
78+
class Operand extends TOperand {
79+
string toString() { result = "Operand" }
6380

6481
final Language::Location getLocation() { result = getUse().getLocation() }
6582

csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Operand.qll

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,49 @@ private newtype TOperand =
2323
defInstr = Construction::getPhiOperandDefinition(useInstr, predecessorBlock, overlap)
2424
}
2525

26-
private class OperandBase extends TOperand {
26+
/**
27+
* Base class for all register operands. This is a placeholder for the IPA union type that we will
28+
* eventually use for this purpose.
29+
*/
30+
private class RegisterOperandBase extends TRegisterOperand {
2731
abstract string toString();
2832
}
2933

30-
private class RegisterOperandBase extends OperandBase, TRegisterOperand {
31-
abstract override string toString();
32-
}
33-
34+
/**
35+
* Returns the register operand with the specified parameters.
36+
*/
3437
private RegisterOperandBase registerOperand(
3538
Instruction useInstr, RegisterOperandTag tag, Instruction defInstr
3639
) {
3740
result = TRegisterOperand(useInstr, tag, defInstr)
3841
}
3942

40-
private class NonPhiMemoryOperandBase extends OperandBase, TNonPhiMemoryOperand {
41-
abstract override string toString();
43+
/**
44+
* Base class for all non-Phi memory operands. This is a placeholder for the IPA union type that we
45+
* will eventually use for this purpose.
46+
*/
47+
private class NonPhiMemoryOperandBase extends TNonPhiMemoryOperand {
48+
abstract string toString();
4249
}
4350

51+
/**
52+
* Returns the non-Phi memory operand with the specified parameters.
53+
*/
4454
private NonPhiMemoryOperandBase nonPhiMemoryOperand(Instruction useInstr, MemoryOperandTag tag) {
4555
result = TNonPhiMemoryOperand(useInstr, tag)
4656
}
4757

48-
private class PhiOperandBase extends OperandBase, TPhiOperand {
49-
abstract override string toString();
58+
/**
59+
* Base class for all Phi operands. This is a placeholder for the IPA union type that we will
60+
* eventually use for this purpose.
61+
*/
62+
private class PhiOperandBase extends TPhiOperand {
63+
abstract string toString();
5064
}
5165

66+
/**
67+
* Returns the Phi operand with the specified parameters.
68+
*/
5269
private PhiOperandBase phiOperand(
5370
Instruction useInstr, Instruction defInstr, IRBlock predecessorBlock, Overlap overlap
5471
) {
@@ -58,8 +75,8 @@ private PhiOperandBase phiOperand(
5875
/**
5976
* A source operand of an `Instruction`. The operand represents a value consumed by the instruction.
6077
*/
61-
class Operand extends OperandBase {
62-
override string toString() { result = "Operand" }
78+
class Operand extends TOperand {
79+
string toString() { result = "Operand" }
6380

6481
final Language::Location getLocation() { result = getUse().getLocation() }
6582

0 commit comments

Comments
 (0)