[llvm-commits] [llvm] r77251 - in /llvm/trunk: include/llvm/MC/MCContext.h include/llvm/MC/MCSection.h include/llvm/MC/MCSymbol.h lib/MC/MCContext.cpp

Daniel Dunbar daniel at zuster.org
Mon Jul 27 14:22:31 PDT 2009


Author: ddunbar
Date: Mon Jul 27 16:22:30 2009
New Revision: 77251

URL: http://llvm.org/viewvc/llvm-project?rev=77251&view=rev
Log:
Move MCContext and friends to StringRef based APIs.

Modified:
    llvm/trunk/include/llvm/MC/MCContext.h
    llvm/trunk/include/llvm/MC/MCSection.h
    llvm/trunk/include/llvm/MC/MCSymbol.h
    llvm/trunk/lib/MC/MCContext.cpp

Modified: llvm/trunk/include/llvm/MC/MCContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=77251&r1=77250&r2=77251&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCContext.h (original)
+++ llvm/trunk/include/llvm/MC/MCContext.h Mon Jul 27 16:22:30 2009
@@ -18,6 +18,7 @@
   class MCValue;
   class MCSection;
   class MCSymbol;
+  class StringRef;
 
   /// MCContext - Context object for machine code objects.
   class MCContext {
@@ -46,19 +47,19 @@
     ~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 @@
     /// @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.

Modified: llvm/trunk/include/llvm/MC/MCSection.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSection.h?rev=77251&r1=77250&r2=77251&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCSection.h (original)
+++ llvm/trunk/include/llvm/MC/MCSection.h Mon Jul 27 16:22:30 2009
@@ -15,6 +15,7 @@
 #define LLVM_MC_MCSECTION_H
 
 #include <string>
+#include "llvm/ADT/StringRef.h"
 
 namespace llvm {
 
@@ -25,7 +26,7 @@
     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

Modified: llvm/trunk/include/llvm/MC/MCSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbol.h?rev=77251&r1=77250&r2=77251&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCSymbol.h (original)
+++ llvm/trunk/include/llvm/MC/MCSymbol.h Mon Jul 27 16:22:30 2009
@@ -15,6 +15,7 @@
 #define LLVM_MC_MCSYMBOL_H
 
 #include <string>
+#include "llvm/ADT/StringRef.h"
 
 namespace llvm {
   class MCSection;
@@ -46,7 +47,7 @@
 
   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

Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=77251&r1=77250&r2=77251&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Mon Jul 27 16:22:30 2009
@@ -21,7 +21,7 @@
 MCContext::~MCContext() {
 }
 
-MCSection *MCContext::GetSection(const char *Name) {
+MCSection *MCContext::GetSection(const StringRef &Name) {
   MCSection *&Entry = Sections[Name];
   
   if (!Entry)
@@ -30,7 +30,7 @@
   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 @@
   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::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 @@
   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);
 }
 





More information about the llvm-commits mailing list