Skip to content

Commit b5c0a0f

Browse files
committed
C++: remove all uses of Declaration::isDefined
1 parent 5ee6076 commit b5c0a0f

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

cpp/ql/src/JPL_C/LOC-3/Rule 17/BasicIntTypes.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ predicate allowedTypedefs(TypedefType t) {
3030
* Gets a type which appears literally in the declaration of `d`.
3131
*/
3232
Type getAnImmediateUsedType(Declaration d) {
33-
d.isDefined() and
33+
d.hasDefinition() and
3434
(
3535
result = d.(Function).getType() or
3636
result = d.(Variable).getType()

cpp/ql/src/Security/CWE/CWE-457/InitializationFunctions.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ class InitializationFunction extends Function {
198198
)
199199
or
200200
// If we have no definition, we look at SAL annotations
201-
not this.isDefined() and
201+
not this.hasDefinition() and
202202
this.getParameter(i).(SALParameter).isOut() and
203203
evidence = SuggestiveSALAnnotation()
204204
or
205205
// We have some external information that this function conditionally initializes
206-
not this.isDefined() and
206+
not this.hasDefinition() and
207207
any(ValidatedExternalCondInitFunction vc).isExternallyVerified(this, i) and
208208
evidence = ExternalEvidence()
209209
}
@@ -406,7 +406,7 @@ class ConditionalInitializationFunction extends InitializationFunction {
406406
* Explicitly ignore pure virtual functions.
407407
*/
408408

409-
this.isDefined() and
409+
this.hasDefinition() and
410410
this.paramNotReassignedAt(this, i, c) and
411411
not this instanceof PureVirtualFunction
412412
)
@@ -616,11 +616,11 @@ private predicate functionSignature(Function f, string qualifiedName, string typ
616616
* are never statically linked together.
617617
*/
618618
private Function getAPossibleDefinition(Function undefinedFunction) {
619-
not undefinedFunction.isDefined() and
619+
not undefinedFunction.hasDefinition() and
620620
exists(string qn, string typeSig |
621621
functionSignature(undefinedFunction, qn, typeSig) and functionSignature(result, qn, typeSig)
622622
) and
623-
result.isDefined()
623+
result.hasDefinition()
624624
}
625625

626626
/**
@@ -631,7 +631,7 @@ private Function getAPossibleDefinition(Function undefinedFunction) {
631631
*/
632632
private Function getTarget1(Call c) {
633633
result = VirtualDispatch::getAViableTarget(c) and
634-
result.isDefined()
634+
result.hasDefinition()
635635
}
636636

637637
/**

cpp/ql/src/semmle/code/cpp/Declaration.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ abstract class DeclarationEntry extends Locatable {
304304
* available), or the name declared by this entry otherwise.
305305
*/
306306
string getCanonicalName() {
307-
if getDeclaration().isDefined()
307+
if getDeclaration().hasDefinition()
308308
then result = getDeclaration().getDefinition().getName()
309309
else result = getName()
310310
}

cpp/ql/src/semmle/code/cpp/UserType.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class UserType extends Type, Declaration, NameQualifyingElement, AccessHolder, @
3838
override Specifier getASpecifier() { result = Type.super.getASpecifier() }
3939

4040
override Location getLocation() {
41-
if isDefined()
41+
if hasDefinition()
4242
then result = this.getDefinitionLocation()
4343
else result = this.getADeclarationLocation()
4444
}

cpp/ql/src/semmle/code/cpp/security/FunctionWithWrappers.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private predicate wrapperFunctionStep(
1919
) {
2020
not target.isVirtual() and
2121
not source.isVirtual() and
22-
source.isDefined() and
22+
source.hasDefinition() and
2323
exists(Call call, Expr arg, Parameter sourceParam |
2424
// there is a 'call' to 'target' with argument 'arg' at index 'targetParamIndex'
2525
target = resolveCall(call) and

cpp/ql/test/library-tests/templates/prototype_bodies/isdef_hasblock.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import cpp
33
// It should be the case that "f.isDefined()" is equivalent to "exists(f.getBlock())".
44
from Function f, string isdef, string hasblock
55
where
6-
(if f.isDefined() then isdef = "defined" else isdef = "not defined") and
6+
(if f.hasDefinition() then isdef = "defined" else isdef = "not defined") and
77
(if exists(f.getBlock()) then hasblock = "has block" else hasblock = "no block")
88
select f.getName(), isdef, hasblock

0 commit comments

Comments
 (0)