@@ -3,11 +3,17 @@ 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 ) }
9-
10- override string getCanonicalQLClass ( ) { result = "TypedefType" }
13+ TypedefType ( ) {
14+ usertypes ( underlyingElement ( this ) , _, 5 ) or
15+ usertypes ( underlyingElement ( this ) , _, 14 )
16+ }
1117
1218 /**
1319 * Gets the base type of this typedef type.
@@ -26,10 +32,6 @@ class TypedefType extends UserType {
2632 result = this .getBaseType ( ) .getPointerIndirectionLevel ( )
2733 }
2834
29- override string explain ( ) {
30- result = "typedef {" + this .getBaseType ( ) .explain ( ) + "} as \"" + this .getName ( ) + "\""
31- }
32-
3335 override predicate isDeeplyConst ( ) { this .getBaseType ( ) .isDeeplyConst ( ) } // Just an alias
3436
3537 override predicate isDeeplyConstBelow ( ) { this .getBaseType ( ) .isDeeplyConstBelow ( ) } // Just an alias
@@ -45,6 +47,32 @@ class TypedefType extends UserType {
4547 override Type stripType ( ) { result = getBaseType ( ) .stripType ( ) }
4648}
4749
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+
4876/**
4977 * A C++ typedef type that is directly enclosed by a function.
5078 */
0 commit comments