diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-09-24 08:24:28 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-09-24 08:24:28 +0000 |
| commit | cc9c03386fe004af6f1406a79a94b761eb8c9829 (patch) | |
| tree | 516b164f382da2f64ffc14125ee8f8c11a5ee6c3 /llvm/lib | |
| parent | 7cd3c2d1512acdd1b683cc6c659506fc9668792b (diff) | |
| download | bcm5719-llvm-cc9c03386fe004af6f1406a79a94b761eb8c9829.tar.gz bcm5719-llvm-cc9c03386fe004af6f1406a79a94b761eb8c9829.zip | |
Add support for a marker byte that indicates that we shouldn't add the user
prefix to a symbol name
llvm-svn: 23421
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/Mangler.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/VMCore/Mangler.cpp b/llvm/lib/VMCore/Mangler.cpp index 0847604b8f8..2dc0767f9b1 100644 --- a/llvm/lib/VMCore/Mangler.cpp +++ b/llvm/lib/VMCore/Mangler.cpp @@ -28,16 +28,21 @@ static std::string MangleLetter(unsigned char C) { /// 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(const std::string &X, const char *Prefix) { std::string Result; - // Mangle the first letter specially, don't allow numbers... - if ((X[0] < 'a' || X[0] > 'z') && (X[0] < 'A' || X[0] > 'Z') && X[0] != '_') - Result += MangleLetter(X[0]); + // If X does not start with (char)1, add the prefix. + std::string::const_iterator I = X.begin(); + if (*I != 1) + Result = Prefix; else - Result += X[0]; + ++I; // Skip over the marker. + + // Mangle the first letter specially, don't allow numbers... + if (*I >= '0' && *I <= '9') + Result += MangleLetter(*I++); - for (std::string::const_iterator I = X.begin()+1, E = X.end(); I != E; ++I) + for (std::string::const_iterator E = X.end(); I != E; ++I) if ((*I < 'a' || *I > 'z') && (*I < 'A' || *I > 'Z') && (*I < '0' || *I > '9') && *I != '_') Result += MangleLetter(*I); @@ -75,7 +80,7 @@ std::string Mangler::getValueName(const Value *V) { if (gv && isa<Function>(gv) && cast<Function>(gv)->getIntrinsicID()) { name = gv->getName(); // Is an intrinsic function } else if (gv && !gv->hasInternalLinkage() && !MangledGlobals.count(gv)) { - name = Prefix + makeNameProper(gv->getName()); + name = makeNameProper(gv->getName(), Prefix); } else { // Non-global, or global with internal linkage / colliding name // -> mangle. |

