diff options
author | Tim Shen <timshen91@gmail.com> | 2016-06-09 19:54:46 +0000 |
---|---|---|
committer | Tim Shen <timshen91@gmail.com> | 2016-06-09 19:54:46 +0000 |
commit | f120a7b6a31ae73e0d59f58e6f1dd72318a72525 (patch) | |
tree | 10a5b92b5f5a301c4d0f4c71ad29e67856b40fdd /clang/lib/AST | |
parent | 17b4701070e068eebdb1927130feb0eed1273980 (diff) | |
download | bcm5719-llvm-f120a7b6a31ae73e0d59f58e6f1dd72318a72525.tar.gz bcm5719-llvm-f120a7b6a31ae73e0d59f58e6f1dd72318a72525.zip |
[Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr.
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).
Differential Revision: http://reviews.llvm.org/D20498
llvm-svn: 272296
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/Expr.cpp | 7 | ||||
-rw-r--r-- | clang/lib/AST/ExprCXX.cpp | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 4c0492c3935..dc87c0a8e26 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -2890,7 +2890,6 @@ bool Expr::HasSideEffects(const ASTContext &Ctx, case CXXThrowExprClass: case CXXNewExprClass: case CXXDeleteExprClass: - case ExprWithCleanupsClass: case CoawaitExprClass: case CoyieldExprClass: // These always have a side-effect. @@ -2903,6 +2902,12 @@ bool Expr::HasSideEffects(const ASTContext &Ctx, return Finder.hasSideEffects(); } + case ExprWithCleanupsClass: + if (IncludePossibleEffects) + if (cast<ExprWithCleanups>(this)->cleanupsHaveSideEffects()) + return true; + break; + case ParenExprClass: case ArraySubscriptExprClass: case OMPArraySectionExprClass: diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index dbfe58c8b3d..7978b0a90aa 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -1039,6 +1039,7 @@ bool LambdaExpr::isMutable() const { } ExprWithCleanups::ExprWithCleanups(Expr *subexpr, + bool CleanupsHaveSideEffects, ArrayRef<CleanupObject> objects) : Expr(ExprWithCleanupsClass, subexpr->getType(), subexpr->getValueKind(), subexpr->getObjectKind(), @@ -1046,16 +1047,19 @@ ExprWithCleanups::ExprWithCleanups(Expr *subexpr, subexpr->isInstantiationDependent(), subexpr->containsUnexpandedParameterPack()), SubExpr(subexpr) { + ExprWithCleanupsBits.CleanupsHaveSideEffects = CleanupsHaveSideEffects; ExprWithCleanupsBits.NumObjects = objects.size(); for (unsigned i = 0, e = objects.size(); i != e; ++i) getTrailingObjects<CleanupObject>()[i] = objects[i]; } ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, Expr *subexpr, + bool CleanupsHaveSideEffects, ArrayRef<CleanupObject> objects) { void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(objects.size()), llvm::alignOf<ExprWithCleanups>()); - return new (buffer) ExprWithCleanups(subexpr, objects); + return new (buffer) + ExprWithCleanups(subexpr, CleanupsHaveSideEffects, objects); } ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects) |