expose a static function as a static method on the MCSymbol class.
authorChris Lattner <sabre@nondot.org>
Wed, 13 Jan 2010 21:09:59 +0000 (21:09 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 13 Jan 2010 21:09:59 +0000 (21:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93350 91177308-0d34-0410-b5e6-96231b3b80d8

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

index cfe04d8855e16bc44f8cb8412a8e03223971c64c..eb594532fe0b49836caf7f2f9540753b97243974 100644 (file)
@@ -136,6 +136,11 @@ namespace llvm {
 
     /// dump - Print the value to stderr.
     void dump() const;
+    
+    /// printMangledName - Print the specified string in mangled form if it uses
+    /// any unusual characters.
+    static void printMangledName(StringRef Str, raw_ostream &OS,
+                                 const MCAsmInfo *MAI);
   };
 
 } // end namespace llvm
index 83200a0bb9f2be32ca5e5477354f5aad045231b0..265d06cceba129f77e9b6f1f4f124459e0127010 100644 (file)
@@ -52,11 +52,14 @@ static bool NameNeedsEscaping(StringRef Str, const MCAsmInfo &MAI) {
   return false;
 }
 
-static void PrintMangledName(raw_ostream &OS, StringRef Str,
-                             const MCAsmInfo &MAI) {
+/// printMangledName - Print the specified string in mangled form if it uses
+/// any unusual characters.
+void MCSymbol::printMangledName(StringRef Str, raw_ostream &OS,
+                                const MCAsmInfo *MAI) {
   // The first character is not allowed to be a number unless the target
   // explicitly allows it.
-  if (!MAI.doesAllowNameToStartWithDigit() && Str[0] >= '0' && Str[0] <= '9') {
+  if ((MAI == 0 || !MAI->doesAllowNameToStartWithDigit()) &&
+      Str[0] >= '0' && Str[0] <= '9') {
     MangleLetter(OS, Str[0]);
     Str = Str.substr(1);
   }
@@ -95,7 +98,7 @@ void MCSymbol::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
 
   // On systems that do not allow quoted names, print with mangling.
   if (!MAI->doesAllowQuotesInName())
-    return PrintMangledName(OS, getName(), *MAI);
+    return printMangledName(getName(), OS, MAI);
 
   // If the string contains a double quote or newline, we still have to mangle
   // it.