aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-08-13 20:08:14 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-08-13 20:08:14 +0000
commit0d729105ecb50a7e3cbe6e57c29149edfa5cf05a (patch)
tree8c4f1bc2fdc5e9cbbc8a853c152f440f642276b5 /lib/AST/Expr.cpp
parent37f7a3326791dd625a4aa9a097b5fad0a757c956 (diff)
Factor out computation of whether a typeid's expression is potentially
evaluated into a CXXTypeid member function. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161779 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r--lib/AST/Expr.cpp20
1 files changed, 4 insertions, 16 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 8ae7a2ddc3..24361efafa 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -2757,22 +2757,10 @@ bool Expr::HasSideEffects(const ASTContext &Ctx) const {
break;
}
- case CXXTypeidExprClass: {
- // A typeid expression has side-effects if it can throw.
- const CXXTypeidExpr *TE = cast<CXXTypeidExpr>(this);
- if (TE->isTypeOperand())
- return false;
- const CXXRecordDecl *RD =
- TE->getExprOperand()->getType()->getAsCXXRecordDecl();
- if (!RD || !RD->isPolymorphic() ||
- !TE->getExprOperand()->
- Classify(const_cast<ASTContext&>(Ctx)).isGLValue())
- // Not a glvalue of polymorphic class type: the expression is an
- // unevaluated operand.
- return false;
- // Might throw.
- return true;
- }
+ case CXXTypeidExprClass:
+ // typeid might throw if its subexpression is potentially-evaluated, so has
+ // side-effects in that case whether or not its subexpression does.
+ return cast<CXXTypeidExpr>(this)->isPotentiallyEvaluated();
case CXXConstructExprClass:
case CXXTemporaryObjectExprClass: {