@@ -23,7 +23,7 @@ import codingstandards.cpp.Call
2323import codingstandards.cpp.SideEffect
2424
2525/**
26- * Holds if the function is in a template scope and should be excluded.
26+ * Holds if `f` is a `Function` in a template scope and should be excluded.
2727 */
2828predicate isInTemplateScope ( Function f ) {
2929 f .isFromTemplateInstantiation ( _)
@@ -39,9 +39,7 @@ class PointerLikeParam extends Parameter {
3939
4040 PointerLikeParam ( ) {
4141 pointerLikeType = this .getType ( ) and
42- not pointerLikeType .pointsToConst ( ) and
43- // Exclude pointers to non-object types
44- not pointerLikeType .getInnerType ( ) instanceof RoutineType
42+ not pointerLikeType .pointsToConst ( )
4543 }
4644
4745 /**
@@ -69,42 +67,6 @@ class PointerLikeParam extends Parameter {
6967 Expr getAPointerLikeAccess ( ) { result = getAPointerLikeAccessOf ( this .getAnAccess ( ) ) }
7068}
7169
72- /**
73- * A `VariableEffect` whose target variable is a `PointerLikeParam`.
74- *
75- * Examples of pointer-like effects on a pointer-like parameter `p` would include `p = ...`, `++p`,
76- * `*p = ...`, and `++*p`, etc.
77- */
78- class PointerLikeEffect extends VariableEffect {
79- PointerLikeParam param ;
80-
81- PointerLikeEffect ( ) { param = this .getTarget ( ) }
82-
83- /**
84- * Holds if this effect modifies the pointed-to or referred-to object.
85- *
86- * For example, `*p = 0` modifies the inner type if `p` is a pointer, and `p = 0` affects the
87- * inner type if `p` is a reference.
88- */
89- predicate affectsInnerType ( ) {
90- if param .getPointerLikeType ( ) instanceof ReferenceType
91- then affectsOuterType ( )
92- else not affectsOuterType ( )
93- }
94-
95- /**
96- * Holds if this effect modifies the pointer or reference itself.
97- *
98- * For example, `p = ...` and `++p` modify the outer type, whether that type is a pointer or
99- * reference, while `*p = 0` does not modify the outer type.
100- */
101- predicate affectsOuterType ( ) {
102- this .( Assignment ) .getLValue ( ) = param .getAnAccess ( )
103- or
104- this .( CrementOperation ) .getOperand ( ) = param .getAnAccess ( )
105- }
106- }
107-
10870/**
10971 * A candidate parameter that could have its target type const-qualified.
11072 */
@@ -119,8 +81,8 @@ class NonConstParam extends PointerLikeParam {
11981 not exists ( AsmStmt a | a .getEnclosingFunction ( ) = this .getFunction ( ) ) and
12082 // Must have a pointer, array, or lvalue reference type with non-const target
12183 // Exclude pointers to non-object types
122- not pointerLikeType .getInnerType ( ) instanceof RoutineType and
123- not pointerLikeType .getInnerType ( ) instanceof VoidType and
84+ not pointerLikeType .getInnerType + ( ) . getUnderlyingType ( ) instanceof RoutineType and
85+ not pointerLikeType .getInnerType + ( ) . getUnderlyingType ( ) instanceof VoidType and
12486 // Exclude virtual functions
12587 not this .getFunction ( ) .isVirtual ( ) and
12688 // Exclude functions in template scope
@@ -130,10 +92,7 @@ class NonConstParam extends PointerLikeParam {
13092 // Exclude deleted functions
13193 not this .getFunction ( ) .isDeleted ( ) and
13294 // Exclude any parameter whose underlying data is modified
133- not exists ( PointerLikeEffect effect |
134- effect .getTarget ( ) = this and
135- effect .affectsInnerType ( )
136- ) and
95+ not exists ( AliasParameter alias | alias = this | alias .isModified ( ) ) and
13796 // Exclude parameters passed as arguments to non-const pointer/ref params
13897 not exists ( CallArgumentExpr arg |
13998 arg = this .getAPointerLikeAccess ( ) and
0 commit comments