aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/MC/MCSymbol.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-15 06:15:35 +0000
committerChris Lattner <sabre@nondot.org>2010-03-15 06:15:35 +0000
commitc28cc093e3b5b8601cb5024a5365a6f31f49839a (patch)
tree00f05f95c95cfd6ee3616fd54f07b2c5eaf8ace7 /include/llvm/MC/MCSymbol.h
parente002da34efeed0f1622c767b3ca1eeaa791124ed (diff)
downloadexternal_llvm-c28cc093e3b5b8601cb5024a5365a6f31f49839a.zip
external_llvm-c28cc093e3b5b8601cb5024a5365a6f31f49839a.tar.gz
external_llvm-c28cc093e3b5b8601cb5024a5365a6f31f49839a.tar.bz2
fix a memory leak yjasskin pointed out: MCSymbol is bump pointer
allocated and thus not freed. This is cool except that it contains and std::string so the string data didn't get freed. In any case there is no reason to redundantly store the string data in the MCSymbol anyway, just make the MCSymbol ref the string data in the MCContext StringMap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/MC/MCSymbol.h')
-rw-r--r--include/llvm/MC/MCSymbol.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/include/llvm/MC/MCSymbol.h b/include/llvm/MC/MCSymbol.h
index d5c4d95..e41eb2a 100644
--- a/include/llvm/MC/MCSymbol.h
+++ b/include/llvm/MC/MCSymbol.h
@@ -14,9 +14,7 @@
#ifndef LLVM_MC_MCSYMBOL_H
#define LLVM_MC_MCSYMBOL_H
-#include <string>
#include "llvm/ADT/StringRef.h"
-#include "llvm/System/DataTypes.h"
namespace llvm {
class MCExpr;
@@ -38,8 +36,9 @@ namespace llvm {
// FIXME: Use a PointerInt wrapper for this?
static const MCSection *AbsolutePseudoSection;
- /// Name - The name of the symbol.
- std::string Name;
+ /// Name - The name of the symbol. The referred-to string data is actually
+ /// held by the StringMap that lives in MCContext.
+ StringRef Name;
/// Section - The section the symbol is defined in. This is null for
/// undefined symbols, and the special AbsolutePseudoSection value for
@@ -56,14 +55,14 @@ namespace llvm {
private: // MCContext creates and uniques these.
friend class MCContext;
- MCSymbol(StringRef _Name, bool _IsTemporary)
- : Name(_Name), Section(0), Value(0), IsTemporary(_IsTemporary) {}
+ MCSymbol(StringRef name, bool isTemporary)
+ : Name(name), Section(0), Value(0), IsTemporary(isTemporary) {}
MCSymbol(const MCSymbol&); // DO NOT IMPLEMENT
void operator=(const MCSymbol&); // DO NOT IMPLEMENT
public:
/// getName - Get the symbol name.
- const std::string &getName() const { return Name; }
+ StringRef getName() const { return Name; }
/// @name Symbol Type
/// @{