mirror of
https://github.com/github/codeql.git
synced 2026-06-19 03:41:07 +02:00
Merge pull request #413 from jbj/return-this-getblock
C++: Restore `exists(getBlock())` in AV Rule 82
This commit is contained in:
@@ -83,6 +83,7 @@ predicate assignOperatorWithWrongType(Operator op, string msg) {
|
||||
predicate assignOperatorWithWrongResult(Operator op, string msg) {
|
||||
op.hasName("operator=")
|
||||
and not returnsDereferenceThis(op)
|
||||
and exists(op.getBlock())
|
||||
and not op.getType() instanceof VoidType
|
||||
and not assignOperatorWithWrongType(op, _)
|
||||
and msg = "Assignment operator in class " + op.getDeclaringType().getName() + " does not return a reference to *this."
|
||||
|
||||
@@ -171,6 +171,16 @@ class Reachability {
|
||||
static Reachability staticInstance;
|
||||
};
|
||||
|
||||
class Forgivable {
|
||||
// GOOD: wrong return type but that doesn't matter on a deleted function.
|
||||
Forgivable operator=(const Forgivable &_val) = delete;
|
||||
|
||||
private:
|
||||
// GOOD: wrong return type but that doesn't matter because this operator is
|
||||
// private and probably also unimplemented, so no code can call it.
|
||||
Forgivable operator=(int *_val);
|
||||
};
|
||||
|
||||
int main() {
|
||||
Container c;
|
||||
c = c;
|
||||
|
||||
Reference in New Issue
Block a user