diff --git a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected index a530c429072e..346ace60e2fe 100644 --- a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected +++ b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected @@ -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| : +# 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| : +#-----| getParameter(0): [Parameter] (unnamed parameter 0) +#-----| Type = [LValueReferenceType] const type_info & +# 4| [MoveAssignmentOperator] std::type_info& std::type_info::operator=(std::type_info&&) +# 4| : +#-----| getParameter(0): [Parameter] (unnamed parameter 0) +#-----| Type = [RValueReferenceType] type_info && diff --git a/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected b/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected index 4f1d1abb4ecf..38f0a0a4f4f7 100644 --- a/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected +++ b/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected @@ -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) = VariableAddress[x] : +# 3| m3_6(int) = InitializeParameter[x] : &:r3_5 +# 4| r4_1(glval) = VariableAddress[t1] : diff --git a/cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency.expected b/cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency.expected index b83d9ea47e38..137b2aee2665 100644 --- a/cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency.expected +++ b/cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency.expected @@ -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 diff --git a/cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency_unsound.expected b/cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency_unsound.expected index b83d9ea47e38..137b2aee2665 100644 --- a/cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency_unsound.expected +++ b/cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency_unsound.expected @@ -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 diff --git a/cpp/ql/test/library-tests/ir/ir/raw_consistency.expected b/cpp/ql/test/library-tests/ir/ir/raw_consistency.expected index e30106d35204..9cdfdd2dcd5e 100644 --- a/cpp/ql/test/library-tests/ir/ir/raw_consistency.expected +++ b/cpp/ql/test/library-tests/ir/ir/raw_consistency.expected @@ -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 diff --git a/cpp/ql/test/library-tests/ir/ir/raw_ir.expected b/cpp/ql/test/library-tests/ir/ir/raw_ir.expected index 937695c13ae5..c9158233914d 100644 --- a/cpp/ql/test/library-tests/ir/ir/raw_ir.expected +++ b/cpp/ql/test/library-tests/ir/ir/raw_ir.expected @@ -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) = VariableAddress[x] : +# 3| mu3_5(int) = InitializeParameter[x] : &:r3_4 +# 4| r4_1(glval) = VariableAddress[t1] : + +# 4| Block 1 +# 4| r4_2(glval) = 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) = 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 : diff --git a/cpp/ql/test/library-tests/ir/ir/type_info_test.cpp b/cpp/ql/test/library-tests/ir/ir/type_info_test.cpp new file mode 100644 index 000000000000..b35870aa4091 --- /dev/null +++ b/cpp/ql/test/library-tests/ir/ir/type_info_test.cpp @@ -0,0 +1,8 @@ +#include + +void type_info_test(int x) { + const std::type_info &t1 = typeid(x); + const std::type_info &t2 = typeid(int); +} + +// semmle-extractor-options: -I. diff --git a/cpp/ql/test/library-tests/ir/ir/typeinfo b/cpp/ql/test/library-tests/ir/ir/typeinfo new file mode 100644 index 000000000000..5b14e219f47e --- /dev/null +++ b/cpp/ql/test/library-tests/ir/ir/typeinfo @@ -0,0 +1,5 @@ +#pragma once + +namespace std{ + class type_info {}; +} diff --git a/cpp/ql/test/library-tests/ir/ir/unaliased_ssa_consistency.expected b/cpp/ql/test/library-tests/ir/ir/unaliased_ssa_consistency.expected index b83d9ea47e38..137b2aee2665 100644 --- a/cpp/ql/test/library-tests/ir/ir/unaliased_ssa_consistency.expected +++ b/cpp/ql/test/library-tests/ir/ir/unaliased_ssa_consistency.expected @@ -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 diff --git a/cpp/ql/test/library-tests/ir/ir/unaliased_ssa_consistency_unsound.expected b/cpp/ql/test/library-tests/ir/ir/unaliased_ssa_consistency_unsound.expected index b83d9ea47e38..137b2aee2665 100644 --- a/cpp/ql/test/library-tests/ir/ir/unaliased_ssa_consistency_unsound.expected +++ b/cpp/ql/test/library-tests/ir/ir/unaliased_ssa_consistency_unsound.expected @@ -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