I forgot to commit this test.
[oota-llvm.git] / lib / VMCore / Mangler.cpp
index 21ba086d19f740e1cb58d56b6664b3e0ec7dbbb9..33eb0449e824067bff0a616f48b945c94597060c 100644 (file)
@@ -47,8 +47,9 @@ std::string Mangler::makeNameProper(const std::string &X,
       ++I;  // Skip over the marker.
     }
     
-    // Mangle the first letter specially, don't allow numbers.
-    if (*I >= '0' && *I <= '9')
+    // Mangle the first letter specially, don't allow numbers unless the target
+    // explicitly allows them.
+    if (!SymbolsCanStartWithDigit && *I >= '0' && *I <= '9')
       Result += MangleLetter(*I++);
 
     for (std::string::const_iterator E = X.end(); I != E; ++I) {
@@ -170,13 +171,12 @@ void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
   // If the global is anonymous or not led with \1, then add the appropriate
   // prefix.
   if (!GV->hasName() || GV->getName()[0] != '\1') {
-    OutName.append(Prefix, Prefix+strlen(Prefix));
-    
     if (GV->hasPrivateLinkage() || isImplicitlyPrivate)
       OutName.append(PrivatePrefix, PrivatePrefix+strlen(PrivatePrefix));
     else if (GV->hasLinkerPrivateLinkage())
       OutName.append(LinkerPrivatePrefix,
                      LinkerPrivatePrefix+strlen(LinkerPrivatePrefix));;
+    OutName.append(Prefix, Prefix+strlen(Prefix));
   }
 
   // If the global has a name, just append it now.
@@ -208,7 +208,7 @@ Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix,
                  const char *linkerPrivatePrefix)
   : Prefix(prefix), PrivatePrefix(privatePrefix),
     LinkerPrivatePrefix(linkerPrivatePrefix), UseQuotes(false),
-    NextAnonGlobalID(1) {
+    SymbolsCanStartWithDigit(false), NextAnonGlobalID(1) {
   std::fill(AcceptableChars, array_endof(AcceptableChars), 0);
 
   // Letters and numbers are acceptable.
@@ -223,4 +223,5 @@ Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix,
   markCharAcceptable('_');
   markCharAcceptable('$');
   markCharAcceptable('.');
+  markCharAcceptable('@');
 }