Skip to content

Commit

Permalink
C++: autoformat for first-class destructors
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmarsh2 committed Jan 24, 2024
1 parent 56c9566 commit 0bc0231
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
3 changes: 2 additions & 1 deletion cpp/ql/lib/semmle/code/cpp/PrintAST.qll
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@ private string getChildAccessorWithoutConversions(Locatable parent, Element chil
exists(int n | expr.getChild(n) = child and result = "getChild(" + n + ")")
or
exists(int n |
expr.getImplicitDestructorCall(n) = child and result = "getImplicitDestructorCall(" + n + ")"
expr.getImplicitDestructorCall(n) = child and
result = "getImplicitDestructorCall(" + n + ")"
)
)
)
Expand Down
4 changes: 1 addition & 3 deletions cpp/ql/lib/semmle/code/cpp/exprs/Expr.qll
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ class Expr extends StmtParent, @expr {
/**
* Gets a compiler-generated destructor call that is performed after this expression.
*/
DestructorCall getAnImplicitDestructorCall() {
synthetic_destructor_call(this, _, result)
}
DestructorCall getAnImplicitDestructorCall() { synthetic_destructor_call(this, _, result) }

/** Gets the location of this expression. */
override Location getLocation() {
Expand Down
6 changes: 2 additions & 4 deletions cpp/ql/lib/semmle/code/cpp/stmts/Stmt.qll
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Stmt extends StmtParent, @stmt {
/**
* Gets the `n`th compiler-generated destructor call that is performed after this statement, in
* order of destruction.
*
*
* For instance, in the following code, `getImplicitDestructorCall(0)` for the block will be the
* destructor call for `c2`:
* ```cpp
Expand All @@ -79,9 +79,7 @@ class Stmt extends StmtParent, @stmt {
/**
* Gets a compiler-generated destructor call that is performed after this statement.
*/
DestructorCall getAnImplicitDestructorCall() {
synthetic_destructor_call(this, _, result)
}
DestructorCall getAnImplicitDestructorCall() { synthetic_destructor_call(this, _, result) }

override Location getLocation() { stmts(underlyingElement(this), _, result) }

Expand Down
10 changes: 5 additions & 5 deletions cpp/ql/test/library-tests/destructors/destructors.ql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import cpp

query predicate exprDestructors(Expr e, int i, DestructorCall d, Expr destructed) {
d = e.getImplicitDestructorCall(i) and
d.getQualifier() = destructed
d = e.getImplicitDestructorCall(i) and
d.getQualifier() = destructed
}

query predicate stmtDestructors(Stmt s, int i, DestructorCall d, Expr destructed) {
d = s.getImplicitDestructorCall(i) and
d.getQualifier() = destructed
}
d = s.getImplicitDestructorCall(i) and
d.getQualifier() = destructed
}

0 comments on commit 0bc0231

Please sign in to comment.