Skip to content

Commit 42657db

Browse files
author
Dave Bartolomeo
committed
C++: Miscellaneous IR QLDoc
1 parent 1fa3847 commit 42657db

File tree

25 files changed

+88
-20
lines changed

25 files changed

+88
-20
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
/**
2+
* Module used to configure the IR generation process.
3+
*/
4+
15
import implementation.IRConfiguration
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
/**
2+
* Outputs a representation of the IR as a control flow graph.
3+
*
4+
* This file contains the actual implementation of `PrintIR.ql`. For test cases and very small
5+
* databases, `PrintIR.ql` can be run directly to dump the IR for the entire database. For most
6+
* uses, however, it is better to write a query that imports `PrintIR.qll`, extends
7+
* `PrintIRConfiguration`, and overrides `shouldPrintFunction()` to select a subset of functions to
8+
* dump.
9+
*/
10+
111
import implementation.aliased_ssa.PrintIR

cpp/ql/src/semmle/code/cpp/ir/implementation/IRType.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ private newtype TIRType =
3232
* all pointer types map to the same instance of `IRAddressType`.
3333
*/
3434
class IRType extends TIRType {
35+
/** Gets a textual representation of this type. */
3536
string toString() { none() }
3637

3738
/**

cpp/ql/src/semmle/code/cpp/ir/implementation/MemoryAccessKind.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Provides classes that describe how a particular `Instruction` or its operands access memory.
3+
*/
4+
5+
private import IRConfiguration
6+
17
private newtype TMemoryAccessKind =
28
TIndirectMemoryAccess() or
39
TBufferMemoryAccess() or
@@ -14,6 +20,7 @@ private newtype TMemoryAccessKind =
1420
* memory result.
1521
*/
1622
class MemoryAccessKind extends TMemoryAccessKind {
23+
/** Gets a textual representation of this access kind. */
1724
string toString() { none() }
1825

1926
/**

cpp/ql/src/semmle/code/cpp/ir/implementation/Opcode.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ private newtype TOpcode =
9191
TUnreached() or
9292
TNewObj()
9393

94+
/**
95+
* An opcode that specifies the operation performed by an `Instruction`.
96+
*/
9497
class Opcode extends TOpcode {
9598
/** Gets a textual representation of this element. */
9699
string toString() { result = "UnknownOpcode" }

cpp/ql/src/semmle/code/cpp/ir/implementation/TempVariableTag.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ private import Imports::TempVariableTag
1212
* computed on each branch. The set of possible `TempVariableTag`s is language-dependent.
1313
*/
1414
class TempVariableTag extends TTempVariableTag {
15+
/** Gets a textual representation of this tag. */
1516
string toString() { result = getTempVariableTagId(this) }
1617
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ private import Cached
2020
* Most consumers should use the class `IRBlock`.
2121
*/
2222
class IRBlockBase extends TIRBlock {
23+
/** Gets a textual representation of this block. */
2324
final string toString() { result = getFirstInstruction(this).toString() }
2425

2526
/** Gets the source location of the first non-`Phi` instruction in this block. */
@@ -282,4 +283,4 @@ private module Cached {
282283
idominance(isEntryBlock/1, blockSuccessor/2)(_, dominator, block)
283284
}
284285

285-
Instruction getFirstInstruction(TIRBlock block) { block = MkIRBlock(result) }
286+
private Instruction getFirstInstruction(TIRBlock block) { block = MkIRBlock(result) }

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Provides classes that represent variables accessed by the IR.
3+
*/
4+
15
private import internal.IRInternal
26
import IRFunction
37
private import internal.IRVariableImports as Imports

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
22
* Outputs a representation of the IR as a control flow graph.
33
*
4-
* This file contains the actual implementation of `PrintAST.ql`. For test cases and very small
5-
* databases, `PrintAST.ql` can be run directly to dump the IR for the entire database. For most
6-
* uses, however, it is better to write a query that imports `PrintAST.qll`, extends
4+
* This file contains the actual implementation of `PrintIR.ql`. For test cases and very small
5+
* databases, `PrintIR.ql` can be run directly to dump the IR for the entire database. For most
6+
* uses, however, it is better to write a query that imports `PrintIR.qll`, extends
77
* `PrintIRConfiguration`, and overrides `shouldPrintFunction()` to select a subset of functions to
88
* dump.
99
*/
@@ -19,6 +19,7 @@ private newtype TPrintIRConfiguration = MkPrintIRConfiguration()
1919
* The query can extend this class to control which functions are printed.
2020
*/
2121
class PrintIRConfiguration extends TPrintIRConfiguration {
22+
/** Gets a textual representation of this configuration. */
2223
string toString() { result = "PrintIRConfiguration" }
2324

2425
/**

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ private import Cached
2020
* Most consumers should use the class `IRBlock`.
2121
*/
2222
class IRBlockBase extends TIRBlock {
23+
/** Gets a textual representation of this block. */
2324
final string toString() { result = getFirstInstruction(this).toString() }
2425

2526
/** Gets the source location of the first non-`Phi` instruction in this block. */
@@ -282,4 +283,4 @@ private module Cached {
282283
idominance(isEntryBlock/1, blockSuccessor/2)(_, dominator, block)
283284
}
284285

285-
Instruction getFirstInstruction(TIRBlock block) { block = MkIRBlock(result) }
286+
private Instruction getFirstInstruction(TIRBlock block) { block = MkIRBlock(result) }

0 commit comments

Comments
 (0)