[PATCH] Add a public accessor for GlobalCtors in CodeGenModule

Keno Fischer kfischer at college.harvard.edu
Sun Dec 28 10:51:30 PST 2014


I'm using clang in a JIT context where I found it useful to be able to
access the GlobalCtors and especially clear them once I have emitted
and called them. I'd like to add a public method to be able to access
the list. Thoughts?

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D6790

Files:
  lib/CodeGen/CodeGenModule.h

Index: lib/CodeGen/CodeGenModule.h
===================================================================
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -261,6 +261,7 @@
   CodeGenModule(const CodeGenModule &) LLVM_DELETED_FUNCTION;
   void operator=(const CodeGenModule &) LLVM_DELETED_FUNCTION;
 
+public:
   struct Structor {
     Structor() : Priority(0), Initializer(nullptr), AssociatedData(nullptr) {}
     Structor(int Priority, llvm::Constant *Initializer,
@@ -274,6 +275,7 @@
 
   typedef std::vector<Structor> CtorList;
 
+private:
   ASTContext &Context;
   const LangOptions &LangOpts;
   const CodeGenOptions &CodeGenOpts;
@@ -624,6 +626,9 @@
     return VTables.getMicrosoftVTableContext();
   }
 
+  CtorList &getGlobalCtors() { return GlobalCtors; }
+  CtorList &getGlobalDtors() { return GlobalDtors; }
+
   llvm::MDNode *getTBAAInfo(QualType QTy);
   llvm::MDNode *getTBAAInfoForVTablePtr();
   llvm::MDNode *getTBAAStructInfo(QualType QTy);

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6790.17659.patch
Type: text/x-patch
Size: 978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141228/caf662c6/attachment.bin>


More information about the cfe-commits mailing list