Skip to content

Commit 9cfd339

Browse files
committed
C++: Move 'getImpl' to a private non-member predicate.
1 parent be1af88 commit 9cfd339

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,10 +1079,18 @@ module SsaCached {
10791079
predicate variableWrite = SsaInput::variableWrite/4;
10801080
}
10811081

1082+
/** Gets the `DefImpl` corresponding to `def`. */
1083+
private DefImpl getDefImpl(SsaImpl::DefinitionExt def) {
1084+
exists(SourceVariable sv, IRBlock bb, int i |
1085+
def.definesAt(sv, bb, i, _) and
1086+
result.hasIndexInBlock(bb, i, sv)
1087+
)
1088+
}
1089+
10821090
class GlobalDef extends DefinitionExt {
10831091
GlobalDefImpl impl;
10841092

1085-
GlobalDef() { impl = this.getImpl() }
1093+
GlobalDef() { impl = getDefImpl(this) }
10861094

10871095
/**
10881096
* Gets the global (or `static` local) variable written to by this SSA
@@ -1142,38 +1150,30 @@ class DefinitionExt extends SsaImpl::DefinitionExt {
11421150
not result instanceof PhiNode
11431151
}
11441152

1145-
/** INTERNAL: Do not use. */
1146-
DefImpl getImpl() {
1147-
exists(SourceVariable sv, IRBlock bb, int i |
1148-
this.definesAt(sv, bb, i, _) and
1149-
result.hasIndexInBlock(bb, i, sv)
1150-
)
1151-
}
1152-
11531153
/**
11541154
* INTERNAL: Do not use.
11551155
*/
1156-
Node0Impl getValue() { result = this.getImpl().getValue() }
1156+
Node0Impl getValue() { result = getDefImpl(this).getValue() }
11571157

11581158
/** Gets the indirection index of this definition. */
1159-
int getIndirectionIndex() { result = this.getImpl().getIndirectionIndex() }
1159+
int getIndirectionIndex() { result = getDefImpl(this).getIndirectionIndex() }
11601160

11611161
/** Gets the indirection of this definition. */
1162-
int getIndirection() { result = this.getImpl().getIndirection() }
1162+
int getIndirection() { result = getDefImpl(this).getIndirection() }
11631163

11641164
/**
11651165
* Holds if this definition is guaranteed to totally overwrite the buffer
11661166
* being written to.
11671167
*/
1168-
predicate isCertain() { this.getImpl().isCertain() }
1168+
predicate isCertain() { getDefImpl(this).isCertain() }
11691169

11701170
/**
11711171
* Gets the enclosing declaration of this definition.
11721172
*
11731173
* Note that this may be a variable when this definition defines a global, or
11741174
* a static local, variable.
11751175
*/
1176-
Declaration getFunction() { result = this.getImpl().getBlock().getEnclosingFunction() }
1176+
Declaration getFunction() { result = getDefImpl(this).getBlock().getEnclosingFunction() }
11771177

11781178
/** Gets the underlying type of the variable being defined by this definition. */
11791179
Type getUnderlyingType() { result = this.getSourceVariable().getType() }

0 commit comments

Comments
 (0)