mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
C++: add test for constructors in C++17 decl-in-if
This commit is contained in:
@@ -16539,6 +16539,72 @@ ir.cpp:
|
||||
# 2174| Type = [Class] Bool
|
||||
# 2174| ValueCategory = lvalue
|
||||
# 2175| getStmt(1): [ReturnStmt] return ...
|
||||
# 2178| [CopyAssignmentOperator] Bool2& Bool2::operator=(Bool2 const&)
|
||||
# 2178| <params>:
|
||||
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
|
||||
#-----| Type = [LValueReferenceType] const Bool2 &
|
||||
# 2178| [CopyConstructor] void Bool2::Bool2(Bool2 const&)
|
||||
# 2178| <params>:
|
||||
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
|
||||
#-----| Type = [LValueReferenceType] const Bool2 &
|
||||
# 2180| [Constructor] void Bool2::Bool2(bool)
|
||||
# 2180| <params>:
|
||||
# 2180| getParameter(0): [Parameter] b_
|
||||
# 2180| Type = [BoolType] bool
|
||||
# 2181| [ConversionOperator] bool Bool2::operator bool()
|
||||
# 2181| <params>:
|
||||
# 2182| [Destructor] void Bool2::~Bool2()
|
||||
# 2182| <params>:
|
||||
# 2185| [TopLevelFunction] void IfInitiaiizationConstructor(bool)
|
||||
# 2185| <params>:
|
||||
# 2185| getParameter(0): [Parameter] b
|
||||
# 2185| Type = [BoolType] bool
|
||||
# 2185| getEntryPoint(): [BlockStmt] { ... }
|
||||
# 2186| getStmt(0): [IfStmt] if (...) ...
|
||||
# 2186| getCondition(): [ConditionDeclExpr] (condition decl)
|
||||
# 2186| Type = [BoolType] bool
|
||||
# 2186| ValueCategory = prvalue
|
||||
# 2186| getChild(0): [FunctionCall] call to operator bool
|
||||
# 2186| Type = [BoolType] bool
|
||||
# 2186| ValueCategory = prvalue
|
||||
# 2186| getQualifier(): [VariableAccess] B
|
||||
# 2186| Type = [Class] Bool2
|
||||
# 2186| ValueCategory = prvalue(load)
|
||||
# 2186| getThen(): [BlockStmt] { ... }
|
||||
# 2187| getStmt(0): [DeclStmt] declaration
|
||||
# 2187| getDeclarationEntry(0): [VariableDeclarationEntry] definition of s1
|
||||
# 2187| Type = [Struct] String
|
||||
# 2187| getVariable().getInitializer(): [Initializer] initializer for s1
|
||||
# 2187| getExpr(): [ConstructorCall] call to String
|
||||
# 2187| Type = [VoidType] void
|
||||
# 2187| ValueCategory = prvalue
|
||||
# 2188| getImplicitDestructorCall(0): [DestructorCall] call to ~String
|
||||
# 2188| Type = [VoidType] void
|
||||
# 2188| ValueCategory = prvalue
|
||||
# 2188| getQualifier(): [VariableAccess] s1
|
||||
# 2188| Type = [Struct] String
|
||||
# 2188| ValueCategory = lvalue
|
||||
# 2188| getElse(): [BlockStmt] { ... }
|
||||
# 2189| getStmt(0): [DeclStmt] declaration
|
||||
# 2189| getDeclarationEntry(0): [VariableDeclarationEntry] definition of s2
|
||||
# 2189| Type = [Struct] String
|
||||
# 2189| getVariable().getInitializer(): [Initializer] initializer for s2
|
||||
# 2189| getExpr(): [ConstructorCall] call to String
|
||||
# 2189| Type = [VoidType] void
|
||||
# 2189| ValueCategory = prvalue
|
||||
# 2190| getImplicitDestructorCall(0): [DestructorCall] call to ~String
|
||||
# 2190| Type = [VoidType] void
|
||||
# 2190| ValueCategory = prvalue
|
||||
# 2190| getQualifier(): [VariableAccess] s2
|
||||
# 2190| Type = [Struct] String
|
||||
# 2190| ValueCategory = lvalue
|
||||
# 2190| getImplicitDestructorCall(0): [DestructorCall] call to ~Bool2
|
||||
# 2190| Type = [VoidType] void
|
||||
# 2190| ValueCategory = prvalue
|
||||
# 2190| getQualifier(): [VariableAccess] B
|
||||
# 2190| Type = [Class] Bool2
|
||||
# 2190| ValueCategory = lvalue
|
||||
# 2191| getStmt(1): [ReturnStmt] return ...
|
||||
perf-regression.cpp:
|
||||
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
|
||||
# 4| <params>:
|
||||
|
||||
@@ -2174,4 +2174,20 @@ void IfDestructors3(bool b) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Bool2 {
|
||||
public:
|
||||
Bool2(bool b_);
|
||||
operator bool();
|
||||
~Bool2();
|
||||
};
|
||||
|
||||
void IfInitiaiizationConstructor(bool b) {
|
||||
if(Bool2 B = Bool2(b)) {
|
||||
String s1;
|
||||
} else {
|
||||
String s2;
|
||||
}
|
||||
}
|
||||
|
||||
// semmle-extractor-options: -std=c++17 --clang
|
||||
|
||||
@@ -12302,6 +12302,78 @@ ir.cpp:
|
||||
# 2169| v2169_7(void) = AliasedUse : ~m?
|
||||
# 2169| v2169_8(void) = ExitFunction :
|
||||
|
||||
# 2185| void IfInitiaiizationConstructor(bool)
|
||||
# 2185| Block 0
|
||||
# 2185| v2185_1(void) = EnterFunction :
|
||||
# 2185| mu2185_2(unknown) = AliasedDefinition :
|
||||
# 2185| mu2185_3(unknown) = InitializeNonLocal :
|
||||
# 2185| r2185_4(glval<bool>) = VariableAddress[b] :
|
||||
# 2185| mu2185_5(bool) = InitializeParameter[b] : &:r2185_4
|
||||
# 2186| r2186_1(glval<Bool2>) = VariableAddress[B] :
|
||||
# 2186| mu2186_2(Bool2) = Uninitialized[B] : &:r2186_1
|
||||
# 2186| r2186_3(glval<unknown>) = FunctionAddress[Bool2] :
|
||||
# 2186| r2186_4(glval<bool>) = VariableAddress[b] :
|
||||
# 2186| r2186_5(bool) = Load[b] : &:r2186_4, ~m?
|
||||
# 2186| v2186_6(void) = Call[Bool2] : func:r2186_3, this:r2186_1, 0:r2186_5
|
||||
# 2186| mu2186_7(unknown) = ^CallSideEffect : ~m?
|
||||
# 2186| mu2186_8(Bool2) = ^IndirectMayWriteSideEffect[-1] : &:r2186_1
|
||||
|
||||
# 2186| (no string representation)
|
||||
# 2186| CopyValue: (condition decl)
|
||||
# 2186| ConditionalBranch: (condition decl)
|
||||
#-----| False -> Block 3
|
||||
#-----| True -> Block 2
|
||||
|
||||
# 2186| Block 1
|
||||
# 2186| r2186_9(glval<Bool2>) = VariableAddress[B] :
|
||||
# 2186| r2186_10(glval<unknown>) = FunctionAddress[operator bool] :
|
||||
# 2186| r2186_11(bool) = Call[operator bool] : func:r2186_10, this:r2186_9
|
||||
# 2186| mu2186_12(unknown) = ^CallSideEffect : ~m?
|
||||
# 2186| v2186_13(void) = ^IndirectReadSideEffect[-1] : &:r2186_9, ~m?
|
||||
# 2186| mu2186_14(Bool2) = ^IndirectMayWriteSideEffect[-1] : &:r2186_9
|
||||
|
||||
# 2187| Block 2
|
||||
# 2187| r2187_1(glval<String>) = VariableAddress[s1] :
|
||||
# 2187| mu2187_2(String) = Uninitialized[s1] : &:r2187_1
|
||||
# 2187| r2187_3(glval<unknown>) = FunctionAddress[String] :
|
||||
# 2187| v2187_4(void) = Call[String] : func:r2187_3, this:r2187_1
|
||||
# 2187| mu2187_5(unknown) = ^CallSideEffect : ~m?
|
||||
# 2187| mu2187_6(String) = ^IndirectMayWriteSideEffect[-1] : &:r2187_1
|
||||
# 2188| r2188_1(glval<String>) = VariableAddress[s1] :
|
||||
# 2188| r2188_2(glval<unknown>) = FunctionAddress[~String] :
|
||||
# 2188| v2188_3(void) = Call[~String] : func:r2188_2, this:r2188_1
|
||||
# 2188| mu2188_4(unknown) = ^CallSideEffect : ~m?
|
||||
# 2188| v2188_5(void) = ^IndirectReadSideEffect[-1] : &:r2188_1, ~m?
|
||||
# 2188| mu2188_6(String) = ^IndirectMayWriteSideEffect[-1] : &:r2188_1
|
||||
#-----| Goto -> Block 4
|
||||
|
||||
# 2189| Block 3
|
||||
# 2189| r2189_1(glval<String>) = VariableAddress[s2] :
|
||||
# 2189| mu2189_2(String) = Uninitialized[s2] : &:r2189_1
|
||||
# 2189| r2189_3(glval<unknown>) = FunctionAddress[String] :
|
||||
# 2189| v2189_4(void) = Call[String] : func:r2189_3, this:r2189_1
|
||||
# 2189| mu2189_5(unknown) = ^CallSideEffect : ~m?
|
||||
# 2189| mu2189_6(String) = ^IndirectMayWriteSideEffect[-1] : &:r2189_1
|
||||
# 2190| r2190_1(glval<String>) = VariableAddress[s2] :
|
||||
# 2190| r2190_2(glval<unknown>) = FunctionAddress[~String] :
|
||||
# 2190| v2190_3(void) = Call[~String] : func:r2190_2, this:r2190_1
|
||||
# 2190| mu2190_4(unknown) = ^CallSideEffect : ~m?
|
||||
# 2190| v2190_5(void) = ^IndirectReadSideEffect[-1] : &:r2190_1, ~m?
|
||||
# 2190| mu2190_6(String) = ^IndirectMayWriteSideEffect[-1] : &:r2190_1
|
||||
#-----| Goto -> Block 4
|
||||
|
||||
# 2190| Block 4
|
||||
# 2190| r2190_7(glval<Bool2>) = VariableAddress[B] :
|
||||
# 2190| r2190_8(glval<unknown>) = FunctionAddress[~Bool2] :
|
||||
# 2190| v2190_9(void) = Call[~Bool2] : func:r2190_8, this:r2190_7
|
||||
# 2190| mu2190_10(unknown) = ^CallSideEffect : ~m?
|
||||
# 2190| v2190_11(void) = ^IndirectReadSideEffect[-1] : &:r2190_7, ~m?
|
||||
# 2190| mu2190_12(Bool2) = ^IndirectMayWriteSideEffect[-1] : &:r2190_7
|
||||
# 2191| v2191_1(void) = NoOp :
|
||||
# 2185| v2185_6(void) = ReturnVoid :
|
||||
# 2185| v2185_7(void) = AliasedUse : ~m?
|
||||
# 2185| v2185_8(void) = ExitFunction :
|
||||
|
||||
perf-regression.cpp:
|
||||
# 6| void Big::Big()
|
||||
# 6| Block 0
|
||||
|
||||
Reference in New Issue
Block a user