[llvm-commits] [llvm] r124127 - in /llvm/trunk: lib/MC/MCParser/ELFAsmParser.cpp test/MC/ELF/section.s

Rafael Espindola rafael.espindola at gmail.com
Mon Jan 24 10:02:54 PST 2011


Author: rafael
Date: Mon Jan 24 12:02:54 2011
New Revision: 124127

URL: http://llvm.org/viewvc/llvm-project?rev=124127&view=rev
Log:
Handle strings in section names the same way as gas:
* If the name is a single string, we remove the quotes
* If the name starts without a quote, we include any quotes in the name

Modified:
    llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
    llvm/trunk/test/MC/ELF/section.s

Modified: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp?rev=124127&r1=124126&r2=124127&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Mon Jan 24 12:02:54 2011
@@ -168,6 +168,12 @@
   SMLoc FirstLoc = getLexer().getLoc();
   unsigned Size = 0;
 
+  if (getLexer().is(AsmToken::String)) {
+    SectionName = getTok().getIdentifier();
+    Lex();
+    return false;
+  }
+
   for (;;) {
     StringRef Tmp;
     unsigned CurSize;
@@ -176,10 +182,15 @@
     if (getLexer().is(AsmToken::Minus)) {
       CurSize = 1;
       Lex(); // Consume the "-".
-    } else if (!getParser().ParseIdentifier(Tmp))
-      CurSize = Tmp.size();
-    else
+    } else if (getLexer().is(AsmToken::String)) {
+      CurSize = getTok().getIdentifier().size() + 2;
+      Lex();
+    } else if (getLexer().is(AsmToken::Identifier)) {
+      CurSize = getTok().getIdentifier().size();
+      Lex();
+    } else {
       break;
+    }
 
     Size += CurSize;
     SectionName = StringRef(FirstLoc.getPointer(), Size);

Modified: llvm/trunk/test/MC/ELF/section.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/section.s?rev=124127&r1=124126&r2=124127&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/section.s (original)
+++ llvm/trunk/test/MC/ELF/section.s Mon Jan 24 12:02:54 2011
@@ -101,3 +101,10 @@
 // CHECK-NEXT:   ('sh_addralign', 0x00000001)
 // CHECK-NEXT:   ('sh_entsize', 0x00000000)
 // CHECK-NEXT:  ),
+
+// Test that we handle the strings like gas
+.section bar-"foo"
+.section "foo"
+
+// CHECK: ('sh_name', 0x0000008a) # 'bar-"foo"'
+// CHECK: ('sh_name', 0x00000094) # 'foo'





More information about the llvm-commits mailing list