зеркало из https://github.com/github/codeql.git
C++: Update IR generation for changes in frontend
This commit is contained in:
Родитель
3145c53a19
Коммит
4339e18ed6
|
@ -648,19 +648,7 @@ abstract class TranslatedCrementOperation extends TranslatedNonConstantExpr {
|
||||||
class TranslatedPrefixCrementOperation extends TranslatedCrementOperation {
|
class TranslatedPrefixCrementOperation extends TranslatedCrementOperation {
|
||||||
override PrefixCrementOperation expr;
|
override PrefixCrementOperation expr;
|
||||||
|
|
||||||
override Instruction getResult() {
|
override Instruction getResult() { result = this.getUnloadedOperand().getResult() }
|
||||||
if expr.isPRValueCategory()
|
|
||||||
then
|
|
||||||
// If this is C, then the result of a prefix crement is a prvalue for the
|
|
||||||
// new value assigned to the operand. If this is C++, then the result is
|
|
||||||
// an lvalue, but that lvalue is being loaded as part of this expression.
|
|
||||||
// EDG doesn't mark this as a load.
|
|
||||||
result = this.getInstruction(CrementOpTag())
|
|
||||||
else
|
|
||||||
// This is C++, where the result is an lvalue for the operand, and that
|
|
||||||
// lvalue is not being loaded as part of this expression.
|
|
||||||
result = this.getUnloadedOperand().getResult()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TranslatedPostfixCrementOperation extends TranslatedCrementOperation {
|
class TranslatedPostfixCrementOperation extends TranslatedCrementOperation {
|
||||||
|
@ -1503,19 +1491,7 @@ class TranslatedAssignExpr extends TranslatedNonConstantExpr {
|
||||||
result = this.getRightOperand().getFirstInstruction()
|
result = this.getRightOperand().getFirstInstruction()
|
||||||
}
|
}
|
||||||
|
|
||||||
final override Instruction getResult() {
|
final override Instruction getResult() { result = this.getLeftOperand().getResult() }
|
||||||
if expr.isPRValueCategory()
|
|
||||||
then
|
|
||||||
// If this is C, then the result of an assignment is a prvalue for the new
|
|
||||||
// value assigned to the left operand. If this is C++, then the result is
|
|
||||||
// an lvalue, but that lvalue is being loaded as part of this expression.
|
|
||||||
// EDG doesn't mark this as a load.
|
|
||||||
result = this.getRightOperand().getResult()
|
|
||||||
else
|
|
||||||
// This is C++, where the result is an lvalue for the left operand,
|
|
||||||
// and that lvalue is not being loaded as part of this expression.
|
|
||||||
result = this.getLeftOperand().getResult()
|
|
||||||
}
|
|
||||||
|
|
||||||
final TranslatedExpr getLeftOperand() {
|
final TranslatedExpr getLeftOperand() {
|
||||||
result = getTranslatedExpr(expr.getLValue().getFullyConverted())
|
result = getTranslatedExpr(expr.getLValue().getFullyConverted())
|
||||||
|
@ -1641,19 +1617,7 @@ class TranslatedAssignOperation extends TranslatedNonConstantExpr {
|
||||||
result = this.getRightOperand().getFirstInstruction()
|
result = this.getRightOperand().getFirstInstruction()
|
||||||
}
|
}
|
||||||
|
|
||||||
final override Instruction getResult() {
|
final override Instruction getResult() { result = this.getUnloadedLeftOperand().getResult() }
|
||||||
if expr.isPRValueCategory()
|
|
||||||
then
|
|
||||||
// If this is C, then the result of an assignment is a prvalue for the new
|
|
||||||
// value assigned to the left operand. If this is C++, then the result is
|
|
||||||
// an lvalue, but that lvalue is being loaded as part of this expression.
|
|
||||||
// EDG doesn't mark this as a load.
|
|
||||||
result = this.getStoredValue()
|
|
||||||
else
|
|
||||||
// This is C++, where the result is an lvalue for the left operand,
|
|
||||||
// and that lvalue is not being loaded as part of this expression.
|
|
||||||
result = this.getUnloadedLeftOperand().getResult()
|
|
||||||
}
|
|
||||||
|
|
||||||
final TranslatedExpr getUnloadedLeftOperand() {
|
final TranslatedExpr getUnloadedLeftOperand() {
|
||||||
result = this.getLoadedLeftOperand().getOperand()
|
result = this.getLoadedLeftOperand().getOperand()
|
||||||
|
@ -3237,11 +3201,9 @@ predicate exprNeedsCopyIfNotLoaded(Expr expr) {
|
||||||
(
|
(
|
||||||
expr instanceof AssignExpr
|
expr instanceof AssignExpr
|
||||||
or
|
or
|
||||||
expr instanceof AssignOperation and
|
expr instanceof AssignOperation
|
||||||
not expr.isPRValueCategory() // is C++
|
|
||||||
or
|
or
|
||||||
expr instanceof PrefixCrementOperation and
|
expr instanceof PrefixCrementOperation
|
||||||
not expr.isPRValueCategory() // is C++
|
|
||||||
or
|
or
|
||||||
// Because the load is on the `e` in `e++`.
|
// Because the load is on the `e` in `e++`.
|
||||||
expr instanceof PostfixCrementOperation
|
expr instanceof PostfixCrementOperation
|
||||||
|
|
Загрузка…
Ссылка в новой задаче