C++: Autoformat for named destructors in IR

This commit is contained in:
Robert Marsh
2024-02-09 22:35:12 +00:00
parent 1b571f8992
commit d1160f86e1
6 changed files with 25 additions and 10 deletions

View File

@@ -261,7 +261,7 @@ CppType getInstructionOperandType(Instruction instruction, TypedOperandTag tag)
Instruction getPhiInstructionBlockStart(PhiInstruction instr) { none() }
Instruction getInstructionSuccessor(Instruction instruction, EdgeKind kind) {
result =
result =
getInstructionTranslatedElement(instruction)
.getInstructionSuccessor(getInstructionTag(instruction), kind)
}

View File

@@ -447,7 +447,9 @@ private int initializeAllocationGroup() { result = 3 }
abstract class TranslatedSideEffect extends TranslatedElement {
final override TranslatedElement getChild(int n) { none() }
final override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) { none() }
final override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) {
none()
}
final override Instruction getFirstInstruction(EdgeKind kind) {
result = this.getInstruction(OnlyInstructionTag()) and

View File

@@ -70,7 +70,9 @@ abstract class TranslatedFlexibleCondition extends TranslatedCondition, Conditio
none()
}
final override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) { none() }
final override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) {
none()
}
abstract TranslatedCondition getOperand();
}
@@ -96,7 +98,9 @@ class TranslatedParenthesisCondition extends TranslatedFlexibleCondition {
abstract class TranslatedNativeCondition extends TranslatedCondition, TTranslatedNativeCondition {
TranslatedNativeCondition() { this = TTranslatedNativeCondition(expr) }
final override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) { none() }
final override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) {
none()
}
}
abstract class TranslatedBinaryLogicalOperation extends TranslatedNativeCondition, ConditionContext {

View File

@@ -407,7 +407,9 @@ abstract class TranslatedParameter extends TranslatedElement {
result = this.getParent().getChildSuccessor(this, kind)
}
final override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) { none() }
final override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) {
none()
}
final override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
tag = InitializerVariableAddressTag() and
@@ -762,7 +764,7 @@ class TranslatedReadEffects extends TranslatedElement, TTranslatedReadEffects {
.getFirstInstruction(any(GotoEdge goto))
else result = this.getParent().getChildSuccessor(this, any(GotoEdge goto))
}
override TranslatedElement getLastChild() {
result = this.getChild(max(int id | exists(this.getChild(id))))
}

View File

@@ -27,7 +27,9 @@ class TranslatedStaticStorageDurationVarInit extends TranslatedRootElement,
kind instanceof GotoEdge
}
override Instruction getALastInstructionInternal() { result = this.getInstruction(ExitFunctionTag()) }
override Instruction getALastInstructionInternal() {
result = this.getInstruction(ExitFunctionTag())
}
override TranslatedElement getChild(int n) {
n = 1 and

View File

@@ -384,7 +384,9 @@ class TranslatedExprStmt extends TranslatedStmt {
result = this.getExpr().getFirstInstruction(kind)
}
override Instruction getALastInstructionInternal() { result = this.getExpr().getALastInstruction() }
override Instruction getALastInstructionInternal() {
result = this.getExpr().getALastInstruction()
}
override TranslatedElement getLastChild() { result = this.getExpr() }
@@ -997,7 +999,8 @@ class TranslatedForStmt extends TranslatedLoop {
child = this.getUpdate() and result = this.getFirstConditionInstruction(kind)
or
exists(int lastDestructorIndex |
lastDestructorIndex = max(int n | exists(this.getChild(n)) and n >= this.getFirstDestructorCallIndex()) and
lastDestructorIndex =
max(int n | exists(this.getChild(n)) and n >= this.getFirstDestructorCallIndex()) and
child = this.getChild(lastDestructorIndex) and
result = this.getParent().getChildSuccessor(this, kind)
)
@@ -1162,7 +1165,9 @@ class TranslatedSwitchStmt extends TranslatedStmt {
else result = this.getFirstExprInstruction(kind)
}
override Instruction getALastInstructionInternal() { result = this.getBody().getALastInstruction() }
override Instruction getALastInstructionInternal() {
result = this.getBody().getALastInstruction()
}
override TranslatedElement getLastChild() { result = this.getBody() }