Skip to content

Commit 1828970

Browse files
committed
C++: Add an example of double negation to the IR tests.
1 parent 3bc1d47 commit 1828970

File tree

4 files changed

+40
-11
lines changed

4 files changed

+40
-11
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4932,7 +4932,20 @@ ir.c:
49324932
# 103| Type = [IntType] int
49334933
# 103| ValueCategory = prvalue(load)
49344934
# 103| getThen(): [BlockStmt] { ... }
4935-
# 104| getStmt(16): [ReturnStmt] return ...
4935+
# 105| getStmt(16): [DeclStmt] declaration
4936+
# 105| getDeclarationEntry(0): [VariableDeclarationEntry] definition of double_negation
4937+
# 105| Type = [IntType] int
4938+
# 105| getVariable().getInitializer(): [Initializer] initializer for double_negation
4939+
# 105| getExpr(): [NotExpr] ! ...
4940+
# 105| Type = [IntType] int
4941+
# 105| ValueCategory = prvalue
4942+
# 105| getOperand(): [NotExpr] ! ...
4943+
# 105| Type = [IntType] int
4944+
# 105| ValueCategory = prvalue
4945+
# 105| getOperand(): [VariableAccess] x1
4946+
# 105| Type = [IntType] int
4947+
# 105| ValueCategory = prvalue(load)
4948+
# 106| getStmt(17): [ReturnStmt] return ...
49364949
ir.cpp:
49374950
# 1| [TopLevelFunction] void Constants()
49384951
# 1| <params>:

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3969,11 +3969,18 @@ ir.c:
39693969
# 103| v103_6(void) = NoOp :
39703970
#-----| Goto -> Block 40
39713971

3972-
# 104| Block 40
3973-
# 104| v104_1(void) = NoOp :
3974-
# 84| v84_9(void) = ReturnVoid :
3975-
# 84| v84_10(void) = AliasedUse : m84_3
3976-
# 84| v84_11(void) = ExitFunction :
3972+
# 105| Block 40
3973+
# 105| r105_1(glval<int>) = VariableAddress[double_negation] :
3974+
# 105| r105_2(glval<int>) = VariableAddress[x1] :
3975+
# 105| r105_3(int) = Load[x1] : &:r105_2, m84_6
3976+
# 105| r105_4(int) = Constant[0] :
3977+
# 105| r105_5(bool) = CompareEQ : r105_3, r105_4
3978+
# 105| r105_6(bool) = LogicalNot : r105_5
3979+
# 105| m105_7(int) = Store[double_negation] : &:r105_1, r105_6
3980+
# 106| v106_1(void) = NoOp :
3981+
# 84| v84_9(void) = ReturnVoid :
3982+
# 84| v84_10(void) = AliasedUse : m84_3
3983+
# 84| v84_11(void) = ExitFunction :
39773984

39783985
ir.cpp:
39793986
# 1| void Constants()

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ void branch_on_integral_in_c(int x1, int x2) {
101101
int x_1_and_2 = x1 && x2;
102102
if(x_1_and_2) {}
103103
if(!x_1_and_2) {}
104+
105+
int double_negation = !!x1;
104106
}
105107

106108
// semmle-extractor-options: --microsoft

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3605,11 +3605,18 @@ ir.c:
36053605
# 103| v103_6(void) = NoOp :
36063606
#-----| Goto -> Block 40
36073607

3608-
# 104| Block 40
3609-
# 104| v104_1(void) = NoOp :
3610-
# 84| v84_8(void) = ReturnVoid :
3611-
# 84| v84_9(void) = AliasedUse : ~m?
3612-
# 84| v84_10(void) = ExitFunction :
3608+
# 105| Block 40
3609+
# 105| r105_1(glval<int>) = VariableAddress[double_negation] :
3610+
# 105| r105_2(glval<int>) = VariableAddress[x1] :
3611+
# 105| r105_3(int) = Load[x1] : &:r105_2, ~m?
3612+
# 105| r105_4(int) = Constant[0] :
3613+
# 105| r105_5(bool) = CompareEQ : r105_3, r105_4
3614+
# 105| r105_6(bool) = LogicalNot : r105_5
3615+
# 105| mu105_7(int) = Store[double_negation] : &:r105_1, r105_6
3616+
# 106| v106_1(void) = NoOp :
3617+
# 84| v84_8(void) = ReturnVoid :
3618+
# 84| v84_9(void) = AliasedUse : ~m?
3619+
# 84| v84_10(void) = ExitFunction :
36133620

36143621
ir.cpp:
36153622
# 1| void Constants()

0 commit comments

Comments
 (0)