Merge pull request #855 from jbj/ir-getRealParent

C++: Simplify TranslatedElement.getRealParent
This commit is contained in:
Dave Bartolomeo 2019-01-31 10:15:30 -08:00 коммит произвёл GitHub
Родитель 8896d3bf88 5b685383c8
Коммит b0b2fc80c1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 3 добавлений и 24 удалений

Просмотреть файл

@ -17,36 +17,15 @@ Type getIntType() {
result.(IntType).isImplicitlySigned()
}
/**
* If `expr` is a conversion, gets the expression being converted. Otherwise,
* returns `expr`.
*/
private Expr getUnconvertedExpr(Expr expr) {
if expr instanceof Conversion then (
result = getUnconvertedExpr(expr.(Conversion).getExpr())
) else (
result = expr
)
}
/**
* Gets the "real" parent of `expr`. This predicate treats conversions as if
* they were explicit nodes in the expression tree, rather than as implicit
* nodes as in the regular AST representation.
*/
private Element getRealParent(Expr expr) {
if expr.hasConversion() then (
// The expression has a conversion, so treat that as its parent
result = expr.getConversion()
)
else (
// Either the expression is a top-level conversion, or it's not a
// conversion. The real parent is the parent of the original unconverted
// expression.
result = getUnconvertedExpr(expr).getParent() or
// The parent of a DestructorDestruction is the destructor itself.
result.(Destructor).getADestruction() = expr
)
result = expr.getParentWithConversions()
or
result.(Destructor).getADestruction() = expr
}
/**