C++: Add a testcase with failing IR generation.

This commit is contained in:
Mathias Vorreiter Pedersen
2024-02-07 11:38:02 +00:00
parent c5dc88345d
commit d0b0440427
10 changed files with 103 additions and 16 deletions

View File

@@ -16132,6 +16132,31 @@ ir.cpp:
# 2112| getExpr(): [VariableAccess] end
# 2112| Type = [CharPointerType] char *
# 2112| ValueCategory = prvalue(load)
# 2115| [CopyAssignmentOperator] HasOperatorBool& HasOperatorBool::operator=(HasOperatorBool const&)
# 2115| <params>:
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
#-----| Type = [LValueReferenceType] const HasOperatorBool &
# 2115| [MoveAssignmentOperator] HasOperatorBool& HasOperatorBool::operator=(HasOperatorBool&&)
# 2115| <params>:
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
#-----| Type = [RValueReferenceType] HasOperatorBool &&
# 2116| [ConversionOperator] bool HasOperatorBool::operator bool()
# 2116| <params>:
# 2119| [TopLevelFunction] void call_as_child_of_ConditionDeclExpr()
# 2119| <params>:
# 2119| getEntryPoint(): [BlockStmt] { ... }
# 2120| getStmt(0): [IfStmt] if (...) ...
# 2120| getCondition(): [ConditionDeclExpr] (condition decl)
# 2120| Type = [BoolType] bool
# 2120| ValueCategory = prvalue
# 2120| getChild(0): [FunctionCall] call to operator bool
# 2120| Type = [BoolType] bool
# 2120| ValueCategory = prvalue
# 2120| getQualifier(): [VariableAccess] b
# 2120| Type = [Struct] HasOperatorBool
# 2120| ValueCategory = prvalue(load)
# 2120| getThen(): [BlockStmt] { ... }
# 2121| getStmt(1): [ReturnStmt] return ...
perf-regression.cpp:
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
# 4| <params>:

View File

@@ -12441,6 +12441,16 @@ ir.cpp:
# 2109| v2109_12(void) = AliasedUse : m2109_3
# 2109| v2109_13(void) = ExitFunction :
# 2119| void call_as_child_of_ConditionDeclExpr()
# 2119| Block 0
# 2119| v2119_1(void) = EnterFunction :
# 2119| m2119_2(unknown) = AliasedDefinition :
# 2119| m2119_3(unknown) = InitializeNonLocal :
# 2119| m2119_4(unknown) = Chi : total:m2119_2, partial:m2119_3
# 2120| r2120_1(glval<HasOperatorBool>) = VariableAddress[b] :
# 2120| r2120_2(HasOperatorBool) = Constant[0] :
# 2120| m2120_3(HasOperatorBool) = Store[b] : &:r2120_1, r2120_2
perf-regression.cpp:
# 6| void Big::Big()
# 6| Block 0

View File

@@ -6,13 +6,18 @@ missingOperandType
duplicateChiOperand
sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:2120:25:2120:42 | Store: 0 | Instruction 'Store: 0' has no successors in function '$@'. | ir.cpp:2119:6:2119:39 | void call_as_child_of_ConditionDeclExpr() | void call_as_child_of_ConditionDeclExpr() |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction
memoryOperandDefinitionIsUnmodeled
operandAcrossFunctions
instructionWithoutUniqueBlock
missingCanonicalLanguageType
multipleCanonicalLanguageTypes
containsLoopOfForwardEdges
missingIRType
multipleIRTypes
lostReachability
backEdgeCountMismatch
useNotDominatedByDefinition
@@ -24,8 +29,4 @@ nonUniqueEnclosingIRFunction
fieldAddressOnNonPointer
thisArgumentIsNonPointer
nonUniqueIRVariable
missingCanonicalLanguageType
multipleCanonicalLanguageTypes
missingIRType
multipleIRTypes
missingCppType

View File

@@ -6,13 +6,18 @@ missingOperandType
duplicateChiOperand
sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:2120:25:2120:42 | Store: 0 | Instruction 'Store: 0' has no successors in function '$@'. | ir.cpp:2119:6:2119:39 | void call_as_child_of_ConditionDeclExpr() | void call_as_child_of_ConditionDeclExpr() |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction
memoryOperandDefinitionIsUnmodeled
operandAcrossFunctions
instructionWithoutUniqueBlock
missingCanonicalLanguageType
multipleCanonicalLanguageTypes
containsLoopOfForwardEdges
missingIRType
multipleIRTypes
lostReachability
backEdgeCountMismatch
useNotDominatedByDefinition
@@ -24,8 +29,4 @@ nonUniqueEnclosingIRFunction
fieldAddressOnNonPointer
thisArgumentIsNonPointer
nonUniqueIRVariable
missingCanonicalLanguageType
multipleCanonicalLanguageTypes
missingIRType
multipleIRTypes
missingCppType

View File

@@ -2112,4 +2112,12 @@ char* test_strtod(char *s) {
return end;
}
struct HasOperatorBool {
operator bool();
};
void call_as_child_of_ConditionDeclExpr() {
if(HasOperatorBool b = HasOperatorBool()) {}
}
// semmle-extractor-options: -std=c++17 --clang

View File

