C++: Add a skeleton class for requires expressions

This commit is contained in:
Jeroen Ketema
2024-10-08 15:35:16 +02:00
parent d0ca39fb03
commit 723236d15b
15 changed files with 11082 additions and 1716 deletions

View File

@@ -23564,6 +23564,26 @@ ir.cpp:
# 2686| Value = [CStyleCast] 0
# 2686| ValueCategory = prvalue
# 2687| getStmt(1): [ReturnStmt] return ...
# 2691| [TopLevelFunction] int concepts::requires_use()
# 2691| <params>:
# 2691| getEntryPoint(): [BlockStmt] { ... }
# 2692| getStmt(0): [DeclStmt] declaration
# 2692| getDeclarationEntry(0): [VariableDeclarationEntry] definition of y
# 2692| Type = [IntType] int
# 2692| getVariable().getInitializer(): [Initializer] initializer for y
#-----| getExpr(): [RequiresExpr] requires ...
#-----| Type = [BoolType] bool
#-----| Value = [RequiresExpr] 1
#-----| ValueCategory = prvalue
#-----| getExpr().getFullyConverted(): [CStyleCast] (int)...
#-----| Conversion = [IntegralConversion] integral conversion
#-----| Type = [IntType] int
#-----| Value = [CStyleCast] 1
#-----| ValueCategory = prvalue
# 2693| getStmt(1): [ReturnStmt] return ...
# 2693| getExpr(): [VariableAccess] y
# 2693| Type = [IntType] int
# 2693| ValueCategory = prvalue(load)
many-defs-per-use.cpp:
# 34| [TopLevelFunction] void many_defs_per_use()
# 34| <params>:

View File

@@ -19099,6 +19099,24 @@ ir.cpp:
# 2684| Block 8
# 2684| v2684_14(void) = Unreached :
# 2691| int concepts::requires_use()
# 2691| Block 0
# 2691| v2691_1(void) = EnterFunction :
# 2691| m2691_2(unknown) = AliasedDefinition :
# 2691| m2691_3(unknown) = InitializeNonLocal :
# 2691| m2691_4(unknown) = Chi : total:m2691_2, partial:m2691_3
# 2692| r2692_1(glval<int>) = VariableAddress[y] :
#-----| r0_1(int) = Constant[1] :
#-----| m0_2(int) = Store[y] : &:r2692_1, r0_1
# 2693| r2693_1(glval<int>) = VariableAddress[#return] :
# 2693| r2693_2(glval<int>) = VariableAddress[y] :
# 2693| r2693_3(int) = Load[y] : &:r2693_2, m0_2
# 2693| m2693_4(int) = Store[#return] : &:r2693_1, r2693_3
# 2691| r2691_5(glval<int>) = VariableAddress[#return] :
# 2691| v2691_6(void) = ReturnValue : &:r2691_5, m2693_4
# 2691| v2691_7(void) = AliasedUse : m2691_3
# 2691| v2691_8(void) = ExitFunction :
many-defs-per-use.cpp:
# 34| void many_defs_per_use()
# 34| Block 0

View File

@@ -2686,4 +2686,13 @@ void test(bool b)
twice_call_use(b ? "" : "");
}
namespace concepts {
int requires_use() {
int y = requires { sizeof(int) > 0; };
return y;
}
}
// semmle-extractor-options: -std=c++20 --clang

View File

@@ -17422,6 +17422,23 @@ ir.cpp:
# 2684| v2684_7(void) = AliasedUse : ~m?
# 2684| v2684_8(void) = ExitFunction :
# 2691| int concepts::requires_use()
# 2691| Block 0
# 2691| v2691_1(void) = EnterFunction :
# 2691| mu2691_2(unknown) = AliasedDefinition :
# 2691| mu2691_3(unknown) = InitializeNonLocal :
# 2692| r2692_1(glval<int>) = VariableAddress[y] :
#-----| r0_1(int) = Constant[1] :
#-----| mu0_2(int) = Store[y] : &:r2692_1, r0_1
# 2693| r2693_1(glval<int>) = VariableAddress[#return] :
# 2693| r2693_2(glval<int>) = VariableAddress[y] :
# 2693| r2693_3(int) = Load[y] : &:r2693_2, ~m?
# 2693| mu2693_4(int) = Store[#return] : &:r2693_1, r2693_3
# 2691| r2691_4(glval<int>) = VariableAddress[#return] :
# 2691| v2691_5(void) = ReturnValue : &:r2691_4, ~m?
# 2691| v2691_6(void) = AliasedUse : ~m?
# 2691| v2691_7(void) = ExitFunction :
many-defs-per-use.cpp:
# 34| void many_defs_per_use()
# 34| Block 0