mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-23 16:19:52 +00:00
Put MCSectionCOFF::Name into the MCContext instead of leaking it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99231 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -42,9 +42,8 @@ namespace llvm {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class MCSectionCOFF : public MCSection {
|
class MCSectionCOFF : public MCSection {
|
||||||
// FIXME: This memory is leaked because MCSectionCOFF is bump pointer
|
// The memory for this string is stored in the same MCContext as *this.
|
||||||
// allocated and this never gets freed.
|
StringRef Name;
|
||||||
std::string Name;
|
|
||||||
|
|
||||||
/// IsDirective - This is true if the section name is a directive, not
|
/// IsDirective - This is true if the section name is a directive, not
|
||||||
/// something that should be printed with ".section".
|
/// something that should be printed with ".section".
|
||||||
@@ -61,7 +60,7 @@ namespace llvm {
|
|||||||
static MCSectionCOFF *Create(StringRef Name, bool IsDirective,
|
static MCSectionCOFF *Create(StringRef Name, bool IsDirective,
|
||||||
SectionKind K, MCContext &Ctx);
|
SectionKind K, MCContext &Ctx);
|
||||||
|
|
||||||
const std::string &getName() const { return Name; }
|
StringRef getName() const { return Name; }
|
||||||
bool isDirective() const { return IsDirective; }
|
bool isDirective() const { return IsDirective; }
|
||||||
|
|
||||||
virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
|
virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
|
||||||
|
|||||||
@@ -26,7 +26,11 @@ MCSection::~MCSection() {
|
|||||||
|
|
||||||
MCSectionCOFF *MCSectionCOFF::
|
MCSectionCOFF *MCSectionCOFF::
|
||||||
Create(StringRef Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
|
Create(StringRef Name, bool IsDirective, SectionKind K, MCContext &Ctx) {
|
||||||
return new (Ctx) MCSectionCOFF(Name, IsDirective, K);
|
char *NameCopy = static_cast<char*>(
|
||||||
|
Ctx.Allocate(Name.size(), /*Alignment=*/1));
|
||||||
|
memcpy(NameCopy, Name.data(), Name.size());
|
||||||
|
return new (Ctx) MCSectionCOFF(StringRef(NameCopy, Name.size()),
|
||||||
|
IsDirective, K);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,
|
void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,
|
||||||
|
|||||||
Reference in New Issue
Block a user