Skip to content

Commit e2feed7

Browse files
committed
C++: Generate SSA variables for all calls instead of just for calls to
allocators.
1 parent 560b876 commit e2feed7

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternals.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ abstract private class DefOrUseImpl extends TDefOrUseImpl {
193193

194194
/**
195195
* Gets the instruction that computes the base of this definition or use.
196-
* This is always a `VariableAddressInstruction` or an `AllocationInstruction`.
196+
* This is always a `VariableAddressInstruction` or an `CallInstruction`.
197197
*/
198198
abstract BaseSourceVariableInstruction getBase();
199199

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternalsCommon.qll

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,6 @@ int countIndirectionsForCppType(LanguageType langType) {
146146
)
147147
}
148148

149-
/**
150-
* A `CallInstruction` that calls an allocation function such
151-
* as `malloc` or `operator new`.
152-
*/
153-
class AllocationInstruction extends CallInstruction {
154-
AllocationInstruction() { this.getStaticCallTarget() instanceof Cpp::AllocationFunction }
155-
}
156-
157149
private predicate isIndirectionType(Type t) { t instanceof Indirection }
158150

159151
private predicate hasUnspecifiedBaseType(Indirection t, Type base) {
@@ -368,7 +360,7 @@ newtype TBaseSourceVariable =
368360
// Each IR variable gets its own source variable
369361
TBaseIRVariable(IRVariable var) or
370362
// Each allocation gets its own source variable
371-
TBaseCallVariable(AllocationInstruction call)
363+
TBaseCallVariable(CallInstruction call) { not call.getResultIRType() instanceof IRVoidType }
372364

373365
abstract private class AbstractBaseSourceVariable extends TBaseSourceVariable {
374366
/** Gets a textual representation of this element. */
@@ -396,11 +388,11 @@ class BaseIRVariable extends AbstractBaseSourceVariable, TBaseIRVariable {
396388
}
397389

398390
class BaseCallVariable extends AbstractBaseSourceVariable, TBaseCallVariable {
399-
AllocationInstruction call;
391+
CallInstruction call;
400392

401393
BaseCallVariable() { this = TBaseCallVariable(call) }
402394

403-
AllocationInstruction getCallInstruction() { result = call }
395+
CallInstruction getCallInstruction() { result = call }
404396

405397
override string toString() { result = call.toString() }
406398

@@ -504,8 +496,7 @@ private class BaseIRVariableInstruction extends BaseSourceVariableInstruction,
504496
override BaseIRVariable getBaseSourceVariable() { result.getIRVariable() = this.getIRVariable() }
505497
}
506498

507-
private class BaseAllocationInstruction extends BaseSourceVariableInstruction, AllocationInstruction
508-
{
499+
private class BaseCallInstruction extends BaseSourceVariableInstruction, CallInstruction {
509500
override BaseCallVariable getBaseSourceVariable() { result.getCallInstruction() = this }
510501
}
511502

0 commit comments

Comments
 (0)