Skip to content

Commit 472c93a

Browse files
Add changes to join order and prevent cartesian product through rewrite
1 parent ed088be commit 472c93a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

cpp/common/src/codingstandards/cpp/types/Compatible.qll

+14-4
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ module TypesCompatibleConfig implements TypeEquivalenceSig {
5353
or
5454
// Enum types are compatible with one of char, int, or signed int, but the implementation
5555
// decides.
56-
[t1, t2] instanceof Enum and
57-
([t1, t2] instanceof CharType or [t1, t2] instanceof IntType)
56+
t1 instanceof Enum and
57+
(t2 instanceof CharType or t2 instanceof IntType)
58+
or
59+
t2 instanceof Enum and
60+
(t1 instanceof CharType or t1 instanceof IntType)
5861
}
5962

6063
bindingset[t1, t2]
@@ -348,8 +351,15 @@ module FunctionDeclarationTypeEquivalence<TypeEquivalenceSig Config> {
348351
predicate equalParameterTypes(FunctionDeclarationEntry f1, FunctionDeclarationEntry f2) {
349352
f1.getDeclaration() = f2.getDeclaration() and
350353
forall(int i | exists([f1, f2].getParameterDeclarationEntry(i)) |
351-
TypeEquivalence<Config, FunctionSignatureType>::equalTypes(f1.getParameterDeclarationEntry(i)
352-
.getType(), f2.getParameterDeclarationEntry(i).getType())
354+
equalParameterTypesAt(f1, f2, pragma[only_bind_into](i))
355+
)
356+
}
357+
358+
predicate equalParameterTypesAt(FunctionDeclarationEntry f1, FunctionDeclarationEntry f2, int i) {
359+
pragma[only_bind_out](f1.getDeclaration()) = pragma[only_bind_out](f2.getDeclaration()) and
360+
TypeEquivalence<Config, FunctionSignatureType>::equalTypes(
361+
f1.getParameterDeclarationEntry(i).getType(),
362+
f2.getParameterDeclarationEntry(i).getType()
353363
)
354364
}
355365
}

0 commit comments

Comments
 (0)