File tree Expand file tree Collapse file tree 2 files changed +14
-18
lines changed
cpp/common/src/codingstandards/cpp
c/common/src/codingstandards/c Expand file tree Collapse file tree 2 files changed +14
-18
lines changed Original file line number Diff line number Diff line change 11import cpp
2+ import codingstandards.cpp.Pointers
23import codingstandards.cpp.UndefinedBehavior
34
45/**
56 * Library for modeling undefined behavior.
67 */
78abstract class CUndefinedBehavior extends UndefinedBehavior { }
89
9- class PointerOrArrayType extends DerivedType {
10- PointerOrArrayType ( ) {
11- this instanceof PointerType or
12- this instanceof ArrayType
13- }
14- }
15-
16- Type get ( Function main ) {
17- main .getName ( ) = "main" and
18- main .getNumberOfParameters ( ) = 2 and
19- main .getType ( ) .getUnderlyingType ( ) instanceof IntType and
20- main .getParameter ( 0 ) .getType ( ) .getUnderlyingType ( ) instanceof IntType and
21- result = main .getParameter ( 1 ) .getType ( ) .getUnderlyingType ( ) .( PointerOrArrayType ) .getBaseType ( )
22- }
23-
2410/**
2511 * A function which has the signature - but not the name - of a main function.
2612 */
@@ -32,9 +18,9 @@ class C99MainFunction extends Function {
3218 this .getParameter ( 1 )
3319 .getType ( )
3420 .getUnderlyingType ( )
35- .( PointerOrArrayType )
21+ .( UnspecifiedPointerOrArrayType )
3622 .getBaseType ( )
37- .( PointerOrArrayType )
23+ .( UnspecifiedPointerOrArrayType )
3824 .getBaseType ( ) instanceof CharType
3925 or
4026 this .getNumberOfParameters ( ) = 0 and
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import cpp
66import codingstandards.cpp.Type
77
88/**
9- * A type that is a pointer or array type.
9+ * A type that is a pointer or array type after stripping top-level specifiers .
1010 */
1111class PointerOrArrayType extends DerivedType {
1212 PointerOrArrayType ( ) {
@@ -15,6 +15,16 @@ class PointerOrArrayType extends DerivedType {
1515 }
1616}
1717
18+ /**
19+ * A type that is a pointer or array type.
20+ */
21+ class UnspecifiedPointerOrArrayType extends DerivedType {
22+ UnspecifiedPointerOrArrayType ( ) {
23+ this instanceof PointerType or
24+ this instanceof ArrayType
25+ }
26+ }
27+
1828/**
1929 * An expression which performs pointer arithmetic
2030 */
You can’t perform that action at this time.
0 commit comments