Skip to content

Commit 07c1520

Browse files
author
Dave Bartolomeo
committed
C++/C#: Move ast out of TRawInstruction
1 parent 2aabe43 commit 07c1520

File tree

6 files changed

+27
-28
lines changed

6 files changed

+27
-28
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ private module Cached {
4444
class TStageInstruction =
4545
TRawInstruction or TPhiInstruction or TChiInstruction or TUnreachedInstruction;
4646

47-
private TRawInstruction rawInstruction(IRFunctionBase irFunc, Opcode opcode, Language::AST ast) {
48-
result = TRawInstruction(irFunc, opcode, ast, _, _) and
47+
private TRawInstruction rawInstruction(IRFunctionBase irFunc, Opcode opcode) {
48+
result = TRawInstruction(irFunc, opcode, _, _) and
4949
result instanceof OldInstruction
5050
}
5151

@@ -265,7 +265,7 @@ private module Cached {
265265

266266
cached
267267
Language::AST getInstructionAST(Instruction instr) {
268-
instr = rawInstruction(_, _, result)
268+
result = getOldInstruction(instr).getAST()
269269
or
270270
exists(RawIR::Instruction blockStartInstr |
271271
instr = phiInstruction(_, blockStartInstr, _) and
@@ -302,7 +302,7 @@ private module Cached {
302302

303303
cached
304304
Opcode getInstructionOpcode(Instruction instr) {
305-
instr = rawInstruction(_, result, _)
305+
instr = rawInstruction(_, result)
306306
or
307307
instr = phiInstruction(_, _, _) and result instanceof Opcode::Phi
308308
or
@@ -313,7 +313,7 @@ private module Cached {
313313

314314
cached
315315
IRFunctionBase getInstructionEnclosingIRFunction(Instruction instr) {
316-
instr = rawInstruction(result, _, _)
316+
instr = rawInstruction(result, _)
317317
or
318318
instr = phiInstruction(result, _, _)
319319
or

cpp/ql/src/semmle/code/cpp/ir/implementation/internal/TInstruction.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ private import Imports::Opcode
1515
cached
1616
newtype TInstruction =
1717
TRawInstruction(
18-
IRFunctionBase irFunc, Opcode opcode, Language::AST ast,
19-
IRConstruction::Raw::InstructionTag1 tag1, IRConstruction::Raw::InstructionTag2 tag2
18+
IRFunctionBase irFunc, Opcode opcode, IRConstruction::Raw::InstructionTag1 tag1,
19+
IRConstruction::Raw::InstructionTag2 tag2
2020
) {
21-
IRConstruction::Raw::hasInstruction(irFunc.getFunction(), opcode, ast, tag1, tag2)
21+
IRConstruction::Raw::hasInstruction(irFunc.getFunction(), opcode, tag1, tag2)
2222
} or
2323
TUnaliasedSSAPhiInstruction(
2424
IRFunctionBase irFunc, TRawInstruction blockStartInstr,

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ private import TranslatedStmt
1515
private import TranslatedFunction
1616

1717
TranslatedElement getInstructionTranslatedElement(Instruction instruction) {
18-
instruction = TRawInstruction(_, _, _, result, _)
18+
instruction = TRawInstruction(_, _, result, _)
1919
}
2020

2121
InstructionTag getInstructionTag(Instruction instruction) {
22-
instruction = TRawInstruction(_, _, _, _, result)
22+
instruction = TRawInstruction(_, _, _, result)
2323
}
2424

2525
pragma[noinline]
@@ -45,10 +45,9 @@ module Raw {
4545

4646
cached
4747
predicate hasInstruction(
48-
Function func, Opcode opcode, Element ast, TranslatedElement element, InstructionTag tag
48+
Function func, Opcode opcode, TranslatedElement element, InstructionTag tag
4949
) {
5050
element.hasInstruction(opcode, tag, _) and
51-
ast = element.getAST() and
5251
func = element.getFunction()
5352
}
5453

@@ -370,7 +369,7 @@ private module Cached {
370369

371370
cached
372371
Locatable getInstructionAST(TStageInstruction instr) {
373-
instr = TRawInstruction(_, _, result, _, _)
372+
result = getInstructionTranslatedElement(instr).getAST()
374373
}
375374

376375
cached
@@ -383,12 +382,12 @@ private module Cached {
383382

384383
cached
385384
Opcode getInstructionOpcode(TStageInstruction instr) {
386-
instr = TRawInstruction(_, result, _, _, _)
385+
instr = TRawInstruction(_, result, _, _)
387386
}
388387

389388
cached
390389
IRFunctionBase getInstructionEnclosingIRFunction(TStageInstruction instr) {
391-
instr = TRawInstruction(result, _, _, _, _)
390+
instr = TRawInstruction(result, _, _, _)
392391
}
393392

394393
cached

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ private module Cached {
4444
class TStageInstruction =
4545
TRawInstruction or TPhiInstruction or TChiInstruction or TUnreachedInstruction;
4646

47-
private TRawInstruction rawInstruction(IRFunctionBase irFunc, Opcode opcode, Language::AST ast) {
48-
result = TRawInstruction(irFunc, opcode, ast, _, _) and
47+
private TRawInstruction rawInstruction(IRFunctionBase irFunc, Opcode opcode) {
48+
result = TRawInstruction(irFunc, opcode, _, _) and
4949
result instanceof OldInstruction
5050
}
5151

@@ -265,7 +265,7 @@ private module Cached {
265265

266266
cached
267267
Language::AST getInstructionAST(Instruction instr) {
268-
instr = rawInstruction(_, _, result)
268+
result = getOldInstruction(instr).getAST()
269269
or
270270
exists(RawIR::Instruction blockStartInstr |
271271
instr = phiInstruction(_, blockStartInstr, _) and
@@ -302,7 +302,7 @@ private module Cached {
302302

303303
cached
304304
Opcode getInstructionOpcode(Instruction instr) {
305-
instr = rawInstruction(_, result, _)
305+
instr = rawInstruction(_, result)
306306
or
307307
instr = phiInstruction(_, _, _) and result instanceof Opcode::Phi
308308
or
@@ -313,7 +313,7 @@ private module Cached {
313313

314314
cached
315315
IRFunctionBase getInstructionEnclosingIRFunction(Instruction instr) {
316-
instr = rawInstruction(result, _, _)
316+
instr = rawInstruction(result, _)
317317
or
318318
instr = phiInstruction(result, _, _)
319319
or

csharp/ql/src/experimental/ir/implementation/internal/TInstruction.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ private import Imports::Opcode
1515
cached
1616
newtype TInstruction =
1717
TRawInstruction(
18-
IRFunctionBase irFunc, Opcode opcode, Language::AST ast,
19-
IRConstruction::Raw::InstructionTag1 tag1, IRConstruction::Raw::InstructionTag2 tag2
18+
IRFunctionBase irFunc, Opcode opcode, IRConstruction::Raw::InstructionTag1 tag1,
19+
IRConstruction::Raw::InstructionTag2 tag2
2020
) {
21-
IRConstruction::Raw::hasInstruction(irFunc.getFunction(), opcode, ast, tag1, tag2)
21+
IRConstruction::Raw::hasInstruction(irFunc.getFunction(), opcode, tag1, tag2)
2222
} or
2323
TUnaliasedSSAPhiInstruction(
2424
IRFunctionBase irFunc, TRawInstruction blockStartInstr,

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ private module Cached {
4444
class TStageInstruction =
4545
TRawInstruction or TPhiInstruction or TChiInstruction or TUnreachedInstruction;
4646

47-
private TRawInstruction rawInstruction(IRFunctionBase irFunc, Opcode opcode, Language::AST ast) {
48-
result = TRawInstruction(irFunc, opcode, ast, _, _) and
47+
private TRawInstruction rawInstruction(IRFunctionBase irFunc, Opcode opcode) {
48+
result = TRawInstruction(irFunc, opcode, _, _) and
4949
result instanceof OldInstruction
5050
}
5151

@@ -265,7 +265,7 @@ private module Cached {
265265

266266
cached
267267
Language::AST getInstructionAST(Instruction instr) {
268-
instr = rawInstruction(_, _, result)
268+
result = getOldInstruction(instr).getAST()
269269
or
270270
exists(RawIR::Instruction blockStartInstr |
271271
instr = phiInstruction(_, blockStartInstr, _) and
@@ -302,7 +302,7 @@ private module Cached {
302302

303303
cached
304304
Opcode getInstructionOpcode(Instruction instr) {
305-
instr = rawInstruction(_, result, _)
305+
instr = rawInstruction(_, result)
306306
or
307307
instr = phiInstruction(_, _, _) and result instanceof Opcode::Phi
308308
or
@@ -313,7 +313,7 @@ private module Cached {
313313

314314
cached
315315
IRFunctionBase getInstructionEnclosingIRFunction(Instruction instr) {
316-
instr = rawInstruction(result, _, _)
316+
instr = rawInstruction(result, _)
317317
or
318318
instr = phiInstruction(result, _, _)
319319
or

0 commit comments

Comments
 (0)