mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
C++: Give names in structured binding declarations correct IR types
This commit is contained in:
@@ -11,6 +11,15 @@ private Type getDecayedType(Type type) {
|
||||
result.(PointerType).getBaseType() = type.(ArrayType).getBaseType()
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if the sepcified variable is a structured binding with a non-reference
|
||||
* type.
|
||||
*/
|
||||
predicate isNonReferenceStructuredBinding(Variable v) {
|
||||
v.isStructuredBinding() and
|
||||
not v.getUnderlyingType() instanceof ReferenceType
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual type of the specified variable, as opposed to the declared type.
|
||||
* This returns the type of the variable after any pointer decay is applied, and
|
||||
@@ -30,7 +39,10 @@ Type getVariableType(Variable v) {
|
||||
result = v.getInitializer().getExpr().getType()
|
||||
or
|
||||
not exists(v.getInitializer()) and result = v.getType()
|
||||
else result = v.getType()
|
||||
else
|
||||
if isNonReferenceStructuredBinding(v)
|
||||
then exists(ReferenceType r | r.getBaseType() = v.getUnderlyingType() | result = r)
|
||||
else result = v.getType()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -6694,6 +6694,8 @@
|
||||
| ir.cpp:1466:26:1466:27 | StoreValue | r1466_3 |
|
||||
| ir.cpp:1466:26:1466:27 | Unary | r1466_2 |
|
||||
| ir.cpp:1467:9:1467:10 | Address | &:r1467_2 |
|
||||
| ir.cpp:1467:9:1467:14 | ChiPartial | partial:m1467_3 |
|
||||
| ir.cpp:1467:9:1467:14 | ChiTotal | total:m0_14 |
|
||||
| ir.cpp:1467:14:1467:14 | StoreValue | r1467_1 |
|
||||
| ir.cpp:1468:14:1468:16 | Address | &:r1468_1 |
|
||||
| ir.cpp:1468:20:1468:21 | StoreValue | r1468_3 |
|
||||
@@ -6801,9 +6803,11 @@
|
||||
| ir.cpp:1500:22:1500:22 | Unary | r1500_2 |
|
||||
| ir.cpp:1501:13:1501:13 | Address | &:r1501_1 |
|
||||
| ir.cpp:1501:17:1501:17 | Address | &:r1501_2 |
|
||||
| ir.cpp:1501:17:1501:17 | Load | m1498_8 |
|
||||
| ir.cpp:1501:17:1501:17 | Load | ~m1498_8 |
|
||||
| ir.cpp:1501:17:1501:17 | StoreValue | r1501_3 |
|
||||
| ir.cpp:1502:9:1502:9 | Address | &:r1502_2 |
|
||||
| ir.cpp:1502:9:1502:13 | ChiPartial | partial:m1502_3 |
|
||||
| ir.cpp:1502:9:1502:13 | ChiTotal | total:m1498_22 |
|
||||
| ir.cpp:1502:13:1502:13 | StoreValue | r1502_1 |
|
||||
| ir.cpp:1503:9:1503:10 | Address | &:r1503_4 |
|
||||
| ir.cpp:1503:9:1503:14 | ChiPartial | partial:m1503_5 |
|
||||
|
||||
@@ -7915,22 +7915,22 @@ ir.cpp:
|
||||
# 1466| r1466_2(glval<int[2]>) = VariableAddress[xs] :
|
||||
# 1466| r1466_3(int(&)[2]) = CopyValue : r1466_2
|
||||
# 1466| mu1466_4(int(&)[2]) = Store[(unnamed local variable)] : &:r1466_1, r1466_3
|
||||
# 1466| r1466_5(glval<int>) = VariableAddress[x0] :
|
||||
# 1466| r1466_5(glval<int &>) = VariableAddress[x0] :
|
||||
#-----| r0_1(glval<int(&)[2]>) = VariableAddress[(unnamed local variable)] :
|
||||
#-----| r0_2(int(&)[2]) = Load[(unnamed local variable)] : &:r0_1, ~m?
|
||||
#-----| r0_3(glval<int[2]>) = CopyValue : r0_2
|
||||
#-----| r0_4(int *) = Convert : r0_3
|
||||
#-----| r0_5(unsigned long) = Constant[0] :
|
||||
#-----| r0_6(glval<int>) = PointerAdd[4] : r0_4, r0_5
|
||||
#-----| mu0_7(int) = Store[x0] : &:r1466_5, r0_6
|
||||
# 1466| r1466_6(glval<int>) = VariableAddress[x1] :
|
||||
#-----| mu0_7(int &) = Store[x0] : &:r1466_5, r0_6
|
||||
# 1466| r1466_6(glval<int &>) = VariableAddress[x1] :
|
||||
#-----| r0_8(glval<int(&)[2]>) = VariableAddress[(unnamed local variable)] :
|
||||
#-----| r0_9(int(&)[2]) = Load[(unnamed local variable)] : &:r0_8, ~m?
|
||||
#-----| r0_10(glval<int[2]>) = CopyValue : r0_9
|
||||
#-----| r0_11(int *) = Convert : r0_10
|
||||
#-----| r0_12(unsigned long) = Constant[1] :
|
||||
#-----| r0_13(glval<int>) = PointerAdd[4] : r0_11, r0_12
|
||||
#-----| mu0_14(int) = Store[x1] : &:r1466_6, r0_13
|
||||
#-----| mu0_14(int &) = Store[x1] : &:r1466_6, r0_13
|
||||
# 1467| r1467_1(int) = Constant[3] :
|
||||
# 1467| r1467_2(glval<int>) = VariableAddress[x1] :
|
||||
# 1467| mu1467_3(int) = Store[x1] : &:r1467_2, r1467_1
|
||||
@@ -8015,38 +8015,38 @@ ir.cpp:
|
||||
# 1498| r1498_2(glval<StructuredBindingDataMemberStruct>) = VariableAddress[s] :
|
||||
# 1498| r1498_3(StructuredBindingDataMemberStruct) = Load[s] : &:r1498_2, ~m?
|
||||
# 1498| mu1498_4(StructuredBindingDataMemberStruct) = Store[(unnamed local variable)] : &:r1498_1, r1498_3
|
||||
# 1498| r1498_5(glval<int>) = VariableAddress[i] :
|
||||
# 1498| r1498_5(glval<int &>) = VariableAddress[i] :
|
||||
# 1498| r1498_6(glval<StructuredBindingDataMemberStruct>) = VariableAddress[(unnamed local variable)] :
|
||||
# 1498| r1498_7(glval<int>) = FieldAddress[i] : r1498_6
|
||||
# 1498| mu1498_8(int) = Store[i] : &:r1498_5, r1498_7
|
||||
# 1498| r1498_9(glval<double>) = VariableAddress[d] :
|
||||
# 1498| mu1498_8(int &) = Store[i] : &:r1498_5, r1498_7
|
||||
# 1498| r1498_9(glval<double &>) = VariableAddress[d] :
|
||||
# 1498| r1498_10(glval<StructuredBindingDataMemberStruct>) = VariableAddress[(unnamed local variable)] :
|
||||
# 1498| r1498_11(glval<double>) = FieldAddress[d] : r1498_10
|
||||
# 1498| mu1498_12(double) = Store[d] : &:r1498_9, r1498_11
|
||||
# 1498| r1498_13(glval<unsigned int>) = VariableAddress[b] :
|
||||
# 1498| mu1498_12(double &) = Store[d] : &:r1498_9, r1498_11
|
||||
# 1498| r1498_13(glval<unsigned int &>) = VariableAddress[b] :
|
||||
# 1498| r1498_14(glval<StructuredBindingDataMemberStruct>) = VariableAddress[(unnamed local variable)] :
|
||||
# 1498| r1498_15(glval<unsigned int>) = FieldAddress[b] : r1498_14
|
||||
# 1498| mu1498_16(unsigned int) = Store[b] : &:r1498_13, r1498_15
|
||||
# 1498| r1498_17(glval<int>) = VariableAddress[r] :
|
||||
# 1498| mu1498_16(unsigned int &) = Store[b] : &:r1498_13, r1498_15
|
||||
# 1498| r1498_17(glval<int &>) = VariableAddress[r] :
|
||||
# 1498| r1498_18(glval<StructuredBindingDataMemberStruct>) = VariableAddress[(unnamed local variable)] :
|
||||
# 1498| r1498_19(glval<int &>) = FieldAddress[r] : r1498_18
|
||||
# 1498| r1498_20(int &) = Load[?] : &:r1498_19, ~m?
|
||||
# 1498| r1498_21(glval<int>) = CopyValue : r1498_20
|
||||
# 1498| mu1498_22(int) = Store[r] : &:r1498_17, r1498_21
|
||||
# 1498| r1498_23(glval<int *>) = VariableAddress[p] :
|
||||
# 1498| mu1498_22(int &) = Store[r] : &:r1498_17, r1498_21
|
||||
# 1498| r1498_23(glval<int *&>) = VariableAddress[p] :
|
||||
# 1498| r1498_24(glval<StructuredBindingDataMemberStruct>) = VariableAddress[(unnamed local variable)] :
|
||||
# 1498| r1498_25(glval<int *>) = FieldAddress[p] : r1498_24
|
||||
# 1498| mu1498_26(int *) = Store[p] : &:r1498_23, r1498_25
|
||||
# 1498| r1498_27(glval<int[2]>) = VariableAddress[xs] :
|
||||
# 1498| mu1498_26(int *&) = Store[p] : &:r1498_23, r1498_25
|
||||
# 1498| r1498_27(glval<int(&)[2]>) = VariableAddress[xs] :
|
||||
# 1498| r1498_28(glval<StructuredBindingDataMemberStruct>) = VariableAddress[(unnamed local variable)] :
|
||||
# 1498| r1498_29(glval<int[2]>) = FieldAddress[xs] : r1498_28
|
||||
# 1498| mu1498_30(int[2]) = Store[xs] : &:r1498_27, r1498_29
|
||||
# 1498| r1498_31(glval<int>) = VariableAddress[r_alt] :
|
||||
# 1498| mu1498_30(int(&)[2]) = Store[xs] : &:r1498_27, r1498_29
|
||||
# 1498| r1498_31(glval<int &>) = VariableAddress[r_alt] :
|
||||
# 1498| r1498_32(glval<StructuredBindingDataMemberStruct>) = VariableAddress[(unnamed local variable)] :
|
||||
# 1498| r1498_33(glval<int &>) = FieldAddress[r_alt] : r1498_32
|
||||
# 1498| r1498_34(int &) = Load[?] : &:r1498_33, ~m?
|
||||
# 1498| r1498_35(glval<int>) = CopyValue : r1498_34
|
||||
# 1498| mu1498_36(int) = Store[r_alt] : &:r1498_31, r1498_35
|
||||
# 1498| mu1498_36(int &) = Store[r_alt] : &:r1498_31, r1498_35
|
||||
# 1499| r1499_1(double) = Constant[4.0] :
|
||||
# 1499| r1499_2(glval<double>) = VariableAddress[d] :
|
||||
# 1499| mu1499_3(double) = Store[d] : &:r1499_2, r1499_1
|
||||
|
||||
Reference in New Issue
Block a user