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

Skip to content

Commit 6bd22b0

Browse files
author
Robert Marsh
authored
Merge pull request #1607 from dave-bartolomeo/dave/CrossLanguageIR
C++: Start preparing IR for supporting multiple languages
2 parents 5125a41 + efa854e commit 6bd22b0

83 files changed

Lines changed: 636 additions & 509 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config/identical-files.json

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,46 +21,76 @@
2121
"cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImplCommon.qll",
2222
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImplCommon.qll"
2323
],
24-
"C++ IR Instruction": [
24+
"IR Instruction": [
2525
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll",
2626
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll",
2727
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll"
2828
],
29-
"C++ IR IRBlock": [
29+
"IR IRBlock": [
3030
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRBlock.qll",
3131
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRBlock.qll",
3232
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRBlock.qll"
3333
],
34-
"C++ IR IRVariable": [
34+
"IR IRVariable": [
3535
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRVariable.qll",
3636
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRVariable.qll",
3737
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRVariable.qll"
3838
],
39-
"C++ IR IRFunction": [
39+
"IR IRFunction": [
4040
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRFunction.qll",
4141
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRFunction.qll",
4242
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRFunction.qll"
4343
],
44-
"C++ IR Operand": [
44+
"IR Operand": [
4545
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Operand.qll",
4646
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Operand.qll",
4747
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll"
4848
],
49-
"C++ IR IRImpl": [
49+
"IR IR": [
5050
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IR.qll",
5151
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IR.qll",
5252
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IR.qll"
5353
],
54-
"C++ IR IRSanityImpl": [
54+
"IR IRSanity": [
5555
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRSanity.qll",
5656
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRSanity.qll",
5757
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRSanity.qll"
5858
],
59-
"C++ IR PrintIRImpl": [
59+
"IR PrintIR": [
6060
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/PrintIR.qll",
6161
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/PrintIR.qll",
6262
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/PrintIR.qll"
6363
],
64+
"C++ IR InstructionImports": [
65+
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/InstructionImports.qll",
66+
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/InstructionImports.qll",
67+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/InstructionImports.qll"
68+
],
69+
"C++ IR IRImports": [
70+
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/IRImports.qll",
71+
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/IRImports.qll",
72+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/IRImports.qll"
73+
],
74+
"C++ IR IRBlockImports": [
75+
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/IRBlockImports.qll",
76+
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/IRBlockImports.qll",
77+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/IRBlockImports.qll"
78+
],
79+
"C++ IR IRVariableImports": [
80+
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/IRVariableImports.qll",
81+
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/IRVariableImports.qll",
82+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/IRVariableImports.qll"
83+
],
84+
"C++ IR OperandImports": [
85+
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/OperandImports.qll",
86+
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/OperandImports.qll",
87+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/OperandImports.qll"
88+
],
89+
"C++ IR PrintIRImports": [
90+
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/PrintIRImports.qll",
91+
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/PrintIRImports.qll",
92+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/PrintIRImports.qll"
93+
],
6494
"C++ SSA AliasAnalysis": [
6595
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/AliasAnalysis.qll",
6696
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasAnalysis.qll"

cpp/ql/src/Likely Bugs/RedundantNullCheckSimple.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* LGTM until its performance is well understood.
1717
*/
1818

19+
import cpp
1920
import semmle.code.cpp.ir.IR
2021
import semmle.code.cpp.ir.ValueNumbering
2122

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1 @@
1-
import cpp
2-
3-
private newtype TIRConfiguration = MkIRConfiguration()
4-
5-
/**
6-
* The query can extend this class to control which functions have IR generated for them.
7-
*/
8-
class IRConfiguration extends TIRConfiguration {
9-
string toString() {
10-
result = "IRConfiguration"
11-
}
12-
13-
/**
14-
* Holds if IR should be created for function `func`. By default, holds for all functions.
15-
*/
16-
predicate shouldCreateIRForFunction(Function func) {
17-
any()
18-
}
19-
}
1+
import implementation.IRConfiguration

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowDispatch.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
private import cpp
12
private import semmle.code.cpp.ir.IR
23

34
Function viableImpl(CallInstruction call) { result = viableCallable(call) }

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

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import cpp
1+
private import internal.EdgeKindInternal
22

33
private newtype TEdgeKind =
44
TGotoEdge() or // Single successor (including fall-through)
@@ -7,9 +7,7 @@ private newtype TEdgeKind =
77
TExceptionEdge() or // Thrown exception
88
TDefaultEdge() or // 'default' label of switch
99
TCaseEdge(string minValue, string maxValue) { // Case label of switch
10-
exists(SwitchCase switchCase |
11-
hasCaseEdge(switchCase, minValue, maxValue)
12-
)
10+
Language::hasCaseEdge(minValue, maxValue)
1311
}
1412

1513
/**
@@ -122,20 +120,3 @@ class CaseEdge extends EdgeKind, TCaseEdge {
122120
CaseEdge caseEdge(string minValue, string maxValue) {
123121
result = TCaseEdge(minValue, maxValue)
124122
}
125-
126-
private predicate hasCaseEdge(SwitchCase switchCase, string minValue,
127-
string maxValue) {
128-
minValue = switchCase.getExpr().getFullyConverted().getValue() and
129-
if exists(switchCase.getEndExpr()) then
130-
maxValue = switchCase.getEndExpr().getFullyConverted().getValue()
131-
else
132-
maxValue = minValue
133-
}
134-
135-
EdgeKind getCaseEdge(SwitchCase switchCase) {
136-
exists(CaseEdge edge |
137-
result = edge and
138-
hasCaseEdge(switchCase, edge.getMinValue(), edge.getMaxValue())
139-
) or
140-
(switchCase instanceof DefaultCase and result instanceof DefaultEdge)
141-
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
private import internal.IRConfigurationInternal
2+
3+
private newtype TIRConfiguration = MkIRConfiguration()
4+
5+
/**
6+
* The query can extend this class to control which functions have IR generated for them.
7+
*/
8+
class IRConfiguration extends TIRConfiguration {
9+
string toString() {
10+
result = "IRConfiguration"
11+
}
12+
13+
/**
14+
* Holds if IR should be created for function `func`. By default, holds for all functions.
15+
*/
16+
predicate shouldCreateIRForFunction(Language::Function func) {
17+
any()
18+
}
19+
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import cpp
2-
31
private newtype TMemoryAccessKind =
42
TIndirectMemoryAccess() or
53
TIndirectMayMemoryAccess() or

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import cpp
21
private import semmle.code.cpp.ir.internal.TempVariableTag
32

43
class TempVariableTag extends TTempVariableTag {

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

Lines changed: 0 additions & 44 deletions
This file was deleted.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import Instruction
33
import IRBlock
44
import IRVariable
55
import Operand
6-
import semmle.code.cpp.ir.implementation.EdgeKind
7-
import semmle.code.cpp.ir.implementation.MemoryAccessKind
6+
private import internal.IRImports as Imports
7+
import Imports::EdgeKind
8+
import Imports::MemoryAccessKind
89

910
private newtype TIRPropertyProvider = MkIRPropertyProvider()
1011

0 commit comments

Comments
 (0)