Skip to content

Commit ebdf553

Browse files
authored
Merge pull request #8806 from dbartol/dbartol/typedefs/work
C++: Work around missing size for typedef
2 parents 3e8274e + 83fdff5 commit ebdf553

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cpp/ql/lib/semmle/code/cpp/ir/internal/CppType.qll

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private predicate isOpaqueType(Type type) {
141141
* Holds if an `IROpaqueType` with the specified `tag` and `byteSize` should exist.
142142
*/
143143
predicate hasOpaqueType(Type tag, int byteSize) {
144-
isOpaqueType(tag) and byteSize = getTypeSize(tag)
144+
isOpaqueType(tag) and byteSize = getTypeSize(tag.getUnspecifiedType())
145145
or
146146
tag instanceof UnknownType and Raw::needsUnknownOpaqueType(byteSize)
147147
}
@@ -153,17 +153,18 @@ private IRType getIRTypeForPRValue(Type type) {
153153
exists(Type unspecifiedType | unspecifiedType = type.getUnspecifiedType() |
154154
isOpaqueType(unspecifiedType) and
155155
exists(IROpaqueType opaqueType | opaqueType = result |
156-
opaqueType.getByteSize() = getTypeSize(type) and
156+
opaqueType.getByteSize() = getTypeSize(unspecifiedType) and
157157
opaqueType.getTag() = unspecifiedType
158158
)
159159
or
160-
unspecifiedType instanceof BoolType and result.(IRBooleanType).getByteSize() = type.getSize()
160+
unspecifiedType instanceof BoolType and
161+
result.(IRBooleanType).getByteSize() = unspecifiedType.getSize()
161162
or
162163
isSignedIntegerType(unspecifiedType) and
163-
result.(IRSignedIntegerType).getByteSize() = type.getSize()
164+
result.(IRSignedIntegerType).getByteSize() = unspecifiedType.getSize()
164165
or
165166
isUnsignedIntegerType(unspecifiedType) and
166-
result.(IRUnsignedIntegerType).getByteSize() = type.getSize()
167+
result.(IRUnsignedIntegerType).getByteSize() = unspecifiedType.getSize()
167168
or
168169
exists(FloatingPointType floatType, IRFloatingPointType irFloatType |
169170
floatType = unspecifiedType and
@@ -173,7 +174,8 @@ private IRType getIRTypeForPRValue(Type type) {
173174
irFloatType.getDomain() = floatType.getDomain()
174175
)
175176
or
176-
isPointerIshType(unspecifiedType) and result.(IRAddressType).getByteSize() = getTypeSize(type)
177+
isPointerIshType(unspecifiedType) and
178+
result.(IRAddressType).getByteSize() = getTypeSize(unspecifiedType)
177179
or
178180
unspecifiedType instanceof FunctionPointerIshType and
179181
result.(IRFunctionAddressType).getByteSize() = getTypeSize(type)

0 commit comments

Comments
 (0)