aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGRtti.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-11-17 02:16:21 +0000
committerMike Stump <mrs@apple.com>2009-11-17 02:16:21 +0000
commitea2c0b5dec07c28222856e66177f0922c9f508b1 (patch)
tree393c9976d660328c2d79e4cb9595c02fca242353 /lib/CodeGen/CGRtti.cpp
parenta24dc2e38c7fb0f7f138b3d14b5f0f241fd0eccf (diff)
Add typeid for the builtin types. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89028 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGRtti.cpp')
-rw-r--r--lib/CodeGen/CGRtti.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/CodeGen/CGRtti.cpp b/lib/CodeGen/CGRtti.cpp
index ce8f2c89f3..5ac2095c25 100644
--- a/lib/CodeGen/CGRtti.cpp
+++ b/lib/CodeGen/CGRtti.cpp
@@ -76,7 +76,7 @@ public:
return llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), c);
}
- llvm::Constant *Buildclass_type_infoRef(const CXXRecordDecl *RD) {
+ llvm::Constant *BuildTypeRef(QualType Ty) {
const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
llvm::Constant *C;
@@ -85,8 +85,7 @@ public:
llvm::SmallString<256> OutName;
llvm::raw_svector_ostream Out(OutName);
- mangleCXXRtti(CGM.getMangleContext(), CGM.getContext().getTagDeclType(RD),
- Out);
+ mangleCXXRtti(CGM.getMangleContext(), Ty, Out);
C = CGM.getModule().getGlobalVariable(Out.str());
if (C)
@@ -100,6 +99,10 @@ public:
return llvm::ConstantExpr::getBitCast(C, Int8PtrTy);
}
+ llvm::Constant *Buildclass_type_infoRef(const CXXRecordDecl *RD) {
+ return BuildTypeRef(CGM.getContext().getTagDeclType(RD));
+ }
+
/// CalculateFlags - Calculate the flags for the __vmi_class_type_info
/// datastructure. 1 for non-diamond repeated inheritance, 2 for a dimond
/// shaped class.
@@ -234,6 +237,24 @@ public:
return Rtti;
#endif
}
+
+ llvm::Constant *BuildType(QualType Ty) {
+ const clang::Type &Type
+ = *CGM.getContext().getCanonicalType(Ty).getTypePtr();
+ switch (Type.getTypeClass()) {
+ default: {
+ // FIXME: Add all the missing types, such as pointer, array...
+ assert(0 && "typeid expression");
+ const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
+ return llvm::Constant::getNullValue(Int8PtrTy);
+ }
+
+ case Type::Builtin: {
+ // We expect all type_info objects for builtin types to be in the library.
+ return BuildTypeRef(Ty);
+ }
+ }
+ }
};
llvm::Constant *CodeGenModule::GenerateRttiRef(const CXXRecordDecl *RD) {
@@ -247,3 +268,9 @@ llvm::Constant *CodeGenModule::GenerateRtti(const CXXRecordDecl *RD) {
return b.Buildclass_type_info(RD);
}
+
+llvm::Constant *CodeGenModule::GenerateRttiNonClass(QualType Ty) {
+ RttiBuilder b(*this);
+
+ return b.BuildType(Ty);
+}