mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Add support for a marker byte that indicates that we shouldn't add the user
prefix to a symbol name git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23421 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8baaa4f0b6
commit
5b845c9443
@ -28,16 +28,21 @@ 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(const std::string &X, const char *Prefix) {
|
||||||
std::string Result;
|
std::string Result;
|
||||||
|
|
||||||
// Mangle the first letter specially, don't allow numbers...
|
// If X does not start with (char)1, add the prefix.
|
||||||
if ((X[0] < 'a' || X[0] > 'z') && (X[0] < 'A' || X[0] > 'Z') && X[0] != '_')
|
std::string::const_iterator I = X.begin();
|
||||||
Result += MangleLetter(X[0]);
|
if (*I != 1)
|
||||||
|
Result = Prefix;
|
||||||
else
|
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') &&
|
if ((*I < 'a' || *I > 'z') && (*I < 'A' || *I > 'Z') &&
|
||||||
(*I < '0' || *I > '9') && *I != '_')
|
(*I < '0' || *I > '9') && *I != '_')
|
||||||
Result += MangleLetter(*I);
|
Result += MangleLetter(*I);
|
||||||
@ -75,7 +80,7 @@ std::string Mangler::getValueName(const Value *V) {
|
|||||||
if (gv && isa<Function>(gv) && cast<Function>(gv)->getIntrinsicID()) {
|
if (gv && isa<Function>(gv) && cast<Function>(gv)->getIntrinsicID()) {
|
||||||
name = gv->getName(); // Is an intrinsic function
|
name = gv->getName(); // Is an intrinsic function
|
||||||
} else if (gv && !gv->hasInternalLinkage() && !MangledGlobals.count(gv)) {
|
} else if (gv && !gv->hasInternalLinkage() && !MangledGlobals.count(gv)) {
|
||||||
name = Prefix + makeNameProper(gv->getName());
|
name = makeNameProper(gv->getName(), Prefix);
|
||||||
} else {
|
} else {
|
||||||
// Non-global, or global with internal linkage / colliding name
|
// Non-global, or global with internal linkage / colliding name
|
||||||
// -> mangle.
|
// -> mangle.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user