@@ -10070,6 +10070,10 @@
| ir.cpp:2112:10:2112:12 | Address | &:r2112_2 |
| ir.cpp:2112:10:2112:12 | Load | m2111_11 |
| ir.cpp:2112:10:2112:12 | StoreValue | r2112_3 |
| ir.cpp:2119:6:2119:39 | ChiPartial | partial:m2119_3 |
| ir.cpp:2119:6:2119:39 | ChiTotal | total:m2119_2 |
| ir.cpp:2120:6:2120:42 | Address | &:r2120_1 |
| ir.cpp:2120:25:2120:42 | StoreValue | r2120_2 |
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
| perf-regression.cpp:6:3:6:5 | Address | &:r6_7 |

View File

@@ -1,4 +1,5 @@
missingOperand
| ir.cpp:2120:6:2120:42 | CopyValue: (condition decl) | Instruction 'CopyValue' is missing an expected operand with tag 'Unary' in function '$@'. | ir.cpp:2119:6:2119:39 | void call_as_child_of_ConditionDeclExpr() | void call_as_child_of_ConditionDeclExpr() |
unexpectedOperand
duplicateOperand
missingPhiOperand
@@ -6,6 +7,8 @@ missingOperandType
duplicateChiOperand
sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:2120:22:2120:22 | IndirectMayWriteSideEffect: b | Instruction 'IndirectMayWriteSideEffect: b' has no successors in function '$@'. | ir.cpp:2119:6:2119:39 | void call_as_child_of_ConditionDeclExpr() | void call_as_child_of_ConditionDeclExpr() |
| ir.cpp:2120:25:2120:42 | Store: 0 | Instruction 'Store: 0' has no successors in function '$@'. | ir.cpp:2119:6:2119:39 | void call_as_child_of_ConditionDeclExpr() | void call_as_child_of_ConditionDeclExpr() |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction

View File

@@ -11647,6 +11647,39 @@ ir.cpp:
# 2109| v2109_11(void) = AliasedUse : ~m?
# 2109| v2109_12(void) = ExitFunction :
# 2119| void call_as_child_of_ConditionDeclExpr()
# 2119| Block 0
# 2119| v2119_1(void) = EnterFunction :
# 2119| mu2119_2(unknown) = AliasedDefinition :
# 2119| mu2119_3(unknown) = InitializeNonLocal :
# 2120| r2120_1(glval<HasOperatorBool>) = VariableAddress[b] :
# 2120| r2120_2(HasOperatorBool) = Constant[0] :
# 2120| mu2120_3(HasOperatorBool) = Store[b] : &:r2120_1, r2120_2
# 2120| (no string representation)
# 2120| CopyValue: (condition decl)
# 2120| ConditionalBranch: (condition decl)
#-----| False -> Block 3
#-----| True -> Block 2
# 2120| Block 1
# 2120| r2120_4(glval<HasOperatorBool>) = VariableAddress[b] :
# 2120| r2120_5(glval<unknown>) = FunctionAddress[operator bool] :
# 2120| r2120_6(bool) = Call[operator bool] : func:r2120_5, this:r2120_4
# 2120| mu2120_7(unknown) = ^CallSideEffect : ~m?
# 2120| v2120_8(void) = ^IndirectReadSideEffect[-1] : &:r2120_4, ~m?
# 2120| mu2120_9(HasOperatorBool) = ^IndirectMayWriteSideEffect[-1] : &:r2120_4
# 2120| Block 2
# 2120| v2120_10(void) = NoOp :
#-----| Goto -> Block 3
# 2121| Block 3
# 2121| v2121_1(void) = NoOp :
# 2119| v2119_4(void) = ReturnVoid :
# 2119| v2119_5(void) = AliasedUse : ~m?
# 2119| v2119_6(void) = ExitFunction :
perf-regression.cpp:
# 6| void Big::Big()
# 6| Block 0

View File

@@ -6,13 +6,18 @@ missingOperandType
duplicateChiOperand
sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:2120:25:2120:42 | Store: 0 | Instruction 'Store: 0' has no successors in function '$@'. | ir.cpp:2119:6:2119:39 | void call_as_child_of_ConditionDeclExpr() | void call_as_child_of_ConditionDeclExpr() |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction
memoryOperandDefinitionIsUnmodeled
operandAcrossFunctions
instructionWithoutUniqueBlock
missingCanonicalLanguageType
multipleCanonicalLanguageTypes
containsLoopOfForwardEdges
missingIRType
multipleIRTypes
lostReachability
backEdgeCountMismatch
useNotDominatedByDefinition
@@ -24,8 +29,4 @@ nonUniqueEnclosingIRFunction
fieldAddressOnNonPointer
thisArgumentIsNonPointer
nonUniqueIRVariable
missingCanonicalLanguageType
multipleCanonicalLanguageTypes
missingIRType
multipleIRTypes
missingCppType

View File

@@ -6,13 +6,18 @@ missingOperandType
duplicateChiOperand
sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:2120:25:2120:42 | Store: 0 | Instruction 'Store: 0' has no successors in function '$@'. | ir.cpp:2119:6:2119:39 | void call_as_child_of_ConditionDeclExpr() | void call_as_child_of_ConditionDeclExpr() |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction
memoryOperandDefinitionIsUnmodeled
operandAcrossFunctions
instructionWithoutUniqueBlock
missingCanonicalLanguageType
multipleCanonicalLanguageTypes
containsLoopOfForwardEdges
missingIRType
multipleIRTypes
lostReachability
backEdgeCountMismatch
useNotDominatedByDefinition
@@ -24,8 +29,4 @@ nonUniqueEnclosingIRFunction
fieldAddressOnNonPointer
thisArgumentIsNonPointer
nonUniqueIRVariable
missingCanonicalLanguageType
multipleCanonicalLanguageTypes
missingIRType
multipleIRTypes
missingCppType