mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
C++ IR: Tests with ErrorExpr
This commit is contained in:
@@ -190,6 +190,31 @@ bad_asts.cpp:
|
||||
# 27| Type = const Point &
|
||||
# 27| ValueCategory = prvalue(load)
|
||||
# 28| 1: return ...
|
||||
# 30| void Bad::errorExpr()
|
||||
# 30| params:
|
||||
# 30| body: { ... }
|
||||
# 31| 0: ExprStmt
|
||||
#-----| 0: <error expr>
|
||||
#-----| Type = error
|
||||
#-----| ValueCategory = prvalue(load)
|
||||
# 32| 1: declaration
|
||||
# 32| 0: definition of x
|
||||
# 32| Type = int
|
||||
# 32| init: initializer for x
|
||||
# 32| expr: <error expr>
|
||||
# 32| Type = error
|
||||
# 32| ValueCategory = prvalue
|
||||
# 33| 2: ExprStmt
|
||||
# 33| 0: ... = ...
|
||||
# 33| Type = int
|
||||
# 33| ValueCategory = lvalue
|
||||
# 33| 0: x
|
||||
# 33| Type = int
|
||||
# 33| ValueCategory = lvalue
|
||||
#-----| 1: <error expr>
|
||||
#-----| Type = error
|
||||
#-----| ValueCategory = prvalue(load)
|
||||
# 34| 3: return ...
|
||||
clang.cpp:
|
||||
# 5| int* globalIntAddress()
|
||||
# 5| params:
|
||||
|
||||
@@ -4,6 +4,7 @@ duplicateOperand
|
||||
missingPhiOperand
|
||||
missingOperandType
|
||||
instructionWithoutSuccessor
|
||||
| bad_asts.cpp:30:8:30:16 | UnmodeledDefinition: errorExpr |
|
||||
ambiguousSuccessors
|
||||
unexplainedLoop
|
||||
unnecessaryPhiInstruction
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// semmle-extractor-options: -std=c++17
|
||||
// semmle-extractor-options: -std=c++17 --expect_errors
|
||||
|
||||
// Test cases that illustrate known bad ASTs that we have to work around in IR generation.
|
||||
namespace Bad {
|
||||
@@ -26,4 +26,10 @@ namespace Bad {
|
||||
void CallCopyConstructor(const Point& a) {
|
||||
Point b = a; // Copy constructor contains literal expressions with no values.
|
||||
}
|
||||
|
||||
void errorExpr() {
|
||||
0 = 1;
|
||||
int x = 0[0];
|
||||
x = 1[1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,28 @@ bad_asts.cpp:
|
||||
# 26| v0_13(void) = UnmodeledUse : mu*
|
||||
# 26| v0_14(void) = ExitFunction :
|
||||
|
||||
# 30| void Bad::errorExpr()
|
||||
# 30| Block 0
|
||||
# 30| v0_0(void) = EnterFunction :
|
||||
# 30| mu0_1(unknown) = AliasedDefinition :
|
||||
# 30| mu0_2(unknown) = UnmodeledDefinition :
|
||||
|
||||
#-----| Block 1
|
||||
#-----| r1_0(error) = Load : ~mu0_2
|
||||
# 33| r1_1(glval<int>) = VariableAddress[x] :
|
||||
# 33| mu1_2(int) = Store : &:r1_1, r1_0
|
||||
# 34| v1_3(void) = NoOp :
|
||||
# 30| v1_4(void) = ReturnVoid :
|
||||
# 30| v1_5(void) = UnmodeledUse : mu*
|
||||
# 30| v1_6(void) = ExitFunction :
|
||||
|
||||
#-----| Block 2
|
||||
#-----| r2_0(error) = Load : ~mu0_2
|
||||
# 32| r2_1(glval<int>) = VariableAddress[x] :
|
||||
|
||||
# 32| Block 3
|
||||
# 32| mu3_0(int) = Store : &:r2_1
|
||||
|
||||
clang.cpp:
|
||||
# 5| int* globalIntAddress()
|
||||
# 5| Block 0
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
missingOperand
|
||||
| bad_asts.cpp:32:12:32:16 | Store: <error expr> | Instruction 'Store' is missing an expected operand with tag 'StoreValue' in function '$@'. | bad_asts.cpp:30:8:30:16 | IR: errorExpr | void Bad::errorExpr() |
|
||||
| file://:0:0:0:0 | Load: <error expr> | Instruction 'Load' is missing an expected operand with tag 'Address' in function '$@'. | bad_asts.cpp:30:8:30:16 | IR: errorExpr | void Bad::errorExpr() |
|
||||
| file://:0:0:0:0 | Load: <error expr> | Instruction 'Load' is missing an expected operand with tag 'Address' in function '$@'. | bad_asts.cpp:30:8:30:16 | IR: errorExpr | void Bad::errorExpr() |
|
||||
unexpectedOperand
|
||||
duplicateOperand
|
||||
missingPhiOperand
|
||||
missingOperandType
|
||||
instructionWithoutSuccessor
|
||||
| bad_asts.cpp:30:8:30:16 | UnmodeledDefinition: errorExpr |
|
||||
| bad_asts.cpp:32:9:32:9 | VariableAddress: definition of x |
|
||||
| bad_asts.cpp:32:12:32:16 | Store: <error expr> |
|
||||
ambiguousSuccessors
|
||||
unexplainedLoop
|
||||
unnecessaryPhiInstruction
|
||||
|
||||
@@ -4,6 +4,7 @@ duplicateOperand
|
||||
missingPhiOperand
|
||||
missingOperandType
|
||||
instructionWithoutSuccessor
|
||||
| bad_asts.cpp:30:8:30:16 | UnmodeledDefinition: errorExpr |
|
||||
ambiguousSuccessors
|
||||
unexplainedLoop
|
||||
unnecessaryPhiInstruction
|
||||
|
||||
Reference in New Issue
Block a user