mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #19805 from github/idrissrio/namespace-attributes
C++: fix typedef resolution in `ArrayType`
This commit is contained in:
4
cpp/ql/lib/change-notes/2025-06-17-arraytype-typedefs.md
Normal file
4
cpp/ql/lib/change-notes/2025-06-17-arraytype-typedefs.md
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
category: fix
|
||||||
|
---
|
||||||
|
* `resolveTypedefs` now properly resolves typedefs for `ArrayType`s.
|
||||||
@@ -1589,6 +1589,11 @@ class ArrayType extends DerivedType {
|
|||||||
* Holds if this array is a variable-length array (VLA).
|
* Holds if this array is a variable-length array (VLA).
|
||||||
*/
|
*/
|
||||||
predicate isVla() { type_is_vla(underlyingElement(this)) }
|
predicate isVla() { type_is_vla(underlyingElement(this)) }
|
||||||
|
|
||||||
|
override Type resolveTypedefs() {
|
||||||
|
result.(ArrayType).getBaseType() = this.getBaseType().resolveTypedefs() and
|
||||||
|
result.(ArrayType).getArraySize() = this.getArraySize()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
typedef int int_t;
|
||||||
|
int_t g1[10];
|
||||||
|
int_t g2[2][4];
|
||||||
|
|
||||||
|
typedef float float_t;
|
||||||
|
float_t arr1[5];
|
||||||
|
float_t (*a_pointer)[10];
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
| file://:0:0:0:0 | float_t[5] | file://:0:0:0:0 | float[5] | ArrayTypedefs.cpp:6:9:6:12 | definition of arr1 |
|
||||||
|
| file://:0:0:0:0 | float_t[10] | file://:0:0:0:0 | float[10] | ArrayTypedefs.cpp:7:11:7:19 | definition of a_pointer |
|
||||||
|
| file://:0:0:0:0 | int_t[2][4] | file://:0:0:0:0 | int[2][4] | ArrayTypedefs.cpp:3:7:3:8 | definition of g2 |
|
||||||
|
| file://:0:0:0:0 | int_t[4] | file://:0:0:0:0 | int[4] | ArrayTypedefs.cpp:3:7:3:8 | definition of g2 |
|
||||||
|
| file://:0:0:0:0 | int_t[10] | file://:0:0:0:0 | int[10] | ArrayTypedefs.cpp:2:7:2:8 | definition of g1 |
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import cpp
|
||||||
|
|
||||||
|
from ArrayType type
|
||||||
|
select type, type.resolveTypedefs(), type.getATypeNameUse()
|
||||||
Reference in New Issue
Block a user