1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

reduce duplicate mangling logic by using MCSymbol::printMangledName.

llvm-svn: 93351
This commit is contained in:
Chris Lattner 2010-01-13 21:12:34 +00:00
parent 9498bee8a3
commit 4dcb71cc65

View File

@ -35,6 +35,7 @@
#include "llvm/CodeGen/IntrinsicLowering.h" #include "llvm/CodeGen/IntrinsicLowering.h"
#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar.h"
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/Support/CallSite.h" #include "llvm/Support/CallSite.h"
@ -343,31 +344,11 @@ namespace {
char CWriter::ID = 0; char CWriter::ID = 0;
static bool isAcceptableChar(char C) {
if ((C < 'a' || C > 'z') && (C < 'A' || C > 'Z') &&
(C < '0' || C > '9') && C != '_' && C != '$' && C != '@')
return false;
return true;
}
static char HexDigit(int V) {
return V < 10 ? V+'0' : V+'A'-10;
}
static std::string Mangle(const std::string &S) { static std::string Mangle(const std::string &S) {
std::string Result; std::string Result;
raw_string_ostream OS(Result);
for (unsigned i = 0, e = S.size(); i != e; ++i) MCSymbol::printMangledName(S, OS, 0);
if (isAcceptableChar(S[i])) return OS.str();
Result += S[i];
else {
Result += '_';
Result += HexDigit((S[i] >> 4) & 15);
Result += HexDigit(S[i] & 15);
Result += '_';
}
return Result;
} }