diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-13 14:01:59 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-13 14:01:59 +0000 |
commit | de9a1a2055851a0f0a88e459cd23a246a90efd45 (patch) | |
tree | dd4e2b5072fd4a527b5c39f3f64d8f07032a6c45 /lib/MC | |
parent | 7af43e0ad01a5f85f9066b69faba990a72f89536 (diff) | |
download | external_llvm-de9a1a2055851a0f0a88e459cd23a246a90efd45.zip external_llvm-de9a1a2055851a0f0a88e459cd23a246a90efd45.tar.gz external_llvm-de9a1a2055851a0f0a88e459cd23a246a90efd45.tar.bz2 |
Remove AllowQuotesInName and friends from MCAsmInfo.
Accepting quotes is a property of an assembler, not of an object file. For
example, ELF can support any names for sections and symbols, but the gnu
assembler only accepts quotes in some contexts and llvm-mc in a few more.
LLVM should not produce different symbols based on a guess about which assembler
will be reading the code it is printing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194575 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCAsmInfo.cpp | 3 | ||||
-rw-r--r-- | lib/MC/MCAsmInfoCOFF.cpp | 1 | ||||
-rw-r--r-- | lib/MC/MCAsmInfoDarwin.cpp | 1 | ||||
-rw-r--r-- | lib/MC/MCSectionELF.cpp | 53 |
4 files changed, 30 insertions, 28 deletions
diff --git a/lib/MC/MCAsmInfo.cpp b/lib/MC/MCAsmInfo.cpp index fd822b5..28f1c95 100644 --- a/lib/MC/MCAsmInfo.cpp +++ b/lib/MC/MCAsmInfo.cpp @@ -50,9 +50,6 @@ MCAsmInfo::MCAsmInfo() { Code32Directive = ".code32"; Code64Directive = ".code64"; AssemblerDialect = 0; - AllowQuotesInName = false; - AllowNameToStartWithDigit = false; - AllowPeriodsInName = true; AllowAtInName = false; UseDataRegionDirectives = false; ZeroDirective = "\t.zero\t"; diff --git a/lib/MC/MCAsmInfoCOFF.cpp b/lib/MC/MCAsmInfoCOFF.cpp index 33350d9..9d9f98e 100644 --- a/lib/MC/MCAsmInfoCOFF.cpp +++ b/lib/MC/MCAsmInfoCOFF.cpp @@ -43,7 +43,6 @@ MCAsmInfoCOFF::MCAsmInfoCOFF() { void MCAsmInfoMicrosoft::anchor() { } MCAsmInfoMicrosoft::MCAsmInfoMicrosoft() { - AllowQuotesInName = true; } void MCAsmInfoGNUCOFF::anchor() { } diff --git a/lib/MC/MCAsmInfoDarwin.cpp b/lib/MC/MCAsmInfoDarwin.cpp index d362a98..704c816 100644 --- a/lib/MC/MCAsmInfoDarwin.cpp +++ b/lib/MC/MCAsmInfoDarwin.cpp @@ -26,7 +26,6 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() { GlobalPrefix = "_"; PrivateGlobalPrefix = "L"; LinkerPrivateGlobalPrefix = "l"; - AllowQuotesInName = true; HasSingleParameterDotFile = false; HasSubsectionsViaSymbols = true; diff --git a/lib/MC/MCSectionELF.cpp b/lib/MC/MCSectionELF.cpp index ff9c4d3..09eb3e7 100644 --- a/lib/MC/MCSectionELF.cpp +++ b/lib/MC/MCSectionELF.cpp @@ -32,6 +32,29 @@ bool MCSectionELF::ShouldOmitSectionDirective(StringRef Name, return false; } +static void printName(raw_ostream &OS, StringRef Name) { + if (Name.find_first_not_of("0123456789_." + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == Name.npos) { + OS << Name; + return; + } + OS << '"'; + for (const char *B = Name.begin(), *E = Name.end(); B < E; ++B) { + if (*B == '"') // Unquoted " + OS << "\\\""; + else if (*B != '\\') // Neither " or backslash + OS << *B; + else if (B + 1 == E) // Trailing backslash + OS << "\\\\"; + else { + OS << B[0] << B[1]; // Quoted character + ++B; + } + } + OS << '"'; +} + void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS, const MCExpr *Subsection) const { @@ -44,27 +67,8 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, return; } - StringRef name = getSectionName(); - if (name.find_first_not_of("0123456789_." - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == name.npos) { - OS << "\t.section\t" << name; - } else { - OS << "\t.section\t\""; - for (const char *b = name.begin(), *e = name.end(); b < e; ++b) { - if (*b == '"') // Unquoted " - OS << "\\\""; - else if (*b != '\\') // Neither " or backslash - OS << *b; - else if (b + 1 == e) // Trailing backslash - OS << "\\\\"; - else { - OS << b[0] << b[1]; // Quoted character - ++b; - } - } - OS << '"'; - } + OS << "\t.section\t"; + printName(OS, getSectionName()); // Handle the weird solaris syntax if desired. if (MAI.usesSunStyleELFSectionSwitchSyntax() && @@ -135,8 +139,11 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, OS << "," << EntrySize; } - if (Flags & ELF::SHF_GROUP) - OS << "," << Group->getName() << ",comdat"; + if (Flags & ELF::SHF_GROUP) { + OS << ","; + printName(OS, Group->getName()); + OS << ",comdat"; + } OS << '\n'; if (Subsection) |