summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/llvm/IR/GlobalAlias.h21
-rw-r--r--include/llvm/IR/GlobalObject.h4
-rw-r--r--include/llvm/IR/GlobalValue.h10
3 files changed, 20 insertions, 15 deletions
diff --git a/include/llvm/IR/GlobalAlias.h b/include/llvm/IR/GlobalAlias.h
index d9f0b4a89b..a77d1630f4 100644
--- a/include/llvm/IR/GlobalAlias.h
+++ b/include/llvm/IR/GlobalAlias.h
@@ -34,7 +34,7 @@ class GlobalAlias : public GlobalValue, public ilist_node<GlobalAlias> {
void setParent(Module *parent);
GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
- const Twine &Name, GlobalObject *Aliasee, Module *Parent);
+ const Twine &Name, Constant *Aliasee, Module *Parent);
public:
// allocate space for exactly one operand
@@ -46,7 +46,7 @@ public:
/// the end of the specified module's alias list.
static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
LinkageTypes Linkage, const Twine &Name,
- GlobalObject *Aliasee, Module *Parent);
+ Constant *Aliasee, Module *Parent);
// Without the Aliasee.
static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
@@ -56,14 +56,14 @@ public:
// The module is taken from the Aliasee.
static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
LinkageTypes Linkage, const Twine &Name,
- GlobalObject *Aliasee);
+ GlobalValue *Aliasee);
// Type, Parent and AddressSpace taken from the Aliasee.
static GlobalAlias *create(LinkageTypes Linkage, const Twine &Name,
- GlobalObject *Aliasee);
+ GlobalValue *Aliasee);
// Linkage, Type, Parent and AddressSpace taken from the Aliasee.
- static GlobalAlias *create(const Twine &Name, GlobalObject *Aliasee);
+ static GlobalAlias *create(const Twine &Name, GlobalValue *Aliasee);
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
@@ -78,14 +78,13 @@ public:
///
void eraseFromParent() override;
- /// set/getAliasee - These methods retrive and set alias target.
- void setAliasee(GlobalObject *GO);
- const GlobalObject *getAliasee() const {
+ /// These methods retrive and set alias target.
+ void setAliasee(Constant *Aliasee);
+ const Constant *getAliasee() const {
return const_cast<GlobalAlias *>(this)->getAliasee();
}
-
- GlobalObject *getAliasee() {
- return cast_or_null<GlobalObject>(getOperand(0));
+ Constant *getAliasee() {
+ return getOperand(0);
}
static bool isValidLinkage(LinkageTypes L) {
diff --git a/include/llvm/IR/GlobalObject.h b/include/llvm/IR/GlobalObject.h
index 3bc8b8531d..74cc18eeb1 100644
--- a/include/llvm/IR/GlobalObject.h
+++ b/include/llvm/IR/GlobalObject.h
@@ -40,8 +40,8 @@ public:
}
void setAlignment(unsigned Align);
- bool hasSection() const { return !getSection().empty(); }
- const std::string &getSection() const { return Section; }
+ bool hasSection() const { return !StringRef(getSection()).empty(); }
+ const char *getSection() const { return Section.c_str(); }
void setSection(StringRef S);
void copyAttributesFrom(const GlobalValue *Src) override;
diff --git a/include/llvm/IR/GlobalValue.h b/include/llvm/IR/GlobalValue.h
index 04c97a01d6..5e99886a5f 100644
--- a/include/llvm/IR/GlobalValue.h
+++ b/include/llvm/IR/GlobalValue.h
@@ -146,8 +146,14 @@ public:
}
void setDLLStorageClass(DLLStorageClassTypes C) { DllStorageClass = C; }
- bool hasSection() const { return !getSection().empty(); }
- const std::string &getSection() const;
+ bool hasSection() const { return !StringRef(getSection()).empty(); }
+ // It is unfortunate that we have to use "char *" in here since this is
+ // always non NULL, but:
+ // * The C API expects a null terminated string, so we cannot use StringRef.
+ // * The C API expects us to own it, so we cannot use a std:string.
+ // * For GlobalAliases we can fail to find the section and we have to
+ // return "", so we cannot use a "const std::string &".
+ const char *getSection() const;
/// Global values are always pointers.
inline PointerType *getType() const {