mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
Merge pull request #5854 from dbartol/dbartol/smart-pointers/side-effects
C++: Generate side effect instructions for smart pointer indirections
This commit is contained in:
@@ -416,3 +416,46 @@ predicate addressOperandAllocationAndOffset(
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Predicates used only for printing annotated IR dumps. These should not be used in production
|
||||
* queries.
|
||||
*/
|
||||
module Print {
|
||||
string getOperandProperty(Operand operand, string key) {
|
||||
key = "alloc" and
|
||||
result =
|
||||
strictconcat(Configuration::Allocation allocation, IntValue bitOffset |
|
||||
addressOperandAllocationAndOffset(operand, allocation, bitOffset)
|
||||
|
|
||||
allocation.toString() + Ints::getBitOffsetString(bitOffset), ", "
|
||||
)
|
||||
or
|
||||
key = "prop" and
|
||||
result =
|
||||
strictconcat(Instruction destInstr, IntValue bitOffset, string value |
|
||||
operandIsPropagatedIncludingByCall(operand, bitOffset, destInstr) and
|
||||
if destInstr = operand.getUse()
|
||||
then value = "@" + Ints::getBitOffsetString(bitOffset) + "->result"
|
||||
else value = "@" + Ints::getBitOffsetString(bitOffset) + "->" + destInstr.getResultId()
|
||||
|
|
||||
value, ", "
|
||||
)
|
||||
}
|
||||
|
||||
string getInstructionProperty(Instruction instr, string key) {
|
||||
key = "prop" and
|
||||
result =
|
||||
strictconcat(IntValue bitOffset, Operand sourceOperand, string value |
|
||||
operandIsPropagatedIncludingByCall(sourceOperand, bitOffset, instr) and
|
||||
if instr = sourceOperand.getUse()
|
||||
then value = sourceOperand.getDumpId() + Ints::getBitOffsetString(bitOffset) + "->@"
|
||||
else
|
||||
value =
|
||||
sourceOperand.getUse().getResultId() + "." + sourceOperand.getDumpId() +
|
||||
Ints::getBitOffsetString(bitOffset) + "->@"
|
||||
|
|
||||
value, ", "
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1073,7 +1073,10 @@ module SSAConsistency {
|
||||
locationCount > 1 and
|
||||
func = operand.getEnclosingIRFunction() and
|
||||
funcText = Language::getIdentityString(func.getFunction()) and
|
||||
message = "Operand has " + locationCount.toString() + " memory accesses in function '$@'."
|
||||
message =
|
||||
operand.getUse().toString() + " " + "Operand has " + locationCount.toString() +
|
||||
" memory accesses in function '$@': " +
|
||||
strictconcat(Alias::getOperandMemoryLocation(operand).toString(), ", ")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user