@@ -3,11 +3,18 @@ private import semmle.code.cpp.internal.ResolveClass
33
44/**
55 * 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>;
611 */
712class TypedefType extends UserType {
8- TypedefType ( ) { usertypes ( underlyingElement ( this ) , _, 5 ) }
913
10- override string getCanonicalQLClass ( ) { result = "TypedefType" }
14+ TypedefType ( ) {
15+ usertypes ( underlyingElement ( this ) , _, 5 ) or
16+ usertypes ( underlyingElement ( this ) , _, 14 )
17+ }
1118
1219 /**
1320 * Gets the base type of this typedef type.
@@ -26,10 +33,6 @@ class TypedefType extends UserType {
2633 result = this .getBaseType ( ) .getPointerIndirectionLevel ( )
2734 }
2835
29- override string explain ( ) {
30- result = "typedef {" + this .getBaseType ( ) .explain ( ) + "} as \"" + this .getName ( ) + "\""
31- }
32-
3336 override predicate isDeeplyConst ( ) { this .getBaseType ( ) .isDeeplyConst ( ) } // Just an alias
3437
3538 override predicate isDeeplyConstBelow ( ) { this .getBaseType ( ) .isDeeplyConstBelow ( ) } // Just an alias
@@ -45,6 +48,34 @@ class TypedefType extends UserType {
4548 override Type stripType ( ) { result = getBaseType ( ) .stripType ( ) }
4649}
4750
51+ /**
52+ * A traditional C/C++ typedef type. See 4.9.1.
53+ */
54+ class CTypedefType extends TypedefType {
55+
56+ CTypedefType ( ) {
57+ usertypes ( underlyingElement ( this ) , _, 5 )
58+ }
59+
60+ override string getCanonicalQLClass ( ) { result = "CTypedefType" }
61+
62+ override string explain ( ) { result = "typedef {" + this .getBaseType ( ) .explain ( ) + "} as \"" + this .getName ( ) + "\"" }
63+ }
64+
65+ /**
66+ * A using alias C++ typedef type.
67+ */
68+ class UsingAliasTypedefType extends TypedefType {
69+
70+ UsingAliasTypedefType ( ) {
71+ usertypes ( underlyingElement ( this ) , _, 14 )
72+ }
73+
74+ override string getCanonicalQLClass ( ) { result = "UsingAliasTypedefType" }
75+
76+ override string explain ( ) { result = "using {" + this .getBaseType ( ) .explain ( ) + "} as \"" + this .getName ( ) + "\"" }
77+ }
78+
4879/**
4980 * A C++ typedef type that is directly enclosed by a function.
5081 */
0 commit comments