Merge pull request #15609 from jketema/destructors3

C++: Output the declaration entries used in range-based for-loops
This commit is contained in:
Jeroen Ketema
2024-02-14 11:37:09 +01:00
committed by GitHub
5 changed files with 207 additions and 10 deletions

View File

@@ -835,7 +835,11 @@ private predicate namedExprChildPredicates(Expr expr, Element ele, string pred)
or
expr.(OverloadedArrayExpr).getArrayOffset() = ele and pred = "getArrayOffset()"
or
expr.(OverloadedPointerDereferenceExpr).getExpr() = ele and pred = "getExpr()"
// OverloadedPointerDereferenceExpr::getExpr/0 also considers qualifiers, which are already handled above for all Call classes.
not expr.(OverloadedPointerDereferenceExpr).getQualifier() =
expr.(OverloadedPointerDereferenceExpr).getExpr() and
expr.(OverloadedPointerDereferenceExpr).getExpr() = ele and
pred = "getExpr()"
or
expr.(CommaExpr).getLeftOperand() = ele and pred = "getLeftOperand()"
or

View File

@@ -474,7 +474,6 @@ private module IRDeclarationEntries {
* This class exists to work around the fact that `DeclStmt`s in some cases
* do not have `DeclarationEntry`s. Currently, this is the case for:
* - `DeclStmt`s in template instantiations.
* - `DeclStmt`s that are generated by the desugaring of range-based for-loops.
*
* So instead, the IR works with `IRDeclarationEntry`s that synthesize missing
* `DeclarationEntry`s when there is no result for `DeclStmt::getDeclarationEntry`.

View File

@@ -9479,7 +9479,43 @@ ir.cpp:
# 1079| getEntryPoint(): [BlockStmt] { ... }
# 1080| getStmt(0): [RangeBasedForStmt] for(...:...) ...
# 1080| getChild(0): [DeclStmt] declaration
# 1080| getDeclarationEntry(0): (no string representation)
# 1080| Type = [LValueReferenceType] const vector<int> &
#-----| getVariable().getInitializer(): [Initializer] initializer for (__range)
# 1080| getExpr(): [VariableAccess] v
# 1080| Type = [LValueReferenceType] const vector<int> &
# 1080| ValueCategory = prvalue(load)
# 1080| getExpr().getFullyConverted(): [ReferenceToExpr] (reference to)
# 1080| Type = [LValueReferenceType] const vector<int> &
# 1080| ValueCategory = prvalue
# 1080| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
# 1080| Type = [SpecifiedType] const vector<int>
# 1080| ValueCategory = lvalue
# 1080| getBeginEndDeclaration(): [DeclStmt] declaration
# 1080| getDeclarationEntry(0): (no string representation)
# 1080| Type = [NestedStruct] iterator
#-----| getVariable().getInitializer(): [Initializer] initializer for (__begin)
# 1080| getExpr(): [FunctionCall] call to begin
# 1080| Type = [NestedStruct] iterator
# 1080| ValueCategory = prvalue
# 1080| getQualifier(): [VariableAccess] (__range)
# 1080| Type = [LValueReferenceType] const vector<int> &
# 1080| ValueCategory = prvalue(load)
#-----| getQualifier().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
#-----| Type = [SpecifiedType] const vector<int>
#-----| ValueCategory = lvalue
# 1080| getDeclarationEntry(1): (no string representation)
# 1080| Type = [NestedStruct] iterator
#-----| getVariable().getInitializer(): [Initializer] initializer for (__end)
# 1080| getExpr(): [FunctionCall] call to end
# 1080| Type = [NestedStruct] iterator
# 1080| ValueCategory = prvalue
# 1080| getQualifier(): [VariableAccess] (__range)
# 1080| Type = [LValueReferenceType] const vector<int> &
# 1080| ValueCategory = prvalue(load)
#-----| getQualifier().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
#-----| Type = [SpecifiedType] const vector<int>
#-----| ValueCategory = lvalue
# 1080| getCondition(): [FunctionCall] call to operator!=
# 1080| Type = [BoolType] bool
# 1080| ValueCategory = prvalue
@@ -9500,6 +9536,22 @@ ir.cpp:
# 1080| Type = [NestedStruct] iterator
# 1080| ValueCategory = lvalue
# 1080| getChild(4): [DeclStmt] declaration
# 1080| getDeclarationEntry(0): [VariableDeclarationEntry] definition of e
# 1080| Type = [IntType] int
# 1080| getVariable().getInitializer(): [Initializer] initializer for e
# 1080| getExpr(): [OverloadedPointerDereferenceExpr] call to operator*
# 1080| Type = [LValueReferenceType] int &
# 1080| ValueCategory = prvalue
# 1080| getQualifier(): [VariableAccess] (__begin)
# 1080| Type = [NestedStruct] iterator
# 1080| ValueCategory = lvalue
#-----| getQualifier().getFullyConverted(): [CStyleCast] (const iterator)...
#-----| Conversion = [GlvalueConversion] glvalue conversion
#-----| Type = [SpecifiedType] const iterator
#-----| ValueCategory = lvalue
# 1080| getExpr().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
# 1080| Type = [IntType] int
# 1080| ValueCategory = prvalue(load)
# 1080| getStmt(): [BlockStmt] { ... }
# 1081| getStmt(0): [IfStmt] if (...) ...
# 1081| getCondition(): [GTExpr] ... > ...
@@ -9520,7 +9572,43 @@ ir.cpp:
# 1080| ValueCategory = lvalue
# 1086| getStmt(1): [RangeBasedForStmt] for(...:...) ...
# 1086| getChild(0): [DeclStmt] declaration
# 1086| getDeclarationEntry(0): (no string representation)
# 1086| Type = [LValueReferenceType] const vector<int> &
#-----| getVariable().getInitializer(): [Initializer] initializer for (__range)
# 1086| getExpr(): [VariableAccess] v
# 1086| Type = [LValueReferenceType] const vector<int> &
# 1086| ValueCategory = prvalue(load)
# 1086| getExpr().getFullyConverted(): [ReferenceToExpr] (reference to)
# 1086| Type = [LValueReferenceType] const vector<int> &
# 1086| ValueCategory = prvalue
# 1086| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
# 1086| Type = [SpecifiedType] const vector<int>
# 1086| ValueCategory = lvalue
# 1086| getBeginEndDeclaration(): [DeclStmt] declaration
# 1086| getDeclarationEntry(0): (no string representation)
# 1086| Type = [NestedStruct] iterator
#-----| getVariable().getInitializer(): [Initializer] initializer for (__begin)
# 1086| getExpr(): [FunctionCall] call to begin
# 1086| Type = [NestedStruct] iterator
# 1086| ValueCategory = prvalue
# 1086| getQualifier(): [VariableAccess] (__range)
# 1086| Type = [LValueReferenceType] const vector<int> &
# 1086| ValueCategory = prvalue(load)
#-----| getQualifier().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
#-----| Type = [SpecifiedType] const vector<int>
#-----| ValueCategory = lvalue
# 1086| getDeclarationEntry(1): (no string representation)
# 1086| Type = [NestedStruct] iterator
#-----| getVariable().getInitializer(): [Initializer] initializer for (__end)
# 1086| getExpr(): [FunctionCall] call to end
# 1086| Type = [NestedStruct] iterator
# 1086| ValueCategory = prvalue
# 1086| getQualifier(): [VariableAccess] (__range)
# 1086| Type = [LValueReferenceType] const vector<int> &
# 1086| ValueCategory = prvalue(load)
#-----| getQualifier().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
#-----| Type = [SpecifiedType] const vector<int>
#-----| ValueCategory = lvalue
# 1086| getCondition(): [FunctionCall] call to operator!=
# 1086| Type = [BoolType] bool
# 1086| ValueCategory = prvalue
@@ -9541,6 +9629,29 @@ ir.cpp:
# 1086| Type = [NestedStruct] iterator
# 1086| ValueCategory = lvalue
# 1086| getChild(4): [DeclStmt] declaration
# 1086| getDeclarationEntry(0): [VariableDeclarationEntry] definition of e
# 1086| Type = [LValueReferenceType] const int &
# 1086| getVariable().getInitializer(): [Initializer] initializer for e
# 1086| getExpr(): [OverloadedPointerDereferenceExpr] call to operator*
# 1086| Type = [LValueReferenceType] int &
# 1086| ValueCategory = prvalue
# 1086| getQualifier(): [VariableAccess] (__begin)
# 1086| Type = [NestedStruct] iterator
# 1086| ValueCategory = lvalue
#-----| getQualifier().getFullyConverted(): [CStyleCast] (const iterator)...
#-----| Conversion = [GlvalueConversion] glvalue conversion
#-----| Type = [SpecifiedType] const iterator
#-----| ValueCategory = lvalue
# 1086| getExpr().getFullyConverted(): [ReferenceToExpr] (reference to)
# 1086| Type = [LValueReferenceType] const int &
# 1086| ValueCategory = prvalue
# 1086| getExpr(): [CStyleCast] (const int)...
# 1086| Conversion = [GlvalueConversion] glvalue conversion
# 1086| Type = [SpecifiedType] const int
# 1086| ValueCategory = lvalue
# 1086| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
# 1086| Type = [IntType] int
# 1086| ValueCategory = lvalue
# 1086| getStmt(): [BlockStmt] { ... }
# 1087| getStmt(0): [IfStmt] if (...) ...
# 1087| getCondition(): [LTExpr] ... < ...
@@ -16410,7 +16521,48 @@ ir.cpp:
# 2152| ValueCategory = prvalue
# 2153| getStmt(5): [RangeBasedForStmt] for(...:...) ...
# 2153| getChild(0): [DeclStmt] declaration
# 2153| getDeclarationEntry(0): (no string representation)
# 2153| Type = [LValueReferenceType] vector<ClassWithDestructor> &
#-----| getVariable().getInitializer(): [Initializer] initializer for (__range)
# 2153| getExpr(): [VariableAccess] ys
# 2153| Type = [ClassTemplateInstantiation,Struct] vector<ClassWithDestructor>
# 2153| ValueCategory = lvalue
# 2153| getExpr().getFullyConverted(): [ReferenceToExpr] (reference to)
# 2153| Type = [LValueReferenceType] vector<ClassWithDestructor> &
# 2153| ValueCategory = prvalue
# 2153| getBeginEndDeclaration(): [DeclStmt] declaration
# 2153| getDeclarationEntry(0): (no string representation)
# 2153| Type = [NestedStruct] iterator
#-----| getVariable().getInitializer(): [Initializer] initializer for (__begin)
# 2153| getExpr(): [FunctionCall] call to begin
# 2153| Type = [NestedStruct] iterator
# 2153| ValueCategory = prvalue
# 2153| getQualifier(): [VariableAccess] (__range)
# 2153| Type = [LValueReferenceType] vector<ClassWithDestructor> &
# 2153| ValueCategory = prvalue(load)
#-----| getQualifier().getFullyConverted(): [CStyleCast] (const vector<ClassWithDestructor>)...
#-----| Conversion = [GlvalueConversion] glvalue conversion
#-----| Type = [SpecifiedType] const vector<ClassWithDestructor>
#-----| ValueCategory = lvalue
#-----| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
#-----| Type = [ClassTemplateInstantiation,Struct] vector<ClassWithDestructor>
#-----| ValueCategory = lvalue
# 2153| getDeclarationEntry(1): (no string representation)
# 2153| Type = [NestedStruct] iterator
#-----| getVariable().getInitializer(): [Initializer] initializer for (__end)
# 2153| getExpr(): [FunctionCall] call to end
# 2153| Type = [NestedStruct] iterator
# 2153| ValueCategory = prvalue
# 2153| getQualifier(): [VariableAccess] (__range)
# 2153| Type = [LValueReferenceType] vector<ClassWithDestructor> &
# 2153| ValueCategory = prvalue(load)
#-----| getQualifier().getFullyConverted(): [CStyleCast] (const vector<ClassWithDestructor>)...
#-----| Conversion = [GlvalueConversion] glvalue conversion
#-----| Type = [SpecifiedType] const vector<ClassWithDestructor>
#-----| ValueCategory = lvalue
#-----| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
#-----| Type = [ClassTemplateInstantiation,Struct] vector<ClassWithDestructor>
#-----| ValueCategory = lvalue
# 2153| getCondition(): [FunctionCall] call to operator!=
# 2153| Type = [BoolType] bool
# 2153| ValueCategory = prvalue
@@ -16431,6 +16583,22 @@ ir.cpp:
# 2153| Type = [NestedStruct] iterator
# 2153| ValueCategory = lvalue
# 2153| getChild(4): [DeclStmt] declaration
# 2153| getDeclarationEntry(0): [VariableDeclarationEntry] definition of y
# 2153| Type = [Class] ClassWithDestructor
# 2153| getVariable().getInitializer(): [Initializer] initializer for y
# 2153| getExpr(): [OverloadedPointerDereferenceExpr] call to operator*
# 2153| Type = [LValueReferenceType] ClassWithDestructor &
# 2153| ValueCategory = prvalue
# 2153| getQualifier(): [VariableAccess] (__begin)
# 2153| Type = [NestedStruct] iterator
# 2153| ValueCategory = lvalue
#-----| getQualifier().getFullyConverted(): [CStyleCast] (const iterator)...
#-----| Conversion = [GlvalueConversion] glvalue conversion
#-----| Type = [SpecifiedType] const iterator
#-----| ValueCategory = lvalue
# 2153| getExpr().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
# 2153| Type = [Class] ClassWithDestructor
# 2153| ValueCategory = prvalue(load)
# 2154| getStmt(): [ExprStmt] ExprStmt
# 2154| getExpr(): [FunctionCall] call to set_x
# 2154| Type = [VoidType] void

View File

@@ -5540,10 +5540,10 @@
| ir.cpp:1079:39:1079:39 | Address | &:r1079_7 |
| ir.cpp:1079:39:1079:39 | Load | m1079_6 |
| ir.cpp:1079:39:1079:39 | SideEffect | m1079_8 |
| ir.cpp:1080:5:1084:5 | Address | &:r1080_1 |
| ir.cpp:1080:5:1084:5 | Address | &:r1080_7 |
| ir.cpp:1080:5:1084:5 | Address | &:r1080_15 |
| ir.cpp:1080:5:1084:5 | Address | &:r1080_33 |
| ir.cpp:1080:5:1080:5 | Address | &:r1080_1 |
| ir.cpp:1080:5:1080:5 | Address | &:r1080_7 |
| ir.cpp:1080:5:1080:5 | Address | &:r1080_15 |
| ir.cpp:1080:14:1080:14 | Address | &:r1080_33 |
| ir.cpp:1080:18:1080:18 | Address | &:r1080_2 |
| ir.cpp:1080:18:1080:18 | Address | &:r1080_8 |
| ir.cpp:1080:18:1080:18 | Address | &:r1080_16 |
@@ -5606,10 +5606,10 @@
| ir.cpp:1081:13:1081:13 | Load | m1080_40 |
| ir.cpp:1081:13:1081:17 | Condition | r1081_4 |
| ir.cpp:1081:17:1081:17 | Right | r1081_3 |
| ir.cpp:1086:5:1090:5 | Address | &:r1086_1 |
| ir.cpp:1086:5:1090:5 | Address | &:r1086_7 |
| ir.cpp:1086:5:1090:5 | Address | &:r1086_15 |
| ir.cpp:1086:5:1090:5 | Address | &:r1086_42 |
| ir.cpp:1086:5:1086:5 | Address | &:r1086_1 |
| ir.cpp:1086:5:1086:5 | Address | &:r1086_7 |
| ir.cpp:1086:5:1086:5 | Address | &:r1086_15 |
| ir.cpp:1086:21:1086:21 | Address | &:r1086_42 |
| ir.cpp:1086:25:1086:25 | Address | &:r1086_2 |
| ir.cpp:1086:25:1086:25 | Address | &:r1086_8 |
| ir.cpp:1086:25:1086:25 | Address | &:r1086_16 |

View File

@@ -5,11 +5,37 @@ uniqueNodeLocation
missingLocation
uniqueNodeToString
| builtin.c:5:5:5:11 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:6:5:6:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:6:5:6:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:6:5:6:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:6:5:6:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:6:5:6:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:6:5:6:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:6:5:6:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:6:5:6:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:6:5:6:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:6:5:6:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:28:5:28:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:28:5:28:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:28:5:28:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:28:5:28:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:28:5:28:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:28:5:28:5 | (no string representation) | Node should have one toString but has 0. |
| cpp11.cpp:28:5:28:5 | (no string representation) | Node should have one toString but has 0. |
| misc.c:227:7:227:28 | (no string representation) | Node should have one toString but has 0. |
| static_init_templates.cpp:80:18:80:23 | (no string representation) | Node should have one toString but has 0. |
| static_init_templates.cpp:80:18:80:23 | (no string representation) | Node should have one toString but has 0. |
| static_init_templates.cpp:89:18:89:23 | (no string representation) | Node should have one toString but has 0. |
| static_init_templates.cpp:89:18:89:23 | (no string representation) | Node should have one toString but has 0. |
| stream_it.cpp:11:3:11:3 | (no string representation) | Node should have one toString but has 0. |
| stream_it.cpp:11:3:11:3 | (no string representation) | Node should have one toString but has 0. |
| stream_it.cpp:11:3:11:3 | (no string representation) | Node should have one toString but has 0. |
| stream_it.cpp:11:3:11:3 | (no string representation) | Node should have one toString but has 0. |
| stream_it.cpp:11:3:11:3 | (no string representation) | Node should have one toString but has 0. |
| stream_it.cpp:11:3:11:3 | (no string representation) | Node should have one toString but has 0. |
| stream_it.cpp:11:3:11:3 | (no string representation) | Node should have one toString but has 0. |
| stream_it.cpp:11:3:11:3 | (no string representation) | Node should have one toString but has 0. |
| stream_it.cpp:11:3:11:3 | (no string representation) | Node should have one toString but has 0. |
parameterCallable
localFlowIsLocal
readStepIsLocal