2015-05-14 16 views
0

有這似乎符合我需要一個構造函數:如何在模塊的末尾插入GlobalVariable?

00055 /// GlobalVariable ctor - If a parent module is specified, the global is 
00056 /// automatically inserted into the end of the specified modules global list. 
00057 GlobalVariable(Type *Ty, bool isConstant, LinkageTypes Linkage, 
00058     Constant *Initializer = nullptr, const Twine &Name = "", 
00059     ThreadLocalMode = NotThreadLocal, unsigned AddressSpace = 0, 
00060     bool isExternallyInitialized = false); 

根據下面的文檔,如果指定了父模塊的GV插在它的結束。如何指定模塊?

回答

0

看起來評論是錯誤的。您可以使用this constructor,它將Module&作爲第一個參數。您可以指定一個GlobalVariable用於之前要插入的新插入,但它是可選的,如果沒有它,則在最後插入新的全局插入。

或者(您的問題的標題去),如果你已經有了一個GlobalVariable,你可以調用getGlobalListModulepush_back全局變量到它。