[llvm-commits] [llvm] r93692 - in /llvm/trunk: include/llvm/Target/Mangler.h lib/Target/CBackend/CBackend.cpp lib/Target/Mangler.cpp
Chris Lattner
sabre at nondot.org
Sun Jan 17 11:32:30 PST 2010
Author: lattner
Date: Sun Jan 17 13:32:29 2010
New Revision: 93692
URL: http://llvm.org/viewvc/llvm-project?rev=93692&view=rev
Log:
stop the CBE from using Mangler::appendMangledName, which is a private function, it is mangling types, which don't matter how they are done.
Modified:
llvm/trunk/include/llvm/Target/Mangler.h
llvm/trunk/lib/Target/CBackend/CBackend.cpp
llvm/trunk/lib/Target/Mangler.cpp
Modified: llvm/trunk/include/llvm/Target/Mangler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Mangler.h?rev=93692&r1=93691&r2=93692&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/Mangler.h (original)
+++ llvm/trunk/include/llvm/Target/Mangler.h Sun Jan 17 13:32:29 2010
@@ -68,11 +68,6 @@
/// 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<char> &OutName, StringRef Str,
- const MCAsmInfo *MAI);
};
} // End llvm namespace
Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=93692&r1=93691&r2=93692&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
+++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Sun Jan 17 13:32:29 2010
@@ -351,10 +351,19 @@
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 @@
// 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 @@
// 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";
Modified: llvm/trunk/lib/Target/Mangler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mangler.cpp?rev=93692&r1=93691&r2=93692&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mangler.cpp (original)
+++ llvm/trunk/lib/Target/Mangler.cpp Sun Jan 17 13:32:29 2010
@@ -58,8 +58,8 @@
/// appendMangledName - Add the specified string in mangled form if it uses
/// any unusual characters.
-void Mangler::appendMangledName(SmallVectorImpl<char> &OutName, StringRef Str,
- const MCAsmInfo *MAI) {
+static void appendMangledName(SmallVectorImpl<char> &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()) &&
More information about the llvm-commits
mailing list