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

Skip to content

Commit 7ef0d5e

Browse files
committed
C++: respond to technical nits
1 parent 2b9afe9 commit 7ef0d5e

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ cached private module Cached {
183183
result instanceof UnmodeledDefinitionInstruction and
184184
instruction.getFunction() = result.getFunction()
185185
or
186-
result = getChiInstructionTotalOperand(instruction.(ChiInstruction), tag.(ChiTotalOperandTag))
186+
result = getChiInstructionTotalOperand(instruction)
187187
}
188188

189189
cached Instruction getPhiInstructionOperandDefinition(PhiInstruction instr,
@@ -203,7 +203,7 @@ cached private module Cached {
203203
)
204204
}
205205

206-
cached Instruction getChiInstructionTotalOperand(ChiInstruction chiInstr, ChiTotalOperandTag tag) {
206+
cached Instruction getChiInstructionTotalOperand(ChiInstruction chiInstr) {
207207
exists(Alias::VirtualVariable vvar, OldIR::Instruction oldInstr, OldIR::IRBlock defBlock,
208208
int defRank, int defIndex, OldIR::IRBlock useBlock, int useRank |
209209
ChiTag(oldInstr) = chiInstr.getTag() and
@@ -233,6 +233,11 @@ cached private module Cached {
233233
result = getOldInstruction(instruction).getUnconvertedResultExpression()
234234
}
235235

236+
/*
237+
* This adds Chi nodes to the instruction successor relation; if an instruction has a Chi node,
238+
* that node is its successor in the new successor relation, and the Chi node's successors are
239+
* the new instructions generated from the successors of the old instruction
240+
*/
236241
cached Instruction getInstructionSuccessor(Instruction instruction, EdgeKind kind) {
237242
if(hasChiNode(_, getOldInstruction(instruction)))
238243
then
@@ -331,6 +336,10 @@ cached private module Cached {
331336
(
332337
access = Alias::getOperandMemoryAccess(use.getAnOperand())
333338
or
339+
/*
340+
* a partial write to a virtual variable is going to generate a use of that variable when
341+
* Chi nodes are inserted, so we need to mark it as a use in the old IR
342+
*/
334343
access = Alias::getResultMemoryAccess(use) and
335344
access.isPartialMemoryAccess()
336345
) and
@@ -471,8 +480,7 @@ cached private module Cached {
471480
ma = Alias::getResultMemoryAccess(def) and
472481
ma.isPartialMemoryAccess() and
473482
ma.getVirtualVariable() = vvar
474-
) and
475-
not def instanceof OldIR::UnmodeledDefinitionInstruction
483+
)
476484
}
477485
}
478486

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ string getInstructionTagId(TInstructionTag tag) {
9494
tag = OnlyInstructionTag() and result = "Only" or // Single instruction (not including implicit Load)
9595
tag = InitializerVariableAddressTag() and result = "InitVarAddr" or
9696
tag = InitializerStoreTag() and result = "InitStore" or
97+
tag = InitializerUninitializedTag() and result = "InitUninit" or
9798
tag = ZeroPadStringConstantTag() and result = "ZeroPadConst" or
9899
tag = ZeroPadStringElementIndexTag() and result = "ZeroPadElemIndex" or
99100
tag = ZeroPadStringElementAddressTag() and result = "ZeroPadElemAddr" or
@@ -113,6 +114,7 @@ string getInstructionTagId(TInstructionTag tag) {
113114
tag = ExitFunctionTag() and result = "ExitFunc" or
114115
tag = UnmodeledDefinitionTag() and result = "UnmodeledDef" or
115116
tag = UnmodeledUseTag() and result = "UnmodeledUse" or
117+
tag = AliasedDefinitionTag() and result = "AliasedDef" or
116118
tag = SwitchBranchTag() and result = "SwitchBranch" or
117119
tag = CallTargetTag() and result = "CallTarget" or
118120
tag = CallTag() and result = "Call" or

0 commit comments

Comments
 (0)