C++: autoformat for first-class destructors

This commit is contained in:
Robert Marsh
2024-01-23 18:11:12 +00:00
parent 56c9566867
commit 0bc023139b
4 changed files with 10 additions and 13 deletions

View File

@@ -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 + ")"
)
)
)

View File

@@ -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() {

View File

@@ -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
@@ -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) }

View File

@@ -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
}