mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
Merge pull request #2045 from AndreiDiaconu1/ircsharp-various-fixes
C# IR: Minor sanity fixes
This commit is contained in:
@@ -843,6 +843,9 @@ class TranslatedNonFieldVariableAccess extends TranslatedVariableAccess {
|
||||
implies
|
||||
expr = expr.getParent().(LocalVariableDeclAndInitExpr).getInitializer()
|
||||
)
|
||||
or
|
||||
// Static field accesses should be modeled as `TranslatedNonFieldAccess`
|
||||
expr.(FieldAccess).getTarget().isStatic()
|
||||
}
|
||||
|
||||
override Instruction getFirstInstruction() {
|
||||
@@ -875,6 +878,11 @@ class TranslatedNonFieldVariableAccess extends TranslatedVariableAccess {
|
||||
class TranslatedFieldAccess extends TranslatedVariableAccess {
|
||||
override FieldAccess expr;
|
||||
|
||||
TranslatedFieldAccess() {
|
||||
// Static field accesses should be modeled as `TranslatedNonFieldAccess`
|
||||
not expr.getTarget().isStatic()
|
||||
}
|
||||
|
||||
override Instruction getFirstInstruction() {
|
||||
// If there is a qualifier
|
||||
if exists(this.getQualifier())
|
||||
|
||||
@@ -75,7 +75,7 @@ class TranslatedFunction extends TranslatedElement, TTranslatedFunction {
|
||||
else
|
||||
if exists(getParameter(0))
|
||||
then result = this.getParameter(0).getFirstInstruction()
|
||||
else result = this.getBody().getFirstInstruction()
|
||||
else result = this.getBodyOrReturn()
|
||||
)
|
||||
or
|
||||
(
|
||||
@@ -85,7 +85,7 @@ class TranslatedFunction extends TranslatedElement, TTranslatedFunction {
|
||||
else
|
||||
if exists(getConstructorInitializer())
|
||||
then result = this.getConstructorInitializer().getFirstInstruction()
|
||||
else result = this.getBody().getFirstInstruction()
|
||||
else result = this.getBodyOrReturn()
|
||||
)
|
||||
or
|
||||
tag = ReturnValueAddressTag() and
|
||||
@@ -110,16 +110,22 @@ class TranslatedFunction extends TranslatedElement, TTranslatedFunction {
|
||||
else
|
||||
if exists(getConstructorInitializer())
|
||||
then result = this.getConstructorInitializer().getFirstInstruction()
|
||||
else result = this.getBody().getFirstInstruction()
|
||||
else result = this.getBodyOrReturn()
|
||||
)
|
||||
or
|
||||
child = this.getConstructorInitializer() and
|
||||
result = this.getBody().getFirstInstruction()
|
||||
result = this.getBodyOrReturn()
|
||||
or
|
||||
child = this.getBody() and
|
||||
result = this.getReturnSuccessorInstruction()
|
||||
}
|
||||
|
||||
private Instruction getBodyOrReturn() {
|
||||
if exists(this.getBody())
|
||||
then result = this.getBody().getFirstInstruction()
|
||||
else result = this.getReturnSuccessorInstruction()
|
||||
}
|
||||
|
||||
final override predicate hasInstruction(
|
||||
Opcode opcode, InstructionTag tag, Type resultType, boolean isLValue
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user