These ExprWithCleanups are added for holding a RunCleanupsScope not
for destructor calls; rather, they are for lifetime marks. This requires
ExprWithCleanups to keep a bit to indicate whether it have cleanups with
side effects (e.g. dtor calls).
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
include/clang/AST/ExprCXX.h | ||
---|---|---|
2871–2872 ↗ | (On Diff #58013) | You may as well put this in the bitfield storage on Stmt. |
include/clang/Sema/CleanupInfo.h | ||
31 ↗ | (On Diff #58013) | Should this be |=? |
include/clang/Sema/Sema.h | ||
444 ↗ | (On Diff #58013) | ExprNeedsCleanups -> ExprWithCleanups |
lib/AST/Expr.cpp | ||
2906–2907 ↗ | (On Diff #58013) | You should only return true if IncludePossibleEffects -- cleanupsHaveSideEffects means there might be a side-effect, not that there definitely is one. (This is a pre-existing bug.) |
lib/Sema/SemaExpr.cpp | ||
4579 ↗ | (On Diff #58013) | This should inherit the side-effects flag from the ExprWithCleanups in the default argument. |
lib/Sema/SemaInit.cpp | ||
6190–6191 ↗ | (On Diff #58013) | Please also sink the calls to mark the destructor referenced and check its access into here too. We should keep the checks for a usable destructor and the triggering of an ExprWithCleanups for the destructor together. |
lib/Sema/SemaExprCXX.cpp | ||
---|---|---|
5636–5639 ↗ | (On Diff #58013) | Please pass these flags into ::Create rather than using a setter. Generally, we aim for the AST to be immutable once created. |
lib/Sema/SemaInit.cpp | ||
6191 ↗ | (On Diff #58013) | I think this may set ExprNeedsCleanups even when unnecessary, if the MTE is lifetime-extended (I think you only actually want an ExprWithCleanups if the storage duration is SD_Automatic). We can't really deal with that here, because we don't know the storage duration of the MTE yet, but please add a FIXME here to not set ExprNeedsCleanups if the temporary is lifetime-extended. |
lib/Sema/SemaInit.cpp | ||
---|---|---|
6190–6191 ↗ | (On Diff #58676) |
As discussed, MaybeBindToTemporary more or less overlaps with this in the access checking perspective. Added a TODO for a potential merge of MaterializeTemporaryExpr and BindToCXXTemporary in the future.
Due to the use of pushCleanupAfterFullExpr in CodeGen::EmitMaterializeTemporaryExpr, there has to have a RunCleanupsScope at FullExpr level to delay and forward the cleanups to its upper level. So even for lifetime-extended variables, the cleanup scope is necessary. |