Skip to content

Commit e67b7af

Browse files
committed
Fix a bug in the shared library
If an operator is declared multiple times including application code, this class would err on the conservative side and treat it as a standard library one.
1 parent 5ccc149 commit e67b7af

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cpp/common/src/codingstandards/cpp/allocations/CustomOperatorNewDelete.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ abstract class CustomOperatorNewOrDelete extends Operator {
2020
exists(getFile().getRelativePath()) and
2121
// Not in a file called `new`, which is likely to be a copy of the standard library
2222
// as it is in our tests
23-
not getFile().getBaseName() = "new"
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+
)
2430
}
2531

2632
/**

0 commit comments

Comments
 (0)