mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
C++ Add test showing incorrect value categories for _Generics
This commit is contained in:
committed by
Alexandre Boulgakov
parent
6273bb60a3
commit
59db802fa4
@@ -4179,6 +4179,40 @@ destructors_for_temps.cpp:
|
||||
# 103| Type = [IntType] int
|
||||
# 103| ValueCategory = prvalue
|
||||
# 104| getStmt(1): [ReturnStmt] return ...
|
||||
generic.c:
|
||||
# 1| [TopLevelFunction] void foo(unsigned int, int)
|
||||
# 1| <params>:
|
||||
# 1| getParameter(0): [Parameter] x
|
||||
# 1| Type = [IntType] unsigned int
|
||||
# 1| getParameter(1): [Parameter] y
|
||||
# 1| Type = [IntType] int
|
||||
# 1| getEntryPoint(): [BlockStmt] { ... }
|
||||
# 2| getStmt(0): [DeclStmt] declaration
|
||||
# 2| getDeclarationEntry(0): [VariableDeclarationEntry] definition of r
|
||||
# 2| Type = [IntType] unsigned int
|
||||
# 3| getStmt(1): [ExprStmt] ExprStmt
|
||||
# 3| getExpr(): [AssignExpr] ... = ...
|
||||
# 3| Type = [IntType] unsigned int
|
||||
# 3| ValueCategory = prvalue
|
||||
# 3| getLValue(): [VariableAccess] r
|
||||
# 3| Type = [IntType] unsigned int
|
||||
# 3| ValueCategory = lvalue
|
||||
# 3| getRValue(): [AddExpr] ... + ...
|
||||
# 3| Type = [IntType] unsigned int
|
||||
# 3| ValueCategory = prvalue
|
||||
# 3| getLeftOperand(): [VariableAccess] x
|
||||
# 3| Type = [IntType] unsigned int
|
||||
# 3| ValueCategory = lvalue
|
||||
# 3| getRightOperand(): [Literal] 1
|
||||
# 3| Type = [IntType] int
|
||||
# 3| Value = [Literal] 1
|
||||
# 3| ValueCategory = prvalue
|
||||
# 3| getRightOperand().getFullyConverted(): [CStyleCast] (unsigned int)...
|
||||
# 3| Conversion = [IntegralConversion] integral conversion
|
||||
# 3| Type = [IntType] unsigned int
|
||||
# 3| Value = [CStyleCast] 1
|
||||
# 3| ValueCategory = prvalue
|
||||
# 4| getStmt(2): [ReturnStmt] return ...
|
||||
ir.c:
|
||||
# 5| [TopLevelFunction] int getX(MyCoords*)
|
||||
# 5| <params>:
|
||||
|
||||
@@ -2958,6 +2958,30 @@ destructors_for_temps.cpp:
|
||||
# 102| v102_9(void) = AliasedUse : ~m103_26
|
||||
# 102| v102_10(void) = ExitFunction :
|
||||
|
||||
generic.c:
|
||||
# 1| void foo(unsigned int, int)
|
||||
# 1| Block 0
|
||||
# 1| v1_1(void) = EnterFunction :
|
||||
# 1| m1_2(unknown) = AliasedDefinition :
|
||||
# 1| m1_3(unknown) = InitializeNonLocal :
|
||||
# 1| m1_4(unknown) = Chi : total:m1_2, partial:m1_3
|
||||
# 1| r1_5(glval<unsigned int>) = VariableAddress[x] :
|
||||
# 1| m1_6(unsigned int) = InitializeParameter[x] : &:r1_5
|
||||
# 1| m1_7(unknown) = Chi : total:m1_4, partial:m1_6
|
||||
# 1| r1_8(glval<int>) = VariableAddress[y] :
|
||||
# 1| m1_9(int) = InitializeParameter[y] : &:r1_8
|
||||
# 2| r2_1(glval<unsigned int>) = VariableAddress[r] :
|
||||
# 2| m2_2(unsigned int) = Uninitialized[r] : &:r2_1
|
||||
# 3| r3_1(glval<unsigned int>) = VariableAddress[x] :
|
||||
# 3| r3_2(unsigned int) = Constant[1] :
|
||||
# 3| r3_3(unsigned int) = Add : r3_1, r3_2
|
||||
# 3| r3_4(glval<unsigned int>) = VariableAddress[r] :
|
||||
# 3| m3_5(unsigned int) = Store[r] : &:r3_4, r3_3
|
||||
# 4| v4_1(void) = NoOp :
|
||||
# 1| v1_10(void) = ReturnVoid :
|
||||
# 1| v1_11(void) = AliasedUse : m1_3
|
||||
# 1| v1_12(void) = ExitFunction :
|
||||
|
||||
ir.c:
|
||||
# 7| void MyCoordsTest(int)
|
||||
# 7| Block 0
|
||||
|
||||
6
cpp/ql/test/library-tests/ir/ir/generic.c
Normal file
6
cpp/ql/test/library-tests/ir/ir/generic.c
Normal file
@@ -0,0 +1,6 @@
|
||||
void foo(unsigned int x, int y) {
|
||||
unsigned int r;
|
||||
r = _Generic(r, unsigned int: x, int: y) + 1;
|
||||
}
|
||||
|
||||
// // semmle-extractor-options: -std=c11
|
||||
@@ -2732,6 +2732,28 @@ destructors_for_temps.cpp:
|
||||
# 102| v102_7(void) = AliasedUse : ~m?
|
||||
# 102| v102_8(void) = ExitFunction :
|
||||
|
||||
generic.c:
|
||||
# 1| void foo(unsigned int, int)
|
||||
# 1| Block 0
|
||||
# 1| v1_1(void) = EnterFunction :
|
||||
# 1| mu1_2(unknown) = AliasedDefinition :
|
||||
# 1| mu1_3(unknown) = InitializeNonLocal :
|
||||
# 1| r1_4(glval<unsigned int>) = VariableAddress[x] :
|
||||
# 1| mu1_5(unsigned int) = InitializeParameter[x] : &:r1_4
|
||||
# 1| r1_6(glval<int>) = VariableAddress[y] :
|
||||
# 1| mu1_7(int) = InitializeParameter[y] : &:r1_6
|
||||
# 2| r2_1(glval<unsigned int>) = VariableAddress[r] :
|
||||
# 2| mu2_2(unsigned int) = Uninitialized[r] : &:r2_1
|
||||
# 3| r3_1(glval<unsigned int>) = VariableAddress[x] :
|
||||
# 3| r3_2(unsigned int) = Constant[1] :
|
||||
# 3| r3_3(unsigned int) = Add : r3_1, r3_2
|
||||
# 3| r3_4(glval<unsigned int>) = VariableAddress[r] :
|
||||
# 3| mu3_5(unsigned int) = Store[r] : &:r3_4, r3_3
|
||||
# 4| v4_1(void) = NoOp :
|
||||
# 1| v1_8(void) = ReturnVoid :
|
||||
# 1| v1_9(void) = AliasedUse : ~m?
|
||||
# 1| v1_10(void) = ExitFunction :
|
||||
|
||||
ir.c:
|
||||
# 7| void MyCoordsTest(int)
|
||||
# 7| Block 0
|
||||
|
||||
Reference in New Issue
Block a user