From 0bd58b0e81961313828aa9ac484ab6b0d6c8d970 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 17 Jan 2010 19:32:29 +0000 Subject: [PATCH] stop the CBE from using Mangler::appendMangledName, which is a private function, it is mangling types, which don't matter how they are done. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93692 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/Mangler.h | 5 ----- lib/Target/CBackend/CBackend.cpp | 21 +++++++++++++++------ lib/Target/Mangler.cpp | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/llvm/Target/Mangler.h b/include/llvm/Target/Mangler.h index e634e789033..c5ac6768fd6 100644 --- a/include/llvm/Target/Mangler.h +++ b/include/llvm/Target/Mangler.h @@ -68,11 +68,6 @@ public: /// have a name, this fills in a unique name for the global. std::string getNameWithPrefix(const GlobalValue *GV, bool isImplicitlyPrivate = false); - - /// appendMangledName - Add the specified string in mangled form if it uses - /// any unusual characters. - static void appendMangledName(SmallVectorImpl &OutName, StringRef Str, - const MCAsmInfo *MAI); }; } // End llvm namespace diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 6a7643a79b6..5015d1bcce8 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -351,10 +351,19 @@ namespace { char CWriter::ID = 0; -static std::string Mangle(const std::string &S) { - SmallString<52> Result; - Mangler::appendMangledName(Result, S, 0); - return std::string(Result.begin(), Result.end()); +static std::string MangleType(const std::string &S) { + std::string Result; + + for (unsigned i = 0, e = S.size(); i != e; ++i) + if (isalnum(S[i]) || S[i] == '_') { + Result += S[i]; + } else { + Result += '_'; + Result += 'A'+(S[i]&15); + Result += 'A'+((S[i]>>4)&15); + Result += '_'; + } + return Result; } @@ -2238,7 +2247,7 @@ void CWriter::printModuleTypes(const TypeSymbolTable &TST) { // Print out forward declarations for structure types before anything else! Out << "/* Structure forward decls */\n"; for (; I != End; ++I) { - std::string Name = "struct " + Mangle("l_"+I->first); + std::string Name = "struct " + MangleType("l_"+I->first); Out << Name << ";\n"; TypeNames.insert(std::make_pair(I->second, Name)); } @@ -2249,7 +2258,7 @@ void CWriter::printModuleTypes(const TypeSymbolTable &TST) { // for struct or opaque types. Out << "/* Typedefs */\n"; for (I = TST.begin(); I != End; ++I) { - std::string Name = Mangle("l_"+I->first); + std::string Name = MangleType("l_"+I->first); Out << "typedef "; printType(Out, I->second, false, Name); Out << ";\n"; diff --git a/lib/Target/Mangler.cpp b/lib/Target/Mangler.cpp index 826f950c4a4..ef6defc58dc 100644 --- a/lib/Target/Mangler.cpp +++ b/lib/Target/Mangler.cpp @@ -58,8 +58,8 @@ static bool NameNeedsEscaping(StringRef Str, const MCAsmInfo &MAI) { /// appendMangledName - Add the specified string in mangled form if it uses /// any unusual characters. -void Mangler::appendMangledName(SmallVectorImpl &OutName, StringRef Str, - const MCAsmInfo *MAI) { +static void appendMangledName(SmallVectorImpl &OutName, StringRef Str, + const MCAsmInfo *MAI) { // The first character is not allowed to be a number unless the target // explicitly allows it. if ((MAI == 0 || !MAI->doesAllowNameToStartWithDigit()) && -- 2.11.0