aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprCXX.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/ExprCXX.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/ExprCXX.cpp')
-rw-r--r--lib/AST/ExprCXX.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index ec9c978f3c..b290fb423a 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -24,6 +24,21 @@ using namespace clang;
// Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===//
+bool CXXTypeidExpr::isPotentiallyEvaluated() const {
+ if (isTypeOperand())
+ return false;
+
+ // C++11 [expr.typeid]p3:
+ // When typeid is applied to an expression other than a glvalue of
+ // polymorphic class type, [...] the expression is an unevaluated operand.
+ const Expr *E = getExprOperand();
+ if (const CXXRecordDecl *RD = E->getType()->getAsCXXRecordDecl())
+ if (RD->isPolymorphic() && E->isGLValue())
+ return true;
+
+ return false;
+}
+
QualType CXXTypeidExpr::getTypeOperand() const {
assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
return Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType()