#include "llvm/IR/Constant.h"
#include "llvm/IR/DerivedTypes.h"
+#include <system_error>
namespace llvm {
class Module;
class GlobalValue : public Constant {
- GlobalValue(const GlobalValue &) LLVM_DELETED_FUNCTION;
+ GlobalValue(const GlobalValue &) = delete;
public:
/// @brief An enumeration for the kinds of linkage for global values.
enum LinkageTypes {
};
protected:
- GlobalValue(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
+ GlobalValue(PointerType *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
LinkageTypes Linkage, const Twine &Name)
: Constant(Ty, VTy, Ops, NumOps), Linkage(Linkage),
Visibility(DefaultVisibility), UnnamedAddr(0),
// (19 + 3 + 2 + 1 + 2 + 5) == 32.
unsigned SubClassData : 19;
protected:
+ static const unsigned GlobalValueSubClassDataBits = 19;
unsigned getGlobalValueSubClassData() const {
return SubClassData;
}
LocalExecTLSModel
};
- ~GlobalValue() {
+ ~GlobalValue() override {
removeDeadConstantUsers(); // remove any dead constants using this.
}
const char *getSection() const;
/// Global values are always pointers.
- inline PointerType *getType() const {
- return cast<PointerType>(User::getType());
- }
+ PointerType *getType() const { return cast<PointerType>(User::getType()); }
+
+ Type *getValueType() const { return getType()->getElementType(); }
static LinkageTypes getLinkOnceLinkage(bool ODR) {
return ODR ? LinkOnceODRLinkage : LinkOnceAnyLinkage;
static bool isAvailableExternallyLinkage(LinkageTypes Linkage) {
return Linkage == AvailableExternallyLinkage;
}
+ static bool isLinkOnceODRLinkage(LinkageTypes Linkage) {
+ return Linkage == LinkOnceODRLinkage;
+ }
static bool isLinkOnceLinkage(LinkageTypes Linkage) {
return Linkage == LinkOnceAnyLinkage || Linkage == LinkOnceODRLinkage;
}
bool hasLinkOnceLinkage() const {
return isLinkOnceLinkage(Linkage);
}
+ bool hasLinkOnceODRLinkage() const { return isLinkOnceODRLinkage(Linkage); }
bool hasWeakLinkage() const {
return isWeakLinkage(Linkage);
}
/// Make sure this GlobalValue is fully read. If the module is corrupt, this
/// returns true and fills in the optional string with information about the
/// problem. If successful, this returns false.
- bool Materialize(std::string *ErrInfo = nullptr);
+ std::error_code materialize();
/// If this GlobalValue is read in, and if the GVMaterializer supports it,
/// release the memory for the function, and set it up to be materialized
/// the current translation unit.
bool isDeclaration() const;
+ bool isDeclarationForLinker() const {
+ if (hasAvailableExternallyLinkage())
+ return true;
+
+ return isDeclaration();
+ }
+
/// This method unlinks 'this' from the containing module, but does not delete
/// it.
virtual void removeFromParent() = 0;
virtual void eraseFromParent() = 0;
/// Get the module that this global value is contained inside of...
- inline Module *getParent() { return Parent; }
- inline const Module *getParent() const { return Parent; }
-
- const DataLayout *getDataLayout() const;
+ Module *getParent() { return Parent; }
+ const Module *getParent() const { return Parent; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const Value *V) {
+ static bool classof(const Value *V) {
return V->getValueID() == Value::FunctionVal ||
V->getValueID() == Value::GlobalVariableVal ||
V->getValueID() == Value::GlobalAliasVal;