Skip to content

Commit de142b2

Browse files
committed
C++: Add IR test that exposes a gap in the extractor output
1 parent 1d56330 commit de142b2

9 files changed

+388
-0
lines changed

cpp/ql/test/library-tests/ir/ir/PrintAST.expected

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13975,6 +13975,150 @@ ir.cpp:
1397513975
# 1815| Type = [IntType] int
1397613976
# 1815| ValueCategory = prvalue(load)
1397713977
# 1817| getStmt(8): [ReturnStmt] return ...
13978+
# 1834| [CopyAssignmentOperator] block_assignment::A& block_assignment::A::operator=(block_assignment::A const&)
13979+
# 1834| <params>:
13980+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13981+
#-----| Type = [LValueReferenceType] const A &
13982+
# 1834| [MoveAssignmentOperator] block_assignment::A& block_assignment::A::operator=(block_assignment::A&&)
13983+
# 1834| <params>:
13984+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
13985+
#-----| Type = [RValueReferenceType] A &&
13986+
#-----| getEntryPoint(): [BlockStmt] { ... }
13987+
#-----| getStmt(0): [ExprStmt] ExprStmt
13988+
#-----| getStmt(1): [ReturnStmt] return ...
13989+
#-----| getExpr(): [PointerDereferenceExpr] * ...
13990+
#-----| Type = [Class] A
13991+
#-----| ValueCategory = lvalue
13992+
#-----| getOperand(): [ThisExpr] this
13993+
#-----| Type = [PointerType] A *
13994+
#-----| ValueCategory = prvalue(load)
13995+
#-----| getExpr().getFullyConverted(): [ReferenceToExpr] (reference to)
13996+
#-----| Type = [LValueReferenceType] A &
13997+
#-----| ValueCategory = prvalue
13998+
# 1834| [Constructor] void block_assignment::A::A()
13999+
# 1834| <params>:
14000+
# 1834| [CopyConstructor] void block_assignment::A::A(block_assignment::A const&)
14001+
# 1834| <params>:
14002+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
14003+
#-----| Type = [LValueReferenceType] const A &
14004+
# 1834| [MoveConstructor] void block_assignment::A::A(block_assignment::A&&)
14005+
# 1834| <params>:
14006+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
14007+
#-----| Type = [RValueReferenceType] A &&
14008+
# 1836| [VirtualFunction] void block_assignment::A::f()
14009+
# 1836| <params>:
14010+
# 1839| [CopyAssignmentOperator] block_assignment::B& block_assignment::B::operator=(block_assignment::B const&)
14011+
# 1839| <params>:
14012+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
14013+
#-----| Type = [LValueReferenceType] const B &
14014+
# 1839| [MoveAssignmentOperator] block_assignment::B& block_assignment::B::operator=(block_assignment::B&&)
14015+
# 1839| <params>:
14016+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
14017+
#-----| Type = [RValueReferenceType] B &&
14018+
#-----| getEntryPoint(): [BlockStmt] { ... }
14019+
#-----| getStmt(0): [ExprStmt] ExprStmt
14020+
# 1839| getExpr(): [FunctionCall] call to operator=
14021+
# 1839| Type = [LValueReferenceType] A &
14022+
# 1839| ValueCategory = prvalue
14023+
# 1839| getQualifier(): [ThisExpr] this
14024+
# 1839| Type = [PointerType] B *
14025+
# 1839| ValueCategory = prvalue(load)
14026+
# 1839| getArgument(0): [PointerDereferenceExpr] * ...
14027+
# 1839| Type = [Class] A
14028+
# 1839| ValueCategory = xvalue
14029+
# 1839| getOperand(): [AddressOfExpr] & ...
14030+
# 1839| Type = [PointerType] B *
14031+
# 1839| ValueCategory = prvalue
14032+
# 1839| getOperand(): [VariableAccess] (unnamed parameter 0)
14033+
# 1839| Type = [RValueReferenceType] B &&
14034+
# 1839| ValueCategory = prvalue(load)
14035+
#-----| getOperand().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
14036+
#-----| Type = [Struct] B
14037+
#-----| ValueCategory = lvalue
14038+
#-----| getOperand().getFullyConverted(): [CStyleCast] (A *)...
14039+
#-----| Conversion = [BaseClassConversion] base class conversion
14040+
#-----| Type = [PointerType] A *
14041+
#-----| ValueCategory = prvalue
14042+
#-----| getQualifier().getFullyConverted(): [CStyleCast] (A *)...
14043+
#-----| Conversion = [BaseClassConversion] base class conversion
14044+
#-----| Type = [PointerType] A *
14045+
#-----| ValueCategory = prvalue
14046+
#-----| getArgument(0).getFullyConverted(): [ReferenceToExpr] (reference to)
14047+
#-----| Type = [LValueReferenceType] A &
14048+
#-----| ValueCategory = prvalue
14049+
#-----| getExpr().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
14050+
#-----| Type = [Class] A
14051+
#-----| ValueCategory = lvalue
14052+
#-----| getStmt(1): [ReturnStmt] return ...
14053+
#-----| getExpr(): [PointerDereferenceExpr] * ...
14054+
#-----| Type = [Struct] B
14055+
#-----| ValueCategory = lvalue
14056+
#-----| getOperand(): [ThisExpr] this
14057+
#-----| Type = [PointerType] B *
14058+
#-----| ValueCategory = prvalue(load)
14059+
#-----| getExpr().getFullyConverted(): [ReferenceToExpr] (reference to)
14060+
#-----| Type = [LValueReferenceType] B &
14061+
#-----| ValueCategory = prvalue
14062+
# 1839| [CopyConstructor] void block_assignment::B::B(block_assignment::B const&)
14063+
# 1839| <params>:
14064+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
14065+
#-----| Type = [LValueReferenceType] const B &
14066+
# 1839| [MoveConstructor] void block_assignment::B::B(block_assignment::B&&)
14067+
# 1839| <params>:
14068+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
14069+
#-----| Type = [RValueReferenceType] B &&
14070+
# 1840| [Constructor] void block_assignment::B::B(block_assignment::A*)
14071+
# 1840| <params>:
14072+
# 1840| getParameter(0): [Parameter] (unnamed parameter 0)
14073+
# 1840| Type = [PointerType] A *
14074+
# 1843| [TopLevelFunction] void block_assignment::foo()
14075+
# 1843| <params>:
14076+
# 1843| getEntryPoint(): [BlockStmt] { ... }
14077+
# 1844| getStmt(0): [DeclStmt] declaration
14078+
# 1844| getDeclarationEntry(0): [VariableDeclarationEntry] definition of v
14079+
# 1844| Type = [Struct] B
14080+
# 1844| getVariable().getInitializer(): [Initializer] initializer for v
14081+
# 1844| getExpr(): [ConstructorCall] call to B
14082+
# 1844| Type = [VoidType] void
14083+
# 1844| ValueCategory = prvalue
14084+
# 1844| getArgument(0): [Literal] 0
14085+
# 1844| Type = [IntType] int
14086+
# 1844| Value = [Literal] 0
14087+
# 1844| ValueCategory = prvalue
14088+
# 1844| getArgument(0).getFullyConverted(): [CStyleCast] (A *)...
14089+
# 1844| Conversion = [IntegralToPointerConversion] integral to pointer conversion
14090+
# 1844| Type = [PointerType] A *
14091+
# 1844| Value = [CStyleCast] 0
14092+
# 1844| ValueCategory = prvalue
14093+
# 1845| getStmt(1): [ExprStmt] ExprStmt
14094+
# 1845| getExpr(): [FunctionCall] call to operator=
14095+
# 1845| Type = [LValueReferenceType] B &
14096+
# 1845| ValueCategory = prvalue
14097+
# 1845| getQualifier(): [VariableAccess] v
14098+
# 1845| Type = [Struct] B
14099+
# 1845| ValueCategory = lvalue
14100+
# 1845| getArgument(0): [ConstructorCall] call to B
14101+
# 1845| Type = [VoidType] void
14102+
# 1845| ValueCategory = prvalue
14103+
# 1845| getArgument(0): [Literal] 0
14104+
# 1845| Type = [IntType] int
14105+
# 1845| Value = [Literal] 0
14106+
# 1845| ValueCategory = prvalue
14107+
# 1845| getArgument(0).getFullyConverted(): [CStyleCast] (A *)...
14108+
# 1845| Conversion = [IntegralToPointerConversion] integral to pointer conversion
14109+
# 1845| Type = [PointerType] A *
14110+
# 1845| Value = [CStyleCast] 0
14111+
# 1845| ValueCategory = prvalue
14112+
# 1845| getArgument(0).getFullyConverted(): [ReferenceToExpr] (reference to)
14113+
# 1845| Type = [LValueReferenceType] B &
14114+
# 1845| ValueCategory = prvalue
14115+
# 1845| getExpr(): [TemporaryObjectExpr] temporary object
14116+
# 1845| Type = [Struct] B
14117+
# 1845| ValueCategory = lvalue
14118+
# 1845| getExpr().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
14119+
# 1845| Type = [Struct] B
14120+
# 1845| ValueCategory = lvalue
14121+
# 1846| getStmt(2): [ReturnStmt] return ...
1397814122
perf-regression.cpp:
1397914123
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
1398014124
# 4| <params>:

cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ missingOperandType
66
duplicateChiOperand
77
sideEffectWithoutPrimary
88
instructionWithoutSuccessor
9+
| file://:0:0:0:0 | InitializeIndirection: (unnamed parameter 0) | Instruction 'InitializeIndirection: (unnamed parameter 0)' has no successors in function '$@'. | ir.cpp:1834:11:1834:11 | block_assignment::A& block_assignment::A::operator=(block_assignment::A&&) | block_assignment::A& block_assignment::A::operator=(block_assignment::A&&) |
910
ambiguousSuccessors
1011
unexplainedLoop
1112
unnecessaryPhiInstruction

cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency_unsound.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ missingOperandType
66
duplicateChiOperand
77
sideEffectWithoutPrimary
88
instructionWithoutSuccessor
9+
| file://:0:0:0:0 | InitializeIndirection: (unnamed parameter 0) | Instruction 'InitializeIndirection: (unnamed parameter 0)' has no successors in function '$@'. | ir.cpp:1834:11:1834:11 | block_assignment::A& block_assignment::A::operator=(block_assignment::A&&) | block_assignment::A& block_assignment::A::operator=(block_assignment::A&&) |
910
ambiguousSuccessors
1011
unexplainedLoop
1112
unnecessaryPhiInstruction

cpp/ql/test/library-tests/ir/ir/ir.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,4 +1830,20 @@ char *global_string = "global string";
18301830

18311831
int global_6 = global_2;
18321832

1833+
namespace block_assignment {
1834+
class A {
1835+
enum {} e[1];
1836+
virtual void f();
1837+
};
1838+
1839+
struct B : A {
1840+
B(A *);
1841+
};
1842+
1843+
void foo() {
1844+
B v(0);
1845+
v = 0;
1846+
}
1847+
}
1848+
18331849
// semmle-extractor-options: -std=c++17 --clang

0 commit comments

Comments
 (0)