mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-04 07:32:13 +00:00
change makeNameProper to take a stringref instead of std::string.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93295 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
af2a8361e4
commit
1cb75460b6
@ -19,6 +19,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class StringRef;
|
||||||
class Type;
|
class Type;
|
||||||
class Module;
|
class Module;
|
||||||
class Value;
|
class Value;
|
||||||
@ -111,7 +112,7 @@ public:
|
|||||||
/// does this for you, so there's no point calling it on the result
|
/// does this for you, so there's no point calling it on the result
|
||||||
/// from getValueName.
|
/// from getValueName.
|
||||||
///
|
///
|
||||||
std::string makeNameProper(const std::string &x,
|
std::string makeNameProper(StringRef x,
|
||||||
ManglerPrefixTy PrefixTy = Mangler::Default);
|
ManglerPrefixTy PrefixTy = Mangler::Default);
|
||||||
|
|
||||||
/// getNameWithPrefix - Fill OutName with the name of the appropriate prefix
|
/// getNameWithPrefix - Fill OutName with the name of the appropriate prefix
|
||||||
|
@ -32,7 +32,7 @@ static std::string MangleLetter(unsigned char C) {
|
|||||||
/// makeNameProper - We don't want identifier names non-C-identifier characters
|
/// makeNameProper - We don't want identifier names non-C-identifier characters
|
||||||
/// in them, so mangle them as appropriate.
|
/// in them, so mangle them as appropriate.
|
||||||
///
|
///
|
||||||
std::string Mangler::makeNameProper(const std::string &X,
|
std::string Mangler::makeNameProper(StringRef X,
|
||||||
ManglerPrefixTy PrefixTy) {
|
ManglerPrefixTy PrefixTy) {
|
||||||
assert(!X.empty() && "Cannot mangle empty strings");
|
assert(!X.empty() && "Cannot mangle empty strings");
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ std::string Mangler::makeNameProper(const std::string &X,
|
|||||||
|
|
||||||
// If X does not start with (char)1, add the prefix.
|
// If X does not start with (char)1, add the prefix.
|
||||||
bool NeedPrefix = true;
|
bool NeedPrefix = true;
|
||||||
std::string::const_iterator I = X.begin();
|
StringRef::iterator I = X.begin();
|
||||||
if (*I == 1) {
|
if (*I == 1) {
|
||||||
NeedPrefix = false;
|
NeedPrefix = false;
|
||||||
++I; // Skip over the marker.
|
++I; // Skip over the marker.
|
||||||
@ -52,7 +52,7 @@ std::string Mangler::makeNameProper(const std::string &X,
|
|||||||
if (!SymbolsCanStartWithDigit && *I >= '0' && *I <= '9')
|
if (!SymbolsCanStartWithDigit && *I >= '0' && *I <= '9')
|
||||||
Result += MangleLetter(*I++);
|
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))
|
if (!isCharAcceptable(*I))
|
||||||
Result += MangleLetter(*I);
|
Result += MangleLetter(*I);
|
||||||
else
|
else
|
||||||
@ -74,7 +74,7 @@ std::string Mangler::makeNameProper(const std::string &X,
|
|||||||
bool NeedPrefix = true;
|
bool NeedPrefix = true;
|
||||||
bool NeedQuotes = false;
|
bool NeedQuotes = false;
|
||||||
std::string Result;
|
std::string Result;
|
||||||
std::string::const_iterator I = X.begin();
|
StringRef::iterator I = X.begin();
|
||||||
if (*I == 1) {
|
if (*I == 1) {
|
||||||
NeedPrefix = false;
|
NeedPrefix = false;
|
||||||
++I; // Skip over the marker.
|
++I; // Skip over the marker.
|
||||||
@ -87,7 +87,7 @@ std::string Mangler::makeNameProper(const std::string &X,
|
|||||||
// Do an initial scan of the string, checking to see if we need quotes or
|
// Do an initial scan of the string, checking to see if we need quotes or
|
||||||
// to escape a '"' or not.
|
// to escape a '"' or not.
|
||||||
if (!NeedQuotes)
|
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)) {
|
if (!isCharAcceptable(*I)) {
|
||||||
NeedQuotes = true;
|
NeedQuotes = true;
|
||||||
break;
|
break;
|
||||||
@ -98,7 +98,7 @@ std::string Mangler::makeNameProper(const std::string &X,
|
|||||||
if (!NeedPrefix)
|
if (!NeedPrefix)
|
||||||
return X.substr(1); // Strip off the \001.
|
return X.substr(1); // Strip off the \001.
|
||||||
|
|
||||||
Result = Prefix + X;
|
Result = Prefix + X.str();
|
||||||
|
|
||||||
if (PrefixTy == Mangler::Private)
|
if (PrefixTy == Mangler::Private)
|
||||||
Result = PrivatePrefix + Result;
|
Result = PrivatePrefix + Result;
|
||||||
@ -109,10 +109,10 @@ std::string Mangler::makeNameProper(const std::string &X,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (NeedPrefix)
|
if (NeedPrefix)
|
||||||
Result = X.substr(0, I-X.begin());
|
Result = X.substr(0, I-X.begin()).str();
|
||||||
|
|
||||||
// Otherwise, construct the string the expensive way.
|
// 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 == '"')
|
if (*I == '"')
|
||||||
Result += "_QQ_";
|
Result += "_QQ_";
|
||||||
else if (*I == '\n')
|
else if (*I == '\n')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user