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
Event Timeline
include/clang/AST/ExprCXX.h | ||
---|---|---|
2871–2872 | You may as well put this in the bitfield storage on Stmt. | |
include/clang/Sema/CleanupInfo.h | ||
32 | Should this be |=? | |
include/clang/Sema/Sema.h | ||
444–445 | ExprNeedsCleanups -> ExprWithCleanups | |
lib/AST/Expr.cpp | ||
2906–2907 | 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 | This should inherit the side-effects flag from the ExprWithCleanups in the default argument. | |
lib/Sema/SemaInit.cpp | ||
6190–6191 | 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 | ||
---|---|---|
5640–5642 | 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 | 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 |
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. |
You may as well put this in the bitfield storage on Stmt.