Skip to content

Commit 7d4d435

Browse files
committed
Merge remote-tracking branch 'upstream/master' into Expr-location-workaround
Conflicts: cpp/ql/test/library-tests/dataflow/fields/dataflow-ir-consistency.expected
2 parents 9813258 + a305d39 commit 7d4d435

16 files changed

+93
-7
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasConfiguration.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class IndirectParameterAllocation extends Allocation, TIndirectParameterAllocati
9090

9191
final override string getUniqueId() { result = var.getUniqueId() }
9292

93-
final override IRType getIRType() { result = var.getIRType() }
93+
final override IRType getIRType() { result instanceof IRUnknownType }
9494

9595
final override predicate isReadOnly() { none() }
9696

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,9 @@ private module CachedForDebugging {
913913
}
914914

915915
module SSAConsistency {
916+
/**
917+
* Holds if a `MemoryOperand` has more than one `MemoryLocation` assigned by alias analysis.
918+
*/
916919
query predicate multipleOperandMemoryLocations(
917920
OldIR::MemoryOperand operand, string message, OldIR::IRFunction func, string funcText
918921
) {
@@ -925,6 +928,9 @@ module SSAConsistency {
925928
)
926929
}
927930

931+
/**
932+
* Holds if a `MemoryLocation` does not have an associated `VirtualVariable`.
933+
*/
928934
query predicate missingVirtualVariableForMemoryLocation(
929935
Alias::MemoryLocation location, string message, OldIR::IRFunction func, string funcText
930936
) {
@@ -933,4 +939,25 @@ module SSAConsistency {
933939
funcText = Language::getIdentityString(func.getFunction()) and
934940
message = "Memory location has no virtual variable in function '$@'."
935941
}
942+
943+
/**
944+
* Holds if a `MemoryLocation` is a member of more than one `VirtualVariable`.
945+
*/
946+
query predicate multipleVirtualVariablesForMemoryLocation(
947+
Alias::MemoryLocation location, string message, OldIR::IRFunction func, string funcText
948+
) {
949+
exists(int vvarCount |
950+
vvarCount = strictcount(location.getVirtualVariable()) and
951+
vvarCount > 1 and
952+
func = location.getIRFunction() and
953+
funcText = Language::getIdentityString(func.getFunction()) and
954+
message =
955+
"Memory location has " + vvarCount.toString() + " virtual variables in function '$@': (" +
956+
concat(Alias::VirtualVariable vvar |
957+
vvar = location.getVirtualVariable()
958+
|
959+
vvar.toString(), ", "
960+
) + ")."
961+
)
962+
}
936963
}

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,9 @@ private module CachedForDebugging {
913913
}
914914

915915
module SSAConsistency {
916+
/**
917+
* Holds if a `MemoryOperand` has more than one `MemoryLocation` assigned by alias analysis.
918+
*/
916919
query predicate multipleOperandMemoryLocations(
917920
OldIR::MemoryOperand operand, string message, OldIR::IRFunction func, string funcText
918921
) {
@@ -925,6 +928,9 @@ module SSAConsistency {
925928
)
926929
}
927930

931+
/**
932+
* Holds if a `MemoryLocation` does not have an associated `VirtualVariable`.
933+
*/
928934
query predicate missingVirtualVariableForMemoryLocation(
929935
Alias::MemoryLocation location, string message, OldIR::IRFunction func, string funcText
930936
) {
@@ -933,4 +939,25 @@ module SSAConsistency {
933939
funcText = Language::getIdentityString(func.getFunction()) and
934940
message = "Memory location has no virtual variable in function '$@'."
935941
}
942+
943+
/**
944+
* Holds if a `MemoryLocation` is a member of more than one `VirtualVariable`.
945+
*/
946+
query predicate multipleVirtualVariablesForMemoryLocation(
947+
Alias::MemoryLocation location, string message, OldIR::IRFunction func, string funcText
948+
) {
949+
exists(int vvarCount |
950+
vvarCount = strictcount(location.getVirtualVariable()) and
951+
vvarCount > 1 and
952+
func = location.getIRFunction() and
953+
funcText = Language::getIdentityString(func.getFunction()) and
954+
message =
955+
"Memory location has " + vvarCount.toString() + " virtual variables in function '$@': (" +
956+
concat(Alias::VirtualVariable vvar |
957+
vvar = location.getVirtualVariable()
958+
|
959+
vvar.toString(), ", "
960+
) + ")."
961+
)
962+
}
936963
}

cpp/ql/test/library-tests/dataflow/fields/dataflow-ir-consistency.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
uniqueEnclosingCallable
22
uniqueTypeBound
3-
| D.cpp:59:5:59:7 | Chi | Node should have one type bound but has 2. |
4-
| by_reference.cpp:106:21:106:41 | Chi | Node should have one type bound but has 2. |
5-
| by_reference.cpp:126:21:126:40 | Chi | Node should have one type bound but has 2. |
63
uniqueTypeRepr
74
uniqueNodeLocation
85
| D.cpp:1:17:1:17 | o | Node should have one location but has 3. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
multipleOperandMemoryLocations
22
missingVirtualVariableForMemoryLocation
3+
multipleVirtualVariablesForMemoryLocation
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
multipleOperandMemoryLocations
22
missingVirtualVariableForMemoryLocation
3+
multipleVirtualVariablesForMemoryLocation
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
multipleOperandMemoryLocations
22
missingVirtualVariableForMemoryLocation
3+
multipleVirtualVariablesForMemoryLocation
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
multipleOperandMemoryLocations
22
missingVirtualVariableForMemoryLocation
3+
multipleVirtualVariablesForMemoryLocation

cpp/ql/test/library-tests/ir/ssa/aliased_ssa_consistency_unsound.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ switchInstructionWithoutDefaultEdge
2020
notMarkedAsConflated
2121
wronglyMarkedAsConflated
2222
invalidOverlap
23-
| ssa.cpp:301:27:301:30 | SideEffect | MemoryOperand 'SideEffect' has a `getDefinitionOverlap()` of 'MayPartiallyOverlap'. | ssa.cpp:301:5:301:8 | IR: main | int main(int, char**) |
2423
missingCanonicalLanguageType
2524
multipleCanonicalLanguageTypes
2625
missingIRType

cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir_unsound.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,7 @@ ssa.cpp:
14411441
# 302| m302_8(unknown) = Chi : total:m301_4, partial:m302_7
14421442
# 302| v302_9(void) = ^BufferReadSideEffect[1] : &:r302_5, ~m301_10
14431443
# 302| m302_10(unknown) = ^BufferMayWriteSideEffect[1] : &:r302_5
1444-
# 302| m302_11(char *) = Chi : total:m301_10, partial:m302_10
1444+
# 302| m302_11(unknown) = Chi : total:m301_10, partial:m302_10
14451445
# 303| r303_1(glval<unknown>) = FunctionAddress[unknownFunction] :
14461446
# 303| r303_2(glval<int>) = VariableAddress[argc] :
14471447
# 303| r303_3(int) = Load : &:r303_2, m301_6
@@ -1452,7 +1452,7 @@ ssa.cpp:
14521452
# 303| m303_8(unknown) = Chi : total:m302_8, partial:m303_7
14531453
# 303| v303_9(void) = ^BufferReadSideEffect[1] : &:r303_5, ~m302_11
14541454
# 303| m303_10(unknown) = ^BufferMayWriteSideEffect[1] : &:r303_5
1455-
# 303| m303_11(char *) = Chi : total:m302_11, partial:m303_10
1455+
# 303| m303_11(unknown) = Chi : total:m302_11, partial:m303_10
14561456
# 304| r304_1(glval<int>) = VariableAddress[#return] :
14571457
# 304| r304_2(glval<char **>) = VariableAddress[argv] :
14581458
# 304| r304_3(char **) = Load : &:r304_2, m301_8

0 commit comments

Comments
 (0)