+
+ Result = '"' + Result + '"';
+ return Result;
+}
+
+/// getMangledName - Returns the mangled name of V, an LLVM Value,
+/// in the current module. If 'Suffix' is specified, the name ends with the
+/// specified suffix. If 'ForcePrivate' is specified, the label is specified
+/// to have a private label prefix.
+///
+std::string Mangler::getMangledName(const GlobalValue *GV, const char *Suffix,
+ bool ForcePrivate) {
+ assert((!isa<Function>(GV) || !cast<Function>(GV)->isIntrinsic()) &&
+ "Intrinsic functions cannot be mangled by Mangler");
+
+ ManglerPrefixTy PrefixTy =
+ (GV->hasPrivateLinkage() || ForcePrivate) ? Mangler::Private :
+ GV->hasLinkerPrivateLinkage() ? Mangler::LinkerPrivate : Mangler::Default;
+
+ if (GV->hasName())
+ return makeNameProper(GV->getNameStr() + Suffix, PrefixTy);
+
+ // Get the ID for the global, assigning a new one if we haven't got one
+ // already.
+ unsigned &ID = AnonGlobalIDs[GV];
+ if (ID == 0) ID = NextAnonGlobalID++;
+
+ // Must mangle the global into a unique ID.
+ return makeNameProper("__unnamed_" + utostr(ID) + Suffix, PrefixTy);