File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
common/src/codingstandards/cpp/allocations
misra/src/rules/RULE-21-6-3 Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -14,19 +14,21 @@ class ConstNoThrowTReferenceType extends ReferenceType {
1414}
1515
1616/** An `operator` that implements one of the `[replacement.functions]`. */
17- abstract class CustomOperatorNewOrDelete extends Operator {
17+ abstract class OperatorNewOrDelete extends Operator {
18+ OperatorNewOrDelete ( ) {
19+ this .getName ( ) .regexpMatch ( "operator new(\\[\\])?" ) or
20+ this .getName ( ) .regexpMatch ( "operator delete(\\[\\])?" )
21+ }
22+ }
23+
24+ /** An `operator` that implements one of the `[replacement.functions]`. */
25+ abstract class CustomOperatorNewOrDelete extends OperatorNewOrDelete {
1826 CustomOperatorNewOrDelete ( ) {
1927 // Not in the standard library
2028 exists ( getFile ( ) .getRelativePath ( ) ) and
2129 // Not in a file called `new`, which is likely to be a copy of the standard library
2230 // as it is in our tests
23- not forall ( File file | file = this .getADeclarationLocation ( ) .getFile ( ) |
24- file .getBaseName ( ) = "new"
25- ) and
26- (
27- this .getName ( ) .regexpMatch ( "operator new(\\[\\])?" ) or
28- this .getName ( ) .regexpMatch ( "operator delete(\\[\\])?" )
29- )
31+ not getFile ( ) .getBaseName ( ) = "new"
3032 }
3133
3234 /**
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ class AdvancedMemoryManagementFunction extends Function {
3535 string describe ( ) { result = description }
3636}
3737
38- class NonStandardNewOrNewArrayOperator extends CustomOperatorNewOrDelete {
38+ class NonStandardNewOrNewArrayOperator extends OperatorNewOrDelete {
3939 NonStandardNewOrNewArrayOperator ( ) {
4040 this .getName ( ) in [ "operator new" , "operator new[]" ] and
4141 not this instanceof CustomOperatorNew // `CustomOperatorNew` only detects replaceable allocation functions.
@@ -61,7 +61,7 @@ class UserDeclaredOperatorNewOrDelete extends FunctionDeclarationEntry {
6161 }
6262}
6363
64- class NonStandardDeleteOrDeleteArrayOperator extends CustomOperatorNewOrDelete {
64+ class NonStandardDeleteOrDeleteArrayOperator extends OperatorNewOrDelete {
6565 NonStandardDeleteOrDeleteArrayOperator ( ) {
6666 this .getName ( ) in [ "operator delete" , "operator delete[]" ] and
6767 not this instanceof CustomOperatorDelete // `CustomOperatorDelete` only detects replaceable deallocation functions.
You can’t perform that action at this time.
0 commit comments