aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGRtti.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-10-10 20:49:04 +0000
committerAnders Carlsson <andersca@mac.com>2009-10-10 20:49:04 +0000
commit656e4c10dcbef73198423b9e2b5d7690269a61b7 (patch)
tree33260bc3fcfe2104290480769371f821ef08707e /lib/CodeGen/CGRtti.cpp
parentf7bcc7e6c803a2b2f7b7f7fdfb2506dd25ec6de8 (diff)
Move our (non-existing) RTTI emission code into CGRtti.cpp. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83732 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGRtti.cpp')
-rw-r--r--lib/CodeGen/CGRtti.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/CodeGen/CGRtti.cpp b/lib/CodeGen/CGRtti.cpp
new file mode 100644
index 0000000000..15f56dc7cc
--- /dev/null
+++ b/lib/CodeGen/CGRtti.cpp
@@ -0,0 +1,48 @@
+//===--- CGCXXRtti.cpp - Emit LLVM Code for C++ RTTI descriptors ----------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This contains code dealing with C++ code generation of RTTI descriptors.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CodeGenModule.h"
+using namespace clang;
+using namespace CodeGen;
+
+llvm::Constant *CodeGenModule::GenerateRtti(const CXXRecordDecl *RD) {
+ llvm::Type *Ptr8Ty;
+ Ptr8Ty = llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext), 0);
+ llvm::Constant *Rtti = llvm::Constant::getNullValue(Ptr8Ty);
+
+ if (!getContext().getLangOptions().Rtti)
+ return Rtti;
+
+ llvm::SmallString<256> OutName;
+ llvm::raw_svector_ostream Out(OutName);
+ QualType ClassTy;
+ ClassTy = getContext().getTagDeclType(RD);
+ mangleCXXRtti(getMangleContext(), ClassTy, Out);
+ llvm::GlobalVariable::LinkageTypes linktype;
+ linktype = llvm::GlobalValue::WeakAnyLinkage;
+ std::vector<llvm::Constant *> info;
+ // assert(0 && "FIXME: implement rtti descriptor");
+ // FIXME: descriptor
+ info.push_back(llvm::Constant::getNullValue(Ptr8Ty));
+ // assert(0 && "FIXME: implement rtti ts");
+ // FIXME: TS
+ info.push_back(llvm::Constant::getNullValue(Ptr8Ty));
+
+ llvm::Constant *C;
+ llvm::ArrayType *type = llvm::ArrayType::get(Ptr8Ty, info.size());
+ C = llvm::ConstantArray::get(type, info);
+ Rtti = new llvm::GlobalVariable(getModule(), type, true, linktype, C,
+ Out.str());
+ Rtti = llvm::ConstantExpr::getBitCast(Rtti, Ptr8Ty);
+ return Rtti;
+}