diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-13 20:08:14 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-13 20:08:14 +0000 |
commit | ef8bf4368ec62eac1948f2c5c0f05f672d4fe1b1 (patch) | |
tree | c2be4f93512a27fd933c2fe16430a61887359856 /clang/lib/AST/ExprCXX.cpp | |
parent | 0bb7f23cfc9b7b27d45c6f3c4f75dd5850f98dbb (diff) | |
download | bcm5719-llvm-ef8bf4368ec62eac1948f2c5c0f05f672d4fe1b1.tar.gz bcm5719-llvm-ef8bf4368ec62eac1948f2c5c0f05f672d4fe1b1.zip |
Factor out computation of whether a typeid's expression is potentially
evaluated into a CXXTypeid member function. No functionality change.
llvm-svn: 161779
Diffstat (limited to 'clang/lib/AST/ExprCXX.cpp')
-rw-r--r-- | clang/lib/AST/ExprCXX.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index ec9c978f3c9..b290fb423a4 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/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() |