Revert [c++20] P1327R1: Support for typeid applied to objects of polymorphic class type in constant evaluation.
This reverts r360977 (git commit f51dc8d2f98f4029247552bc45ef53628ab3b6b9)
llvm-svn: 360987
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 35000f4..e41264e 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -1349,7 +1349,6 @@
AK_Decrement,
AK_MemberCall,
AK_DynamicCast,
- AK_TypeId,
};
static bool isModification(AccessKinds AK) {
@@ -1357,7 +1356,6 @@
case AK_Read:
case AK_MemberCall:
case AK_DynamicCast:
- case AK_TypeId:
return false;
case AK_Assign:
case AK_Increment:
@@ -6031,33 +6029,19 @@
}
bool LValueExprEvaluator::VisitCXXTypeidExpr(const CXXTypeidExpr *E) {
- TypeInfoLValue TypeInfo;
-
if (!E->isPotentiallyEvaluated()) {
+ TypeInfoLValue TypeInfo;
if (E->isTypeOperand())
TypeInfo = TypeInfoLValue(E->getTypeOperand(Info.Ctx).getTypePtr());
else
TypeInfo = TypeInfoLValue(E->getExprOperand()->getType().getTypePtr());
- } else {
- if (!Info.Ctx.getLangOpts().CPlusPlus2a) {
- Info.CCEDiag(E, diag::note_constexpr_typeid_polymorphic)
- << E->getExprOperand()->getType()
- << E->getExprOperand()->getSourceRange();
- }
-
- if (!Visit(E->getExprOperand()))
- return false;
-
- Optional<DynamicType> DynType =
- ComputeDynamicType(Info, E, Result, AK_TypeId);
- if (!DynType)
- return false;
-
- TypeInfo =
- TypeInfoLValue(Info.Ctx.getRecordType(DynType->Type).getTypePtr());
+ return Success(APValue::LValueBase::getTypeInfo(TypeInfo, E->getType()));
}
- return Success(APValue::LValueBase::getTypeInfo(TypeInfo, E->getType()));
+ Info.FFDiag(E, diag::note_constexpr_typeid_polymorphic)
+ << E->getExprOperand()->getType()
+ << E->getExprOperand()->getSourceRange();
+ return false;
}
bool LValueExprEvaluator::VisitCXXUuidofExpr(const CXXUuidofExpr *E) {