mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
C++: Add test showing that the IR translation for typeid is broken
This commit is contained in:
@@ -50174,3 +50174,42 @@ try_except.cpp:
|
||||
# 52| Type = [IntType] int
|
||||
# 52| ValueCategory = prvalue(load)
|
||||
# 54| getStmt(2): [ReturnStmt] return ...
|
||||
type_info_test.cpp:
|
||||
# 3| [TopLevelFunction] void type_info_test(int)
|
||||
# 3| <params>:
|
||||
# 3| getParameter(0): [Parameter] x
|
||||
# 3| Type = [IntType] int
|
||||
# 3| getEntryPoint(): [BlockStmt] { ... }
|
||||
# 4| getStmt(0): [DeclStmt] declaration
|
||||
# 4| getDeclarationEntry(0): [VariableDeclarationEntry] definition of t1
|
||||
# 4| Type = [LValueReferenceType] const type_info &
|
||||
# 4| getVariable().getInitializer(): [Initializer] initializer for t1
|
||||
# 4| getExpr(): [TypeidOperator] typeid ...
|
||||
# 4| Type = [SpecifiedType] const type_info
|
||||
# 4| ValueCategory = lvalue
|
||||
# 4| getExpr(): [VariableAccess] x
|
||||
# 4| Type = [IntType] int
|
||||
# 4| ValueCategory = lvalue
|
||||
# 4| getExpr().getFullyConverted(): [ReferenceToExpr] (reference to)
|
||||
# 4| Type = [LValueReferenceType] const type_info &
|
||||
# 4| ValueCategory = prvalue
|
||||
# 5| getStmt(1): [DeclStmt] declaration
|
||||
# 5| getDeclarationEntry(0): [VariableDeclarationEntry] definition of t2
|
||||
# 5| Type = [LValueReferenceType] const type_info &
|
||||
# 5| getVariable().getInitializer(): [Initializer] initializer for t2
|
||||
# 5| getExpr(): [TypeidOperator] typeid ...
|
||||
# 5| Type = [SpecifiedType] const type_info
|
||||
# 5| ValueCategory = lvalue
|
||||
# 5| getExpr().getFullyConverted(): [ReferenceToExpr] (reference to)
|
||||
# 5| Type = [LValueReferenceType] const type_info &
|
||||
# 5| ValueCategory = prvalue
|
||||
# 6| getStmt(2): [ReturnStmt] return ...
|
||||
typeinfo:
|
||||
# 4| [CopyAssignmentOperator] std::type_info& std::type_info::operator=(std::type_info const&)
|
||||
# 4| <params>:
|
||||
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
|
||||
#-----| Type = [LValueReferenceType] const type_info &
|
||||
# 4| [MoveAssignmentOperator] std::type_info& std::type_info::operator=(std::type_info&&)
|
||||
# 4| <params>:
|
||||
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
|
||||
#-----| Type = [RValueReferenceType] type_info &&
|
||||
|
||||
@@ -39973,3 +39973,14 @@ try_except.cpp:
|
||||
|
||||
# 44| Block 7
|
||||
# 44| v44_10(void) = Unreached :
|
||||
|
||||
type_info_test.cpp:
|
||||
# 3| void type_info_test(int)
|
||||
# 3| Block 0
|
||||
# 3| v3_1(void) = EnterFunction :
|
||||
# 3| m3_2(unknown) = AliasedDefinition :
|
||||
# 3| m3_3(unknown) = InitializeNonLocal :
|
||||
# 3| m3_4(unknown) = Chi : total:m3_2, partial:m3_3
|
||||
# 3| r3_5(glval<int>) = VariableAddress[x] :
|
||||
# 3| m3_6(int) = InitializeParameter[x] : &:r3_5
|
||||
# 4| r4_1(glval<type_info &>) = VariableAddress[t1] :
|
||||
|
||||
@@ -6,6 +6,7 @@ missingOperandType
|
||||
duplicateChiOperand
|
||||
sideEffectWithoutPrimary
|
||||
instructionWithoutSuccessor
|
||||
| type_info_test.cpp:4:25:4:26 | VariableAddress: definition of t1 | Instruction 'VariableAddress: definition of t1' has no successors in function '$@'. | type_info_test.cpp:3:6:3:19 | void type_info_test(int) | void type_info_test(int) |
|
||||
ambiguousSuccessors
|
||||
unexplainedLoop
|
||||
unnecessaryPhiInstruction
|
||||
|
||||
@@ -6,6 +6,7 @@ missingOperandType
|
||||
duplicateChiOperand
|
||||
sideEffectWithoutPrimary
|
||||
instructionWithoutSuccessor
|
||||
| type_info_test.cpp:4:25:4:26 | VariableAddress: definition of t1 | Instruction 'VariableAddress: definition of t1' has no successors in function '$@'. | type_info_test.cpp:3:6:3:19 | void type_info_test(int) | void type_info_test(int) |
|
||||
ambiguousSuccessors
|
||||
unexplainedLoop
|
||||
unnecessaryPhiInstruction
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
missingOperand
|
||||
| type_info_test.cpp:4:30:4:38 | CopyValue: (reference to) | Instruction 'CopyValue' is missing an expected operand with tag 'Unary' in function '$@'. | type_info_test.cpp:3:6:3:19 | void type_info_test(int) | void type_info_test(int) |
|
||||
| type_info_test.cpp:5:30:5:40 | CopyValue: (reference to) | Instruction 'CopyValue' is missing an expected operand with tag 'Unary' in function '$@'. | type_info_test.cpp:3:6:3:19 | void type_info_test(int) | void type_info_test(int) |
|
||||
unexpectedOperand
|
||||
duplicateOperand
|
||||
missingPhiOperand
|
||||
@@ -6,6 +8,9 @@ missingOperandType
|
||||
duplicateChiOperand
|
||||
sideEffectWithoutPrimary
|
||||
instructionWithoutSuccessor
|
||||
| type_info_test.cpp:4:25:4:26 | VariableAddress: definition of t1 | Instruction 'VariableAddress: definition of t1' has no successors in function '$@'. | type_info_test.cpp:3:6:3:19 | void type_info_test(int) | void type_info_test(int) |
|
||||
| type_info_test.cpp:4:37:4:37 | VariableAddress: x | Instruction 'VariableAddress: x' has no successors in function '$@'. | type_info_test.cpp:3:6:3:19 | void type_info_test(int) | void type_info_test(int) |
|
||||
| type_info_test.cpp:5:25:5:26 | VariableAddress: definition of t2 | Instruction 'VariableAddress: definition of t2' has no successors in function '$@'. | type_info_test.cpp:3:6:3:19 | void type_info_test(int) | void type_info_test(int) |
|
||||
ambiguousSuccessors
|
||||
unexplainedLoop
|
||||
unnecessaryPhiInstruction
|
||||
@@ -21,6 +26,8 @@ lostReachability
|
||||
backEdgeCountMismatch
|
||||
useNotDominatedByDefinition
|
||||
| ir.cpp:1535:8:1535:8 | Unary | Operand 'Unary' is not dominated by its definition in function '$@'. | ir.cpp:1535:8:1535:8 | void StructuredBindingDataMemberStruct::StructuredBindingDataMemberStruct() | void StructuredBindingDataMemberStruct::StructuredBindingDataMemberStruct() |
|
||||
| type_info_test.cpp:4:25:4:26 | Address | Operand 'Address' is not dominated by its definition in function '$@'. | type_info_test.cpp:3:6:3:19 | void type_info_test(int) | void type_info_test(int) |
|
||||
| type_info_test.cpp:5:25:5:26 | Address | Operand 'Address' is not dominated by its definition in function '$@'. | type_info_test.cpp:3:6:3:19 | void type_info_test(int) | void type_info_test(int) |
|
||||
switchInstructionWithoutDefaultEdge
|
||||
notMarkedAsConflated
|
||||
wronglyMarkedAsConflated
|
||||
|
||||
@@ -38102,3 +38102,29 @@ try_except.cpp:
|
||||
# 54| v54_1(void) = NoOp :
|
||||
# 44| v44_9(void) = ReturnVoid :
|
||||
#-----| Goto -> Block 1
|
||||
|
||||
type_info_test.cpp:
|
||||
# 3| void type_info_test(int)
|
||||
# 3| Block 0
|
||||
# 3| v3_1(void) = EnterFunction :
|
||||
# 3| mu3_2(unknown) = AliasedDefinition :
|
||||
# 3| mu3_3(unknown) = InitializeNonLocal :
|
||||
# 3| r3_4(glval<int>) = VariableAddress[x] :
|
||||
# 3| mu3_5(int) = InitializeParameter[x] : &:r3_4
|
||||
# 4| r4_1(glval<type_info &>) = VariableAddress[t1] :
|
||||
|
||||
# 4| Block 1
|
||||
# 4| r4_2(glval<int>) = VariableAddress[x] :
|
||||
|
||||
# 4| Block 2
|
||||
# 4| r4_3(type_info &) = CopyValue :
|
||||
# 4| mu4_4(type_info &) = Store[t1] : &:r4_1, r4_3
|
||||
# 5| r5_1(glval<type_info &>) = VariableAddress[t2] :
|
||||
|
||||
# 5| Block 3
|
||||
# 5| r5_2(type_info &) = CopyValue :
|
||||
# 5| mu5_3(type_info &) = Store[t2] : &:r5_1, r5_2
|
||||
# 6| v6_1(void) = NoOp :
|
||||
# 3| v3_6(void) = ReturnVoid :
|
||||
# 3| v3_7(void) = AliasedUse : ~m?
|
||||
# 3| v3_8(void) = ExitFunction :
|
||||
|
||||
8
cpp/ql/test/library-tests/ir/ir/type_info_test.cpp
Normal file
8
cpp/ql/test/library-tests/ir/ir/type_info_test.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <typeinfo>
|
||||
|
||||
void type_info_test(int x) {
|
||||
const std::type_info &t1 = typeid(x);
|
||||
const std::type_info &t2 = typeid(int);
|
||||
}
|
||||
|
||||
// semmle-extractor-options: -I.
|
||||
5
cpp/ql/test/library-tests/ir/ir/typeinfo
Normal file
5
cpp/ql/test/library-tests/ir/ir/typeinfo
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
namespace std{
|
||||
class type_info {};
|
||||
}
|
||||
@@ -6,6 +6,7 @@ missingOperandType
|
||||
duplicateChiOperand
|
||||
sideEffectWithoutPrimary
|
||||
instructionWithoutSuccessor
|
||||
| type_info_test.cpp:4:25:4:26 | VariableAddress: definition of t1 | Instruction 'VariableAddress: definition of t1' has no successors in function '$@'. | type_info_test.cpp:3:6:3:19 | void type_info_test(int) | void type_info_test(int) |
|
||||
ambiguousSuccessors
|
||||
unexplainedLoop
|
||||
unnecessaryPhiInstruction
|
||||
|
||||
@@ -6,6 +6,7 @@ missingOperandType
|
||||
duplicateChiOperand
|
||||
sideEffectWithoutPrimary
|
||||
instructionWithoutSuccessor
|
||||
| type_info_test.cpp:4:25:4:26 | VariableAddress: definition of t1 | Instruction 'VariableAddress: definition of t1' has no successors in function '$@'. | type_info_test.cpp:3:6:3:19 | void type_info_test(int) | void type_info_test(int) |
|
||||
ambiguousSuccessors
|
||||
unexplainedLoop
|
||||
unnecessaryPhiInstruction
|
||||
|
||||
Reference in New Issue
Block a user