summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGObjCMac.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-03-09 20:09:19 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-03-09 20:09:19 +0000
commit30c653655dfe2435fd5bb7b8e1a5da08aad372cc (patch)
treee1f04861d7e991c58d9146926c2fe5cf7a56621d /clang/lib/CodeGen/CGObjCMac.cpp
parenta6778494fb5f5bd697b103ec019cb5486ab1cddc (diff)
downloadbcm5719-llvm-30c653655dfe2435fd5bb7b8e1a5da08aad372cc.tar.gz
bcm5719-llvm-30c653655dfe2435fd5bb7b8e1a5da08aad372cc.zip
NeXT: Add CreateMetadataVar utility method to encapsulate creation of
Obj-C metadata variables (which generally should be handled the same, although they aren't currently). - No functionality change. llvm-svn: 66432
Diffstat (limited to 'clang/lib/CodeGen/CGObjCMac.cpp')
-rw-r--r--clang/lib/CodeGen/CGObjCMac.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 44d56b5a608..ffc40b943b2 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -430,6 +430,18 @@ protected:
uint64_t GetIvarBaseOffset(const llvm::StructLayout *Layout,
FieldDecl *Field);
+ /// CreateMetadataVar - Create a global variable with internal
+ /// linkage for use by the Objective-C runtime.
+ ///
+ /// This is a convenience wrapper which not only creates the
+ /// variable, but also sets the section and alignment and adds the
+ /// global to the UsedGlobals list.
+ llvm::GlobalVariable *CreateMetadataVar(const std::string &Name,
+ llvm::Constant *Init,
+ const char *Section,
+ bool SetAlignment,
+ bool IsUsed);
+
public:
CGObjCCommonMac(CodeGen::CodeGenModule &cgm) : CGM(cgm)
{ }
@@ -1836,6 +1848,28 @@ uint64_t CGObjCCommonMac::GetIvarBaseOffset(const llvm::StructLayout *Layout,
CGM.getTypes().getLLVMFieldNo(Field));
}
+llvm::GlobalVariable *
+CGObjCCommonMac::CreateMetadataVar(const std::string &Name,
+ llvm::Constant *Init,
+ const char *Section,
+ bool SetAlignment,
+ bool IsUsed) {
+ const llvm::Type *Ty = Init->getType();
+ llvm::GlobalVariable *GV =
+ new llvm::GlobalVariable(Ty, false,
+ llvm::GlobalValue::InternalLinkage,
+ Init,
+ Name,
+ &CGM.getModule());
+ if (Section)
+ GV->setSection(Section);
+ if (SetAlignment)
+ GV->setAlignment(CGM.getTargetData().getPreferredAlignment(Ty));
+ if (IsUsed)
+ UsedGlobals.push_back(GV);
+ return GV;
+}
+
llvm::Function *CGObjCMac::ModuleInitFunction() {
// Abuse this interface function as a place to finalize.
FinishModule();
OpenPOWER on IntegriCloud