diff options
Diffstat (limited to 'llvm/lib/IR/Globals.cpp')
-rw-r--r-- | llvm/lib/IR/Globals.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp index a9702b7af81..7e8ef6526fc 100644 --- a/llvm/lib/IR/Globals.cpp +++ b/llvm/lib/IR/Globals.cpp @@ -128,7 +128,7 @@ std::string GlobalValue::getGlobalIdentifier() const { getParent()->getSourceFileName()); } -const char *GlobalValue::getSection() const { +StringRef GlobalValue::getSection() const { if (auto *GA = dyn_cast<GlobalAlias>(this)) { // In general we cannot compute this at the IR level, but we try. if (const GlobalObject *GO = GA->getBaseObject()) @@ -151,7 +151,12 @@ Comdat *GlobalValue::getComdat() { return cast<GlobalObject>(this)->getComdat(); } -void GlobalObject::setSection(StringRef S) { Section = S; } +void GlobalObject::setSection(StringRef S) { + Section = S; + + // The C api requires this to be null terminated. + Section.c_str(); +} bool GlobalValue::isDeclaration() const { // Globals are definitions if they have an initializer. |