C++: Use Opcode::Error for ErrorExpr translation

This commit is contained in:
Jonas Jensen
2019-07-09 13:14:45 +02:00
parent a86ddd50de
commit 4324c97d39
6 changed files with 54 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
private newtype TOpcode = private newtype TOpcode =
TNoOp() or TNoOp() or
TUninitialized() or TUninitialized() or
TError() or
TInitializeParameter() or TInitializeParameter() or
TInitializeThis() or TInitializeThis() or
TEnterFunction() or TEnterFunction() or
@@ -147,6 +148,7 @@ abstract class BufferAccessOpcode extends MemoryAccessOpcode {}
module Opcode { module Opcode {
class NoOp extends Opcode, TNoOp { override final string toString() { result = "NoOp" } } class NoOp extends Opcode, TNoOp { override final string toString() { result = "NoOp" } }
class Uninitialized extends MemoryAccessOpcode, TUninitialized { override final string toString() { result = "Uninitialized" } } class Uninitialized extends MemoryAccessOpcode, TUninitialized { override final string toString() { result = "Uninitialized" } }
class Error extends Opcode, TError { override final string toString() { result = "Error" } }
class InitializeParameter extends MemoryAccessOpcode, TInitializeParameter { override final string toString() { result = "InitializeParameter" } } class InitializeParameter extends MemoryAccessOpcode, TInitializeParameter { override final string toString() { result = "InitializeParameter" } }
class InitializeThis extends Opcode, TInitializeThis { override final string toString() { result = "InitializeThis" } } class InitializeThis extends Opcode, TInitializeThis { override final string toString() { result = "InitializeThis" } }
class EnterFunction extends Opcode, TEnterFunction { override final string toString() { result = "EnterFunction" } } class EnterFunction extends Opcode, TEnterFunction { override final string toString() { result = "EnterFunction" } }

View File

@@ -702,6 +702,22 @@ class FieldAddressInstruction extends FieldInstruction {
} }
} }
/**
* An instruction that produces a well-defined but unknown result and has
* unknown side effects, including side effects that are not conservatively
* modeled in the SSA graph.
*
* This type of instruction appears when there is an `ErrorExpr` in the AST,
* meaning that the extractor could not understand the expression and therefore
* produced a partial AST. Queries that give alerts when some action is _not_
* taken may want to ignore any function that contains an `ErrorInstruction`.
*/
class ErrorInstruction extends Instruction {
ErrorInstruction() {
getOpcode() instanceof Opcode::Error
}
}
class UninitializedInstruction extends VariableInstruction { class UninitializedInstruction extends VariableInstruction {
UninitializedInstruction() { UninitializedInstruction() {
getOpcode() instanceof Opcode::Uninitialized getOpcode() instanceof Opcode::Uninitialized

View File

@@ -702,6 +702,22 @@ class FieldAddressInstruction extends FieldInstruction {
} }
} }
/**
* An instruction that produces a well-defined but unknown result and has
* unknown side effects, including side effects that are not conservatively
* modeled in the SSA graph.
*
* This type of instruction appears when there is an `ErrorExpr` in the AST,
* meaning that the extractor could not understand the expression and therefore
* produced a partial AST. Queries that give alerts when some action is _not_
* taken may want to ignore any function that contains an `ErrorInstruction`.
*/
class ErrorInstruction extends Instruction {
ErrorInstruction() {
getOpcode() instanceof Opcode::Error
}
}
class UninitializedInstruction extends VariableInstruction { class UninitializedInstruction extends VariableInstruction {
UninitializedInstruction() { UninitializedInstruction() {
getOpcode() instanceof Opcode::Uninitialized getOpcode() instanceof Opcode::Uninitialized

View File

@@ -2892,6 +2892,6 @@ class TranslatedErrorExpr extends TranslatedSingleInstructionExpr {
} }
override final Opcode getOpcode() { override final Opcode getOpcode() {
result instanceof Opcode::NoOp result instanceof Opcode::Error
} }
} }

View File

@@ -702,6 +702,22 @@ class FieldAddressInstruction extends FieldInstruction {
} }
} }
/**
* An instruction that produces a well-defined but unknown result and has
* unknown side effects, including side effects that are not conservatively
* modeled in the SSA graph.
*
* This type of instruction appears when there is an `ErrorExpr` in the AST,
* meaning that the extractor could not understand the expression and therefore
* produced a partial AST. Queries that give alerts when some action is _not_
* taken may want to ignore any function that contains an `ErrorInstruction`.
*/
class ErrorInstruction extends Instruction {
ErrorInstruction() {
getOpcode() instanceof Opcode::Error
}
}
class UninitializedInstruction extends VariableInstruction { class UninitializedInstruction extends VariableInstruction {
UninitializedInstruction() { UninitializedInstruction() {
getOpcode() instanceof Opcode::Uninitialized getOpcode() instanceof Opcode::Uninitialized

View File

@@ -53,12 +53,12 @@ bad_asts.cpp:
# 30| v0_0(void) = EnterFunction : # 30| v0_0(void) = EnterFunction :
# 30| mu0_1(unknown) = AliasedDefinition : # 30| mu0_1(unknown) = AliasedDefinition :
# 30| mu0_2(unknown) = UnmodeledDefinition : # 30| mu0_2(unknown) = UnmodeledDefinition :
#-----| r0_3(glval<error>) = NoOp : #-----| r0_3(glval<error>) = Error :
#-----| r0_4(error) = Load : &:r0_3, ~mu0_2 #-----| r0_4(error) = Load : &:r0_3, ~mu0_2
# 32| r0_5(glval<int>) = VariableAddress[x] : # 32| r0_5(glval<int>) = VariableAddress[x] :
# 32| r0_6(error) = NoOp : # 32| r0_6(error) = Error :
# 32| mu0_7(int) = Store : &:r0_5, r0_6 # 32| mu0_7(int) = Store : &:r0_5, r0_6
#-----| r0_8(glval<error>) = NoOp : #-----| r0_8(glval<error>) = Error :
#-----| r0_9(error) = Load : &:r0_8, ~mu0_2 #-----| r0_9(error) = Load : &:r0_8, ~mu0_2
# 33| r0_10(glval<int>) = VariableAddress[x] : # 33| r0_10(glval<int>) = VariableAddress[x] :
# 33| mu0_11(int) = Store : &:r0_10, r0_9 # 33| mu0_11(int) = Store : &:r0_10, r0_9