/// makeNameProper - We don't want identifier names non-C-identifier characters
/// in them, so mangle them as appropriate.
///
-std::string Mangler::makeNameProper(const std::string &X,
+std::string Mangler::makeNameProper(StringRef X,
ManglerPrefixTy PrefixTy) {
assert(!X.empty() && "Cannot mangle empty strings");
// If X does not start with (char)1, add the prefix.
bool NeedPrefix = true;
- std::string::const_iterator I = X.begin();
+ StringRef::iterator I = X.begin();
if (*I == 1) {
NeedPrefix = false;
++I; // Skip over the marker.
if (!SymbolsCanStartWithDigit && *I >= '0' && *I <= '9')
Result += MangleLetter(*I++);
- for (std::string::const_iterator E = X.end(); I != E; ++I) {
+ for (StringRef::iterator E = X.end(); I != E; ++I) {
if (!isCharAcceptable(*I))
Result += MangleLetter(*I);
else
bool NeedPrefix = true;
bool NeedQuotes = false;
std::string Result;
- std::string::const_iterator I = X.begin();
+ StringRef::iterator I = X.begin();
if (*I == 1) {
NeedPrefix = false;
++I; // Skip over the marker.
// Do an initial scan of the string, checking to see if we need quotes or
// to escape a '"' or not.
if (!NeedQuotes)
- for (std::string::const_iterator E = X.end(); I != E; ++I)
+ for (StringRef::iterator E = X.end(); I != E; ++I)
if (!isCharAcceptable(*I)) {
NeedQuotes = true;
break;
if (!NeedPrefix)
return X.substr(1); // Strip off the \001.
- Result = Prefix + X;
+ Result = Prefix + X.str();
if (PrefixTy == Mangler::Private)
Result = PrivatePrefix + Result;
}
if (NeedPrefix)
- Result = X.substr(0, I-X.begin());
+ Result = X.substr(0, I-X.begin()).str();
// Otherwise, construct the string the expensive way.
- for (std::string::const_iterator E = X.end(); I != E; ++I) {
+ for (StringRef::iterator E = X.end(); I != E; ++I) {
if (*I == '"')
Result += "_QQ_";
else if (*I == '\n')