Move MCContext and friends to StringRef based APIs.
authorDaniel Dunbar <daniel@zuster.org>
Mon, 27 Jul 2009 21:22:30 +0000 (21:22 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 27 Jul 2009 21:22:30 +0000 (21:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77251 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCContext.h
include/llvm/MC/MCSection.h
include/llvm/MC/MCSymbol.h
lib/MC/MCContext.cpp

index 846e195139de1af5762029f84c6c5ce78a98209b..24dbc40479bce6f36f2147bc2c0be5f462fbead7 100644 (file)
@@ -18,6 +18,7 @@ namespace llvm {
   class MCValue;
   class MCSection;
   class MCSymbol;
+  class StringRef;
 
   /// MCContext - Context object for machine code objects.
   class MCContext {
@@ -46,19 +47,19 @@ namespace llvm {
     ~MCContext();
 
     /// GetSection - Get or create a new section with the given @param Name.
-    MCSection *GetSection(const char *Name);
+    MCSection *GetSection(const StringRef &Name);
     
     /// CreateSymbol - Create a new symbol with the specified @param Name.
     ///
     /// @param Name - The symbol name, which must be unique across all symbols.
-    MCSymbol *CreateSymbol(const char *Name);
+    MCSymbol *CreateSymbol(const StringRef &Name);
 
     /// GetOrCreateSymbol - Lookup the symbol inside with the specified
     /// @param Name.  If it exists, return it.  If not, create a forward
     /// reference and return it.
     ///
     /// @param Name - The symbol name, which must be unique across all symbols.
-    MCSymbol *GetOrCreateSymbol(const char *Name);
+    MCSymbol *GetOrCreateSymbol(const StringRef &Name);
     
     /// CreateTemporarySymbol - Create a new temporary symbol with the specified
     /// @param Name.
@@ -66,10 +67,10 @@ namespace llvm {
     /// @param Name - The symbol name, for debugging purposes only, temporary
     /// symbols do not surive assembly. If non-empty the name must be unique
     /// across all symbols.
-    MCSymbol *CreateTemporarySymbol(const char *Name = "");
+    MCSymbol *CreateTemporarySymbol(const StringRef &Name = "");
 
     /// LookupSymbol - Get the symbol for @param Name, or null.
-    MCSymbol *LookupSymbol(const char *Name) const;
+    MCSymbol *LookupSymbol(const StringRef &Name) const;
 
     /// ClearSymbolValue - Erase a value binding for @param Symbol, if one
     /// exists.
index 1b127b52e1c9e273b21cf6ec552c42edf7c37cb2..48ffa2facd6b0fa17fce4424d31e95d272db34d3 100644 (file)
@@ -15,6 +15,7 @@
 #define LLVM_MC_MCSECTION_H
 
 #include <string>
+#include "llvm/ADT/StringRef.h"
 
 namespace llvm {
 
@@ -25,7 +26,7 @@ namespace llvm {
     std::string Name;
   private:
     friend class MCContext;
-    MCSection(const char *_Name) : Name(_Name) {}
+    MCSection(const StringRef &_Name) : Name(_Name) {}
     
     MCSection(const MCSection&);      // DO NOT IMPLEMENT
     void operator=(const MCSection&); // DO NOT IMPLEMENT
index 235e6614f973fb926291dafb66974d6613fbaca1..de6dc5fcb876e3505ba340fe0ecd8114d304834f 100644 (file)
@@ -15,6 +15,7 @@
 #define LLVM_MC_MCSYMBOL_H
 
 #include <string>
+#include "llvm/ADT/StringRef.h"
 
 namespace llvm {
   class MCSection;
@@ -46,7 +47,7 @@ namespace llvm {
 
   private:  // MCContext creates and uniques these.
     friend class MCContext;
-    MCSymbol(const char *_Name, bool _IsTemporary) 
+    MCSymbol(const StringRef &_Name, bool _IsTemporary) 
       : Name(_Name), Section(0), IsTemporary(_IsTemporary), IsExternal(false) {}
     
     MCSymbol(const MCSymbol&);       // DO NOT IMPLEMENT
index 6c6019c76ffdf19099ae60f2f8782f0e60b77187..6c74dcd9ecfdf75ff083ab581dd6d41dc25d40c0 100644 (file)
@@ -21,7 +21,7 @@ MCContext::MCContext()
 MCContext::~MCContext() {
 }
 
-MCSection *MCContext::GetSection(const char *Name) {
+MCSection *MCContext::GetSection(const StringRef &Name) {
   MCSection *&Entry = Sections[Name];
   
   if (!Entry)
@@ -30,7 +30,7 @@ MCSection *MCContext::GetSection(const char *Name) {
   return Entry;
 }
 
-MCSymbol *MCContext::CreateSymbol(const char *Name) {
+MCSymbol *MCContext::CreateSymbol(const StringRef &Name) {
   assert(Name[0] != '\0' && "Normal symbols cannot be unnamed!");
 
   // Create and bind the symbol, and ensure that names are unique.
@@ -39,7 +39,7 @@ MCSymbol *MCContext::CreateSymbol(const char *Name) {
   return Entry = new (*this) MCSymbol(Name, false);
 }
 
-MCSymbol *MCContext::GetOrCreateSymbol(const char *Name) {
+MCSymbol *MCContext::GetOrCreateSymbol(const StringRef &Name) {
   MCSymbol *&Entry = Symbols[Name];
   if (Entry) return Entry;
 
@@ -47,9 +47,9 @@ MCSymbol *MCContext::GetOrCreateSymbol(const char *Name) {
 }
 
 
-MCSymbol *MCContext::CreateTemporarySymbol(const char *Name) {
+MCSymbol *MCContext::CreateTemporarySymbol(const StringRef &Name) {
   // If unnamed, just create a symbol.
-  if (Name[0] == '\0')
+  if (Name.empty())
     new (*this) MCSymbol("", true);
     
   // Otherwise create as usual.
@@ -58,7 +58,7 @@ MCSymbol *MCContext::CreateTemporarySymbol(const char *Name) {
   return Entry = new (*this) MCSymbol(Name, true);
 }
 
-MCSymbol *MCContext::LookupSymbol(const char *Name) const {
+MCSymbol *MCContext::LookupSymbol(const StringRef &Name) const {
   return Symbols.lookup(Name);
 }