Skip to content

Commit a32cfda

Browse files
committed
C++: Support mixed typedefs and usings
1 parent 09fe609 commit a32cfda

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

cpp/ql/lib/semmle/code/cpp/TypedefType.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private import semmle.code.cpp.internal.ResolveClass
1313
* ```
1414
*/
1515
class TypedefType extends UserType {
16-
TypedefType() { usertypes(underlyingElement(this), _, [5, 14]) }
16+
TypedefType() { usertypes(underlyingElement(this), _, 18) }
1717

1818
/**
1919
* Gets the base type of this typedef type.
@@ -54,7 +54,7 @@ class TypedefType extends UserType {
5454
* ```
5555
*/
5656
class CTypedefType extends TypedefType {
57-
CTypedefType() { usertypes(underlyingElement(this), _, 5) }
57+
CTypedefType() { usertype_alias_kind(underlyingElement(this), 0) }
5858

5959
override string getAPrimaryQlClass() { result = "CTypedefType" }
6060

@@ -70,7 +70,7 @@ class CTypedefType extends TypedefType {
7070
* ```
7171
*/
7272
class UsingAliasTypedefType extends TypedefType {
73-
UsingAliasTypedefType() { usertypes(underlyingElement(this), _, 14) }
73+
UsingAliasTypedefType() { usertype_alias_kind(underlyingElement(this), 1) }
7474

7575
override string getAPrimaryQlClass() { result = "UsingAliasTypedefType" }
7676

cpp/ql/lib/semmlecode.cpp.dbscheme

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ case @usertype.kind of
776776
| 2 = @class
777777
| 3 = @union
778778
| 4 = @enum
779-
| 5 = @typedef // classic C: typedef typedef type name
779+
// ... 5 = @typedef deprecated // classic C: typedef typedef type name
780780
// ... 6 = @template deprecated
781781
| 7 = @template_parameter
782782
| 8 = @template_template_parameter
@@ -785,10 +785,11 @@ case @usertype.kind of
785785
// ... 11 objc_protocol deprecated
786786
// ... 12 objc_category deprecated
787787
| 13 = @scoped_enum
788-
| 14 = @using_alias // a using name = type style typedef
788+
// ... 14 = @using_alias deprecated // a using name = type style typedef
789789
| 15 = @template_struct
790790
| 16 = @template_class
791791
| 17 = @template_union
792+
| 18 = @alias
792793
;
793794
*/
794795

@@ -811,6 +812,17 @@ usertype_uuid(
811812
string uuid: string ref
812813
);
813814

815+
/*
816+
case @usertype.alias_kind of
817+
| 0 = @typedef
818+
| 1 = @alias
819+
*/
820+
821+
usertype_alias_kind(
822+
int id: @usertype ref,
823+
int alias_kind: int ref
824+
)
825+
814826
nontype_template_parameters(
815827
int id: @expr ref
816828
);

0 commit comments

Comments
 (0)