mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-27 17:31:33 +00:00
fix MCSymbol printing on darwin to exactly match the mangler (handling of \n and " in a symbol name).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81683 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e19f978323
commit
4afcedfad1
@ -65,6 +65,23 @@ static void PrintMangledName(raw_ostream &OS, StringRef Str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// PrintMangledQuotedName - On systems that support quoted symbols, we still
|
||||||
|
/// have to escape some (obscure) characters like " and \n which would break the
|
||||||
|
/// assembler's lexing.
|
||||||
|
static void PrintMangledQuotedName(raw_ostream &OS, StringRef Str) {
|
||||||
|
OS << '"';
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = Str.size(); i != e; ++i) {
|
||||||
|
if (Str[i] == '"')
|
||||||
|
OS << "_QQ_";
|
||||||
|
else if (Str[i] == '\n')
|
||||||
|
OS << "_NL_";
|
||||||
|
else
|
||||||
|
OS << Str[i];
|
||||||
|
}
|
||||||
|
OS << '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MCSymbol::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
void MCSymbol::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
||||||
if (MAI == 0 || !NameNeedsEscaping(getName(), *MAI)) {
|
if (MAI == 0 || !NameNeedsEscaping(getName(), *MAI)) {
|
||||||
@ -72,14 +89,17 @@ void MCSymbol::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On darwin and other systems that allow quoted names, just do that.
|
// On systems that do not allow quoted names, print with mangling.
|
||||||
if (MAI->doesAllowQuotesInName()) {
|
if (!MAI->doesAllowQuotesInName())
|
||||||
OS << '"' << getName() << '"';
|
return PrintMangledName(OS, getName());
|
||||||
return;
|
|
||||||
}
|
// If the string contains a double quote or newline, we still have to mangle
|
||||||
|
// it.
|
||||||
// Otherwise, we have to mangle the name.
|
if (getName().find('"') != std::string::npos ||
|
||||||
PrintMangledName(OS, getName());
|
getName().find('\n') != std::string::npos)
|
||||||
|
return PrintMangledQuotedName(OS, getName());
|
||||||
|
|
||||||
|
OS << '"' << getName() << '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCSymbol::dump() const {
|
void MCSymbol::dump() const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user