@@ -3,11 +3,17 @@ private import semmle.code.cpp.internal.ResolveClass
3
3
4
4
/**
5
5
* A C/C++ typedef type. See 4.9.1.
6
+ *
7
+ * Represents either of the following typedef styles:
8
+ *
9
+ * * CTypedefType: typedef <type> <name>;
10
+ * * UsingAliasTypedefType: using <name> = <type>;
6
11
*/
7
12
class TypedefType extends UserType {
8
- TypedefType ( ) { usertypes ( underlyingElement ( this ) , _, 5 ) }
9
-
10
- override string getCanonicalQLClass ( ) { result = "TypedefType" }
13
+ TypedefType ( ) {
14
+ usertypes ( underlyingElement ( this ) , _, 5 ) or
15
+ usertypes ( underlyingElement ( this ) , _, 14 )
16
+ }
11
17
12
18
/**
13
19
* Gets the base type of this typedef type.
@@ -26,10 +32,6 @@ class TypedefType extends UserType {
26
32
result = this .getBaseType ( ) .getPointerIndirectionLevel ( )
27
33
}
28
34
29
- override string explain ( ) {
30
- result = "typedef {" + this .getBaseType ( ) .explain ( ) + "} as \"" + this .getName ( ) + "\""
31
- }
32
-
33
35
override predicate isDeeplyConst ( ) { this .getBaseType ( ) .isDeeplyConst ( ) } // Just an alias
34
36
35
37
override predicate isDeeplyConstBelow ( ) { this .getBaseType ( ) .isDeeplyConstBelow ( ) } // Just an alias
@@ -45,6 +47,32 @@ class TypedefType extends UserType {
45
47
override Type stripType ( ) { result = getBaseType ( ) .stripType ( ) }
46
48
}
47
49
50
+ /**
51
+ * A traditional C/C++ typedef type. See 4.9.1.
52
+ */
53
+ class CTypedefType extends TypedefType {
54
+ CTypedefType ( ) { usertypes ( underlyingElement ( this ) , _, 5 ) }
55
+
56
+ override string getCanonicalQLClass ( ) { result = "CTypedefType" }
57
+
58
+ override string explain ( ) {
59
+ result = "typedef {" + this .getBaseType ( ) .explain ( ) + "} as \"" + this .getName ( ) + "\""
60
+ }
61
+ }
62
+
63
+ /**
64
+ * A using alias C++ typedef type.
65
+ */
66
+ class UsingAliasTypedefType extends TypedefType {
67
+ UsingAliasTypedefType ( ) { usertypes ( underlyingElement ( this ) , _, 14 ) }
68
+
69
+ override string getCanonicalQLClass ( ) { result = "UsingAliasTypedefType" }
70
+
71
+ override string explain ( ) {
72
+ result = "using {" + this .getBaseType ( ) .explain ( ) + "} as \"" + this .getName ( ) + "\""
73
+ }
74
+ }
75
+
48
76
/**
49
77
* A C++ typedef type that is directly enclosed by a function.
50
78
*/
0 commit comments