summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-05-17 01:46:05 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-05-17 01:46:05 +0000
commit7ee4307bd4450022c3c8777f43a40cc4f0ccc009 (patch)
tree15419c16f2805145912b9210e17268c957869de3 /clang/lib/CodeGen
parent457d7caac82260adc5754d62f7133b178c7766be (diff)
downloadbcm5719-llvm-7ee4307bd4450022c3c8777f43a40cc4f0ccc009.tar.gz
bcm5719-llvm-7ee4307bd4450022c3c8777f43a40cc4f0ccc009.zip
Refactor constant evaluation of typeid(T) to track a symbolic type_info
object rather than tracking the originating expression. This is groundwork for supporting polymorphic typeid expressions. (Note that this somewhat regresses our support for DR1968, but it turns out that that never actually worked anyway, at least in non-trivial cases.) llvm-svn: 360974
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index dd71cf02d95..70904b192a3 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1735,6 +1735,17 @@ ConstantLValueEmitter::tryEmitBase(const APValue::LValueBase &base) {
return nullptr;
}
+ // Handle typeid(T).
+ if (TypeInfoLValue TI = base.dyn_cast<TypeInfoLValue>()) {
+ llvm::Type *StdTypeInfoPtrTy =
+ CGM.getTypes().ConvertType(base.getTypeInfoType())->getPointerTo();
+ llvm::Constant *TypeInfo =
+ CGM.GetAddrOfRTTIDescriptor(QualType(TI.getType(), 0));
+ if (TypeInfo->getType() != StdTypeInfoPtrTy)
+ TypeInfo = llvm::ConstantExpr::getBitCast(TypeInfo, StdTypeInfoPtrTy);
+ return TypeInfo;
+ }
+
// Otherwise, it must be an expression.
return Visit(base.get<const Expr*>());
}
OpenPOWER on IntegriCloud