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
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 8ae7a2d..24361ef 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -2757,22 +2757,10 @@
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: {