[llvm-commits] [llvm] r93295 - in /llvm/trunk: include/llvm/Support/Mangler.h lib/VMCore/Mangler.cpp
Chris Lattner
sabre at nondot.org
Tue Jan 12 20:55:33 PST 2010
Author: lattner
Date: Tue Jan 12 22:55:33 2010
New Revision: 93295
URL: http://llvm.org/viewvc/llvm-project?rev=93295&view=rev
Log:
change makeNameProper to take a stringref instead of std::string.
Modified:
llvm/trunk/include/llvm/Support/Mangler.h
llvm/trunk/lib/VMCore/Mangler.cpp
Modified: llvm/trunk/include/llvm/Support/Mangler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Mangler.h?rev=93295&r1=93294&r2=93295&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Mangler.h (original)
+++ llvm/trunk/include/llvm/Support/Mangler.h Tue Jan 12 22:55:33 2010
@@ -19,6 +19,7 @@
#include <string>
namespace llvm {
+class StringRef;
class Type;
class Module;
class Value;
@@ -111,7 +112,7 @@
/// does this for you, so there's no point calling it on the result
/// from getValueName.
///
- std::string makeNameProper(const std::string &x,
+ std::string makeNameProper(StringRef x,
ManglerPrefixTy PrefixTy = Mangler::Default);
/// getNameWithPrefix - Fill OutName with the name of the appropriate prefix
Modified: llvm/trunk/lib/VMCore/Mangler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=93295&r1=93294&r2=93295&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Mangler.cpp (original)
+++ llvm/trunk/lib/VMCore/Mangler.cpp Tue Jan 12 22:55:33 2010
@@ -32,7 +32,7 @@
/// 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");
@@ -41,7 +41,7 @@
// 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.
@@ -52,7 +52,7 @@
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
@@ -74,7 +74,7 @@
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.
@@ -87,7 +87,7 @@
// 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;
@@ -98,7 +98,7 @@
if (!NeedPrefix)
return X.substr(1); // Strip off the \001.
- Result = Prefix + X;
+ Result = Prefix + X.str();
if (PrefixTy == Mangler::Private)
Result = PrivatePrefix + Result;
@@ -109,10 +109,10 @@
}
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')
More information about the llvm-commits
mailing list