mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C++: Fix obtaining the base type of a VLA
This commit is contained in:
@@ -4185,8 +4185,18 @@ class TranslatedSizeofExpr extends TranslatedNonConstantExpr {
|
||||
|
||||
override string getInstructionConstantValue(InstructionTag tag) {
|
||||
tag = SizeofVlaDimensionTag(-1) and
|
||||
result =
|
||||
getBaseType(vlaDeclStmt.getVariable().getUnderlyingType(), vlaDimensions).getSize().toString()
|
||||
result = this.getVlaBaseType(vlaDeclStmt).getSize().toString()
|
||||
}
|
||||
|
||||
private Type getVlaBaseType(VlaDeclStmt v) {
|
||||
not exists(getParentVlaDecl(v)) and
|
||||
(
|
||||
result = getBaseType(v.getVariable().getUnderlyingType(), v.getNumberOfVlaDimensionStmts())
|
||||
or
|
||||
result = getBaseType(v.getType().getUnderlyingType(), v.getNumberOfVlaDimensionStmts())
|
||||
)
|
||||
or
|
||||
result = this.getVlaBaseType(getParentVlaDecl(v))
|
||||
}
|
||||
|
||||
override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
|
||||
|
||||
@@ -20589,7 +20589,7 @@ ir.cpp:
|
||||
# 2807| m2807_2(long[][][]) = Uninitialized[tmp] : &:r2807_1
|
||||
# 2807| v2807_3(void) = NoOp :
|
||||
# 2808| r2808_1(glval<unsigned long>) = VariableAddress[#return] :
|
||||
# 2808| r2808_2(unsigned long) = Constant :
|
||||
# 2808| r2808_2(unsigned long) = Constant[8] :
|
||||
# 2808| r2808_3(unsigned long) = Mul : r2808_2, r2802_2
|
||||
# 2808| r2808_4(unsigned long) = Mul : r2808_3, r2802_4
|
||||
# 2808| m2808_5(unsigned long) = Store[#return] : &:r2808_1, r2808_4
|
||||
|
||||
@@ -18732,7 +18732,7 @@ ir.cpp:
|
||||
# 2807| mu2807_2(long[][][]) = Uninitialized[tmp] : &:r2807_1
|
||||
# 2807| v2807_3(void) = NoOp :
|
||||
# 2808| r2808_1(glval<unsigned long>) = VariableAddress[#return] :
|
||||
# 2808| r2808_2(unsigned long) = Constant :
|
||||
# 2808| r2808_2(unsigned long) = Constant[8] :
|
||||
# 2808| r2808_3(unsigned long) = Mul : r2808_2, r2802_2
|
||||
# 2808| r2808_4(unsigned long) = Mul : r2808_3, r2802_4
|
||||
# 2808| mu2808_5(unsigned long) = Store[#return] : &:r2808_1, r2808_4
|
||||
|
||||
Reference in New Issue
Block a user